3 ifeq "$(origin CC)" "default"
7 CFLAGS += -g -Wall -Wextra
11 MAKEDEPEND = $(CC) -MM
13 TARGETS = reservoir_sample
15 TESTS = $(addprefix $(TEST_DIR)/, reservoir_sample_test)
16 SOURCES = reservoir_sample.c notify.c
17 OBJECTS = $(SOURCES:.c=.o)
18 TEST_OBJECTS = $(TESTS:=.o) test_suite.o
20 .PHONY: all test check clean
22 all: $(TARGETS) .depend
25 ./version.sh 0 0 prototype
27 .depend: $(SOURCES) version.h
28 $(MAKEDEPEND) $(CPPFLAGS) $^ > $@
31 @rm -rf $(TARGETS) $(TESTS) $(TEST_OBJECTS) $(OBJECTS) *.dSYM .depend core
33 test: $(TESTS) $(TARGETS)
37 @for t in $(TESTS); do \
39 ./$${t} > /dev/null || echo -- $${t} FAILED --;\
42 $(TEST_DIR)/%_test.o: %.c
43 $(CC) $(CFLAGS) $(CPPFLAGS) -DTEST -c -o $@ $<
45 $(TEST_DIR)/reservoir_sample_test: %: %.o test_suite.o notify.o
47 reservoir_sample: %: %.o notify.o