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