added test_coverage target (needs lcov)
[senf.git] / Makefile
1 #----------------------------------------------------------------------
2 # Some SCONS shortcuts
3 #----------------------------------------------------------------------
4
5 CONCURRENCY_LEVEL ?= 2
6
7 ifdef final
8   SCONS_ARGS += "final="$(final)
9 endif
10 ifdef debug
11   SCONS_ARGS += "debug="$(debug)
12 endif
13 ifdef profile
14   SCONS_ARGS += "profile="$(profile)
15 endif
16
17 SCONS=scons -j $(CONCURRENCY_LEVEL) $(SCONS_ARGS)
18
19 default: build
20
21 build:
22         $(SCONS)
23
24 clean:
25         $(SCONS) --clean all
26         find ./ -name \*.gcno | xargs rm -f
27         find ./ -name \*.gcda | xargs rm -f
28         find ./ -name \*.gcov | xargs rm -f
29         rm -f test_coverage.info
30         rm -rf /doc/test_coverage
31
32 all_docs all_tests all:
33         $(SCONS) $@
34         
35 %/test %/doc:
36         $(SCONS) $@
37
38 %/build:
39         $(SCONS) $*
40
41
42 #----------------------------------------------------------------------
43 # test coverage
44 #----------------------------------------------------------------------
45 test_coverage:
46         $(SCONS) debug=1 EXTRA_CCFLAGS="-fprofile-arcs -ftest-coverage" EXTRA_LIBS="gcov" all_tests
47         ln -s ../../boost/ include/senf/  # ugly work-around
48         lcov --directory . --capture --output-file test_coverage.info --base-directory .
49         rm include/senf/boost
50         lcov --output-file /tmp/test_coverage.info.tmp --extract test_coverage.info \*/senf/\*
51         lcov --output-file test_coverage.info --remove /tmp/test_coverage.info.tmp \*/senf/include/\*
52         rm /tmp/test_coverage.info.tmp
53         genhtml --output-directory doc/test_coverage --title "all_tests" test_coverage.info
54
55 #----------------------------------------------------------------------
56 # Subversion stuff
57 #----------------------------------------------------------------------
58 svn_version:
59         @svnversion
60
61 #----------------------------------------------------------------------
62 # Building SENF requires some debian packages
63 #----------------------------------------------------------------------
64 DEB_BASE   = build-essential
65
66 # This line parses the 'Build-Depends' entry from debian/control
67 DEB_SENF   = $(shell perl -an -F'[:,]' -e '                                     \
68                          BEGIN{ $$,=" " }                                       \
69                          $$P=0 if /^\S/;                                        \
70                          map {s/\(.*\)//} @F;                                   \
71                          print @F if $$P;                                       \
72                          if (/^Build-Depends:/) { print @F[1..$$\#F]; $$P=1 }'  \
73                      debian/control | xargs echo)
74
75 prerequisites:
76         aptitude install $(DEB_BASE) $(DEB_SENF)
77
78 package:
79         $(SCONS) deb