Code

390eb8d46a8a4f39240c20df6c5edac4a62feb45
[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 PY_VERS := $(shell pyversions -vr)
24 #tcl version we're building for
25 TCL_VERS := $(shell dpkg -s tcl-dev | grep '^Depends' \
26         | sed 's,.*\<tcl\([0-9.]*\)-dev\>.*,\1,')
28 #let's help configure to figure out our host/build system
29 DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
30 DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
31 DEB_HOST_ARCH_CPU   ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_CPU)
33 ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
34   CONFFLAGS += --build $(DEB_HOST_GNU_TYPE)
35 else
36   CONFFLAGS += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
37 endif
39 #we build the bindings manually from debian/rules
40 CONFFLAGS += --disable-python --disable-ruby
42 #set the right paths
43 CONFFLAGS += --prefix=/usr --docdir=/usr/share/doc/rrdtool
45 #install perl libs in vendor mode
46 CONFFLAGS += --with-perl-options=INSTALLDIRS=vendor 
48 #path to tcl
49 CONFFLAGS += --with-tcllib=/usr/lib/tcl$(TCL_VERS)
51 #let's take care of optimization + debug builds
52 CFLAGS += -Wall -g
53 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
54         CFLAGS += -O0
55 else
56 #don't optimize on arm for now - #447041
57 ifneq ($(DEB_HOST_ARCH_CPU), arm)
58         CFLAGS += -O2
59 endif
60 endif
62 # work-around for a broken dpkg - do not rename this to LDFLAGS :-/
63 LINKER_FLAGS=-Wl,-z,defs
65 configure: config.status
66 config.status: $(QUILT_STAMPFN)
68 ifneq "$(wildcard /usr/share/misc/config.sub)" ""
69         cp -f /usr/share/misc/config.sub config.sub
70 endif
71 ifneq "$(wildcard /usr/share/misc/config.guess)" ""
72         cp -f /usr/share/misc/config.guess config.guess
73 endif
75         dh_autoreconf
77         LDFLAGS="$(LINKER_FLAGS)" \
78         CFLAGS="$(CFLAGS)" \
79         RRDDOCDIR=/usr/share/doc/rrdtool \
80           ./configure $(CONFFLAGS)
82 build: build-arch build-indep 
84 build-arch: build-arch-stamp $(PY_VERS:%=build-python%) $(PY_VERS:%=build-python%-dbg)
85 build-arch-stamp: config.status 
86         make
87         #Fix library path to tcl bindings
88         sed -i -e 's|lib/|lib/tcltk/rrdtool-tcl/|' bindings/tcl/pkgIndex.tcl
89         #sanity check if debian/control lists the right package name
90         LIB_major=`grep '^dlname=' src/librrd.la \
91                         | sed -e "s/^dlname='librrd\.so\.\\([0-9]\+\\)'\$$/\\1/"` \
92                 && test -n "$$LIB_major" \
93                 && grep -q "^Package: librrd$$LIB_major\\>" debian/control
94         touch $@
96 build-python%: build-arch-stamp
97         set -e ;\
98          cd bindings/python ;\
99          BUILDLIBDIR=../../src/.libs LIBDIR=../../src/.libs python$* setup.py build ;\
100          touch $@
102 build-indep: build-arch-stamp
103         #indep stuff is built in build-arch-stamp, too.
105 clean: clean-patched
106 clean-patched: unpatch $(PY_VERS:%=clean-python%) $(PY_VERS:%=clean-python%-dbg)
107         dh_testdir
108         dh_testroot
110         [ ! -f Makefile ] || make distclean
112 ifneq "$(wildcard /usr/share/misc/config.sub)" ""
113         rm -f config.sub
114 endif
115 ifneq "$(wildcard /usr/share/misc/config.guess)" ""
116         rm -f config.guess
117 endif
118         rm -f build-arch-stamp build-indep-stamp config.status install-common-stamp
119         find . -name \*.pyc | xargs rm -f
120         rm -rf bindings/python/build
122         # clean what the Makefiles do not clean ...
123         rm -rf bindings/perl-piped/blib bindings/perl-shared/blib \
124                bindings/perl-piped/Makefile.old bindings/perl-shared/Makefile.old bindings/perl-shared/MYMETA.yml
125         rm -f bindings/tcl/pkgIndex.tcl bindings/tcl/tclrrd*.so
126         rm -f examples/cgi-demo.cgi
127         rm -rf src/.libs src/.deps doc/*.html doc/*.1 doc/*.txt
128         rm -f intltool-extract intltool-merge intltool-update
129         rm -f src/librrd.sym
130         rm -f config.h
132         dh_autoreconf_clean
134         dh_clean
136 clean-python%: unpatch
137         set -e ;\
138          cd bindings/python ;\
139          python$* setup.py clean ;\
140          rm -f build-python$*
143 install: install-arch install-indep
145 install-indep: build-indep install-common-stamp
146         #nothing to do
148 install-common-stamp: build-arch-stamp
149         dh_testdir
150         dh_testroot
151         dh_clean -k
153         make install DESTDIR=$(CURDIR)/debian/tmp
154         # we don't want .txt and .pod documentation in the package
155         rm -rf debian/tmp/usr/share/doc/rrdtool/txt
156         dh_install --sourcedir=$(CURDIR)/debian/tmp -X.la --fail-missing
157         # remove duplicates
158         rm debian/rrdtool/usr/bin/rrdcached
159         rm debian/rrdtool/usr/share/man/man1/rrdcached.1
160         rm debian/rrdtool/usr/share/doc/rrdtool/html/rrdcached.html
162         touch $@
164 install-arch: install-common-stamp $(PY_VERS:%=install-python%)
165         #build and install ruby
166         dh_ruby --install
168         dh_installexamples -s
169         chmod 644 debian/rrdcached/usr/share/doc/rrdcached/examples/RRDCached.pm
171 install-python%: install-common-stamp
172         dh_testdir
173         dh_testroot
174         set -e ;\
175          cd bindings/python ;\
176          python$* setup.py install --root=$(CURDIR)/debian/python-rrdtool \
177                 $(py_setup_install_args) ;\
178          python$*-dbg setup.py install --root=$(CURDIR)/debian/rrdtool-dbg \
179                 $(py_setup_install_args)
181         find $(CURDIR)/debian/rrdtool-dbg -type f -name '*.egg-info' -print0 |\
182                  xargs -0r rm -f
185 binary-indep: build-indep install-indep
186         dh_testdir
187         dh_testroot
188         dh_installchangelogs -i CHANGES
189         dh_installdocs -i -A CONTRIBUTORS NEWS
190         dh_link -i
191         dh_perl -i
192         dh_compress -i
193         dh_fixperms -i
194         dh_installdeb -i
195         dh_gencontrol -i
196         dh_md5sums -i
197         dh_builddeb -i
198         
200 binary-arch: build-arch install-arch
201         dh_testdir
202         dh_testroot
203         dh_installchangelogs -a CHANGES
204         dh_installdocs -a -A CONTRIBUTORS NEWS
205         dh_installdocs -a
206         echo 'tcl:Depends=tcl$(TCL_VERS) | tclsh' >> debian/rrdtool-tcl.substvars
207         dh_python2 -ppython-rrdtool
208         dh_python2 -prrdtool-dbg
209         dh_perl -a
210         dh_installman -a
211         dh_installinit -prrdcached
212         dh_link -a
213         dh_strip -a --dbg-package=rrdtool-dbg
214         dh_compress -a
215         dh_fixperms -a
216         dh_makeshlibs -a -Nliblua5.1-rrd0 -Nliblua5.1-rrd-dev
217         dh_makeshlibs -pliblua5.1-rrd0 -pliblua5.1-rrd-dev -n
218         dh_installdeb -a
219         dh_shlibdeps -a
220         dh_gencontrol -a
221         dh_md5sums -a
222         dh_builddeb -a
225 binary: binary-arch binary-indep
226 .PHONY: build clean configure \
227         binary-indep binary-arch binary \
228         install install-arch \
229         install-python% clean-python% unpatch