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 LDFLAGS="$(LINKER_FLAGS)" \
76 CFLAGS="$(CFLAGS)" \
77 RRDDOCDIR=/usr/share/doc/rrdtool \
78 ./configure $(CONFFLAGS)
80 build: build-arch build-indep
82 build-arch: build-arch-stamp $(PY_VERS:%=build-python%) $(PY_VERS:%=build-python%-dbg)
83 build-arch-stamp: config.status
84 make
85 #Fix library path to tcl bindings
86 sed -i -e 's|lib/|lib/tcltk/rrdtool-tcl/|' bindings/tcl/pkgIndex.tcl
87 #sanity check if debian/control lists the right package name
88 LIB_major=`grep '^dlname=' src/librrd.la \
89 | sed -e "s/^dlname='librrd\.so\.\\([0-9]\+\\)'\$$/\\1/"` \
90 && test -n "$$LIB_major" \
91 && grep -q "^Package: librrd$$LIB_major\\>" debian/control
92 touch $@
94 build-python%: build-arch-stamp
95 set -e ;\
96 cd bindings/python ;\
97 BUILDLIBDIR=../../src/.libs LIBDIR=../../src/.libs python$* setup.py build ;\
98 touch $@
100 build-indep: build-arch-stamp
101 #indep stuff is built in build-arch-stamp, too.
103 clean: clean-patched
104 clean-patched: unpatch $(PY_VERS:%=clean-python%) $(PY_VERS:%=clean-python%-dbg)
105 dh_testdir
106 dh_testroot
108 [ ! -f Makefile ] || make distclean
110 ifneq "$(wildcard /usr/share/misc/config.sub)" ""
111 rm -f config.sub
112 endif
113 ifneq "$(wildcard /usr/share/misc/config.guess)" ""
114 rm -f config.guess
115 endif
116 rm -f build-arch-stamp build-indep-stamp config.status install-common-stamp
117 find . -name \*.pyc | xargs rm -f
118 rm -rf bindings/python/build
120 # clean what the Makefiles do not clean ...
121 rm -rf bindings/perl-piped/blib bindings/perl-shared/blib \
122 bindings/perl-piped/Makefile.old bindings/perl-shared/Makefile.old bindings/perl-shared/MYMETA.yml
123 rm -f bindings/tcl/pkgIndex.tcl bindings/tcl/tclrrd*.so
124 rm -f examples/cgi-demo.cgi
125 rm -rf src/.libs src/.deps doc/*.html doc/*.1 doc/*.txt
126 rm -f intltool-extract intltool-merge intltool-update
127 rm -f src/librrd.sym
128 rm -f config.h
130 dh_clean
132 clean-python%: unpatch
133 set -e ;\
134 cd bindings/python ;\
135 python$* setup.py clean ;\
136 rm -f build-python$*
139 install: install-arch install-indep
141 install-indep: build-indep install-common-stamp
142 #nothing to do
144 install-common-stamp: build-arch-stamp
145 dh_testdir
146 dh_testroot
147 dh_clean -k
149 make install DESTDIR=$(CURDIR)/debian/tmp
150 # we don't want .txt and .pod documentation in the package
151 rm -rf debian/tmp/usr/share/doc/rrdtool/txt
152 dh_install --sourcedir=$(CURDIR)/debian/tmp -X.la --fail-missing
153 # remove duplicates
154 rm debian/rrdtool/usr/bin/rrdcached
155 rm debian/rrdtool/usr/share/man/man1/rrdcached.1
156 rm debian/rrdtool/usr/share/doc/rrdtool/html/rrdcached.html
158 touch $@
160 install-arch: install-common-stamp $(PY_VERS:%=install-python%)
161 #build and install ruby
162 dh_ruby --install
164 dh_installexamples -s
165 chmod 644 debian/rrdcached/usr/share/doc/rrdcached/examples/RRDCached.pm
167 install-python%: install-common-stamp
168 dh_testdir
169 dh_testroot
170 set -e ;\
171 cd bindings/python ;\
172 python$* setup.py install --root=$(CURDIR)/debian/python-rrdtool \
173 $(py_setup_install_args) ;\
174 python$*-dbg setup.py install --root=$(CURDIR)/debian/rrdtool-dbg \
175 $(py_setup_install_args)
177 find $(CURDIR)/debian/rrdtool-dbg -type f -name '*.egg-info' -print0 |\
178 xargs -0r rm -f
181 binary-indep: build-indep install-indep
182 dh_testdir
183 dh_testroot
184 dh_installchangelogs -i CHANGES
185 dh_installdocs -i -A CONTRIBUTORS NEWS
186 dh_link -i
187 dh_perl -i
188 dh_compress -i
189 dh_fixperms -i
190 dh_installdeb -i
191 dh_gencontrol -i
192 dh_md5sums -i
193 dh_builddeb -i
196 binary-arch: build-arch install-arch
197 dh_testdir
198 dh_testroot
199 dh_installchangelogs -a CHANGES
200 dh_installdocs -a -A CONTRIBUTORS NEWS
201 dh_installdocs -a
202 echo 'tcl:Depends=tcl$(TCL_VERS) | tclsh' >> debian/rrdtool-tcl.substvars
203 dh_python2 -ppython-rrdtool
204 dh_python2 -prrdtool-dbg
205 dh_perl -a
206 dh_installman -a
207 dh_installinit -prrdcached
208 dh_link -a
209 dh_strip -a --dbg-package=rrdtool-dbg
210 dh_compress -a
211 dh_fixperms -a
212 dh_makeshlibs -a -Nliblua5.1-rrd0 -Nliblua5.1-rrd-dev
213 dh_makeshlibs -pliblua5.1-rrd0 -pliblua5.1-rrd-dev -n
214 dh_installdeb -a
215 dh_shlibdeps -a
216 dh_gencontrol -a
217 dh_md5sums -a
218 dh_builddeb -a
221 binary: binary-arch binary-indep
222 .PHONY: build clean configure \
223 binary-indep binary-arch binary \
224 install install-arch \
225 install-python% clean-python% unpatch