Split code into modules, handle USR1, minor fixes.
[reservoir_sample] / Makefile
1 #!make
2
3 ifeq "$(origin CC)" "default"
4 CC = clang
5 endif
6
7 CFLAGS += -g -Wall -Wextra
8 CFLAGS += -O3
9 CPPFLAGS += -DNDEBUG
10 LDFLAGS +=
11
12 MAKEDEPEND = $(CC) -MM
13
14 TARGETS = reservoir_sample
15 TEST_DIR = test
16 TESTS = $(addprefix $(TEST_DIR)/, buf_test reservoir_test)
17 SOURCES = reservoir_sample.c notify.c buf.c randomness.c reservoir.c
18 OBJECTS = $(SOURCES:.c=.o)
19 TEST_OBJECTS = $(TESTS:=.o) test_suite.o
20
21 .PHONY: all test check clean
22
23 all: $(TARGETS) .depend
24
25 version.h:
26 ./version.sh 0 0 prototype
27
28 .depend: $(SOURCES) version.h
29 $(MAKEDEPEND) $(CPPFLAGS) $^ > $@
30
31 clean:
32 @rm -rf $(TARGETS) $(TESTS) $(TEST_OBJECTS) $(OBJECTS) *.dSYM .depend core
33
34 test: $(TESTS) $(TARGETS)
35
36
37 check: test
38 @for t in $(TESTS); do \
39 echo Checking $${t};\
40 ./$${t} > /dev/null || echo -- $${t} FAILED --;\
41 done
42
43 $(TEST_DIR)/%_test.o: %.c
44 $(CC) $(CFLAGS) $(CPPFLAGS) -DTEST -c -o $@ $<
45
46 $(TEST_DIR)/buf_test: %: %.o test_suite.o notify.o
47
48 $(TEST_DIR)/reservoir_test: %: %.o test_suite.o notify.o buf.o randomness.o
49
50 reservoir_sample: %: %.o notify.o buf.o randomness.o reservoir.o
51
52 -include .depend