debian: Fix bug from commit 211b05b5 "debian: Modernize use of dh_install."
[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                         --sysconfdir=/etc --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_prep -i
76         dh_installdirs -i
77         $(MAKE) -C _debian DESTDIR=$(CURDIR)/debian/tmp install
78         dh_install -i
79         sed 's/^BUILD_NUMBER = .*/BUILD_NUMBER = $(BUILD_NUMBER)/' \
80                 < debian/rules.modules \
81                 > debian/openvswitch-datapath-source/usr/src/modules/openvswitch-datapath/debian/rules
82         chmod 755 debian/openvswitch-datapath-source/usr/src/modules/openvswitch-datapath/debian/rules
83         cd debian/openvswitch-datapath-source/usr/src && tar -c modules | bzip2 -9 > openvswitch-datapath.tar.bz2 && rm -rf modules
84
85 install-arch: build-arch
86         dh_testdir
87         dh_testroot
88         dh_prep -s
89         dh_installdirs -s
90         $(MAKE) -C _debian DESTDIR=$(CURDIR)/debian/tmp install
91         cp debian/openvswitch-switch.template debian/openvswitch-switch/usr/share/openvswitch/switch/default.template
92         dh_install -s
93
94 # Must not depend on anything. This is to be called by
95 # binary-arch/binary-indep
96 # in another 'make' thread.
97 binary-common:
98         dh_testdir
99         dh_testroot
100         dh_installchangelogs 
101         dh_installdocs
102         dh_installexamples
103         dh_installdebconf
104         dh_installlogrotate
105         dh_installinit -R
106         dh_installcron
107         dh_installman
108         dh_link
109         dh_strip --dbg-package=openvswitch-dbg
110         dh_compress 
111         dh_fixperms
112         dh_pysupport
113         dh_perl
114         dh_makeshlibs
115         dh_installdeb
116         dh_shlibdeps
117         dh_gencontrol
118         dh_md5sums
119         dh_builddeb
120 binary-indep: install-indep
121         $(MAKE) -f debian/rules DH_OPTIONS=-i binary-common
122 binary-arch: install-arch
123         $(MAKE) -f debian/rules DH_OPTIONS=-s binary-common
124
125 binary: binary-arch binary-indep
126 .PHONY: build clean binary-indep binary-arch binary install install-indep install-arch configure
127
128 # This GNU make extensions disables parallel builds for the current Makefile
129 # but not for sub-Makefiles.  This is appropriate here because build-arch and
130 # build-indep both invoke "make" on OVS, which can update some of the same
131 # targets in ways that conflict (e.g. both update tests/testsuite).
132 .NOTPARALLEL: