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 DEB_HOST_ARCH_CPU ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_CPU)
27 ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
28 CONFFLAGS += --build $(DEB_HOST_GNU_TYPE)
29 else
30 CONFFLAGS += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
31 endif
33 #we build the bindings manually from debian/rules
34 CONFFLAGS += --disable-python --disable-ruby
36 #set the right paths
37 CONFFLAGS += --prefix=/usr --docdir=/usr/share/doc/rrdtool
39 #install perl libs in vendor mode
40 CONFFLAGS += --with-perl-options=INSTALLDIRS=vendor
42 #path to tcl
43 CONFFLAGS += --with-tcllib=/usr/lib/tcl$(TCL_VERS)
45 #let's take care of optimization + debug builds
46 CFLAGS += -Wall -g
47 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
48 CFLAGS += -O0
49 else
50 #don't optimize on arm for now - #447041
51 ifneq ($(DEB_HOST_ARCH_CPU), arm)
52 CFLAGS += -O2
53 endif
54 endif
56 # work-around for a broken dpkg - do not rename this to LDFLAGS :-/
57 LINKER_FLAGS=-Wl,-z,defs
59 configure: config.status
60 config.status: $(QUILT_STAMPFN)
62 ifneq "$(wildcard /usr/share/misc/config.sub)" ""
63 cp -f /usr/share/misc/config.sub config.sub
64 endif
65 ifneq "$(wildcard /usr/share/misc/config.guess)" ""
66 cp -f /usr/share/misc/config.guess config.guess
67 endif
69 LDFLAGS="$(LINKER_FLAGS)" \
70 CFLAGS="$(CFLAGS)" \
71 RRDDOCDIR=/usr/share/doc/rrdtool \
72 ./configure $(CONFFLAGS)
74 build: build-arch build-indep
76 build-arch: build-arch-stamp $(PY_VERS:%=build-python%) $(PY_VERS:%=build-python%-dbg)
77 build-arch-stamp: config.status
78 make
79 #Fix library path to tcl bindings
80 sed -i -e 's|lib/|lib/tcltk/rrdtool-tcl/|' bindings/tcl/pkgIndex.tcl
81 #sanity check if debian/control lists the right package name
82 LIB_major=`grep '^dlname=' src/librrd.la \
83 | sed -e "s/^dlname='librrd\.so\.\\([0-9]\+\\)'\$$/\\1/"` \
84 && test -n "$$LIB_major" \
85 && grep -q "^Package: librrd$$LIB_major\\>" debian/control
86 touch $@
88 build-python%: build-arch-stamp
89 set -e ;\
90 cd bindings/python ;\
91 BUILDLIBDIR=../../src/.libs LIBDIR=../../src/.libs python$* setup.py build ;\
92 touch $@
94 build-indep: build-arch-stamp
95 #indep stuff is built in build-arch-stamp, too.
97 clean: clean-patched
98 clean-patched: unpatch $(PY_VERS:%=clean-python%) $(PY_VERS:%=clean-python%-dbg)
99 dh_testdir
100 dh_testroot
102 [ ! -f Makefile ] || make distclean
104 ifneq "$(wildcard /usr/share/misc/config.sub)" ""
105 rm -f config.sub
106 endif
107 ifneq "$(wildcard /usr/share/misc/config.guess)" ""
108 rm -f config.guess
109 endif
110 rm -f build-arch-stamp build-indep-stamp config.status install-common-stamp
111 find . -name \*.pyc | xargs rm -f
112 rm -rf bindings/python/build
114 # clean what the Makefiles do not clean ...
115 rm -rf bindings/perl-piped/blib bindings/perl-shared/blib \
116 bindings/perl-piped/Makefile.old bindings/perl-shared/Makefile.old
117 rm -f bindings/tcl/pkgIndex.tcl bindings/tcl/tclrrd*.so
118 rm -f examples/cgi-demo.cgi
119 rm -rf src/.libs src/.deps doc/*.html doc/*.1 doc/*.txt
120 rm -f intltool-extract intltool-merge intltool-update
121 rm -f src/librrd.sym
122 rm -f config.h
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 # we don't want .txt and .pod documentation in the package
145 rm -rf debian/tmp/usr/share/doc/rrdtool/txt
146 dh_install --sourcedir=$(CURDIR)/debian/tmp --fail-missing
147 # remove duplicates
148 rm debian/rrdtool/usr/bin/rrdcached
149 rm debian/rrdtool/usr/share/man/man1/rrdcached.1
150 rm debian/rrdtool/usr/share/doc/rrdtool/html/rrdcached.html
152 touch $@
154 install-arch: install-common-stamp $(PY_VERS:%=install-python%)
155 #build and install ruby
156 set -e; \
157 cd bindings/ruby ;\
158 for rbv in $(RUBY_VERS); do \
159 ruby$$rbv extconf.rb ;\
160 make ;\
161 make install sitelibdir=$(CURDIR)/debian/librrd-ruby$$rbv`ruby$$rbv -r rbconfig -e 'print Config::CONFIG["rubylibdir"]'` \
162 sitearchdir=$(CURDIR)/debian/librrd-ruby$$rbv`ruby$$rbv -r rbconfig -e 'print Config::CONFIG["archdir"]'` ;\
163 make distclean ;\
164 done
166 dh_installexamples -s
167 chmod 644 debian/rrdcached/usr/share/doc/rrdcached/examples/RRDCached.pm
169 install-python%: install-common-stamp
170 dh_testdir
171 dh_testroot
172 set -e ;\
173 cd bindings/python ;\
174 python$* setup.py install --root=$(CURDIR)/debian/python-rrdtool ;\
175 python$*-dbg setup.py install --root=$(CURDIR)/debian/rrdtool-dbg
176 find $(CURDIR)/debian/rrdtool-dbg -type f -name '*.egg-info' -print0 |\
177 xargs -0r rm -f
180 binary-indep: build-indep install-indep
181 dh_testdir
182 dh_testroot
183 dh_link -plibrrd-ruby /usr/share/doc/librrd-ruby$(RUBY_DEFAULT_VERS) /usr/share/doc/librrd-ruby
184 dh_installchangelogs -i -Nlibrrd-ruby CHANGES
185 dh_installdocs -i -Nlibrrd-ruby -A CONTRIBUTORS NEWS
186 dh_link -i -Nlibrrd-ruby
187 echo 'rubydefault:Depends=librrd-ruby$(RUBY_DEFAULT_VERS)' >> debian/librrd-ruby.substvars
188 dh_perl -i
189 dh_compress -i
190 dh_fixperms -i
191 dh_installdeb -i
192 dh_gencontrol -i
193 dh_md5sums -i
194 dh_builddeb -i
197 binary-arch: build-arch install-arch
198 dh_testdir
199 dh_testroot
200 dh_installchangelogs -a CHANGES
201 dh_installdocs -a -A CONTRIBUTORS NEWS
202 dh_installdocs -a
203 echo 'tcl:Depends=tcl$(TCL_VERS) | tclsh' >> debian/rrdtool-tcl.substvars
204 dh_pysupport -ppython-rrdtool
205 dh_pysupport -prrdtool-dbg
206 dh_perl -a
207 dh_installman -a
208 dh_link -a
209 dh_strip -a --dbg-package=rrdtool-dbg
210 dh_compress -a
211 dh_fixperms -a
212 dh_makeshlibs -a
213 dh_installdeb -a
214 dh_shlibdeps -a
215 dh_gencontrol -a
216 dh_md5sums -a
217 dh_builddeb -a
220 binary: binary-arch binary-indep
221 .PHONY: build clean configure \
222 binary-indep binary-arch binary \
223 install install-arch \
224 install-python% clean-python% unpatch