2 CINCPATH = -isystem include
3 CFLAGS += -std=c++98 -Wall -pedantic
4 LDFLAGS = -lboost_unit_test_framework
7 TESTCMD = ./$(TESTPRG) --detect_memory_leak=1 --report_level=short \
8 # --build_info=yes --log_level=test_suite \
9 # | grep -v "Entering test case " | grep -v "Leaving test case"
11 VALGRIND = valgrind --tool=memcheck --leak-check=yes --db-attach=no \
12 --num-callers=24 --leak-resolution=high --track-fds=yes \
13 --suppressions=valgrind.suppressions
16 SOURCES = $(shell find -name '*.cpp')
17 OBJS = $(SOURCES:.cpp=.o)
21 ALL_CFLAGS = $(CFLAGS) $(CINCPATH)
24 ALL_CFLAGS += -O3 -NDEBUG
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) > /dev/null 2>&1
40 NICE_MEMTEST = @echo " MEMTEST"; $(VALGRIND) --log-file=valgrind.log \
41 $(TESTCMD) > /dev/null 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' < $@.$$$$ > $@; \
75 ifneq ($(MAKECMDGOALS),clean)
76 -include $(addprefix .deps/,$(OBJS:.o=.deps))
84 $(NICE_LINK) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $^
89 $(NICE_CXX) $(ALL_CFLAGS) -c $< -o $@
93 @ln -fs ../../src include/posixx
102 $(NICE_CLEAN) -r $(TESTPRG) include $(OBJS) .deps valgrind.log \
103 *.bb *.bbg *.da *.gcov *.gcda *.gcno gmon.out
105 .PHONY: default all test clean