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