Fix Linux compilation, simplify Makefiles
This commit is contained in:
parent
dab39c226f
commit
39a3e45b6c
6 changed files with 23 additions and 23 deletions
23
Makefile
23
Makefile
|
@ -32,6 +32,9 @@
|
||||||
|
|
||||||
-include config.mk
|
-include config.mk
|
||||||
|
|
||||||
|
.SUFFIXES:
|
||||||
|
.SUFFIXES: .o .c
|
||||||
|
|
||||||
PREFIX ?= /usr/local
|
PREFIX ?= /usr/local
|
||||||
includedir = $(DESTDIR)$(PREFIX)/include
|
includedir = $(DESTDIR)$(PREFIX)/include
|
||||||
libdir = $(DESTDIR)$(PREFIX)/lib
|
libdir = $(DESTDIR)$(PREFIX)/lib
|
||||||
|
@ -41,10 +44,10 @@ hdrs += include/haggis.h
|
||||||
hdrs += include/jobq.h
|
hdrs += include/jobq.h
|
||||||
hdrs += include/linklist.h
|
hdrs += include/linklist.h
|
||||||
|
|
||||||
srcs += src/bytes.c
|
srcs += bytes.c
|
||||||
srcs += src/haggis.c
|
srcs += haggis.c
|
||||||
srcs += src/jobq.c
|
srcs += jobq.c
|
||||||
srcs += src/linklist.c
|
srcs += linklist.c
|
||||||
|
|
||||||
objs = $(srcs:.c=.o)
|
objs = $(srcs:.c=.o)
|
||||||
|
|
||||||
|
@ -60,9 +63,6 @@ shared: libhaggis.so
|
||||||
|
|
||||||
static: libhaggis.a
|
static: libhaggis.a
|
||||||
|
|
||||||
%.o: %.c
|
|
||||||
$(CC) $(CFLAGS) -o $@ -c $<
|
|
||||||
|
|
||||||
libhaggis.a: $(objs)
|
libhaggis.a: $(objs)
|
||||||
$(AR) rcs $@ $?
|
$(AR) rcs $@ $?
|
||||||
|
|
||||||
|
@ -79,8 +79,11 @@ install: libhaggis.a libhaggis.so haggis.h
|
||||||
test: libhaggis.a
|
test: libhaggis.a
|
||||||
$(MAKE) -C test
|
$(MAKE) -C test
|
||||||
|
|
||||||
clean:
|
testclean:
|
||||||
rm -rf *.a *.so src/*.o
|
|
||||||
$(MAKE) -C test clean
|
$(MAKE) -C test clean
|
||||||
|
|
||||||
.PHONY: all shared static clean install test
|
clean:
|
||||||
|
rm -rf *.a *.so *.o
|
||||||
|
$(MAKE) -C test clean
|
||||||
|
|
||||||
|
.PHONY: all shared static clean install testclean test
|
||||||
|
|
|
@ -206,9 +206,9 @@ void init_sha1(haggis_file *f) {
|
||||||
SHA1_CTX ctx;
|
SHA1_CTX ctx;
|
||||||
|
|
||||||
f->cksum.tag = sha1;
|
f->cksum.tag = sha1;
|
||||||
SHA1_Init(&ctx);
|
SHA1Init(&ctx);
|
||||||
SHA1_Update(&ctx, f->data, (size_t)f->len.val);
|
SHA1Update(&ctx, f->data, (size_t)f->len.val);
|
||||||
SHA1_Final(f->cksum.sum.sha1, &ctx);
|
SHA1Final(f->cksum.sum.sha1, &ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
int validate_sha1(haggis_file *file) {
|
int validate_sha1(haggis_file *file) {
|
||||||
|
@ -250,9 +250,9 @@ void init_sha256(haggis_file *f) {
|
||||||
SHA2_CTX ctx;
|
SHA2_CTX ctx;
|
||||||
|
|
||||||
f->cksum.tag = sha256;
|
f->cksum.tag = sha256;
|
||||||
SHA256_Init(&ctx);
|
SHA256Init(&ctx);
|
||||||
SHA256_Update(&ctx, f->data, (size_t)f->len.val);
|
SHA256Update(&ctx, f->data, (size_t)f->len.val);
|
||||||
SHA256_Final(f->cksum.sum.sha256, &ctx);
|
SHA256Final(f->cksum.sum.sha256, &ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
int validate_sha256(haggis_file *file) {
|
int validate_sha256(haggis_file *file) {
|
|
@ -31,8 +31,8 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
CFLAGS += -I../include
|
CFLAGS += -I../include
|
||||||
LIBS += ../libhaggis.a
|
LDLIBS += ../libhaggis.a
|
||||||
LIBS += -lmd
|
LDLIBS += -lmd
|
||||||
|
|
||||||
tests += store_u16
|
tests += store_u16
|
||||||
tests += load_u16
|
tests += load_u16
|
||||||
|
@ -62,10 +62,10 @@ tests += load_file_sha256
|
||||||
total != echo $(tests) | wc -w | awk '{ print $$1 }'
|
total != echo $(tests) | wc -w | awk '{ print $$1 }'
|
||||||
|
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
test: $(tests)
|
test: $(tests) output
|
||||||
@echo -e "\n\t=== \e[0;33mRunning $(total) tests\e[0m ===\n"
|
@echo -e "\n\t=== \e[0;33mRunning $(total) tests\e[0m ===\n"
|
||||||
@idx=1 ; success=0 ; fail=0; for t in $(tests) ; \
|
@idx=1 ; success=0 ; fail=0; for t in $(tests) ; \
|
||||||
do printf "[%02i/$(total)] \%-25s" $${idx} $${t} ; \
|
do printf "[%02i/$(total)] %-25s" $${idx} $${t} ; \
|
||||||
idx=$$(expr $${idx} + 1) ; \
|
idx=$$(expr $${idx} + 1) ; \
|
||||||
./$${t} ; \
|
./$${t} ; \
|
||||||
if [ $$? -eq 0 ] ; \
|
if [ $$? -eq 0 ] ; \
|
||||||
|
@ -79,9 +79,6 @@ test: $(tests)
|
||||||
output:
|
output:
|
||||||
@ [-d $@ ] 2>/dev/null || install -d $@
|
@ [-d $@ ] 2>/dev/null || install -d $@
|
||||||
|
|
||||||
$(tests): $@.c haggis_private.h output
|
|
||||||
$(CC) $(CFLAGS) -o $@ $< $(LIBS)
|
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(tests) output/*
|
rm -rf $(tests) output/*
|
||||||
|
|
Loading…
Add table
Reference in a new issue