Do the Debian package build in a _debian subdirectory.
[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=openflow-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 configure: configure-stamp
29 configure-stamp:
30         dh_testdir
31         test -e configure || ./boot.sh
32         test -d _debian || mkdir _debian
33         cd _debian && ( \
34                 test -e Makefile || \
35                 ../configure --prefix=/usr --localstatedir=/var --enable-ssl)
36         touch configure-stamp
37
38 #Architecture 
39 build: build-arch build-indep
40
41 build-arch: build-arch-stamp
42 build-arch-stamp: configure-stamp 
43         $(MAKE) -C _debian
44         touch $@
45
46 build-indep: build-indep-stamp
47 build-indep-stamp: configure-stamp 
48         $(MAKE) -C _debian dist distdir=openflow
49         touch $@
50
51 clean:
52         dh_testdir
53         dh_testroot
54         rm -f build-arch-stamp build-indep-stamp configure-stamp
55         rm -rf _debian
56         [ ! -f Makefile ] || $(MAKE) distclean
57         dh_clean 
58         debconf-updatepo
59
60 MAJOR=$(shell echo $(KVERS) | sed -e 's/\(...\).*/\1/')
61 ifeq ($(MAJOR),2.6)
62 KO=k
63 l2x=l26
64 dpdir=datapath/linux-2.6
65 else
66 KO=
67 l2x=l24
68 dpdir=datapath/linux-2.4
69 endif
70
71 kdist_clean:
72         dh_clean
73         make KERNELDIR=$(KSRC) KVERREL=$(KVERS) clean
74
75 kdist_config: prep-deb-files
76
77 binary-modules: DSTDIR = $(CURDIR)/debian/$(PKGNAME)/lib/modules/$(KVERS)
78 binary-modules: prep-deb-files
79         dh_testdir
80         dh_testroot
81         dh_clean -k
82         tar xzf openflow.tar.gz
83         cd openflow && ./configure --with-$(l2x)=$(KSRC)
84         cd openflow && $(MAKE) -C $(dpdir)
85         install -d -m755 $(DSTDIR)
86         install -m644 openflow/$(dpdir)/*_mod.$(KO)o $(DSTDIR)/
87         dh_installdocs
88         dh_installchangelogs
89         dh_compress
90         dh_fixperms
91         dh_installdeb
92         dh_gencontrol -- -v$(VERSION)
93         dh_md5sums
94         dh_builddeb --destdir=$(DEB_DESTDIR)
95
96 install: install-indep install-arch
97 install-indep: MODDIR = $(CURDIR)/debian/openflow-datapath-source/usr/src/modules/openflow-datapath
98 install-indep: build-indep
99         dh_testdir
100         dh_testroot
101         dh_clean -k -i 
102         dh_installdirs -i
103         cp _debian/openflow.tar.gz $(MODDIR)
104         cd debian; cp changelog control compat *.modules.in rules $(MODDIR)/debian
105         cd debian/openflow-datapath-source/usr/src && tar -c modules | bzip2 -9 > openflow-datapath.tar.bz2 && rm -rf modules
106         install -m644 debian/openflow-pki.apache2 debian/openflow-pki/etc/apache2/sites-available/openflow-pki
107         dh_install -i
108
109 install-arch: build-arch
110         dh_testdir
111         dh_testroot
112         dh_clean -k -s 
113         dh_installdirs -s
114         $(MAKE) -C _debian DESTDIR=$(CURDIR)/debian/openflow install
115         cp debian/openflow-switch.overrides debian/openflow-switch/usr/share/lintian/overrides/openflow-switch
116         dh_install -s
117
118 # Must not depend on anything. This is to be called by
119 # binary-arch/binary-indep
120 # in another 'make' thread.
121 binary-common:
122         dh_testdir
123         dh_testroot
124         dh_installchangelogs 
125         dh_installdocs
126         dh_installexamples
127         dh_installdebconf
128 #       dh_installlogrotate
129         dh_installinit
130         dh_installman
131         dh_link
132         dh_strip
133         dh_compress 
134         dh_fixperms
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