Rework debian package build: build final and debug packages and split off include...
[senf.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 debian_build=1
17 export debian_build
18
19 # This has to be exported to make some magic below work.
20 export DH_OPTIONS
21
22 #DPKG_ARCH#
23
24 CFLAGS = -Wall -g
25
26 CONCURRENCY_LEVEL ?= 1
27 export CONCURRENCY_LEVEL
28
29 LIBTYPE ?= UNSPEC
30
31 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
32         CFLAGS += -O0
33 else
34         CFLAGS += -O2
35 endif
36
37 destdir=$(CURDIR)/debian/tmp
38
39 configure: configure-stamp
40 configure-stamp:
41         dh_testdir
42 #       # Add here commands to configure the package.
43         rm -f Doxyfile.local SConfig local_config.hh
44         scons prepare
45 #       If needed, we could create new files 'Doxyfile.local',
46 #       'SConfig' and/or 'local_config.hh' here.  We don't remove them
47 #       in 'clean' to allow building a source package from an
48 #       individually configured svn working copy. (The files are ignored
49 #       by dpkg-buildpackge because of appropriate -I arguments provided 
50 #       by 'scons deb' and 'scons debsrc'
51         touch configure-stamp
52
53 build: #build-arch build-indep
54
55 build-arch: build-arch-$(LIBTYPE)-stamp
56 build-arch-$(LIBTYPE)-stamp: configure-stamp
57 #       Add here commands to compile the arch part of the package.
58         scons -j $(CONCURRENCY_LEVEL) default $(SCONS_OPTIONS)
59         touch $@
60
61 build-indep: build-indep-stamp
62 build-indep-stamp: configure-stamp
63 #       Add here commands to compile the indep part of the package.
64         scons -j $(CONCURRENCY_LEVEL) all_docs
65         scons linklint
66         scons fixlinks
67         touch $@
68
69 clean: debclean
70 #       Add here commands to clean up after the build process.
71         -scons -c all
72         -scons -c all LIBSENF=senf_g
73
74 debclean:
75         dh_testdir
76         dh_testroot
77         rm -f build-arch-*-stamp build-indep-stamp configure-stamp
78         dh_clean
79
80 install: #install-indep install-arch
81 install-indep: build-indep
82         dh_testdir
83         dh_testroot
84         dh_clean -k -i
85         dh_installdirs -i
86 #       Add here commands to install the indep part of the package into
87 #       debian/<package>-doc.
88         scons $(destdir)/usr/include $(destdir)/usr/share/doc $(SCONS_OPTIONS) \
89                 PREFIX='$(destdir)/usr' \
90                 DOCINSTALLDIR='$$PREFIX/share/doc/libsenf-doc' \
91                 INCLUDEINSTALLDIR='$$PREFIX/include/senf' 
92 #       We need to install the example sourcecode
93         find Examples \( -name "*.hh" -o -name "*.cc" \) -printf "%P\n" | \
94                 while read src; do \
95                         dir="$(destdir)/usr/share/doc/libsenf-doc/examples/$$(dirname "$$src")"; \
96                         mkdir -p "$$dir"; \
97                         cp "Examples/$$src" "$$dir"; \
98                 done
99         dh_install -X.svn -i
100
101 install-arch: build-arch
102         dh_testdir
103         dh_testroot
104         dh_clean -k -s
105         dh_installdirs # options provided by DH_OPTIONS
106 #       Add here commands to install the arch part of the package into 
107 #       debian/tmp.
108         scons $(destdir)/usr/lib $(SCONS_OPTIONS) PREFIX='$(destdir)/usr'
109         dh_install -X.svn # options provided by DH_OPTIONS
110
111 # Must not depend on anything. This is to be called by
112 # binary-arch/binary-indep
113 # in another 'make' thread.
114 binary-common:
115         dh_testdir
116         dh_testroot
117         dh_installchangelogs
118         dh_installdocs
119         dh_installexamples
120 #       dh_installmenu
121 #       dh_installdebconf       
122 #       dh_installlogrotate     
123 #       dh_installemacsen
124 #       dh_installpam
125 #       dh_installmime
126 #       dh_python
127 #       dh_installinit
128 #       dh_installcron
129 #       dh_installinfo
130         dh_installman
131         dh_link
132         dh_strip
133         dh_compress -Xhtml -Xdoclib -Xexamples
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
143 binary-indep: build-indep install-indep
144         $(MAKE) -f debian/rules DH_OPTIONS=-i binary-common
145
146 binary-arch: binary-arch-final binary-arch-debug
147
148 binary-arch-final:
149         $(MAKE) -f debian/rules \
150                 DH_OPTIONS="-s -Nlibsenf-dbg" \
151                 SCONS_OPTIONS="final=1" \
152                 LIBTYPE="final" \
153                         binary-arch-common
154
155 binary-arch-debug:
156         $(MAKE) -f debian/rules \
157                 DH_OPTIONS="-plibsenf-dbg" \
158                 SCONS_OPTIONS="LIBSENF=senf_g" \
159                 LIBTYPE="debug" \
160                         binary-arch-common
161
162 binary-arch-common: build-arch install-arch
163         $(MAKE) -f debian/rules DH_OPTIONS="$(DH_OPTIONS)" binary-common
164
165 binary: binary-arch binary-indep
166 .PHONY: build clean binary-indep binary-arch binary install install-indep install-arch \
167         binary-arch-common binary-arch-final binary-arch-debug