cc17cd0fec477f6114c3009ae5e5daca7c58628b
[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 #export DH_VERBOSE=1
13
14 PACKAGE=openvswitch
15 PACKAGE_DKMS=openvswitch-datapath-dkms
16 DEB_UPSTREAM_VERSION=$(shell dpkg-parsechangelog | sed -rne 's,^Version: ([0-9]:)*([^-]+).*,\2,p')
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
24 %:
25         dh $@ --with autoreconf,python2 --parallel
26
27 # use --as-needed only if supported by dh-autoreconf (to simplify backporting)
28 DH_AS_NEEDED=$(shell dpkg --compare-versions $$(dpkg --status dh-autoreconf | grep Version | cut -d' ' -f2) ge 6 && echo --as-needed)
29 override_dh_autoreconf:
30         dh_autoreconf $(DH_AS_NEEDED)
31
32 override_dh_auto_configure:
33         dh_auto_configure -- --enable-ssl $(DATAPATH_CONFIGURE_OPTS)
34
35 override_dh_auto_test:
36 ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
37         if $(MAKE) check TESTSUITEFLAGS='$(PARALLEL)' || \
38                                 $(MAKE) check TESTSUITEFLAGS='--recheck'; then :; \
39         else \
40                 cat tests/testsuite.log; \
41                 exit 1; \
42         fi
43 endif
44
45 override_dh_auto_build:
46         dh_auto_build -- dist distdir=openvswitch
47
48 override_dh_auto_clean:
49         rm -f python/ovs/*.pyc python/ovs/db/*.pyc
50         dh_auto_clean
51
52 override_dh_install:
53         dh_install
54         # openvswitch-switch
55         cp debian/openvswitch-switch.template debian/openvswitch-switch/usr/share/openvswitch/switch/default.template
56
57         # ovn-host
58         cp debian/ovn-host.template debian/ovn-host/usr/share/ovn/host/default.template
59
60         # ovn-central
61         cp debian/ovn-central.template debian/ovn-central/usr/share/ovn/central/default.template
62
63         # openvswitch-datapath-source
64         cp debian/rules.modules debian/openvswitch-datapath-source/usr/src/modules/openvswitch-datapath/debian/rules
65         chmod 755 debian/openvswitch-datapath-source/usr/src/modules/openvswitch-datapath/debian/rules
66         cd debian/openvswitch-datapath-source/usr/src && tar -c modules | bzip2 -9 > openvswitch-datapath.tar.bz2 && rm -rf modules
67
68         # openvswitch-datapath-dkms
69         # setup the dirs
70         dh_installdirs -p$(PACKAGE_DKMS) usr/src/$(PACKAGE)-$(DEB_UPSTREAM_VERSION)
71
72         # copy the source
73         cd debian/$(PACKAGE_DKMS)/usr/src/$(PACKAGE)-$(DEB_UPSTREAM_VERSION) && tar xvzf $(CURDIR)/openvswitch.tar.gz && mv openvswitch/* openvswitch/.[a-z]* . && rmdir openvswitch
74
75         # check we can get kernel module names
76         $(MAKE) -C datapath print-build-modules
77
78         # Prepare dkms.conf from the dkms.conf.in template
79         sed "s/__VERSION__/$(DEB_UPSTREAM_VERSION)/g; s/__MODULES__/$(shell $(MAKE) -C datapath print-build-modules | grep -v make)/" debian/dkms.conf.in > debian/$(PACKAGE_DKMS)/usr/src/$(PACKAGE)-$(DEB_UPSTREAM_VERSION)/dkms.conf
80
81         # We don't need the debian folder in there, just upstream sources...
82         rm -rf debian/$(PACKAGE_DKMS)/usr/src/$(PACKAGE)-$(DEB_UPSTREAM_VERSION)/debian
83         # We don't need the rhel stuff in there either
84         rm -rf debian/$(PACKAGE_DKMS)/usr/src/$(PACKAGE)-$(DEB_UPSTREAM_VERSION)/rhel
85         # And we should also clean useless license files, which are already
86         # described in our debian/copyright anyway.
87         rm -f debian/$(PACKAGE_DKMS)/usr/src/$(PACKAGE)-$(DEB_UPSTREAM_VERSION)/COPYING \
88                 debian/$(PACKAGE_DKMS)/usr/src/$(PACKAGE)-$(DEB_UPSTREAM_VERSION)/xenserver/LICENSE
89
90 override_dh_installinit:
91         dh_installinit -R
92
93 override_dh_strip:
94         dh_strip --dbg-package=openvswitch-dbg