Code

1a361eb3805b661886be378ad29a8f86de097af4
[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,')
22 #let's help configure to figure out our host/build system
23 DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
24 DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
25 DEB_HOST_ARCH_CPU   ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_CPU)
27 ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
28   CONFFLAGS += --build $(DEB_HOST_GNU_TYPE)
29 else
30   CONFFLAGS += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
31 endif
33 #we build the bindings manually from debian/rules
34 CONFFLAGS += --disable-python --disable-ruby
36 #set the right paths
37 CONFFLAGS += --prefix=/usr --docdir=/usr/share/doc/rrdtool
39 #install perl libs in vendor mode
40 CONFFLAGS += --with-perl-options=INSTALLDIRS=vendor 
42 #path to tcl
43 CONFFLAGS += --with-tcllib=/usr/lib/tcl$(TCL_VERS)
45 #let's take care of optimization + debug builds
46 CFLAGS += -Wall -g
47 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
48         CFLAGS += -O0
49 else
50 #don't optimize on arm for now - #447041
51 ifneq ($(DEB_HOST_ARCH_CPU), arm)
52         CFLAGS += -O2
53 endif
54 endif
56 # work-around for a broken dpkg - do not rename this to LDFLAGS :-/
57 LINKER_FLAGS=-Wl,-z,defs
59 configure: config.status
60 config.status: $(QUILT_STAMPFN)
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="$(LINKER_FLAGS)" \
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%) $(PY_VERS:%=build-python%-dbg)
77 build-arch-stamp: config.status 
78         make
79         #Fix library path to tcl bindings
80         sed -i -e 's|lib/|lib/tcltk/rrdtool-tcl/|' bindings/tcl/pkgIndex.tcl
81         #sanity check if debian/control lists the right package name
82         LIB_major=`grep '^dlname=' src/librrd.la \
83                         | sed -e "s/^dlname='librrd\.so\.\\([0-9]\+\\)'\$$/\\1/"` \
84                 && test -n "$$LIB_major" \
85                 && grep -q "^Package: librrd$$LIB_major\\>" debian/control
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%) $(PY_VERS:%=clean-python%-dbg)
99         dh_testdir
100         dh_testroot
102         [ ! -f Makefile ] || make distclean
104 ifneq "$(wildcard /usr/share/misc/config.sub)" ""
105         rm -f config.sub
106 endif
107 ifneq "$(wildcard /usr/share/misc/config.guess)" ""
108         rm -f config.guess
109 endif
110         rm -f build-arch-stamp build-indep-stamp config.status install-common-stamp
111         find . -name \*.pyc | xargs rm -f
112         rm -rf bindings/python/build
114         # clean what the Makefiles do not clean ...
115         rm -rf bindings/perl-piped/blib bindings/perl-shared/blib \
116                bindings/perl-piped/Makefile.old bindings/perl-shared/Makefile.old
117         rm -f bindings/tcl/pkgIndex.tcl bindings/tcl/tclrrd*.so
118         rm -f examples/cgi-demo.cgi
119         rm -rf src/.libs src/.deps doc/*.html doc/*.1 doc/*.txt
120         rm -f intltool-extract intltool-merge intltool-update
121         rm -f src/librrd.sym
122         rm -f config.h
124         dh_clean
126 clean-python%: unpatch
127         set -e ;\
128          cd bindings/python ;\
129          python$* setup.py clean ;\
130          rm -f build-python$*
133 install: install-arch install-indep
135 install-indep: build-indep install-common-stamp
136         #nothing to do
138 install-common-stamp: build-arch-stamp
139         dh_testdir
140         dh_testroot
141         dh_clean -k
143         make install DESTDIR=$(CURDIR)/debian/tmp
144         # we don't want .txt and .pod documentation in the package
145         rm -rf debian/tmp/usr/share/doc/rrdtool/txt
146         dh_install --sourcedir=$(CURDIR)/debian/tmp --fail-missing
148         touch $@
150 install-arch: install-common-stamp $(PY_VERS:%=install-python%)
151         #build and install ruby
152         set -e; \
153         cd bindings/ruby ;\
154         for rbv in $(RUBY_VERS); do \
155           ruby$$rbv extconf.rb ;\
156           make ;\
157           make install sitelibdir=$(CURDIR)/debian/librrd-ruby$$rbv`ruby$$rbv -r rbconfig -e 'print Config::CONFIG["rubylibdir"]'` \
158                        sitearchdir=$(CURDIR)/debian/librrd-ruby$$rbv`ruby$$rbv -r rbconfig -e 'print Config::CONFIG["archdir"]'` ;\
159           make distclean ;\
160         done
162         dh_installexamples -s
164 install-python%: install-common-stamp
165         dh_testdir
166         dh_testroot
167         set -e ;\
168          cd bindings/python ;\
169          python$* setup.py install --root=$(CURDIR)/debian/python-rrdtool ;\
170          python$*-dbg setup.py install --root=$(CURDIR)/debian/rrdtool-dbg
171         find $(CURDIR)/debian/rrdtool-dbg -type f -name '*.egg-info' -print0 |\
172                  xargs -0r rm -f
175 binary-indep: build-indep install-indep
176         dh_testdir
177         dh_testroot
178         dh_link -plibrrd-ruby /usr/share/doc/librrd-ruby$(RUBY_DEFAULT_VERS) /usr/share/doc/librrd-ruby
179         dh_installchangelogs -i -Nlibrrd-ruby CHANGES
180         dh_installdocs -i -Nlibrrd-ruby -A CONTRIBUTORS NEWS
181         dh_link -i -Nlibrrd-ruby
182         echo 'rubydefault:Depends=librrd-ruby$(RUBY_DEFAULT_VERS)' >> debian/librrd-ruby.substvars
183         dh_perl -i
184         dh_compress -i
185         dh_fixperms -i
186         dh_installdeb -i
187         dh_gencontrol -i
188         dh_md5sums -i
189         dh_builddeb -i
190         
192 binary-arch: build-arch install-arch
193         dh_testdir
194         dh_testroot
195         dh_installchangelogs -a CHANGES
196         dh_installdocs -a -A CONTRIBUTORS NEWS
197         dh_installdocs -a
198         echo 'tcl:Depends=tcl$(TCL_VERS) | tclsh' >> debian/rrdtool-tcl.substvars
199         dh_pysupport -ppython-rrdtool
200         dh_pysupport -prrdtool-dbg
201         dh_perl -a
202         dh_installman -a
203         dh_link -a
204         dh_strip -a --dbg-package=rrdtool-dbg
205         dh_compress -a
206         dh_fixperms -a
207         dh_makeshlibs -a
208         dh_installdeb -a
209         dh_shlibdeps -a
210         dh_gencontrol -a
211         dh_md5sums -a
212         dh_builddeb -a
215 binary: binary-arch binary-indep
216 .PHONY: build clean configure \
217         binary-indep binary-arch binary \
218         install install-arch \
219         install-python% clean-python% unpatch