3 ifeq "$(origin CC)" "default"
7 CFLAGS += -g -Wall -Wextra
12 MAKEDEPEND = $(CC) -MM
14 TARGETS = reservoir_sample
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
21 .PHONY: all test check clean
23 all: $(TARGETS) .depend
26 ./version.sh 0 0 prototype
28 .depend: $(SOURCES) version.h
29 $(MAKEDEPEND) $(CPPFLAGS) $^ > $@
32 @rm -rf $(TARGETS) $(TESTS) $(TEST_OBJECTS) $(OBJECTS) *.dSYM .depend core
34 test: $(TESTS) $(TARGETS)
38 @for t in $(TESTS); do \
40 ./$${t} > /dev/null || echo -- $${t} FAILED --;\
43 $(TEST_DIR)/%_test.o: %.c
44 $(CC) $(CFLAGS) $(CPPFLAGS) -DTEST -c -o $@ $<
46 $(TEST_DIR)/buf_test: %: %.o test_suite.o notify.o
48 $(TEST_DIR)/reservoir_test: %: %.o test_suite.o notify.o buf.o randomness.o
50 reservoir_sample: %: %.o notify.o buf.o randomness.o reservoir.o