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')
18 #Ruby versions to build for
19 RUBY_VERS := 1.8 1.9
20 RUBY_DEFAULT_VERS := 1.8
22 #Python versions to build for. The work-around-doko way.
23 PY_VERS := $(shell set -e; \
24 for py in `pysupport-parseversions debian/pyversions`; do \
25 if [ -x /usr/bin/python$$py ]; then echo $$py; fi; \
26 done)
28 #tcl version we're building for
29 TCL_VERS := $(shell dpkg -s tcl | grep ^Depends | sed 's,.*tcl\([0-9.]*\).*,\1,')
32 #let's help configure to figure out our host/build system
33 DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
34 DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
35 ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
36 CONFFLAGS += --build $(DEB_HOST_GNU_TYPE)
37 else
38 CONFFLAGS += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
39 endif
41 #we build the bindings manually from debian/rules
42 CONFFLAGS += --disable-python --disable-ruby
44 #set the right paths
45 CONFFLAGS += --prefix=/usr --docdir=/usr/share/doc/rrdtool
47 #install perl libs in vendor mode
48 CONFFLAGS += --with-perl-options=INSTALLDIRS=vendor
50 #path to our ttf font
51 CONFFLAGS += --with-rrd-default-font=/usr/share/rrdtool/librrd$(LIB_major)/DejaVuSansMono-Roman.ttf
54 #let's take care of optimization + debug builds
55 CFLAGS += -Wall -g
56 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
57 CFLAGS += -O0
58 else
59 CFLAGS += -O2
60 endif
62 LDFLAGS="-Wl,-z,defs"
64 configure: config.status
65 config.status: $(QUILT_STAMPFN)
67 ifneq "$(wildcard /usr/share/misc/config.sub)" ""
68 cp -f /usr/share/misc/config.sub config.sub
69 endif
70 ifneq "$(wildcard /usr/share/misc/config.guess)" ""
71 cp -f /usr/share/misc/config.guess config.guess
72 endif
74 LDFLAGS="$(LDFLAGS)"
75 CFLAGS="$(CFLAGS)" \
76 RRDDOCDIR=/usr/share/doc/rrdtool \
77 ./configure $(CONFFLAGS)
79 build: build-arch build-indep
81 build-arch: build-arch-stamp $(PY_VERS:%=build-python%)
82 build-arch-stamp: config.status
84 #configure forgets to set TCL_INC_DIR.
85 make TCL_INC_DIR=/usr/include/tcl
86 #Fix library path to tcl bindings
87 sed -i -e 's|lib/|lib/tcltk/rrdtool-tcl/|' bindings/tcl/pkgIndex.tcl
88 touch $@
90 build-python%: build-arch-stamp
91 set -e ;\
92 cd bindings/python ;\
93 BUILDLIBDIR=../../src/.libs LIBDIR=../../src/.libs python$* setup.py build
94 touch $@
96 build-indep: build-arch-stamp
97 #indep stuff is built in build-arch-stamp, too.
99 clean: clean-patched
100 clean-patched: unpatch $(PY_VERS:%=clean-python%)
101 dh_testdir
102 dh_testroot
103 #sanity check if debian/control lists the right package name
104 grep -q '^Package: librrd$(LIB_major)' debian/control
106 [ ! -f Makefile ] || make distclean
108 ifneq "$(wildcard /usr/share/misc/config.sub)" ""
109 rm -f config.sub
110 endif
111 ifneq "$(wildcard /usr/share/misc/config.guess)" ""
112 rm -f config.guess
113 endif
114 rm -f build-arch-stamp build-indep-stamp config.status install-common-stamp
115 find . -name \*.pyc | xargs rm -f
116 rm -rf bindings/python/build
118 #clean what the Makefiles do not clean....
119 rm -rf bindings/perl-piped/blib bindings/perl-shared/blib \
120 bindings/perl-piped/Makefile.old bindings/perl-shared/Makefile.old
121 rm -f bindings/tcl/pkgIndex.tcl bindings/tcl/tclrrd*.so
122 rm -f examples/cgi-demo.cgi
123 rm -rf src/.libs src/.deps doc/*.html doc/*.1 doc/*.txt
125 dh_clean
127 clean-python%: unpatch
128 set -e ;\
129 cd bindings/python ;\
130 python$* setup.py clean
131 rm -f build-python$*
134 install: install-arch install-indep
136 install-indep: build-indep install-common-stamp
137 #nothing to do
139 install-common-stamp: build-arch-stamp
140 dh_testdir
141 dh_testroot
142 dh_clean -k
144 make install DESTDIR=$(CURDIR)/debian/tmp
145 dh_install --sourcedir=$(CURDIR)/debian/tmp --list-missing
147 touch $@
149 install-arch: install-common-stamp $(PY_VERS:%=install-python%)
150 #build and install ruby
151 set -e; \
152 cd bindings/ruby ;\
153 for rbv in $(RUBY_VERS); do \
154 ruby$$rbv extconf.rb ;\
155 make ;\
156 make install sitelibdir=$(CURDIR)/debian/librrd-ruby$$rbv`ruby$$rbv -r rbconfig -e 'print Config::CONFIG["rubylibdir"]'` \
157 sitearchdir=$(CURDIR)/debian/librrd-ruby$$rbv`ruby$$rbv -r rbconfig -e 'print Config::CONFIG["archdir"]'` ;\
158 make distclean ;\
159 done
161 dh_installexamples -s
163 install-python%: install-common-stamp
164 dh_testdir
165 dh_testroot
166 set -e ;\
167 cd bindings/python ;\
168 python$* setup.py install --root=$(CURDIR)/debian/python-rrdtool
171 binary-indep: build-indep install-indep
172 dh_testdir
173 dh_testroot
174 dh_link -plibrrd-ruby /usr/share/doc/librrd-ruby$(RUBY_DEFAULT_VERS) /usr/share/doc/librrd-ruby
175 dh_link -ppython-rrd /usr/share/doc/python-rrdtool /usr/share/doc/python-rrd
176 dh_installchangelogs -i -Nlibrrd-ruby -Npython-rrd
177 dh_installdocs -i -Nlibrrd-ruby -Npython-rrd -A CONTRIBUTORS
178 dh_link -i -Nlibrrd-ruby -Npython-rrd
179 echo 'rubydefault:Depends=librrd-ruby$(RUBY_DEFAULT_VERS)' >> debian/librrd-ruby.substvars
180 dh_perl -i
181 dh_compress -i
182 dh_fixperms -i
183 dh_installdeb -i
184 dh_gencontrol -i
185 dh_md5sums -i
186 dh_builddeb -i
189 binary-arch: build-arch install-arch
190 dh_testdir
191 dh_testroot
192 dh_installchangelogs -a CHANGES
193 dh_installdocs -a -A CONTRIBUTORS
194 dh_installdocs -a
195 echo 'tcl:Depends=tcl$(TCL_VERS) | tclsh' >> debian/rrdtool-tcl.substvars
196 dh_pysupport -ppython-rrdtool
197 dh_perl -a
198 dh_installman -a
199 dh_link -a
200 dh_strip -a
201 dh_compress -a
202 dh_fixperms -a
203 dh_makeshlibs -a
204 dh_installdeb -a
205 dh_shlibdeps -a
206 dh_gencontrol -a
207 dh_md5sums -a
208 dh_builddeb -a
211 binary: binary-arch binary-indep
212 .PHONY: build clean configure \
213 binary-indep binary-arch binary \
214 install install-arch \
215 install-python% clean-python% unpatch