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 ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
26 CONFFLAGS += --build $(DEB_HOST_GNU_TYPE)
27 else
28 CONFFLAGS += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
29 endif
31 #we build the bindings manually from debian/rules
32 CONFFLAGS += --disable-python --disable-ruby
34 #set the right paths
35 CONFFLAGS += --prefix=/usr --docdir=/usr/share/doc/rrdtool
37 #install perl libs in vendor mode
38 CONFFLAGS += --with-perl-options=INSTALLDIRS=vendor
40 #path to tcl
41 CONFFLAGS += --with-tcllib=/usr/lib/tcl$(TCL_VERS)
43 #let's take care of optimization + debug builds
44 CFLAGS += -Wall -g
45 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
46 CFLAGS += -O0
47 else
48 #don't optimize on arm for now - #447041
49 ifneq ($(DEB_HOST_GNU_TYPE), arm)
50 CFLAGS += -O2
51 endif
52 endif
54 # work-around for a broken dpkg - do not rename this to LDFLAGS :-/
55 LINKER_FLAGS=-Wl,-z,defs
57 configure: config.status
58 config.status: $(QUILT_STAMPFN)
60 ifneq "$(wildcard /usr/share/misc/config.sub)" ""
61 cp -f /usr/share/misc/config.sub config.sub
62 endif
63 ifneq "$(wildcard /usr/share/misc/config.guess)" ""
64 cp -f /usr/share/misc/config.guess config.guess
65 endif
67 LDFLAGS="$(LINKER_FLAGS)" \
68 CFLAGS="$(CFLAGS)" \
69 RRDDOCDIR=/usr/share/doc/rrdtool \
70 ./configure $(CONFFLAGS)
72 build: build-arch build-indep
74 build-arch: build-arch-stamp $(PY_VERS:%=build-python%) $(PY_VERS:%=build-python%-dbg)
75 build-arch-stamp: config.status
76 make
77 #Fix library path to tcl bindings
78 sed -i -e 's|lib/|lib/tcltk/rrdtool-tcl/|' bindings/tcl/pkgIndex.tcl
79 #sanity check if debian/control lists the right package name
80 LIB_major=`grep '^dlname=' src/librrd.la \
81 | sed -e "s/^dlname='librrd\.so\.\\([0-9]\+\\)'\$$/\\1/"` \
82 && test -n "$$LIB_major" \
83 && grep -q "^Package: librrd$$LIB_major\\>" debian/control
84 touch $@
86 build-python%: build-arch-stamp
87 set -e ;\
88 cd bindings/python ;\
89 BUILDLIBDIR=../../src/.libs LIBDIR=../../src/.libs python$* setup.py build ;\
90 touch $@
92 build-indep: build-arch-stamp
93 #indep stuff is built in build-arch-stamp, too.
95 clean: clean-patched
96 clean-patched: unpatch $(PY_VERS:%=clean-python%) $(PY_VERS:%=clean-python%-dbg)
97 dh_testdir
98 dh_testroot
100 [ ! -f Makefile ] || make distclean
102 ifneq "$(wildcard /usr/share/misc/config.sub)" ""
103 rm -f config.sub
104 endif
105 ifneq "$(wildcard /usr/share/misc/config.guess)" ""
106 rm -f config.guess
107 endif
108 rm -f build-arch-stamp build-indep-stamp config.status install-common-stamp
109 find . -name \*.pyc | xargs rm -f
110 rm -rf bindings/python/build
112 # clean what the Makefiles do not clean ...
113 rm -rf bindings/perl-piped/blib bindings/perl-shared/blib \
114 bindings/perl-piped/Makefile.old bindings/perl-shared/Makefile.old
115 rm -f bindings/tcl/pkgIndex.tcl bindings/tcl/tclrrd*.so
116 rm -f examples/cgi-demo.cgi
117 rm -rf src/.libs src/.deps doc/*.html doc/*.1 doc/*.txt
118 rm -f intltool-extract intltool-merge intltool-update
119 rm -f src/librrd.sym
120 rm -f config.h
122 dh_clean
124 clean-python%: unpatch
125 set -e ;\
126 cd bindings/python ;\
127 python$* setup.py clean ;\
128 rm -f build-python$*
131 install: install-arch install-indep
133 install-indep: build-indep install-common-stamp
134 #nothing to do
136 install-common-stamp: build-arch-stamp
137 dh_testdir
138 dh_testroot
139 dh_clean -k
141 make install DESTDIR=$(CURDIR)/debian/tmp
142 # we don't want .txt and .pod documentation in the package
143 rm -rf debian/tmp/usr/share/doc/rrdtool/txt
144 dh_install --sourcedir=$(CURDIR)/debian/tmp --fail-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 ;\
168 python$*-dbg setup.py install --root=$(CURDIR)/debian/rrdtool-dbg
169 find $(CURDIR)/debian/rrdtool-dbg -type f -name '*.egg-info' -print0 |\
170 xargs -0r rm -f
173 binary-indep: build-indep install-indep
174 dh_testdir
175 dh_testroot
176 dh_link -plibrrd-ruby /usr/share/doc/librrd-ruby$(RUBY_DEFAULT_VERS) /usr/share/doc/librrd-ruby
177 dh_installchangelogs -i -Nlibrrd-ruby CHANGES
178 dh_installdocs -i -Nlibrrd-ruby -A CONTRIBUTORS NEWS
179 dh_link -i -Nlibrrd-ruby
180 echo 'rubydefault:Depends=librrd-ruby$(RUBY_DEFAULT_VERS)' >> debian/librrd-ruby.substvars
181 dh_perl -i
182 dh_compress -i
183 dh_fixperms -i
184 dh_installdeb -i
185 dh_gencontrol -i
186 dh_md5sums -i
187 dh_builddeb -i
190 binary-arch: build-arch install-arch
191 dh_testdir
192 dh_testroot
193 dh_installchangelogs -a CHANGES
194 dh_installdocs -a -A CONTRIBUTORS NEWS
195 dh_installdocs -a
196 echo 'tcl:Depends=tcl$(TCL_VERS) | tclsh' >> debian/rrdtool-tcl.substvars
197 dh_pysupport -ppython-rrdtool
198 dh_pysupport -prrdtool-dbg
199 dh_perl -a
200 dh_installman -a
201 dh_link -a
202 dh_strip -a --dbg-package=rrdtool-dbg
203 dh_compress -a
204 dh_fixperms -a
205 dh_makeshlibs -a
206 dh_installdeb -a
207 dh_shlibdeps -a
208 dh_gencontrol -a
209 dh_md5sums -a
210 dh_builddeb -a
213 binary: binary-arch binary-indep
214 .PHONY: build clean configure \
215 binary-indep binary-arch binary \
216 install install-arch \
217 install-python% clean-python% unpatch