From 7eef4f04d9fd1fc8ecc38392ce1adb1c44899adc Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Wed, 1 Sep 2021 11:03:49 -0300 Subject: Refactor C files, split logerr and tests-lib --- Makefile | 44 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 6 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 10351f0..903b94a 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,4 @@ .POSIX: -DEFS = -DVERSION='"$(VERSION)"' -DDATE='"$(DATE)"' PREFIX = /usr/local MANPREFIX = '$(PREFIX)/share/man' VERSION = 0.2.1 @@ -11,12 +10,18 @@ CONTRIBLANGS = .SUFFIXES: -.SUFFIXES: .in +.SUFFIXES: .in .to .c .o .in: sed -e 's:@VERSION@:$(VERSION):g' -e 's:@DATE@:$(DATE):g' < $< > $@ if [ -x $< ]; then chmod +x $@; fi +.c.o: + $(CC) $(CFLAGS) -o $@ -c $< + +.c.to: + $(CC) $(CFLAGS) -DTEST -o $@ -c $< + manpages.en.in = \ doc/remembering.en.1.in \ @@ -30,18 +35,45 @@ manpages.in = $(manpages.en.in) \ doc/remembering.eo.5.in manpages = $(manpages.in:.in=) +sources = \ + src/logerr.c \ + src/remembering.c +objects = $(sources:.c=.o) +t-sources = $(sources) src/tests-lib.c +t-objects = $(t-sources:.c=.to) + all: src/remembering remembering $(manpages) -remembering: src/remembering.c - $(CC) $(CFLAGS) $(DEFS) $(LDFLAGS) -o $@ $? $(LDLIBS) +remembering: $(objects) + $(CC) $(LDFLAGS) -o $@ $(objects) $(LDLIBS) + +remembering-tests: $(t-objects) + $(CC) $(LDFLAGS) -o $@ $(t-objects) $(LDLIBS) + +src/config.h: + printf '#ifndef REMEMBERING_CONFIG_H\n' >> $@ + printf '#define REMEMBERING_CONFIG_H\n' >> $@ + printf '\n' >> $@ + printf '#define _POSIX_C_SOURCE 200809L\n' >> $@ + printf '#define VERSION "$(VERSION)"\n' >> $@ + printf '#define DATE "$(DATE)"\n' >> $@ + printf '#define PROGNAME "$(NAME)"\n' >> $@ + printf '\n' >> $@ + printf '#endif\n' >> $@ -remembering-tests: src/remembering.c - $(CC) $(CFLAGS) $(DEFS) $(LDFLAGS) -DTEST -o $@ $? $(LDLIBS) +src/remembering: src/remembering.in +$(objects) $(t-objects): src/config.h +src/tests-lib.to: src/tests-lib.h +src/logerr.o src/logerr.to: src/logerr.h +src/remembering.o: src/logerr.o +src/remembering.to: src/logerr.to src/tests-lib.to check: all remembering-tests ./remembering-tests + sh tests/assert-catgets.sh $(t-sources) + sh tests/c-lint.sh $(t-sources) sh tests/cli-opts.sh sh tests/install-uninstall.sh sh tests/ranking.sh -- cgit v1.2.3