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 #Python versions to build for. The work-around-doko way.
16 PY_VERS := $(shell set -e; \
17 for py in `pysupport-parseversions debian/pyversions`; do \
18 if [ -x /usr/bin/python$$py ]; then echo $$py; fi; \
19 done)
21 #tcl version we're building for
22 TCL_VERS := $(shell dpkg -s tcl | grep ^Depends | sed 's,.*tcl\([0-9.]*\).*,\1,')
25 #let's help configure to figure out our host/build system
26 DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
27 DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
28 ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
29 CONFFLAGS += --build $(DEB_HOST_GNU_TYPE)
30 else
31 CONFFLAGS += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
32 endif
34 #we build the bindings manually from debian/rules
35 CONFFLAGS += --disable-python --disable-ruby
37 #set the right paths
38 CONFFLAGS += --prefix=/usr --docdir=/usr/share/doc/rrdtool
40 #install perl libs in vendor mode
41 CONFFLAGS += --with-perl-options=INSTALLDIRS=vendor
43 #path to tcl
44 CONFFLAGS += --with-tcllib=/usr/lib/tcl$(TCL_VERS)
46 #let's take care of optimization + debug builds
47 CFLAGS += -Wall -g
48 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
49 CFLAGS += -O0
50 else
51 #don't optimize on arm for now - #447041
52 ifneq ($(DEB_HOST_GNU_TYPE), arm)
53 CFLAGS += -O2
54 endif
55 endif
57 # work-around for a broken dpkg - do not rename this to LDFLAGS :-/
58 LINKER_FLAGS=-Wl,-z,defs
60 configure: config.status
61 config.status: $(QUILT_STAMPFN)
63 ifneq "$(wildcard /usr/share/misc/config.sub)" ""
64 cp -f /usr/share/misc/config.sub config.sub
65 endif
66 ifneq "$(wildcard /usr/share/misc/config.guess)" ""
67 cp -f /usr/share/misc/config.guess config.guess
68 endif
70 LDFLAGS="$(LINKER_FLAGS)" \
71 CFLAGS="$(CFLAGS)" \
72 RRDDOCDIR=/usr/share/doc/rrdtool \
73 ./configure $(CONFFLAGS)
75 build: build-arch build-indep
77 build-arch: build-arch-stamp $(PY_VERS:%=build-python%)
78 build-arch-stamp: config.status
79 make
80 #Fix library path to tcl bindings
81 sed -i -e 's|lib/|lib/tcltk/rrdtool-tcl/|' bindings/tcl/pkgIndex.tcl
82 #sanity check if debian/control lists the right package name
83 LIB_major=`grep '^dlname=' src/librrd.la \
84 | sed -e "s/^dlname='librrd\.so\.\\([0-9]\+\\)'\$$/\\1/"` \
85 && test -n "$$LIB_major" \
86 && grep -q "^Package: librrd$$LIB_major\\>" debian/control
87 touch $@
89 build-python%: build-arch-stamp
90 set -e ;\
91 cd bindings/python ;\
92 BUILDLIBDIR=../../src/.libs LIBDIR=../../src/.libs python$* setup.py build
93 touch $@
95 build-indep: build-arch-stamp
96 #indep stuff is built in build-arch-stamp, too.
98 clean: clean-patched
99 clean-patched: unpatch $(PY_VERS:%=clean-python%)
100 dh_testdir
101 dh_testroot
103 [ ! -f Makefile ] || make distclean
105 ifneq "$(wildcard /usr/share/misc/config.sub)" ""
106 rm -f config.sub
107 endif
108 ifneq "$(wildcard /usr/share/misc/config.guess)" ""
109 rm -f config.guess
110 endif
111 rm -f build-arch-stamp build-indep-stamp config.status install-common-stamp
112 find . -name \*.pyc | xargs rm -f
113 rm -rf bindings/python/build
115 #clean what the Makefiles do not clean....
116 rm -rf bindings/perl-piped/blib bindings/perl-shared/blib \
117 bindings/perl-piped/Makefile.old bindings/perl-shared/Makefile.old
118 rm -f bindings/tcl/pkgIndex.tcl bindings/tcl/tclrrd*.so
119 rm -f examples/cgi-demo.cgi
120 rm -rf src/.libs src/.deps doc/*.html doc/*.1 doc/*.txt
121 rm -f intltool-extract intltool-merge intltool-update
123 dh_clean
125 clean-python%: unpatch
126 set -e ;\
127 cd bindings/python ;\
128 python$* setup.py clean
129 rm -f build-python$*
132 install: install-arch install-indep
134 install-indep: build-indep install-common-stamp
135 #nothing to do
137 install-common-stamp: build-arch-stamp
138 dh_testdir
139 dh_testroot
140 dh_clean -k
142 make install DESTDIR=$(CURDIR)/debian/tmp
143 dh_install --sourcedir=$(CURDIR)/debian/tmp --list-missing
145 touch $@
147 install-arch: install-common-stamp $(PY_VERS:%=install-python%)
148 #build and install ruby
149 set -e; \
150 cd bindings/ruby ;\
151 for rbv in $(RUBY_VERS); do \
152 ruby$$rbv extconf.rb ;\
153 make ;\
154 make install sitelibdir=$(CURDIR)/debian/librrd-ruby$$rbv`ruby$$rbv -r rbconfig -e 'print Config::CONFIG["rubylibdir"]'` \
155 sitearchdir=$(CURDIR)/debian/librrd-ruby$$rbv`ruby$$rbv -r rbconfig -e 'print Config::CONFIG["archdir"]'` ;\
156 make distclean ;\
157 done
159 dh_installexamples -s
161 install-python%: install-common-stamp
162 dh_testdir
163 dh_testroot
164 set -e ;\
165 cd bindings/python ;\
166 python$* setup.py install --root=$(CURDIR)/debian/python-rrdtool
169 binary-indep: build-indep install-indep
170 dh_testdir
171 dh_testroot
172 dh_link -plibrrd-ruby /usr/share/doc/librrd-ruby$(RUBY_DEFAULT_VERS) /usr/share/doc/librrd-ruby
173 dh_link -ppython-rrd /usr/share/doc/python-rrdtool /usr/share/doc/python-rrd
174 dh_installchangelogs -i -Nlibrrd-ruby -Npython-rrd CHANGES
175 dh_installdocs -i -Nlibrrd-ruby -Npython-rrd -A CONTRIBUTORS NEWS
176 dh_link -i -Nlibrrd-ruby -Npython-rrd
177 echo 'rubydefault:Depends=librrd-ruby$(RUBY_DEFAULT_VERS)' >> debian/librrd-ruby.substvars
178 dh_perl -i
179 dh_compress -i
180 dh_fixperms -i
181 dh_installdeb -i
182 dh_gencontrol -i
183 dh_md5sums -i
184 dh_builddeb -i
187 binary-arch: build-arch install-arch
188 dh_testdir
189 dh_testroot
190 dh_installchangelogs -a CHANGES
191 dh_installdocs -a -A CONTRIBUTORS NEWS
192 dh_installdocs -a
193 echo 'tcl:Depends=tcl$(TCL_VERS) | tclsh' >> debian/rrdtool-tcl.substvars
194 dh_pysupport -ppython-rrdtool
195 dh_perl -a
196 dh_installman -a
197 dh_link -a
198 dh_strip -a
199 dh_compress -a
200 dh_fixperms -a
201 dh_makeshlibs -a
202 dh_installdeb -a
203 dh_shlibdeps -a
204 dh_gencontrol -a
205 dh_md5sums -a
206 dh_builddeb -a
209 binary: binary-arch binary-indep
210 .PHONY: build clean configure \
211 binary-indep binary-arch binary \
212 install install-arch \
213 install-python% clean-python% unpatch