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