debian: Honor "noopt", "parallel=<n>" build options.
[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 # Uncomment this to turn on verbose mode.
14 #export DH_VERBOSE=1
15
16 # This has to be exported to make some magic below work.
17 export DH_OPTIONS
18
19 # prefix of the target package name
20 PACKAGE=openvswitch-datapath-module
21 # modifieable for experiments or debugging m-a
22 MA_DIR ?= /usr/share/modass
23 # load generic variable handling
24 -include $(MA_DIR)/include/generic.make
25 # load default rules
26 -include $(MA_DIR)/include/common-rules.make
27
28 DATAPATH_CONFIGURE_OPTS =
29
30 # Official build number.  Leave set to 0 if not an official build.
31 BUILD_NUMBER = 0
32
33 ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
34 NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
35 MAKEFLAGS += -j$(NUMJOBS)
36 endif
37
38 ifneq (,$(filter noopt,$(DEB_BUILD_OPTIONS)))
39 CFLAGS += -O0
40 else
41 CFLAGS += -O2
42 endif
43
44 configure: configure-stamp
45 configure-stamp:
46         dh_testdir
47         test -e configure || ./boot.sh
48         test -d _debian || mkdir _debian
49         cd _debian && ( \
50                 test -e Makefile || \
51                 ../configure --prefix=/usr --localstatedir=/var --enable-ssl \
52                         --with-build-number=$(BUILD_NUMBER) \
53                         CFLAGS="$(CFLAGS)" $(DATAPATH_CONFIGURE_OPTS))
54         touch configure-stamp
55
56 #Architecture 
57 build: build-arch build-indep
58
59 build-arch: build-arch-stamp
60 build-arch-stamp: configure-stamp 
61         $(MAKE) -C _debian
62 ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
63         $(MAKE) -C _debian check
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         debconf-updatepo
80
81 kdist_clean:
82         dh_clean
83         rm -rf openvswitch
84
85 kdist_config: prep-deb-files
86
87 binary-modules: DSTDIR = $(CURDIR)/debian/$(PKGNAME)/lib/modules/$(KVERS)
88 binary-modules: prep-deb-files
89         dh_testdir
90         dh_testroot
91         dh_clean -k
92         tar xzf openvswitch.tar.gz
93         cd openvswitch && ./configure --with-l26=$(KSRC) $(DATAPATH_CONFIGURE_OPTS) --with-build-number=$(BUILD_NUMBER)
94         cd openvswitch && $(MAKE) -C datapath/linux-2.6
95         install -d -m755 $(DSTDIR)
96         install -m644 openvswitch/datapath/linux-2.6/*_mod.ko $(DSTDIR)/
97         dh_installdocs
98         dh_installchangelogs
99         dh_compress
100         dh_fixperms
101         dh_installdeb
102         dh_gencontrol
103         dh_md5sums
104         dh_builddeb --destdir=$(DEB_DESTDIR)
105
106 install: install-indep install-arch
107 install-indep: build-indep
108         dh_testdir
109         dh_testroot
110         dh_clean -k -i 
111         dh_installdirs -i
112         dh_install -i
113         cd debian/openvswitch-datapath-source/usr/src && tar -c modules | bzip2 -9 > openvswitch-datapath.tar.bz2 && rm -rf modules
114         install -m644 debian/openvswitch-pki-server.apache2 debian/openvswitch-pki-server/etc/apache2/sites-available/openvswitch-pki
115         install -m1777 -d debian/corekeeper/var/log/core
116
117 install-arch: build-arch
118         dh_testdir
119         dh_testroot
120         dh_clean -k -s 
121         dh_installdirs -s
122         $(MAKE) -C _debian DESTDIR=$(CURDIR)/debian/openvswitch install
123         cp debian/openvswitch-switch-config.overrides debian/openvswitch-switch-config/usr/share/lintian/overrides/openvswitch-switch-config
124         cp debian/openvswitch-switch.template debian/openvswitch-switch/usr/share/openvswitch/switch/default.template
125         dh_install -s
126         env TERMINFO=debian/openvswitch-switchui/usr/share/terminfo tic -x extras/ezio/ezio3.ti
127
128 # Must not depend on anything. This is to be called by
129 # binary-arch/binary-indep
130 # in another 'make' thread.
131 binary-common:
132         dh_testdir
133         dh_testroot
134         dh_installchangelogs 
135         dh_installdocs
136         dh_installexamples
137         dh_installdebconf
138         dh_installlogrotate
139         dh_installinit
140         dh_installcron
141         dh_installman
142         dh_link
143         dh_strip --dbg-package=openvswitch-dbg
144         dh_compress 
145         dh_fixperms -X var/log/core
146         dh_perl
147         dh_makeshlibs
148         dh_installdeb
149         dh_shlibdeps
150         dh_gencontrol
151         dh_md5sums
152         dh_builddeb
153 binary-indep: install-indep
154         $(MAKE) -f debian/rules DH_OPTIONS=-i binary-common
155 binary-arch: install-arch
156         $(MAKE) -f debian/rules DH_OPTIONS=-s binary-common
157
158 binary: binary-arch binary-indep
159 .PHONY: build clean binary-indep binary-arch binary install install-indep install-arch configure