b21c8dbf0be1d232c59a8d3bc06db184cb3dd9c2
[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 configure: configure-stamp
39 configure-stamp:
40         dh_testdir
41         test -e configure || ./boot.sh
42         test -d _debian || mkdir _debian
43         echo $(DEB_BUILD_OPTIONS)
44         echo $$CC
45         cd _debian && ( \
46                 test -e Makefile || \
47                 ../configure --prefix=/usr --localstatedir=/var --enable-ssl \
48                         --sysconfdir=/etc CFLAGS="$(CFLAGS)" \
49                         $(buildflags) $(DATAPATH_CONFIGURE_OPTS))
50         touch configure-stamp
51
52 #Architecture 
53 build: build-arch build-indep
54
55 build-arch: build-arch-stamp
56 build-arch-stamp: configure-stamp 
57         $(MAKE) -C _debian
58 ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
59         if $(MAKE) -C _debian check TESTSUITEFLAGS='$(PARALLEL)'; then :; \
60         else \
61                 cat _debian/tests/testsuite.log; \
62                 exit 1; \
63         fi
64 endif
65         touch $@
66
67 build-indep: build-indep-stamp
68 build-indep-stamp: configure-stamp 
69         $(MAKE) -C _debian dist distdir=openvswitch
70         touch $@
71
72 clean:
73         dh_testdir
74         dh_testroot
75         rm -f build-arch-stamp build-indep-stamp configure-stamp
76         rm -rf _debian
77         [ ! -f Makefile ] || $(MAKE) distclean
78         dh_clean 
79         rm -f python/ovs/*.pyc python/ovs/db/*.pyc
80
81 install: install-indep install-arch
82 install-indep: build-indep
83         dh_testdir
84         dh_testroot
85         dh_prep -i
86         dh_installdirs -i
87         $(MAKE) -C _debian DESTDIR=$(CURDIR)/debian/tmp install
88         dh_install -i
89         cp debian/rules.modules debian/openvswitch-datapath-source/usr/src/modules/openvswitch-datapath/debian/rules
90         chmod 755 debian/openvswitch-datapath-source/usr/src/modules/openvswitch-datapath/debian/rules
91         cd debian/openvswitch-datapath-source/usr/src && tar -c modules | bzip2 -9 > openvswitch-datapath.tar.bz2 && rm -rf modules
92
93         #dkms stuff
94         # setup the dirs
95         dh_installdirs -p$(pdkms) usr/src/$(PACKAGE)-$(DEB_UPSTREAM_VERSION)
96
97         # copy the source
98         cd debian/$(pdkms)/usr/src/$(PACKAGE)-$(DEB_UPSTREAM_VERSION) && tar xvzf $(CURDIR)/_debian/openvswitch.tar.gz && mv openvswitch/* . && rmdir openvswitch
99
100         # Prepare dkms.conf from the dkms.conf.in template
101         sed "s/__VERSION__/$(DEB_UPSTREAM_VERSION)/g" debian/dkms.conf.in > debian/$(pdkms)/usr/src/$(PACKAGE)-$(DEB_UPSTREAM_VERSION)/dkms.conf
102
103         # We don't need the debian folder in there, just upstream sources...
104         rm -rf debian/$(pdkms)/usr/src/$(PACKAGE)-$(DEB_UPSTREAM_VERSION)/debian
105         # We don't need the rhel stuff in there either
106         rm -rf debian/$(pdkms)/usr/src/$(PACKAGE)-$(DEB_UPSTREAM_VERSION)/rhel
107         # And we should also clean useless license files, which are already
108         # descriped in our debian/copyright anyway.
109         rm -f debian/$(pdkms)/usr/src/$(PACKAGE)-$(DEB_UPSTREAM_VERSION)/COPYING \
110                 debian/$(pdkms)/usr/src/$(PACKAGE)-$(DEB_UPSTREAM_VERSION)/ovsdb/ovsdbmonitor/COPYING \
111                 debian/$(pdkms)/usr/src/$(PACKAGE)-$(DEB_UPSTREAM_VERSION)/xenserver/LICENSE
112
113 install-arch: build-arch
114         dh_testdir
115         dh_testroot
116         dh_prep -s
117         dh_installdirs -s
118         $(MAKE) -C _debian DESTDIR=$(CURDIR)/debian/tmp install
119         cp debian/openvswitch-switch.template debian/openvswitch-switch/usr/share/openvswitch/switch/default.template
120         dh_install -s
121         dh_link -s
122
123 # Must not depend on anything. This is to be called by
124 # binary-arch/binary-indep
125 # in another 'make' thread.
126 binary-common:
127         dh_testdir
128         dh_testroot
129         dh_installchangelogs 
130         dh_installdocs
131         dh_installexamples
132         dh_installdebconf
133         dh_installlogrotate
134         dh_installinit -R
135         dh_installcron
136         dh_installman --language=C
137         dh_link
138         dh_strip --dbg-package=openvswitch-dbg
139         dh_compress 
140         dh_fixperms
141         dh_python2
142         dh_perl
143         dh_makeshlibs
144         dh_installdeb
145         dh_shlibdeps
146         dh_gencontrol
147         dh_md5sums
148         dh_builddeb
149 binary-indep: install-indep
150         $(MAKE) -f debian/rules DH_OPTIONS=-i binary-common
151 binary-arch: install-arch
152         $(MAKE) -f debian/rules DH_OPTIONS=-s binary-common
153
154 binary: binary-arch binary-indep
155 .PHONY: build clean binary-indep binary-arch binary install install-indep install-arch configure
156
157 # This GNU make extensions disables parallel builds for the current Makefile
158 # but not for sub-Makefiles.  This is appropriate here because build-arch and
159 # build-indep both invoke "make" on OVS, which can update some of the same
160 # targets in ways that conflict (e.g. both update tests/testsuite).
161 .NOTPARALLEL: