e2a2694847bae9ed6c892229d1eef617ded42e00
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 #let's help configure to figure out our host/build system
32 DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
33 DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
34 ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
35 CONFFLAGS += --build $(DEB_HOST_GNU_TYPE)
36 else
37 CONFFLAGS += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
38 endif
40 #we build the bindings manually from debian/rules
41 CONFFLAGS += --disable-python --disable-ruby
43 #set the right paths
44 CONFFLAGS += --prefix=/usr --docdir=/usr/share/doc/rrdtool
46 #install perl libs in vendor mode
47 CONFFLAGS += --with-perl-options=INSTALLDIRS=vendor
52 #let's take care of optimization + debug builds
53 CFLAGS += -Wall -g
54 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
55 CFLAGS += -O0
56 else
57 CFLAGS += -O2
58 endif
60 LDFLAGS="-Wl,-z,defs"
62 configure: config.status
63 config.status: $(QUILT_STAMPFN)
65 ifneq "$(wildcard /usr/share/misc/config.sub)" ""
66 cp -f /usr/share/misc/config.sub config.sub
67 endif
68 ifneq "$(wildcard /usr/share/misc/config.guess)" ""
69 cp -f /usr/share/misc/config.guess config.guess
70 endif
72 LDFLAGS="$(LDFLAGS)"
73 CFLAGS="$(CFLAGS)" \
74 RRDDOCDIR=/usr/share/doc/rrdtool \
75 ./configure $(CONFFLAGS)
77 build: build-arch build-indep
79 build-arch: build-arch-stamp $(PY_VERS:%=build-python%)
80 build-arch-stamp: config.status
82 #configure forgets to set TCL_INC_DIR.
83 make TCL_INC_DIR=/usr/include/tcl
84 #Fix library path to tcl bindings
85 sed -i -e 's|lib/|lib/tcltk/rrdtool-tcl/|' bindings/tcl/pkgIndex.tcl
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%)
99 dh_testdir
100 dh_testroot
101 #sanity check if debian/control lists the right package name
102 grep -q '^Package: librrd$(LIB_major)' debian/control
104 [ ! -f Makefile ] || make distclean
106 ifneq "$(wildcard /usr/share/misc/config.sub)" ""
107 rm -f config.sub
108 endif
109 ifneq "$(wildcard /usr/share/misc/config.guess)" ""
110 rm -f config.guess
111 endif
112 rm -f build-arch-stamp build-indep-stamp config.status install-common-stamp
113 find . -name \*.pyc | xargs rm -f
114 rm -rf bindings/python/build
116 #clean what the Makefiles do not clean....
117 rm -rf bindings/perl-piped/blib bindings/perl-shared/blib \
118 bindings/perl-piped/Makefile.old bindings/perl-shared/Makefile.old
119 rm -f bindings/tcl/pkgIndex.tcl bindings/tcl/tclrrd*.so
120 rm -f examples/cgi-demo.cgi
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 dh_install --sourcedir=$(CURDIR)/debian/tmp
144 touch $@
146 install-arch: install-common-stamp $(PY_VERS:%=install-python%)
147 #build and install ruby
148 set -e; \
149 cd bindings/ruby ;\
150 for rbv in $(RUBY_VERS); do \
151 ruby$$rbv extconf.rb ;\
152 make ;\
153 make install sitelibdir=$(CURDIR)/debian/librrd-ruby$$rbv`ruby$$rbv -r rbconfig -e 'print Config::CONFIG["rubylibdir"]'` \
154 sitearchdir=$(CURDIR)/debian/librrd-ruby$$rbv`ruby$$rbv -r rbconfig -e 'print Config::CONFIG["archdir"]'` ;\
155 make distclean ;\
156 done
158 dh_installexamples -s
160 install-python%: install-common-stamp
161 dh_testdir
162 dh_testroot
163 set -e ;\
164 cd bindings/python ;\
165 python$* setup.py install --root=$(CURDIR)/debian/python-rrdtool
168 binary-indep: build-indep install-indep
169 dh_testdir
170 dh_testroot
171 dh_link -plibrrd-ruby /usr/share/doc/librrd-ruby$(RUBY_DEFAULT_VERS) /usr/share/doc/librrd-ruby
172 dh_link -plibrrd2-dev /usr/share/doc/librrd-dev /usr/share/doc/librrd2-dev
173 dh_link -ppython-rrd /usr/share/doc/python-rrdtool /usr/share/doc/python-rrd
174 dh_installchangelogs -i -Nlibrrd-ruby -Nlibrrd2-dev -Npython-rrd
175 dh_installdocs -i -Nlibrrd-ruby -Nlibrrd2-dev -Npython-rrd
176 dh_link -i -Nlibrrd-ruby -Nlibrrd2-dev -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
192 # dh_installexamples -a
193 dh_pysupport -ppython-rrdtool
194 dh_perl -a
195 dh_installman -a
196 dh_link -plibrrd-dev /usr/lib/librrd.so.$(LIB_version) /usr/lib/librrd.so
197 dh_link -plibrrd-dev /usr/lib/librrd_th.so.$(LIB_TH_version) /usr/lib/librrd_th.so
198 dh_link -plibrrd$(LIB_major) /usr/lib/librrd.so.$(LIB_version) /usr/lib/librrd.so.$(LIB_major)
199 dh_link -plibrrd$(LIB_major) /usr/lib/librrd_th.so.$(LIB_TH_version) /usr/lib/librrd_th.so.$(LIB_TH_major)
200 dh_link -a
201 dh_strip -a
202 dh_compress -a
203 dh_fixperms -a
204 dh_makeshlibs -a
205 dh_installdeb -a
206 dh_shlibdeps -a
207 dh_gencontrol -a
208 dh_md5sums -a
209 dh_builddeb -a
212 binary: binary-arch binary-indep
213 .PHONY: build clean configure \
214 binary-indep binary-arch binary \
215 install install-arch \
216 install-python% clean-python% unpatch