Code

Merge branch 'upstream' into experimental
[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 #Python versions to build for. The work-around-doko way.
16 PY_VERS := $(shell set -e; \
17                    for py in `pysupport-parseversions debian/pyversions`; do \
18                        if [ -x /usr/bin/python$$py ]; then echo $$py; fi;    \
19                    done)
21 #tcl version we're building for
22 TCL_VERS := $(shell dpkg -s tcl-dev | grep '^Depends' \
23         | sed 's,.*\<tcl\([0-9.]*\)-dev\>.*,\1,')
26 #let's help configure to figure out our host/build system
27 DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
28 DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
29 ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
30   CONFFLAGS += --build $(DEB_HOST_GNU_TYPE)
31 else
32   CONFFLAGS += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
33 endif
35 #we build the bindings manually from debian/rules
36 CONFFLAGS += --disable-python --disable-ruby
38 #set the right paths
39 CONFFLAGS += --prefix=/usr --docdir=/usr/share/doc/rrdtool
41 #install perl libs in vendor mode
42 CONFFLAGS += --with-perl-options=INSTALLDIRS=vendor 
44 #path to tcl
45 CONFFLAGS += --with-tcllib=/usr/lib/tcl$(TCL_VERS)
47 #let's take care of optimization + debug builds
48 CFLAGS += -Wall -g
49 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
50         CFLAGS += -O0
51 else
52 #don't optimize on arm for now - #447041
53 ifneq ($(DEB_HOST_GNU_TYPE), arm)
54         CFLAGS += -O2
55 endif
56 endif
58 # work-around for a broken dpkg - do not rename this to LDFLAGS :-/
59 LINKER_FLAGS=-Wl,-z,defs
61 configure: config.status
62 config.status: $(QUILT_STAMPFN)
64 ifneq "$(wildcard /usr/share/misc/config.sub)" ""
65         cp -f /usr/share/misc/config.sub config.sub
66 endif
67 ifneq "$(wildcard /usr/share/misc/config.guess)" ""
68         cp -f /usr/share/misc/config.guess config.guess
69 endif
71         LDFLAGS="$(LINKER_FLAGS)" \
72         CFLAGS="$(CFLAGS)" \
73         RRDDOCDIR=/usr/share/doc/rrdtool \
74           ./configure $(CONFFLAGS)
76 build: build-arch build-indep 
78 build-arch: build-arch-stamp $(PY_VERS:%=build-python%)
79 build-arch-stamp: config.status 
80         make
81         #Fix library path to tcl bindings
82         sed -i -e 's|lib/|lib/tcltk/rrdtool-tcl/|' bindings/tcl/pkgIndex.tcl
83         #sanity check if debian/control lists the right package name
84         LIB_major=`grep '^dlname=' src/librrd.la \
85                         | sed -e "s/^dlname='librrd\.so\.\\([0-9]\+\\)'\$$/\\1/"` \
86                 && test -n "$$LIB_major" \
87                 && grep -q "^Package: librrd$$LIB_major\\>" debian/control
88         touch $@
90 build-python%: build-arch-stamp
91         set -e ;\
92          cd bindings/python ;\
93          BUILDLIBDIR=../../src/.libs LIBDIR=../../src/.libs python$* setup.py build
94         touch $@
96 build-indep: build-arch-stamp
97         #indep stuff is built in build-arch-stamp, too.
99 clean: clean-patched
100 clean-patched: unpatch $(PY_VERS:%=clean-python%)
101         dh_testdir
102         dh_testroot
104         [ ! -f Makefile ] || make distclean
106 ifneq "$(wildcard /usr/share/misc/config.sub)" ""
107         rm -f config.sub
108 endif
109 ifneq "$(wildcard /usr/share/misc/config.guess)" ""
110         rm -f config.guess
111 endif
112         rm -f build-arch-stamp build-indep-stamp config.status install-common-stamp
113         find . -name \*.pyc | xargs rm -f
114         rm -rf bindings/python/build
116         #clean what the Makefiles do not clean....
117         rm -rf bindings/perl-piped/blib bindings/perl-shared/blib \
118                bindings/perl-piped/Makefile.old bindings/perl-shared/Makefile.old
119         rm -f bindings/tcl/pkgIndex.tcl bindings/tcl/tclrrd*.so
120         rm -f examples/cgi-demo.cgi
121         rm -rf src/.libs src/.deps doc/*.html doc/*.1 doc/*.txt
122         rm -f intltool-extract intltool-merge intltool-update
124         dh_clean
126 clean-python%: unpatch
127         set -e ;\
128          cd bindings/python ;\
129          python$* setup.py clean
130         rm -f build-python$*
133 install: install-arch install-indep
135 install-indep: build-indep install-common-stamp
136         #nothing to do
138 install-common-stamp: build-arch-stamp
139         dh_testdir
140         dh_testroot
141         dh_clean -k
143         make install DESTDIR=$(CURDIR)/debian/tmp
144         dh_install --sourcedir=$(CURDIR)/debian/tmp --list-missing
146         touch $@
148 install-arch: install-common-stamp $(PY_VERS:%=install-python%)
149         #build and install ruby
150         set -e; \
151         cd bindings/ruby ;\
152         for rbv in $(RUBY_VERS); do \
153           ruby$$rbv extconf.rb ;\
154           make ;\
155           make install sitelibdir=$(CURDIR)/debian/librrd-ruby$$rbv`ruby$$rbv -r rbconfig -e 'print Config::CONFIG["rubylibdir"]'` \
156                        sitearchdir=$(CURDIR)/debian/librrd-ruby$$rbv`ruby$$rbv -r rbconfig -e 'print Config::CONFIG["archdir"]'` ;\
157           make distclean ;\
158         done
160         dh_installexamples -s
162 install-python%: install-common-stamp
163         dh_testdir
164         dh_testroot
165         set -e ;\
166          cd bindings/python ;\
167          python$* setup.py install --root=$(CURDIR)/debian/python-rrdtool
170 binary-indep: build-indep install-indep
171         dh_testdir
172         dh_testroot
173         dh_link -plibrrd-ruby /usr/share/doc/librrd-ruby$(RUBY_DEFAULT_VERS) /usr/share/doc/librrd-ruby
174         dh_link -ppython-rrd /usr/share/doc/python-rrdtool /usr/share/doc/python-rrd
175         dh_installchangelogs -i -Nlibrrd-ruby -Npython-rrd CHANGES
176         dh_installdocs -i -Nlibrrd-ruby -Npython-rrd -A CONTRIBUTORS NEWS
177         dh_link -i -Nlibrrd-ruby -Npython-rrd
178         echo 'rubydefault:Depends=librrd-ruby$(RUBY_DEFAULT_VERS)' >> debian/librrd-ruby.substvars
179         dh_perl -i
180         dh_compress -i
181         dh_fixperms -i
182         dh_installdeb -i
183         dh_gencontrol -i
184         dh_md5sums -i
185         dh_builddeb -i
186         
188 binary-arch: build-arch install-arch
189         dh_testdir
190         dh_testroot
191         dh_installchangelogs -a CHANGES
192         dh_installdocs -a -A CONTRIBUTORS NEWS
193         dh_installdocs -a
194         echo 'tcl:Depends=tcl$(TCL_VERS) | tclsh' >> debian/rrdtool-tcl.substvars
195         dh_pysupport -ppython-rrdtool
196         dh_perl -a
197         dh_installman -a
198         dh_link -a
199         dh_strip -a
200         dh_compress -a
201         dh_fixperms -a
202         dh_makeshlibs -a
203         dh_installdeb -a
204         dh_shlibdeps -a
205         dh_gencontrol -a
206         dh_md5sums -a
207         dh_builddeb -a
210 binary: binary-arch binary-indep
211 .PHONY: build clean configure \
212         binary-indep binary-arch binary \
213         install install-arch \
214         install-python% clean-python% unpatch