aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2021-08-19 16:16:39 -0300
committerEuAndreh <eu@euandre.org>2021-08-19 16:17:12 -0300
commitf19bc2e5d08d8e306faf25d970686f87fc5ccec1 (patch)
tree62d2d5af324c80dd233d5e0499d8a65446c3fa15
parentsrc/gistatic.c: Enforce fn(void) rule (diff)
downloadgistatic-f19bc2e5d08d8e306faf25d970686f87fc5ccec1.tar.gz
gistatic-f19bc2e5d08d8e306faf25d970686f87fc5ccec1.tar.xz
Makefile: Adapt to multiple C sources, generate src/config.h and libgistatic.a
-rw-r--r--Makefile56
1 files changed, 40 insertions, 16 deletions
diff --git a/Makefile b/Makefile
index 52336ed..9ab74e2 100644
--- a/Makefile
+++ b/Makefile
@@ -7,22 +7,16 @@ NAME = gistatic
MAILING_LIST = public-inbox
TRANSLATIONS = pt fr eo
CONTRIBLANGS =
-LDLIBS_FINAL = $(LDLIBS) -lgit2
-CFLAGS_FINAL = $(CFLAGS) \
- -D_POSIX_C_SOURCE=200809L \
- -DVERSION='"$(VERSION)"' \
- -DDATE='"$(DATE)"'
+LDLIBS = -lgit2
.SUFFIXES: .in .t
.in:
sed -e 's:@VERSION@:$(VERSION):g' -e 's:@DATE@:$(DATE):g' < $< > $@
-.c:
- $(CC) $(CFLAGS_FINAL) $(LDFLAGS) -o $@ $< $(LDLIBS_FINAL)
-
.c.t:
- $(CC) $(CFLAGS_FINAL) $(LDFLAGS) -DTEST -o $@ $< $(LDLIBS_FINAL)
+ $(CC) $(CFLAGS) $(LDFLAGS) -DTEST -o $@ $< $(LDLIBS)
+
manpages.en.in = \
doc/gistatic.en.1.in
@@ -32,23 +26,53 @@ manpages.in = $(manpages.en.in) \
doc/gistatic.eo.1.in
manpages = $(manpages.in:.in=)
+sources = \
+ src/tar.c \
+ src/gistatic.c
+objects = $(sources:.c=.o)
+tests = $(sources:.c=.t)
+
+
+all: src/config.h $(manpages) src/gistatic libgistatic.a
+
+
+src/gistatic: $(objects) src/main.o
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(objects) src/main.o $(LDLIBS)
-all: $(manpages) src/gistatic
+libgistatic.a: $(objects)
+ $(AR) $(ARFLAGS) $@ $(objects)
-check: all src/gistatic.t src/tar.t
+src/config.h:
+ touch $@
+ printf '#ifndef GISTATIC_CONFIG_H\n' >> $@
+ printf '#define GISTATIC_CONFIG_H\n\n' >> $@
+ printf '#define _POSIX_C_SOURCE 200809L\n' >> $@
+ printf '#define VERSION "$(VERSION)"\n' >> $@
+ printf '#define DATE "$(DATE)"\n' >> $@
+ printf '\n#endif\n' >> $@
+
+$(objects): src/config.h
+$(tests): src/config.h
+src/gistatic.o: src/gistatic.h src/tar.o src/tar.h
+src/main.o: src/gistatic.h src/gistatic.o
+
+
+check: all $(tests)
rm -f tests/resources/repositories/repo-1/.git
rm -f tests/resources/repositories/repo-2/.git
ln -s .gitdir tests/resources/repositories/repo-1/.git
ln -s .gitdir tests/resources/repositories/repo-2/.git
- ./src/gistatic.t
- ./src/tar.t
- sh tests/integration.sh
+ for t in $(tests); do ./$$t; done
sh tests/assert-catgets.sh src/gistatic.c
+ sh tests/integration.sh
+ sh tests/build-sample.sh
+ sh tests/c-lint.sh src/*.c
clean:
rm -rf public/ $(manpages) README.*.md CHANGELOG.*.md messages.mo \
- src/gistatic src/gistatic.t src/tar.t vgcore.* \
- tests/resources/repositories/repo-1/.git \
+ vgcore.* tmp/ src/config.h \
+ src/*.o src/*.t src/gistatic libgistatic.a \
+ tests/resources/repositories/repo-1/.git \
tests/resources/repositories/repo-2/.git
install: all