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