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