Merge "master" into "ovn".
[cascardo/ovs.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 PACKAGE=openvswitch
14 pdkms=openvswitch-datapath-dkms
15 DEB_UPSTREAM_VERSION=$(shell dpkg-parsechangelog | sed -rne 's,^Version: ([0-9]:)*([^-]+).*,\2,p')
16 srcfiles := $(filter-out debian, $(wildcard * .[^.]*))
17
18 ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
19 PARALLEL = -j$(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
20 else
21 PARALLEL =
22 endif
23 MAKEFLAGS += $(PARALLEL)
24
25 # Old versions of dpkg-buildflags do not understand --export=configure.
26 # When dpkg-buildflags does not understand an option, it prints its full
27 # --help output on stdout, so we have to avoid that here.
28 buildflags := $(shell if dpkg-buildflags --export=configure >/dev/null 2>&1; \
29                       then dpkg-buildflags --export=configure; fi)
30
31 configure: configure-stamp
32 configure-stamp:
33         dh_testdir
34         test -e configure || ./boot.sh
35         test -d _debian || mkdir _debian
36         echo $(DEB_BUILD_OPTIONS)
37         echo $$CC
38         cd _debian && ( \
39                 test -e Makefile || \
40                 ../configure --prefix=/usr --localstatedir=/var --enable-ssl \
41                         --sysconfdir=/etc --host=$(DEB_HOST_GNU_TYPE) \
42                         $(buildflags) $(DATAPATH_CONFIGURE_OPTS))
43         touch configure-stamp
44
45 #Architecture 
46 build: build-arch build-indep
47
48 build-arch: build-arch-stamp
49 build-arch-stamp: configure-stamp 
50         $(MAKE) -C _debian
51 ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
52         if $(MAKE) -C _debian check TESTSUITEFLAGS='$(PARALLEL)' || \
53                 $(MAKE) -C _debian check TESTSUITEFLAGS='--recheck'; then :; \
54         else \
55                 cat _debian/tests/testsuite.log; \
56                 exit 1; \
57         fi
58 endif
59         touch $@
60
61 build-indep: build-indep-stamp
62 build-indep-stamp: configure-stamp 
63         $(MAKE) -C _debian dist distdir=openvswitch
64         touch $@
65
66 clean:
67         dh_testdir
68         dh_testroot
69         rm -f build-arch-stamp build-indep-stamp configure-stamp
70         rm -rf _debian
71         [ ! -f Makefile ] || $(MAKE) distclean
72         dh_clean 
73         rm -f python/ovs/*.pyc python/ovs/db/*.pyc
74
75 install: install-indep install-arch
76 install-indep: build-indep
77         dh_testdir
78         dh_testroot
79         dh_prep -i
80         dh_installdirs -i
81         $(MAKE) -C _debian DESTDIR=$(CURDIR)/debian/tmp install
82         dh_install -i
83         cp debian/rules.modules debian/openvswitch-datapath-source/usr/src/modules/openvswitch-datapath/debian/rules
84         chmod 755 debian/openvswitch-datapath-source/usr/src/modules/openvswitch-datapath/debian/rules
85         cd debian/openvswitch-datapath-source/usr/src && tar -c modules | bzip2 -9 > openvswitch-datapath.tar.bz2 && rm -rf modules
86
87         #dkms stuff
88         # setup the dirs
89         dh_installdirs -p$(pdkms) usr/src/$(PACKAGE)-$(DEB_UPSTREAM_VERSION)
90
91         # copy the source
92         cd debian/$(pdkms)/usr/src/$(PACKAGE)-$(DEB_UPSTREAM_VERSION) && tar xvzf $(CURDIR)/_debian/openvswitch.tar.gz && mv openvswitch/* openvswitch/.[a-z]* . && rmdir openvswitch
93
94         # check we can get kernel module names
95         $(MAKE) -C _debian/datapath print-build-modules
96
97         # Prepare dkms.conf from the dkms.conf.in template
98         sed "s/__VERSION__/$(DEB_UPSTREAM_VERSION)/g; s/__MODULES__/$(shell $(MAKE) -C _debian/datapath print-build-modules | grep -v make)/" debian/dkms.conf.in > debian/$(pdkms)/usr/src/$(PACKAGE)-$(DEB_UPSTREAM_VERSION)/dkms.conf
99
100         # We don't need the debian folder in there, just upstream sources...
101         rm -rf debian/$(pdkms)/usr/src/$(PACKAGE)-$(DEB_UPSTREAM_VERSION)/debian
102         # We don't need the rhel stuff in there either
103         rm -rf debian/$(pdkms)/usr/src/$(PACKAGE)-$(DEB_UPSTREAM_VERSION)/rhel
104         # And we should also clean useless license files, which are already
105         # descriped in our debian/copyright anyway.
106         rm -f debian/$(pdkms)/usr/src/$(PACKAGE)-$(DEB_UPSTREAM_VERSION)/COPYING \
107                 debian/$(pdkms)/usr/src/$(PACKAGE)-$(DEB_UPSTREAM_VERSION)/xenserver/LICENSE
108
109 install-arch: build-arch
110         dh_testdir
111         dh_testroot
112         dh_prep -s
113         dh_installdirs -s
114         $(MAKE) -C _debian DESTDIR=$(CURDIR)/debian/tmp install
115         cp debian/openvswitch-switch.template debian/openvswitch-switch/usr/share/openvswitch/switch/default.template
116         dh_install -s
117         dh_link -s
118
119 # Must not depend on anything. This is to be called by
120 # binary-arch/binary-indep
121 # in another 'make' thread.
122 binary-common:
123         dh_testdir
124         dh_testroot
125         dh_installchangelogs 
126         dh_installdocs
127         dh_installexamples
128         dh_installdebconf
129         dh_installlogrotate
130         dh_installinit -R
131         dh_installcron
132         dh_installman --language=C
133         dh_link
134         dh_strip --dbg-package=openvswitch-dbg
135         dh_compress 
136         dh_fixperms
137         dh_python2
138         dh_perl
139         dh_makeshlibs
140         dh_installdeb
141         dh_shlibdeps
142         dh_gencontrol
143         dh_md5sums
144         dh_builddeb
145 binary-indep: install-indep
146         $(MAKE) -f debian/rules DH_OPTIONS=-i binary-common
147 binary-arch: install-arch
148         $(MAKE) -f debian/rules DH_OPTIONS=-s binary-common
149
150 binary: binary-arch binary-indep
151 .PHONY: build clean binary-indep binary-arch binary install install-indep install-arch configure
152
153 # This GNU make extensions disables parallel builds for the current Makefile
154 # but not for sub-Makefiles.  This is appropriate here because build-arch and
155 # build-indep both invoke "make" on OVS, which can update some of the same
156 # targets in ways that conflict (e.g. both update tests/testsuite).
157 .NOTPARALLEL: