2 LOCAL_CFLAGS = -std=c++98 -Wall -pedantic -isystem include
3 LOCAL_LDFLAGS = -lboost_unit_test_framework
6 TESTCMD = ./$(TESTPRG) --detect_memory_leak=1 --report_level=short \
7 # --build_info=yes --log_level=test_suite \
8 # | grep -v "Entering test case " | grep -v "Leaving test case"
10 VALGRIND = valgrind --tool=memcheck --leak-check=yes --db-attach=no \
11 --num-callers=24 --leak-resolution=high --track-fds=yes \
12 --suppressions=valgrind.suppressions --error-exitcode=1
15 SOURCES = $(shell find -name '*.cpp')
16 OBJS = $(SOURCES:.cpp=.o)
20 ALL_CFLAGS = $(LOCAL_CFLAGS) $(LI_CFLAGS) $(CFLAGS)
21 ALL_LDFLAGS = $(LOCAL_LDFLAGS) $(LI_LDFLAGS) $(LDFLAGS)
24 ALL_CFLAGS += -O3 -DNDEBUG
28 ALL_CFLAGS += -g -DDEBUG
32 ALL_CFLAGS += -g -pg -fprofile-arcs -ftest-coverage
37 NICE_CXX = @echo " CXX $@"; $(CXX)
38 NICE_LINK = @echo " LINK $@"; $(CXX)
39 NICE_TEST = @echo " TEST"; $(TESTCMD) > $(TESTPRG).log 2>&1
40 NICE_MEMTEST = @echo " MEMTEST"; $(VALGRIND) --log-file=valgrind.log \
41 $(TESTCMD) > valgrind.$(TESTPRG).log 2>&1
42 NICE_CLEAN = @echo " CLEAN"; $(RM)
46 NICE_TEST = $(TESTCMD)
47 NICE_MEMTEST = $(VALGRIND) $(TESTCMD)
59 # XXX the mkdir *has* to be inside the rule, otherwise make will build the
60 # dependencies over and over again, because of this:
61 # When a file that is included in the Makefile need to be built by itself,
62 # the Makefile is re-executed after building the files to include. The
63 # problem is, the directory .deps is updated *after* the files are created
64 # in it, so when the Makefile re-executes, the files to include are created
65 # but one of it's dependencies (the .deps directory) is outdated, so the
66 # the files to include are re-built and the Makefile re-executed again,
67 # entering in an infinite loop.
71 $(CC) -MM -MG -MP $(CPPFLAGS) $(ALL_CFLAGS) $< -MF $@.$$$$; \
72 sed 's,\($(notdir $*)\)\.o[ :]*,$(dir $<)\1.o $@ : ,g' \
76 ifneq ($(MAKECMDGOALS),clean)
77 -include $(addprefix .deps/,$(OBJS:.o=.deps))
85 $(NICE_LINK) $(ALL_LDFLAGS) -o $@ $^
90 $(NICE_CXX) $(ALL_CFLAGS) -c $< -o $@
94 @ln -fs ../../src include/posixx
98 .test-stamp: $(TESTPRG)
102 memtest: .memtest-stamp
104 .memtest-stamp: $(TESTPRG)
109 $(NICE_CLEAN) -r $(TESTPRG) include $(OBJS) .deps valgrind.log \
110 *.bb *.bbg *.da *.gcov *.gcda *.gcno gmon.out .*-stamp
112 .PHONY: default all test memtest clean