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