aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2021-03-05 18:15:15 -0300
committerEuAndreh <eu@euandre.org>2021-03-06 01:27:00 -0300
commit65cf8196ea66e207c8c6f5015192eb0b34463457 (patch)
tree70789808399aa65770188043835235759d0d7217 /Makefile
parentEmpty initial commit (diff)
downloadgistatic-65cf8196ea66e207c8c6f5015192eb0b34463457.tar.gz
gistatic-65cf8196ea66e207c8c6f5015192eb0b34463457.tar.xz
Add base project skeleton files
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile96
1 files changed, 96 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..d96ebb9
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,96 @@
+.POSIX:
+CC = c99
+CFLAGS = -std=c99 -Wall -Wextra -Wpedantic -fPIC -g -O3
+LDFLAGS = -Wl,-rpath,$$LIBRARY_PATH
+LDLIBS =
+PREFIX = /usr/local
+MANPREFIX = $(PREFIX)/share/man
+DATE = 1970-01-01
+MAJOR = 0
+MINOR = 1
+PATCH = 0
+VERSION = $(MAJOR).$(MINOR).$(PATCH)
+NAME = gistatic
+
+headers = \
+ src/f.h
+
+sources = \
+ src/f.c
+
+manpages = \
+ doc/f.1
+
+
+objects = $(sources:.c=.o)
+
+.SUFFIXES: .c .o
+
+.c.o:
+ $(CC) -c $(CFLAGS) $(LDFLAGS) -o $@ $<
+
+libname = lib$(NAME)
+liba = $(libname).a
+libso = $(libname).so
+libso-real = $(libso).$(MAJOR).$(MINOR).$(PATCH)
+soaliases = $(libso).$(MAJOR).$(MINOR) $(libso).$(MAJOR) $(libso)
+
+all: $(liba) $(libso-real) run-tests
+
+$(liba): $(headers) $(objects)
+ ar rcsv $@-t $(objects)
+ ranlib $@-t
+ mv $@-t $@
+
+$(libso-real): $(headers) $(objects)
+ $(CC) $(CFLAGS) $(LDFLAGS) -shared -Wl,-soname,$(libso).$(MAJOR) -o $@ $(objects)
+
+$(soaliases): $(libso-real)
+ ln -sf $? $@
+
+run-tests: $(headers) $(sources) tests/tests.c
+ $(CC) $(CFLAGS) $(LDFLAGS) -DTEST -o $@ tests/tests.c $(sources) $(LDLIBS)
+
+fallible-tests: $(headers) $(sources) tests/tests.c
+ $(CC) $(CFLAGS) $(LDFLAGS) -DTEST -DFALLIBLE -o $@ tests/tests.c $(sources) $(LDLIBS) -lfallible
+
+check: run-tests
+ ./run-tests
+
+dev-check: all check fallible-tests
+ valgrind `fallible-check --valgrind-flags` ./run-tests
+ fallible-check ./fallible-tests
+ sh aux/assert-clang-format.sh
+ sh aux/assert-shellcheck.sh
+ sh aux/workflow/assert-todos.sh
+ sh aux/workflow/assert-changelog.sh $(NAME)
+
+do_subst = sed \
+ -e 's:[@]VERSION[@]:$(VERSION):g' \
+ -e 's:[@]DATE[@]:$(DATE):g'
+
+install: all $(soaliases)
+ for h in $(headers); do install -m 644 -D $$h $(DESTDIR)$(PREFIX)/include/`basename $$h`; done
+ for f in $(liba) $(libso-real); do install -m 755 -D $$f $(DESTDIR)$(PREFIX)/lib/$$f; done
+ for a in $(soaliases); do mv $$a $(DESTDIR)$(PREFIX)/lib/; done
+ for m in $(manpages); do \
+ n=$${m##*.}; \
+ mkdir -p $(DESTDIR)$(MANPREFIX)/man$$m; \
+ $(do_subst) < $$m | gzip > $(DESTDIR)$(MANPREFIX)/man$$n/`basename $$m`.gz; \
+ done
+
+uninstall:
+ for h in $(headers); do rm -f $(DESTDIR)$(PREFIX)/include/`basename $$h`; done
+ for l in $(liba) $(libso-real) $(soaliases); do rm -f $(DESTDIR)$(PREFIX)/lib/$$l; done
+ for m in $(manpages); do rm -f $(DESTDIR)$(MANPREFIX)/man$${m##*.}/`basename $$m`.gz; done
+
+clean:
+ rm -rf public/ $(objects) $(liba) $(libso-real) $(soaliases) run-tests fallible* vgcore*
+
+dist:
+ sh aux/workflow/dist.sh $(DATE) $(VERSION) $(NAME)
+
+public: README.md TODOs.md CHANGELOG.md
+ sh aux/workflow/public.sh gistatic $(NAME) public-inbox
+
+.PHONY: all clean check dev-check dist install uninstall