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 #library versions
12 LIB_version := $(shell grep '^librrd_la_LDFLAGS' src/Makefile.am | \
13 sed 's,^[^0-9]*,,g;s,\([0-9]*\):\([0-9]*\):\([0-9]*\),\1.\3.\2,g')
14 LIB_major := $(shell echo $(LIB_version) | sed 's,\..*,,g')
15 LIB_TH_version := $(shell grep '^librrd_th_la_LDFLAGS' src/Makefile.am | \
16 sed 's,^[^0-9]*,,g;s,\([0-9]*\):\([0-9]*\):\([0-9]*\),\1.\3.\2,g')
17 LIB_TH_major := $(shell echo $(LIB_TH_version) | sed 's,\..*,,g')
21 #Ruby versions to build for
22 RUBY_VERS := 1.8 1.9
23 RUBY_DEFAULT_VERS := 1.8
25 #Python versions to build for. The work-around-doko way.
26 PY_VERS := $(shell set -e; \
27 for py in `pysupport-parseversions debian/pyversions`; do \
28 if [ -x /usr/bin/python$$py ]; then echo $$py; fi; \
29 done)
31 #tcl version we're building for
32 TCL_VERS := $(shell dpkg -s tcl | grep ^Depends | sed 's,.*tcl\([0-9.]*\).*,\1,')
35 #let's help configure to figure out our host/build system
36 DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
37 DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
38 ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
39 CONFFLAGS += --build $(DEB_HOST_GNU_TYPE)
40 else
41 CONFFLAGS += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
42 endif
44 #we build the bindings manually from debian/rules
45 CONFFLAGS += --disable-python --disable-ruby
47 #set the right paths
48 CONFFLAGS += --prefix=/usr --docdir=/usr/share/doc/rrdtool
50 #install perl libs in vendor mode
51 CONFFLAGS += --with-perl-options=INSTALLDIRS=vendor
53 #path to our ttf font
54 CONFFLAGS += --with-rrd-default-font=/usr/share/rrdtool/librrd$(LIB_major)/DejaVuSansMono-Roman.ttf
57 #let's take care of optimization + debug builds
58 CFLAGS += -Wall -g
59 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
60 CFLAGS += -O0
61 else
62 #don't optimize on arm for now - #447041
63 ifneq ($(DEB_HOST_GNU_TYPE), arm)
64 CFLAGS += -O2
65 endif
66 endif
68 LDFLAGS="-Wl,-z,defs"
70 configure: config.status
71 config.status: $(QUILT_STAMPFN)
73 ifneq "$(wildcard /usr/share/misc/config.sub)" ""
74 cp -f /usr/share/misc/config.sub config.sub
75 endif
76 ifneq "$(wildcard /usr/share/misc/config.guess)" ""
77 cp -f /usr/share/misc/config.guess config.guess
78 endif
80 LDFLAGS="$(LDFLAGS)"
81 CFLAGS="$(CFLAGS)" \
82 RRDDOCDIR=/usr/share/doc/rrdtool \
83 ./configure $(CONFFLAGS)
85 build: build-arch build-indep
87 build-arch: build-arch-stamp $(PY_VERS:%=build-python%)
88 build-arch-stamp: config.status
90 #configure forgets to set TCL_INC_DIR.
91 make TCL_INC_DIR=/usr/include/tcl
92 #Fix library path to tcl bindings
93 sed -i -e 's|lib/|lib/tcltk/rrdtool-tcl/|' bindings/tcl/pkgIndex.tcl
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%)
107 dh_testdir
108 dh_testroot
109 #sanity check if debian/control lists the right package name
110 grep -q '^Package: librrd$(LIB_major)' debian/control
112 [ ! -f Makefile ] || make distclean
114 ifneq "$(wildcard /usr/share/misc/config.sub)" ""
115 rm -f config.sub
116 endif
117 ifneq "$(wildcard /usr/share/misc/config.guess)" ""
118 rm -f config.guess
119 endif
120 rm -f build-arch-stamp build-indep-stamp config.status install-common-stamp
121 find . -name \*.pyc | xargs rm -f
122 rm -rf bindings/python/build
124 #clean what the Makefiles do not clean....
125 rm -rf bindings/perl-piped/blib bindings/perl-shared/blib \
126 bindings/perl-piped/Makefile.old bindings/perl-shared/Makefile.old
127 rm -f bindings/tcl/pkgIndex.tcl bindings/tcl/tclrrd*.so
128 rm -f examples/cgi-demo.cgi
129 rm -rf src/.libs src/.deps doc/*.html doc/*.1 doc/*.txt
131 dh_clean
133 clean-python%: unpatch
134 set -e ;\
135 cd bindings/python ;\
136 python$* setup.py clean
137 rm -f build-python$*
140 install: install-arch install-indep
142 install-indep: build-indep install-common-stamp
143 #nothing to do
145 install-common-stamp: build-arch-stamp
146 dh_testdir
147 dh_testroot
148 dh_clean -k
150 make install DESTDIR=$(CURDIR)/debian/tmp
151 dh_install --sourcedir=$(CURDIR)/debian/tmp
153 touch $@
155 install-arch: install-common-stamp $(PY_VERS:%=install-python%)
156 #build and install ruby
157 set -e; \
158 cd bindings/ruby ;\
159 for rbv in $(RUBY_VERS); do \
160 ruby$$rbv extconf.rb ;\
161 make ;\
162 make install sitelibdir=$(CURDIR)/debian/librrd-ruby$$rbv`ruby$$rbv -r rbconfig -e 'print Config::CONFIG["rubylibdir"]'` \
163 sitearchdir=$(CURDIR)/debian/librrd-ruby$$rbv`ruby$$rbv -r rbconfig -e 'print Config::CONFIG["archdir"]'` ;\
164 make distclean ;\
165 done
167 dh_installexamples -s
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
177 binary-indep: build-indep install-indep
178 dh_testdir
179 dh_testroot
180 dh_link -plibrrd-ruby /usr/share/doc/librrd-ruby$(RUBY_DEFAULT_VERS) /usr/share/doc/librrd-ruby
181 dh_link -ppython-rrd /usr/share/doc/python-rrdtool /usr/share/doc/python-rrd
182 dh_installchangelogs -i -Nlibrrd-ruby -Npython-rrd
183 dh_installdocs -i -Nlibrrd-ruby -Npython-rrd -A CONTRIBUTORS
184 dh_link -i -Nlibrrd-ruby -Npython-rrd
185 echo 'rubydefault:Depends=librrd-ruby$(RUBY_DEFAULT_VERS)' >> debian/librrd-ruby.substvars
186 dh_perl -i
187 dh_compress -i
188 dh_fixperms -i
189 dh_installdeb -i
190 dh_gencontrol -i
191 dh_md5sums -i
192 dh_builddeb -i
195 binary-arch: build-arch install-arch
196 dh_testdir
197 dh_testroot
198 dh_installchangelogs -a CHANGES
199 dh_installdocs -a -A CONTRIBUTORS
200 dh_installdocs -a
201 echo 'tcl:Depends=tcl$(TCL_VERS) | tclsh' >> debian/rrdtool-tcl.substvars
202 dh_pysupport -ppython-rrdtool
203 dh_perl -a
204 dh_installman -a
205 dh_link -plibrrd2-dev /usr/lib/librrd.so.$(LIB_version) /usr/lib/librrd.so
206 dh_link -plibrrd2-dev /usr/lib/librrd_th.so.$(LIB_TH_version) /usr/lib/librrd_th.so
207 dh_link -plibrrd$(LIB_major) /usr/lib/librrd.so.$(LIB_version) /usr/lib/librrd.so.$(LIB_major)
208 dh_link -plibrrd$(LIB_major) /usr/lib/librrd_th.so.$(LIB_TH_version) /usr/lib/librrd_th.so.$(LIB_TH_major)
209 dh_link -a
210 dh_strip -a
211 dh_compress -a
212 dh_fixperms -a
213 dh_makeshlibs -a
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