Further top-dir cleanup and lcov target
[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
16 SCONS=./tools/scons -j $(CONCURRENCY_LEVEL) $(SCONS_ARGS)
17
18 # DON'T call this default ... default is a valid scons target ;-)
19 build: default
20
21 TARGETS := prepare default examples all_tests all_docs all install_all \
22         deb debsrc debbin linklint fixlinks valgrind lcov
23 ALLTARGETS := $(TARGETS) package build
24
25 $(TARGETS):
26         $(SCONS) $@
27
28 clean:
29         $(SCONS) --clean all
30
31 package: deb
32 test_coverage: lcov
33
34 #----------------------------------------------------------------------
35 # subdirectory build targets
36 #----------------------------------------------------------------------
37
38 %/test %/doc:
39         $(SCONS) $@
40
41 %/build:
42         $(SCONS) $*
43
44 #----------------------------------------------------------------------
45 # remote compile targets
46 #----------------------------------------------------------------------
47
48 CWD = $(shell pwd)
49 $(ALLTARGETS:%=%@%):
50         ssh $* "cd $(CWD) && $(MAKE) SCONS_ARGS=\"$(SCONS_ARGS)\" $(firstword $(subst @, ,$@))"
51
52 #----------------------------------------------------------------------
53 # Subversion stuff
54 #----------------------------------------------------------------------
55
56 svn_version:
57         @v=`svnversion`; if [ $$v=="exported" ]; then gitsvnversion else echo $v; fi
58
59 version: svn_version
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 -alnF'[:,]' -e '                                                      \
68                         BEGIN{$$,=" "} END{splice @R,0,1; print @R}                             \
69                         map {s/\(.*\)|\|.*//; s/[ \n\t]//g} @F;                                 \
70                         push @R,grep {/./} @F if (/^Build-Depends:/i.../^\S/)!~/(^|E0)$$/;'     \
71                                 debian/control)
72
73 prerequisites:
74         aptitude install $(DEB_BASE) $(DEB_SENF)