aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2021-09-01 11:03:49 -0300
committerEuAndreh <eu@euandre.org>2021-09-01 11:07:11 -0300
commit7eef4f04d9fd1fc8ecc38392ce1adb1c44899adc (patch)
tree7366fac128a49fb2b128090ca6b69f147ebfe583 /Makefile
parenttests/lib.sh: Update (diff)
downloadremembering-7eef4f04d9fd1fc8ecc38392ce1adb1c44899adc.tar.gz
remembering-7eef4f04d9fd1fc8ecc38392ce1adb1c44899adc.tar.xz
Refactor C files, split logerr and tests-lib
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile44
1 files changed, 38 insertions, 6 deletions
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