1 #!/usr/bin/make -f
2 # -*- makefile -*-
4 # Uncomment this to turn on verbose mode.
5 #export DH_VERBOSE=1
8 #library versions
9 LIB_version := $(shell grep '^librrd_la_LDFLAGS' src/Makefile.am | \
10 sed 's,^[^0-9]*,,g;s,\([0-9]*\):\([0-9]*\):\([0-9]*\),\1.\3.\2,g')
11 LIB_major := $(shell echo $(LIB_version) | sed 's,\..*,,g')
12 LIB_TH_version := $(shell grep '^librrd_th_la_LDFLAGS' src/Makefile.am | \
13 sed 's,^[^0-9]*,,g;s,\([0-9]*\):\([0-9]*\):\([0-9]*\),\1.\3.\2,g')
14 LIB_TH_major := $(shell echo $(LIB_TH_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 #let's help configure to figure out our host/build system
29 DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
30 DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
31 ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
32 CONFFLAGS += --build $(DEB_HOST_GNU_TYPE)
33 else
34 CONFFLAGS += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
35 endif
37 #we build the bindings manually from debian/rules
38 CONFFLAGS += --disable-python --disable-ruby
40 #set the right paths
41 CONFFLAGS += --prefix=/usr --docdir=/usr/share/doc/rrdtool
43 #install perl libs in vendor mode
44 CONFFLAGS += --with-perl-options=INSTALLDIRS=vendor
49 #let's take care of optimization + debug builds
50 CFLAGS += -Wall -g
51 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
52 CFLAGS += -O0
53 else
54 CFLAGS += -O2
55 endif
57 LDFLAGS="-Wl,-z,defs"
59 configure: config.status
60 config.status:
62 ifneq "$(wildcard /usr/share/misc/config.sub)" ""
63 cp -f /usr/share/misc/config.sub config.sub
64 endif
65 ifneq "$(wildcard /usr/share/misc/config.guess)" ""
66 cp -f /usr/share/misc/config.guess config.guess
67 endif
69 LDFLAGS="$(LDFLAGS)"
70 CFLAGS="$(CFLAGS)" \
71 RRDDOCDIR=/usr/share/doc/rrdtool \
72 ./configure $(CONFFLAGS)
74 build: build-arch build-indep
76 build-arch: build-arch-stamp $(PY_VERS:%=build-python%)
77 build-arch-stamp: config.status
79 #configure forgets to set TCL_INC_DIR.
80 make TCL_INC_DIR=/usr/include/tcl
81 touch $@
83 build-python%: build-arch-stamp
84 set -e ;\
85 cd bindings/python ;\
86 BUILDLIBDIR=../../src/.libs LIBDIR=../../src/.libs python$* setup.py build
87 touch $@
89 build-indep: build-indep-stamp
90 build-indep-stamp: config.status
92 clean: $(PY_VERS:%=clean-python%)
93 dh_testdir
94 dh_testroot
95 #sanity check if debian/control lists the right package name
96 grep -q '^Package: librrd$(LIB_major)' debian/control
98 [ ! -f Makefile ] || make distclean
100 ifneq "$(wildcard /usr/share/misc/config.sub)" ""
101 rm -f config.sub
102 endif
103 ifneq "$(wildcard /usr/share/misc/config.guess)" ""
104 rm -f config.guess
105 endif
106 rm -f build-arch-stamp build-indep-stamp config.status
107 find . -name \*.pyc | xargs rm -f
108 rm -rf bindings/python/build
110 #clean what the Makefiles do not clean....
111 rm -rf bindings/perl-piped/blib bindings/perl-shared/blib \
112 bindings/perl-piped/Makefile.old bindings/perl-shared/Makefile.old
113 rm -f bindings/tcl/pkgIndex.tcl bindings/tcl/tclrrd*.so
114 rm -f examples/cgi-demo.cgi
116 dh_clean
118 clean-python%:
119 set -e ;\
120 cd bindings/python ;\
121 python$* setup.py clean
122 rm -f build-python$*
124 install: install-arch
126 install-arch: $(PY_VERS:%=install-python%)
127 dh_testdir
128 dh_testroot
129 dh_clean -k -s -Npython-rrd
130 dh_installdirs -s
132 make install DESTDIR=$(CURDIR)/debian/tmp
134 #build and install ruby
135 set -e; \
136 cd bindings/ruby ;\
137 for rbv in $(RUBY_VERS); do \
138 ruby$$rbv extconf.rb ;\
139 make ;\
140 make install sitelibdir=$(CURDIR)/debian/librrd-ruby$$rbv`ruby$$rbv -r rbconfig -e 'print Config::CONFIG["rubylibdir"]'` \
141 sitearchdir=$(CURDIR)/debian/librrd-ruby$$rbv`ruby$$rbv -r rbconfig -e 'print Config::CONFIG["archdir"]'` ;\
142 make distclean ;\
143 done
145 dh_install -s --sourcedir=$(CURDIR)/debian/tmp
146 dh_installexamples -s
148 install-python%:
149 dh_testdir
150 dh_testroot
151 dh_clean -k -s
152 set -e ;\
153 cd bindings/python ;\
154 python$* setup.py install --root=$(CURDIR)/debian/python-rrd
157 binary-indep:
158 dh_testdir
159 dh_testroot
160 dh_clean -k -i
161 dh_link -plibrrd-ruby /usr/share/doc/librrd-ruby$(RUBY_DEFAULT_VERS) /usr/share/doc/librrd-ruby
162 dh_link -plibrrd2-dev /usr/share/doc/librrd-dev /usr/share/doc/librrd2-dev
163 dh_installchangelogs
164 dh_installdocs -i -Nlibrrd-ruby -Nlibrrd2-dev
165 dh_link -i -Nlibrrd-ruby -Nlibrrd2-dev
166 dh_perl -i
167 dh_compress -i
168 dh_fixperms -i
169 dh_installdeb -i
170 dh_gencontrol -i
171 dh_md5sums -i
172 dh_builddeb -i
175 binary-arch: build-arch install-arch
176 dh_testdir
177 dh_testroot
178 dh_installchangelogs -a CHANGES
179 dh_installdocs -a
180 # dh_installexamples -a
181 dh_pysupport -ppython-rrd
182 dh_perl -a
183 dh_installman -a
184 echo 'rubydefault:Depends=librrd-ruby$(RUBY_DEFAULT_VERS)' >> debian/librrd-ruby.substvars
185 dh_link -plibrrd-dev /usr/lib/librrd.so.$(LIB_version) /usr/lib/librrd.so
186 dh_link -plibrrd-dev /usr/lib/librrd_th.so.$(LIB_TH_version) /usr/lib/librrd_th.so
187 dh_link -plibrrd$(LIB_major) /usr/lib/librrd.so.$(LIB_version) /usr/lib/librrd.so.$(LIB_major)
188 dh_link -plibrrd$(LIB_major) /usr/lib/librrd_th.so.$(LIB_TH_version) /usr/lib/librrd_th.so.$(LIB_TH_major)
189 dh_link -a
190 dh_strip -a
191 dh_compress -a
192 dh_fixperms -a
193 dh_makeshlibs -a
194 dh_installdeb -a
195 dh_shlibdeps -a
196 dh_gencontrol -a
197 dh_md5sums -a
198 dh_builddeb -a
201 binary: binary-arch binary-indep
202 .PHONY: build clean configure \
203 binary-indep binary-arch binary \
204 install install-arch \
205 install-python% clean-python%