Code

86d0382479b7b494a855b1970da2832f53152879
[pkg-rrdtool.git] / debian / rules
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 PY_VERS := $(shell pyversions -vr)
17 #tcl version we're building for
18 TCL_VERS := $(shell dpkg -s tcl-dev | grep '^Depends' \
19         | sed 's,.*\<tcl\([0-9.]*\)-dev\>.*,\1,')
21 LUA = /usr/bin/lua5.1
23 #let's help configure to figure out our host/build system
24 DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
25 DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
26 DEB_HOST_ARCH_CPU   ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_CPU)
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 #enable lua installation
47 CONFFLAGS += --enable-lua-site-install
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 #don't optimize on arm for now - #447041
55 ifneq ($(DEB_HOST_ARCH_CPU), arm)
56         CFLAGS += -O2
57 endif
58 endif
60 # work-around for a broken dpkg - do not rename this to LDFLAGS :-/
61 LINKER_FLAGS=-Wl,-z,defs
63 configure: config.status
64 config.status: $(QUILT_STAMPFN)
66 ifneq "$(wildcard /usr/share/misc/config.sub)" ""
67         cp -f /usr/share/misc/config.sub config.sub
68 endif
69 ifneq "$(wildcard /usr/share/misc/config.guess)" ""
70         cp -f /usr/share/misc/config.guess config.guess
71 endif
73         LDFLAGS="$(LINKER_FLAGS)" \
74         CFLAGS="$(CFLAGS)" \
75         RRDDOCDIR=/usr/share/doc/rrdtool \
76         LUA=$(LUA) \
77           ./configure $(CONFFLAGS)
79 build: build-arch build-indep 
81 build-arch: build-arch-stamp $(PY_VERS:%=build-python%) $(PY_VERS:%=build-python%-dbg)
82 build-arch-stamp: config.status 
83         make
84         #Fix library path to tcl bindings
85         sed -i -e 's|lib/|lib/tcltk/rrdtool-tcl/|' bindings/tcl/pkgIndex.tcl
86         #sanity check if debian/control lists the right package name
87         LIB_major=`grep '^dlname=' src/librrd.la \
88                         | sed -e "s/^dlname='librrd\.so\.\\([0-9]\+\\)'\$$/\\1/"` \
89                 && test -n "$$LIB_major" \
90                 && grep -q "^Package: librrd$$LIB_major\\>" debian/control
91         touch $@
93 build-python%: build-arch-stamp
94         set -e ;\
95          cd bindings/python ;\
96          BUILDLIBDIR=../../src/.libs LIBDIR=../../src/.libs python$* setup.py build ;\
97          touch $@
99 build-indep: build-arch-stamp
100         #indep stuff is built in build-arch-stamp, too.
102 clean: clean-patched
103 clean-patched: unpatch $(PY_VERS:%=clean-python%) $(PY_VERS:%=clean-python%-dbg)
104         dh_testdir
105         dh_testroot
107         [ ! -f Makefile ] || make distclean
109 ifneq "$(wildcard /usr/share/misc/config.sub)" ""
110         rm -f config.sub
111 endif
112 ifneq "$(wildcard /usr/share/misc/config.guess)" ""
113         rm -f config.guess
114 endif
115         rm -f build-arch-stamp build-indep-stamp config.status install-common-stamp
116         find . -name \*.pyc | xargs rm -f
117         rm -rf bindings/python/build
119         # clean what the Makefiles do not clean ...
120         rm -rf bindings/perl-piped/blib bindings/perl-shared/blib \
121                bindings/perl-piped/Makefile.old bindings/perl-shared/Makefile.old
122         rm -f bindings/tcl/pkgIndex.tcl bindings/tcl/tclrrd*.so
123         rm -f examples/cgi-demo.cgi
124         rm -rf src/.libs src/.deps doc/*.html doc/*.1 doc/*.txt
125         rm -f intltool-extract intltool-merge intltool-update
126         rm -f src/librrd.sym
127         rm -f config.h
129         dh_clean
131 clean-python%: unpatch
132         set -e ;\
133          cd bindings/python ;\
134          python$* setup.py clean ;\
135          rm -f build-python$*
138 install: install-arch install-indep
140 install-indep: build-indep install-common-stamp
141         #nothing to do
143 install-common-stamp: build-arch-stamp
144         dh_testdir
145         dh_testroot
146         dh_clean -k
148         make install DESTDIR=$(CURDIR)/debian/tmp
149         # we don't want .txt and .pod documentation in the package
150         rm -rf debian/tmp/usr/share/doc/rrdtool/txt
151         dh_install --sourcedir=$(CURDIR)/debian/tmp --fail-missing
152         # remove duplicates
153         rm debian/rrdtool/usr/bin/rrdcached
154         rm debian/rrdtool/usr/share/man/man1/rrdcached.1
155         rm debian/rrdtool/usr/share/doc/rrdtool/html/rrdcached.html
157         touch $@
159 install-arch: install-common-stamp $(PY_VERS:%=install-python%)
160         #build and install ruby
161         set -e; \
162         cd bindings/ruby ;\
163         for rbv in $(RUBY_VERS); do \
164           ruby$$rbv extconf.rb ;\
165           make ;\
166           make install sitelibdir=$(CURDIR)/debian/librrd-ruby$$rbv`ruby$$rbv -r rbconfig -e 'print Config::CONFIG["rubylibdir"]'` \
167                        sitearchdir=$(CURDIR)/debian/librrd-ruby$$rbv`ruby$$rbv -r rbconfig -e 'print Config::CONFIG["archdir"]'` ;\
168           make distclean ;\
169         done
171         dh_installexamples -s
172         chmod 644 debian/rrdcached/usr/share/doc/rrdcached/examples/RRDCached.pm
174 install-python%: install-common-stamp
175         dh_testdir
176         dh_testroot
177         set -e ;\
178          cd bindings/python ;\
179          python$* setup.py install --root=$(CURDIR)/debian/python-rrdtool ;\
180          python$*-dbg setup.py install --root=$(CURDIR)/debian/rrdtool-dbg
181         find $(CURDIR)/debian/rrdtool-dbg -type f -name '*.egg-info' -print0 |\
182                  xargs -0r rm -f
185 binary-indep: build-indep install-indep
186         dh_testdir
187         dh_testroot
188         dh_link -plibrrd-ruby /usr/share/doc/librrd-ruby$(RUBY_DEFAULT_VERS) /usr/share/doc/librrd-ruby
189         dh_installchangelogs -i -Nlibrrd-ruby CHANGES
190         dh_installdocs -i -Nlibrrd-ruby -A CONTRIBUTORS NEWS
191         dh_link -i -Nlibrrd-ruby
192         echo 'rubydefault:Depends=librrd-ruby$(RUBY_DEFAULT_VERS)' >> debian/librrd-ruby.substvars
193         dh_perl -i
194         dh_compress -i
195         dh_fixperms -i
196         dh_installdeb -i
197         dh_gencontrol -i
198         dh_md5sums -i
199         dh_builddeb -i
200         
202 binary-arch: build-arch install-arch
203         dh_testdir
204         dh_testroot
205         dh_installchangelogs -a CHANGES
206         dh_installdocs -a -A CONTRIBUTORS NEWS
207         dh_installdocs -a
208         echo 'tcl:Depends=tcl$(TCL_VERS) | tclsh' >> debian/rrdtool-tcl.substvars
209         dh_pysupport -ppython-rrdtool
210         dh_pysupport -prrdtool-dbg
211         dh_perl -a
212         dh_installman -a
213         dh_link -a
214         dh_strip -a --dbg-package=rrdtool-dbg
215         dh_compress -a
216         dh_fixperms -a
217         dh_makeshlibs -a
218         dh_installdeb -a
219         dh_shlibdeps -a
220         dh_gencontrol -a
221         dh_md5sums -a
222         dh_builddeb -a
225 binary: binary-arch binary-indep
226 .PHONY: build clean configure \
227         binary-indep binary-arch binary \
228         install install-arch \
229         install-python% clean-python% unpatch