Code

Prepare to build with Python 2.6
[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
10 #needed to build with Python 2.6
11 -include /usr/share/python/python.mk
12 ifeq (,$(py_sitename))
13   py_sitename = site-packages
14   py_libdir = /usr/lib/python$(subst python,,$(1))/site-packages
15   py_sitename_sh = $(py_sitename)
16   py_libdir_sh = $(py_libdir)
17   py_setup_install_args = 
18 endif
22 #Ruby versions to build for
23 RUBY_VERS := 1.8 1.9
24 RUBY_DEFAULT_VERS := 1.8
26 PY_VERS := $(shell pyversions -vr)
28 #tcl version we're building for
29 TCL_VERS := $(shell dpkg -s tcl-dev | grep '^Depends' \
30         | sed 's,.*\<tcl\([0-9.]*\)-dev\>.*,\1,')
33 #let's help configure to figure out our host/build system
34 DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
35 DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
36 ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
37   CONFFLAGS += --build $(DEB_HOST_GNU_TYPE)
38 else
39   CONFFLAGS += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
40 endif
42 #we build the bindings manually from debian/rules
43 CONFFLAGS += --disable-python --disable-ruby
45 #set the right paths
46 CONFFLAGS += --prefix=/usr --docdir=/usr/share/doc/rrdtool
48 #install perl libs in vendor mode
49 CONFFLAGS += --with-perl-options=INSTALLDIRS=vendor 
51 #path to tcl
52 CONFFLAGS += --with-tcllib=/usr/lib/tcl$(TCL_VERS)
54 #let's take care of optimization + debug builds
55 CFLAGS += -Wall -g
56 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
57         CFLAGS += -O0
58 else
59 #don't optimize on arm for now - #447041
60 ifneq ($(DEB_HOST_GNU_TYPE), arm)
61         CFLAGS += -O2
62 endif
63 endif
65 # work-around for a broken dpkg - do not rename this to LDFLAGS :-/
66 LINKER_FLAGS=-Wl,-z,defs
68 configure: config.status
69 config.status: $(QUILT_STAMPFN)
71 ifneq "$(wildcard /usr/share/misc/config.sub)" ""
72         cp -f /usr/share/misc/config.sub config.sub
73 endif
74 ifneq "$(wildcard /usr/share/misc/config.guess)" ""
75         cp -f /usr/share/misc/config.guess config.guess
76 endif
78         LDFLAGS="$(LINKER_FLAGS)" \
79         CFLAGS="$(CFLAGS)" \
80         RRDDOCDIR=/usr/share/doc/rrdtool \
81           ./configure $(CONFFLAGS)
83 build: build-arch build-indep 
85 build-arch: build-arch-stamp $(PY_VERS:%=build-python%) $(PY_VERS:%=build-python%-dbg)
86 build-arch-stamp: config.status 
87         make
88         #Fix library path to tcl bindings
89         sed -i -e 's|lib/|lib/tcltk/rrdtool-tcl/|' bindings/tcl/pkgIndex.tcl
90         #sanity check if debian/control lists the right package name
91         LIB_major=`grep '^dlname=' src/librrd.la \
92                         | sed -e "s/^dlname='librrd\.so\.\\([0-9]\+\\)'\$$/\\1/"` \
93                 && test -n "$$LIB_major" \
94                 && grep -q "^Package: librrd$$LIB_major\\>" debian/control
95         touch $@
97 build-python%: build-arch-stamp
98         set -e ;\
99          cd bindings/python ;\
100          BUILDLIBDIR=../../src/.libs LIBDIR=../../src/.libs python$* setup.py build ;\
101          touch $@
103 build-indep: build-arch-stamp
104         #indep stuff is built in build-arch-stamp, too.
106 clean: clean-patched
107 clean-patched: unpatch $(PY_VERS:%=clean-python%) $(PY_VERS:%=clean-python%-dbg)
108         dh_testdir
109         dh_testroot
111         [ ! -f Makefile ] || make distclean
113 ifneq "$(wildcard /usr/share/misc/config.sub)" ""
114         rm -f config.sub
115 endif
116 ifneq "$(wildcard /usr/share/misc/config.guess)" ""
117         rm -f config.guess
118 endif
119         rm -f build-arch-stamp build-indep-stamp config.status install-common-stamp
120         find . -name \*.pyc | xargs rm -f
121         rm -rf bindings/python/build
123         # clean what the Makefiles do not clean ...
124         rm -rf bindings/perl-piped/blib bindings/perl-shared/blib \
125                bindings/perl-piped/Makefile.old bindings/perl-shared/Makefile.old
126         rm -f bindings/tcl/pkgIndex.tcl bindings/tcl/tclrrd*.so
127         rm -f examples/cgi-demo.cgi
128         rm -rf src/.libs src/.deps doc/*.html doc/*.1 doc/*.txt
129         rm -f intltool-extract intltool-merge intltool-update
130         rm -f src/librrd.sym
132         dh_clean
134 clean-python%: unpatch
135         set -e ;\
136          cd bindings/python ;\
137          python$* setup.py clean ;\
138          rm -f build-python$*
141 install: install-arch install-indep
143 install-indep: build-indep install-common-stamp
144         #nothing to do
146 install-common-stamp: build-arch-stamp
147         dh_testdir
148         dh_testroot
149         dh_clean -k
151         make install DESTDIR=$(CURDIR)/debian/tmp
152         # we don't want .txt and .pod documentation in the package
153         rm -rf debian/tmp/usr/share/doc/rrdtool/txt
154         dh_install --sourcedir=$(CURDIR)/debian/tmp --fail-missing
156         touch $@
158 install-arch: install-common-stamp $(PY_VERS:%=install-python%)
159         #build and install ruby
160         set -e; \
161         cd bindings/ruby ;\
162         for rbv in $(RUBY_VERS); do \
163           ruby$$rbv extconf.rb ;\
164           make ;\
165           make install sitelibdir=$(CURDIR)/debian/librrd-ruby$$rbv`ruby$$rbv -r rbconfig -e 'print Config::CONFIG["rubylibdir"]'` \
166                        sitearchdir=$(CURDIR)/debian/librrd-ruby$$rbv`ruby$$rbv -r rbconfig -e 'print Config::CONFIG["archdir"]'` ;\
167           make distclean ;\
168         done
170         dh_installexamples -s
172 install-python%: install-common-stamp
173         dh_testdir
174         dh_testroot
175         set -e ;\
176          cd bindings/python ;\
177          python$* setup.py install --root=$(CURDIR)/debian/python-rrdtool \
178                 $(py_setup_install_args) ;\
179          python$*-dbg setup.py install --root=$(CURDIR)/debian/rrdtool-dbg \
180                 $(py_setup_install_args)
182         find $(CURDIR)/debian/rrdtool-dbg -type f -name '*.egg-info' -print0 |\
183                  xargs -0r rm -f
186 binary-indep: build-indep install-indep
187         dh_testdir
188         dh_testroot
189         dh_link -plibrrd-ruby /usr/share/doc/librrd-ruby$(RUBY_DEFAULT_VERS) /usr/share/doc/librrd-ruby
190         dh_installchangelogs -i -Nlibrrd-ruby CHANGES
191         dh_installdocs -i -Nlibrrd-ruby -A CONTRIBUTORS NEWS
192         dh_link -i -Nlibrrd-ruby
193         echo 'rubydefault:Depends=librrd-ruby$(RUBY_DEFAULT_VERS)' >> debian/librrd-ruby.substvars
194         dh_perl -i
195         dh_compress -i
196         dh_fixperms -i
197         dh_installdeb -i
198         dh_gencontrol -i
199         dh_md5sums -i
200         dh_builddeb -i
201         
203 binary-arch: build-arch install-arch
204         dh_testdir
205         dh_testroot
206         dh_installchangelogs -a CHANGES
207         dh_installdocs -a -A CONTRIBUTORS NEWS
208         dh_installdocs -a
209         echo 'tcl:Depends=tcl$(TCL_VERS) | tclsh' >> debian/rrdtool-tcl.substvars
210         dh_pysupport -ppython-rrdtool
211         dh_pysupport -prrdtool-dbg
212         dh_perl -a
213         dh_installman -a
214         dh_link -a
215         dh_strip -a --dbg-package=rrdtool-dbg
216         dh_compress -a
217         dh_fixperms -a
218         dh_makeshlibs -a
219         dh_installdeb -a
220         dh_shlibdeps -a
221         dh_gencontrol -a
222         dh_md5sums -a
223         dh_builddeb -a
226 binary: binary-arch binary-indep
227 .PHONY: build clean configure \
228         binary-indep binary-arch binary \
229         install install-arch \
230         install-python% clean-python% unpatch