Fix Linux compilation, simplify Makefiles

This commit is contained in:
Nathan Fisher 2023-08-10 22:42:43 -04:00
parent dab39c226f
commit 39a3e45b6c
6 changed files with 23 additions and 23 deletions

View file

@ -32,6 +32,9 @@
-include config.mk
.SUFFIXES:
.SUFFIXES: .o .c
PREFIX ?= /usr/local
includedir = $(DESTDIR)$(PREFIX)/include
libdir = $(DESTDIR)$(PREFIX)/lib
@ -41,10 +44,10 @@ hdrs += include/haggis.h
hdrs += include/jobq.h
hdrs += include/linklist.h
srcs += src/bytes.c
srcs += src/haggis.c
srcs += src/jobq.c
srcs += src/linklist.c
srcs += bytes.c
srcs += haggis.c
srcs += jobq.c
srcs += linklist.c
objs = $(srcs:.c=.o)
@ -60,9 +63,6 @@ shared: libhaggis.so
static: libhaggis.a
%.o: %.c
$(CC) $(CFLAGS) -o $@ -c $<
libhaggis.a: $(objs)
$(AR) rcs $@ $?
@ -79,8 +79,11 @@ install: libhaggis.a libhaggis.so haggis.h
test: libhaggis.a
$(MAKE) -C test
clean:
rm -rf *.a *.so src/*.o
testclean:
$(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

View file

@ -206,9 +206,9 @@ void init_sha1(haggis_file *f) {
SHA1_CTX ctx;
f->cksum.tag = sha1;
SHA1_Init(&ctx);
SHA1_Update(&ctx, f->data, (size_t)f->len.val);
SHA1_Final(f->cksum.sum.sha1, &ctx);
SHA1Init(&ctx);
SHA1Update(&ctx, f->data, (size_t)f->len.val);
SHA1Final(f->cksum.sum.sha1, &ctx);
}
int validate_sha1(haggis_file *file) {
@ -250,9 +250,9 @@ void init_sha256(haggis_file *f) {
SHA2_CTX ctx;
f->cksum.tag = sha256;
SHA256_Init(&ctx);
SHA256_Update(&ctx, f->data, (size_t)f->len.val);
SHA256_Final(f->cksum.sum.sha256, &ctx);
SHA256Init(&ctx);
SHA256Update(&ctx, f->data, (size_t)f->len.val);
SHA256Final(f->cksum.sum.sha256, &ctx);
}
int validate_sha256(haggis_file *file) {

View file

View file

@ -31,8 +31,8 @@
#
CFLAGS += -I../include
LIBS += ../libhaggis.a
LIBS += -lmd
LDLIBS += ../libhaggis.a
LDLIBS += -lmd
tests += store_u16
tests += load_u16
@ -62,10 +62,10 @@ tests += load_file_sha256
total != echo $(tests) | wc -w | awk '{ print $$1 }'
.PHONY: test
test: $(tests)
test: $(tests) output
@echo -e "\n\t=== \e[0;33mRunning $(total) tests\e[0m ===\n"
@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) ; \
./$${t} ; \
if [ $$? -eq 0 ] ; \
@ -79,9 +79,6 @@ test: $(tests)
output:
@ [-d $@ ] 2>/dev/null || install -d $@
$(tests): $@.c haggis_private.h output
$(CC) $(CFLAGS) -o $@ $< $(LIBS)
.PHONY: clean
clean:
rm -rf $(tests) output/*