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