debian: Run build tests during build (unless "nocheck" is specified).
[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 configure: configure-stamp
34 configure-stamp:
35         dh_testdir
36         test -e configure || ./boot.sh
37         test -d _debian || mkdir _debian
38         cd _debian && ( \
39                 test -e Makefile || \
40                 ../configure --prefix=/usr --localstatedir=/var --enable-ssl \
41                         --with-build-number=$(BUILD_NUMBER) \
42                         $(DATAPATH_CONFIGURE_OPTS))
43         touch configure-stamp
44
45 #Architecture 
46 build: build-arch build-indep
47
48 build-arch: build-arch-stamp
49 build-arch-stamp: configure-stamp 
50         $(MAKE) -C _debian
51 ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
52         $(MAKE) -C _debian check
53 endif
54         touch $@
55
56 build-indep: build-indep-stamp
57 build-indep-stamp: configure-stamp 
58         $(MAKE) -C _debian dist distdir=openvswitch
59         touch $@
60
61 clean:
62         dh_testdir
63         dh_testroot
64         rm -f build-arch-stamp build-indep-stamp configure-stamp
65         rm -rf _debian
66         [ ! -f Makefile ] || $(MAKE) distclean
67         dh_clean 
68         debconf-updatepo
69
70 kdist_clean:
71         dh_clean
72         rm -rf openvswitch
73
74 kdist_config: prep-deb-files
75
76 binary-modules: DSTDIR = $(CURDIR)/debian/$(PKGNAME)/lib/modules/$(KVERS)
77 binary-modules: prep-deb-files
78         dh_testdir
79         dh_testroot
80         dh_clean -k
81         tar xzf openvswitch.tar.gz
82         cd openvswitch && ./configure --with-l26=$(KSRC) $(DATAPATH_CONFIGURE_OPTS) --with-build-number=$(BUILD_NUMBER)
83         cd openvswitch && $(MAKE) -C datapath/linux-2.6
84         install -d -m755 $(DSTDIR)
85         install -m644 openvswitch/datapath/linux-2.6/*_mod.ko $(DSTDIR)/
86         dh_installdocs
87         dh_installchangelogs
88         dh_compress
89         dh_fixperms
90         dh_installdeb
91         dh_gencontrol
92         dh_md5sums
93         dh_builddeb --destdir=$(DEB_DESTDIR)
94
95 install: install-indep install-arch
96 install-indep: build-indep
97         dh_testdir
98         dh_testroot
99         dh_clean -k -i 
100         dh_installdirs -i
101         dh_install -i
102         cd debian/openvswitch-datapath-source/usr/src && tar -c modules | bzip2 -9 > openvswitch-datapath.tar.bz2 && rm -rf modules
103         install -m644 debian/openvswitch-pki-server.apache2 debian/openvswitch-pki-server/etc/apache2/sites-available/openvswitch-pki
104         install -m1777 -d debian/corekeeper/var/log/core
105
106 install-arch: build-arch
107         dh_testdir
108         dh_testroot
109         dh_clean -k -s 
110         dh_installdirs -s
111         $(MAKE) -C _debian DESTDIR=$(CURDIR)/debian/openvswitch install
112         cp debian/openvswitch-switch-config.overrides debian/openvswitch-switch-config/usr/share/lintian/overrides/openvswitch-switch-config
113         cp debian/openvswitch-switch.template debian/openvswitch-switch/usr/share/openvswitch/switch/default.template
114         dh_install -s
115         env TERMINFO=debian/openvswitch-switchui/usr/share/terminfo tic -x extras/ezio/ezio3.ti
116
117 # Must not depend on anything. This is to be called by
118 # binary-arch/binary-indep
119 # in another 'make' thread.
120 binary-common:
121         dh_testdir
122         dh_testroot
123         dh_installchangelogs 
124         dh_installdocs
125         dh_installexamples
126         dh_installdebconf
127         dh_installlogrotate
128         dh_installinit
129         dh_installcron
130         dh_installman
131         dh_link
132         dh_strip --dbg-package=openvswitch-dbg
133         dh_compress 
134         dh_fixperms -X var/log/core
135         dh_perl
136         dh_makeshlibs
137         dh_installdeb
138         dh_shlibdeps
139         dh_gencontrol
140         dh_md5sums
141         dh_builddeb
142 binary-indep: install-indep
143         $(MAKE) -f debian/rules DH_OPTIONS=-i binary-common
144 binary-arch: install-arch
145         $(MAKE) -f debian/rules DH_OPTIONS=-s binary-common
146
147 binary: binary-arch binary-indep
148 .PHONY: build clean binary-indep binary-arch binary install install-indep install-arch configure