Code

rules: Clean python*-dbg as well.
[pkg-rrdtool.git] / debian / rules
1 #!/usr/bin/make -f
2 # -*- makefile -*-
4 # Uncomment this to turn on verbose mode.
5 #export DH_VERBOSE=1
7 #we use quilt
8 include /usr/share/quilt/quilt.make
11 #Ruby versions to build for
12 RUBY_VERS := 1.8 1.9
13 RUBY_DEFAULT_VERS := 1.8
15 PY_VERS := $(shell pyversions -vr)
17 #tcl version we're building for
18 TCL_VERS := $(shell dpkg -s tcl-dev | grep '^Depends' \
19         | sed 's,.*\<tcl\([0-9.]*\)-dev\>.*,\1,')
22 #let's help configure to figure out our host/build system
23 DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
24 DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
25 ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
26   CONFFLAGS += --build $(DEB_HOST_GNU_TYPE)
27 else
28   CONFFLAGS += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
29 endif
31 #we build the bindings manually from debian/rules
32 CONFFLAGS += --disable-python --disable-ruby
34 #set the right paths
35 CONFFLAGS += --prefix=/usr --docdir=/usr/share/doc/rrdtool
37 #install perl libs in vendor mode
38 CONFFLAGS += --with-perl-options=INSTALLDIRS=vendor 
40 #path to tcl
41 CONFFLAGS += --with-tcllib=/usr/lib/tcl$(TCL_VERS)
43 #let's take care of optimization + debug builds
44 CFLAGS += -Wall -g
45 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
46         CFLAGS += -O0
47 else
48 #don't optimize on arm for now - #447041
49 ifneq ($(DEB_HOST_GNU_TYPE), arm)
50         CFLAGS += -O2
51 endif
52 endif
54 # work-around for a broken dpkg - do not rename this to LDFLAGS :-/
55 LINKER_FLAGS=-Wl,-z,defs
57 configure: config.status
58 config.status: $(QUILT_STAMPFN)
60 ifneq "$(wildcard /usr/share/misc/config.sub)" ""
61         cp -f /usr/share/misc/config.sub config.sub
62 endif
63 ifneq "$(wildcard /usr/share/misc/config.guess)" ""
64         cp -f /usr/share/misc/config.guess config.guess
65 endif
67         LDFLAGS="$(LINKER_FLAGS)" \
68         CFLAGS="$(CFLAGS)" \
69         RRDDOCDIR=/usr/share/doc/rrdtool \
70           ./configure $(CONFFLAGS)
72 build: build-arch build-indep 
74 build-arch: build-arch-stamp $(PY_VERS:%=build-python%) $(PY_VERS:%=build-python%-dbg)
75 build-arch-stamp: config.status 
76         make
77         #Fix library path to tcl bindings
78         sed -i -e 's|lib/|lib/tcltk/rrdtool-tcl/|' bindings/tcl/pkgIndex.tcl
79         #sanity check if debian/control lists the right package name
80         LIB_major=`grep '^dlname=' src/librrd.la \
81                         | sed -e "s/^dlname='librrd\.so\.\\([0-9]\+\\)'\$$/\\1/"` \
82                 && test -n "$$LIB_major" \
83                 && grep -q "^Package: librrd$$LIB_major\\>" debian/control
84         touch $@
86 build-python%: build-arch-stamp
87         set -e ;\
88          cd bindings/python ;\
89          BUILDLIBDIR=../../src/.libs LIBDIR=../../src/.libs python$* setup.py build ;\
90          touch $@
92 build-indep: build-arch-stamp
93         #indep stuff is built in build-arch-stamp, too.
95 clean: clean-patched
96 clean-patched: unpatch $(PY_VERS:%=clean-python%) $(PY_VERS:%=clean-python%-dbg)
97         dh_testdir
98         dh_testroot
100         [ ! -f Makefile ] || make distclean
102 ifneq "$(wildcard /usr/share/misc/config.sub)" ""
103         rm -f config.sub
104 endif
105 ifneq "$(wildcard /usr/share/misc/config.guess)" ""
106         rm -f config.guess
107 endif
108         rm -f build-arch-stamp build-indep-stamp config.status install-common-stamp
109         find . -name \*.pyc | xargs rm -f
110         rm -rf bindings/python/build
112         # clean what the Makefiles do not clean ...
113         rm -rf bindings/perl-piped/blib bindings/perl-shared/blib \
114                bindings/perl-piped/Makefile.old bindings/perl-shared/Makefile.old
115         rm -f bindings/tcl/pkgIndex.tcl bindings/tcl/tclrrd*.so
116         rm -f examples/cgi-demo.cgi
117         rm -rf src/.libs src/.deps doc/*.html doc/*.1 doc/*.txt
118         rm -f intltool-extract intltool-merge intltool-update
119         rm -f src/librrd.sym
121         dh_clean
123 clean-python%: unpatch
124         set -e ;\
125          cd bindings/python ;\
126          python$* setup.py clean ;\
127          rm -f build-python$*
130 install: install-arch install-indep
132 install-indep: build-indep install-common-stamp
133         #nothing to do
135 install-common-stamp: build-arch-stamp
136         dh_testdir
137         dh_testroot
138         dh_clean -k
140         make install DESTDIR=$(CURDIR)/debian/tmp
141         # we don't want .txt and .pod documentation in the package
142         rm -rf debian/tmp/usr/share/doc/rrdtool/txt
143         dh_install --sourcedir=$(CURDIR)/debian/tmp --fail-missing
145         touch $@
147 install-arch: install-common-stamp $(PY_VERS:%=install-python%)
148         #build and install ruby
149         set -e; \
150         cd bindings/ruby ;\
151         for rbv in $(RUBY_VERS); do \
152           ruby$$rbv extconf.rb ;\
153           make ;\
154           make install sitelibdir=$(CURDIR)/debian/librrd-ruby$$rbv`ruby$$rbv -r rbconfig -e 'print Config::CONFIG["rubylibdir"]'` \
155                        sitearchdir=$(CURDIR)/debian/librrd-ruby$$rbv`ruby$$rbv -r rbconfig -e 'print Config::CONFIG["archdir"]'` ;\
156           make distclean ;\
157         done
159         dh_installexamples -s
161 install-python%: install-common-stamp
162         dh_testdir
163         dh_testroot
164         set -e ;\
165          cd bindings/python ;\
166          python$* setup.py install --root=$(CURDIR)/debian/python-rrdtool ;\
167          python$*-dbg setup.py install --root=$(CURDIR)/debian/rrdtool-dbg
168         find $(CURDIR)/debian/rrdtool-dbg -type f -name '*.egg-info' -print0 |\
169                  xargs -0r rm -f
172 binary-indep: build-indep install-indep
173         dh_testdir
174         dh_testroot
175         dh_link -plibrrd-ruby /usr/share/doc/librrd-ruby$(RUBY_DEFAULT_VERS) /usr/share/doc/librrd-ruby
176         dh_installchangelogs -i -Nlibrrd-ruby CHANGES
177         dh_installdocs -i -Nlibrrd-ruby -A CONTRIBUTORS NEWS
178         dh_link -i -Nlibrrd-ruby
179         echo 'rubydefault:Depends=librrd-ruby$(RUBY_DEFAULT_VERS)' >> debian/librrd-ruby.substvars
180         dh_perl -i
181         dh_compress -i
182         dh_fixperms -i
183         dh_installdeb -i
184         dh_gencontrol -i
185         dh_md5sums -i
186         dh_builddeb -i
187         
189 binary-arch: build-arch install-arch
190         dh_testdir
191         dh_testroot
192         dh_installchangelogs -a CHANGES
193         dh_installdocs -a -A CONTRIBUTORS NEWS
194         dh_installdocs -a
195         echo 'tcl:Depends=tcl$(TCL_VERS) | tclsh' >> debian/rrdtool-tcl.substvars
196         dh_pysupport -ppython-rrdtool
197         dh_pysupport -prrdtool-dbg
198         dh_perl -a
199         dh_installman -a
200         dh_link -a
201         dh_strip -a --dbg-package=rrdtool-dbg
202         dh_compress -a
203         dh_fixperms -a
204         dh_makeshlibs -a
205         dh_installdeb -a
206         dh_shlibdeps -a
207         dh_gencontrol -a
208         dh_md5sums -a
209         dh_builddeb -a
212 binary: binary-arch binary-indep
213 .PHONY: build clean configure \
214         binary-indep binary-arch binary \
215         install install-arch \
216         install-python% clean-python% unpatch