debian: Clean .pyc files in "clean" target.
[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 PACKAGE=openvswitch
17 pdkms=openvswitch-datapath-dkms
18 DEB_UPSTREAM_VERSION=$(shell dpkg-parsechangelog | sed -rne 's,^Version: ([0-9]:)*([^-]+).*,\2,p')
19 srcfiles := $(filter-out debian, $(wildcard * .[^.]*))
20
21 ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
22 PARALLEL = -j$(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
23 else
24 PARALLEL =
25 endif
26 MAKEFLAGS += $(PARALLEL)
27
28 ifneq (,$(filter noopt,$(DEB_BUILD_OPTIONS)))
29 CFLAGS += -O0
30 else
31 CFLAGS += -O2
32 endif
33
34 configure: configure-stamp
35 configure-stamp:
36         dh_testdir
37         test -e configure || ./boot.sh
38         test -d _debian || mkdir _debian
39         echo $(DEB_BUILD_OPTIONS)
40         echo $$CC
41         cd _debian && ( \
42                 test -e Makefile || \
43                 ../configure --prefix=/usr --localstatedir=/var --enable-ssl \
44                         --sysconfdir=/etc --with-build-number=$(BUILD_NUMBER) \
45                         CFLAGS="$(CFLAGS)" $(DATAPATH_CONFIGURE_OPTS))
46         touch configure-stamp
47
48 #Architecture 
49 build: build-arch build-indep
50
51 build-arch: build-arch-stamp
52 build-arch-stamp: configure-stamp 
53         $(MAKE) -C _debian
54 ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
55         if $(MAKE) -C _debian check TESTSUITEFLAGS='$(PARALLEL)'; then :; \
56         else \
57                 cat _debian/tests/testsuite.log; \
58                 exit 1; \
59         fi
60 endif
61         touch $@
62
63 build-indep: build-indep-stamp
64 build-indep-stamp: configure-stamp 
65         $(MAKE) -C _debian dist distdir=openvswitch
66         touch $@
67
68 clean:
69         dh_testdir
70         dh_testroot
71         rm -f build-arch-stamp build-indep-stamp configure-stamp
72         rm -rf _debian
73         [ ! -f Makefile ] || $(MAKE) distclean
74         dh_clean 
75         rm -f python/ovs/*.pyc python/ovs/db/*.pyc
76
77 install: install-indep install-arch
78 install-indep: build-indep
79         dh_testdir
80         dh_testroot
81         dh_prep -i
82         dh_installdirs -i
83         $(MAKE) -C _debian DESTDIR=$(CURDIR)/debian/tmp install
84         dh_install -i
85         sed 's/^BUILD_NUMBER = .*/BUILD_NUMBER = $(BUILD_NUMBER)/' \
86                 < debian/rules.modules \
87                 > debian/openvswitch-datapath-source/usr/src/modules/openvswitch-datapath/debian/rules
88         chmod 755 debian/openvswitch-datapath-source/usr/src/modules/openvswitch-datapath/debian/rules
89         cd debian/openvswitch-datapath-source/usr/src && tar -c modules | bzip2 -9 > openvswitch-datapath.tar.bz2 && rm -rf modules
90
91         #dkms stuff
92         # setup the dirs
93         dh_installdirs -p$(pdkms) usr/src/$(PACKAGE)-$(DEB_UPSTREAM_VERSION)
94
95         # copy the source
96         cd debian/$(pdkms)/usr/src/$(PACKAGE)-$(DEB_UPSTREAM_VERSION) && tar xvzf $(CURDIR)/_debian/openvswitch.tar.gz && mv openvswitch/* . && rmdir openvswitch
97
98         # Prepare dkms.conf from the dkms.conf.in template
99         sed "s/__VERSION__/$(DEB_UPSTREAM_VERSION)/g" debian/dkms.conf.in > debian/$(pdkms)/usr/src/$(PACKAGE)-$(DEB_UPSTREAM_VERSION)/dkms.conf
100
101 install-arch: build-arch
102         dh_testdir
103         dh_testroot
104         dh_prep -s
105         dh_installdirs -s
106         $(MAKE) -C _debian DESTDIR=$(CURDIR)/debian/tmp install
107         cp debian/openvswitch-switch.template debian/openvswitch-switch/usr/share/openvswitch/switch/default.template
108         dh_install -s
109
110 # Must not depend on anything. This is to be called by
111 # binary-arch/binary-indep
112 # in another 'make' thread.
113 binary-common:
114         dh_testdir
115         dh_testroot
116         dh_installchangelogs 
117         dh_installdocs
118         dh_installexamples
119         dh_installdebconf
120         dh_installlogrotate
121         dh_installinit -R -Nopenvswitch-switch
122         dh_installinit -R -popenvswitch-switch --error-handler=init_script_error
123         dh_installcron
124         dh_installman --language=C
125         dh_link
126         dh_strip --dbg-package=openvswitch-dbg
127         dh_compress 
128         dh_fixperms
129         dh_python2
130         dh_perl
131         dh_makeshlibs
132         dh_installdeb
133         dh_shlibdeps
134         dh_gencontrol
135         dh_md5sums
136         dh_builddeb
137 binary-indep: install-indep
138         $(MAKE) -f debian/rules DH_OPTIONS=-i binary-common
139 binary-arch: install-arch
140         $(MAKE) -f debian/rules DH_OPTIONS=-s binary-common
141
142 binary: binary-arch binary-indep
143 .PHONY: build clean binary-indep binary-arch binary install install-indep install-arch configure
144
145 # This GNU make extensions disables parallel builds for the current Makefile
146 # but not for sub-Makefiles.  This is appropriate here because build-arch and
147 # build-indep both invoke "make" on OVS, which can update some of the same
148 # targets in ways that conflict (e.g. both update tests/testsuite).
149 .NOTPARALLEL: