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