debian: Run tests in parallel too.
[sliver-openvswitch.git] / debian / rules
1 #!/usr/bin/make -f
2 # -*- makefile -*-
3 # Sample debian/rules that uses debhelper.
4 #
5 # This file was originally written by Joey Hess and Craig Small.
6 # As a special exception, when this file is copied by dh-make into a
7 # dh-make output file, you may use that output file without restriction.
8 # This special exception was added by Craig Small in version 0.37 of dh-make.
9 #
10 # Modified to make a template file for a multi-binary package with separated
11 # build-arch and build-indep targets  by Bill Allombert 2001
12
13 # Official build number.  Leave set to 0 if not an official build.
14 BUILD_NUMBER = 0
15
16 ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
17 PARALLEL = -j$(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
18 else
19 PARALLEL =
20 endif
21 MAKEFLAGS += $(PARALLEL)
22
23 ifneq (,$(filter noopt,$(DEB_BUILD_OPTIONS)))
24 CFLAGS += -O0
25 else
26 CFLAGS += -O2
27 endif
28
29 configure: configure-stamp
30 configure-stamp:
31         dh_testdir
32         test -e configure || ./boot.sh
33         test -d _debian || mkdir _debian
34         echo $(DEB_BUILD_OPTIONS)
35         echo $$CC
36         cd _debian && ( \
37                 test -e Makefile || \
38                 ../configure --prefix=/usr --localstatedir=/var --enable-ssl \
39                         --with-build-number=$(BUILD_NUMBER) \
40                         CFLAGS="$(CFLAGS)" $(DATAPATH_CONFIGURE_OPTS))
41         touch configure-stamp
42
43 #Architecture 
44 build: build-arch build-indep
45
46 build-arch: build-arch-stamp
47 build-arch-stamp: configure-stamp 
48         $(MAKE) -C _debian
49 ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
50         if $(MAKE) -C _debian check TESTSUITEFLAGS='$(PARALLEL)'; then :; \
51         else \
52                 cat _debian/tests/testsuite.log; \
53                 exit 1; \
54         fi
55 endif
56         touch $@
57
58 build-indep: build-indep-stamp
59 build-indep-stamp: configure-stamp 
60         $(MAKE) -C _debian dist distdir=openvswitch
61         touch $@
62
63 clean:
64         dh_testdir
65         dh_testroot
66         rm -f build-arch-stamp build-indep-stamp configure-stamp
67         rm -rf _debian
68         [ ! -f Makefile ] || $(MAKE) distclean
69         dh_clean 
70
71 install: install-indep install-arch
72 install-indep: build-indep
73         dh_testdir
74         dh_testroot
75         dh_clean -k -i 
76         dh_installdirs -i
77         dh_install -i
78         sed 's/^BUILD_NUMBER = .*/BUILD_NUMBER = $(BUILD_NUMBER)/' \
79                 < debian/rules.modules \
80                 > debian/openvswitch-datapath-source/usr/src/modules/openvswitch-datapath/debian/rules
81         chmod 755 debian/openvswitch-datapath-source/usr/src/modules/openvswitch-datapath/debian/rules
82         cd debian/openvswitch-datapath-source/usr/src && tar -c modules | bzip2 -9 > openvswitch-datapath.tar.bz2 && rm -rf modules
83
84 install-arch: build-arch
85         dh_testdir
86         dh_testroot
87         dh_clean -k -s 
88         dh_installdirs -s
89         $(MAKE) -C _debian DESTDIR=$(CURDIR)/debian/openvswitch install
90         cp debian/openvswitch-switch.template debian/openvswitch-switch/usr/share/openvswitch/switch/default.template
91         dh_install -s
92
93 # Must not depend on anything. This is to be called by
94 # binary-arch/binary-indep
95 # in another 'make' thread.
96 binary-common:
97         dh_testdir
98         dh_testroot
99         dh_installchangelogs 
100         dh_installdocs
101         dh_installexamples
102         dh_installdebconf
103         dh_installlogrotate
104         dh_installinit
105         dh_installcron
106         dh_installman
107         dh_link
108         dh_strip --dbg-package=openvswitch-dbg
109         dh_compress 
110         dh_fixperms -X var/log/core
111         dh_pysupport
112         dh_perl
113         dh_makeshlibs
114         dh_installdeb
115         dh_shlibdeps
116         dh_gencontrol
117         dh_md5sums
118         dh_builddeb
119 binary-indep: install-indep
120         $(MAKE) -f debian/rules DH_OPTIONS=-i binary-common
121 binary-arch: install-arch
122         $(MAKE) -f debian/rules DH_OPTIONS=-s binary-common
123
124 binary: binary-arch binary-indep
125 .PHONY: build clean binary-indep binary-arch binary install install-indep install-arch configure
126
127 # This GNU make extensions disables parallel builds for the current Makefile
128 # but not for sub-Makefiles.  This is appropriate here because build-arch and
129 # build-indep both invoke "make" on OVS, which can update some of the same
130 # targets in ways that conflict (e.g. both update tests/testsuite).
131 .NOTPARALLEL: