Code

Merge branch 'upstream'
[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 #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 #tcl version we're building for
32 TCL_VERS := $(shell dpkg -s tcl | grep ^Depends | sed 's,.*tcl\([0-9.]*\).*,\1,')
35 #let's help configure to figure out our host/build system
36 DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
37 DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
38 ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
39   CONFFLAGS += --build $(DEB_HOST_GNU_TYPE)
40 else
41   CONFFLAGS += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
42 endif
44 #we build the bindings manually from debian/rules
45 CONFFLAGS += --disable-python --disable-ruby
47 #set the right paths
48 CONFFLAGS += --prefix=/usr --docdir=/usr/share/doc/rrdtool
50 #install perl libs in vendor mode
51 CONFFLAGS += --with-perl-options=INSTALLDIRS=vendor 
55 #let's take care of optimization + debug builds
56 CFLAGS += -Wall -g
57 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
58         CFLAGS += -O0
59 else
60         CFLAGS += -O2
61 endif
63 LDFLAGS="-Wl,-z,defs"
65 configure: config.status
66 config.status: $(QUILT_STAMPFN)
68 ifneq "$(wildcard /usr/share/misc/config.sub)" ""
69         cp -f /usr/share/misc/config.sub config.sub
70 endif
71 ifneq "$(wildcard /usr/share/misc/config.guess)" ""
72         cp -f /usr/share/misc/config.guess config.guess
73 endif
75         LDFLAGS="$(LDFLAGS)"
76         CFLAGS="$(CFLAGS)" \
77         RRDDOCDIR=/usr/share/doc/rrdtool \
78           ./configure $(CONFFLAGS)
80 build: build-arch build-indep 
82 build-arch: build-arch-stamp $(PY_VERS:%=build-python%)
83 build-arch-stamp: config.status 
85         #configure forgets to set TCL_INC_DIR.
86         make TCL_INC_DIR=/usr/include/tcl
87         #Fix library path to tcl bindings
88         sed -i -e 's|lib/|lib/tcltk/rrdtool-tcl/|' bindings/tcl/pkgIndex.tcl
89         touch $@
91 build-python%: build-arch-stamp
92         set -e ;\
93          cd bindings/python ;\
94          BUILDLIBDIR=../../src/.libs LIBDIR=../../src/.libs python$* setup.py build
95         touch $@
97 build-indep: build-arch-stamp
98         #indep stuff is built in build-arch-stamp, too.
100 clean: clean-patched
101 clean-patched: unpatch $(PY_VERS:%=clean-python%)
102         dh_testdir
103         dh_testroot
104         #sanity check if debian/control lists the right package name
105         grep -q '^Package: librrd$(LIB_major)' debian/control
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
126         dh_clean
128 clean-python%: unpatch
129         set -e ;\
130          cd bindings/python ;\
131          python$* setup.py clean
132         rm -f build-python$*
135 install: install-arch install-indep
137 install-indep: build-indep install-common-stamp
138         #nothing to do
140 install-common-stamp: build-arch-stamp
141         dh_testdir
142         dh_testroot
143         dh_clean -k
145         make install DESTDIR=$(CURDIR)/debian/tmp
146         dh_install --sourcedir=$(CURDIR)/debian/tmp
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
172 binary-indep: build-indep install-indep
173         dh_testdir
174         dh_testroot
175         dh_link -plibrrd-ruby /usr/share/doc/librrd-ruby$(RUBY_DEFAULT_VERS) /usr/share/doc/librrd-ruby
176         dh_link -ppython-rrd /usr/share/doc/python-rrdtool /usr/share/doc/python-rrd
177         dh_installchangelogs -i -Nlibrrd-ruby -Npython-rrd
178         dh_installdocs -i -Nlibrrd-ruby -Npython-rrd -A CONTRIBUTORS
179         dh_link -i -Nlibrrd-ruby -Npython-rrd
180         echo 'rubydefault:Depends=librrd-ruby$(RUBY_DEFAULT_VERS)' >> debian/librrd-ruby.substvars
181         dh_perl -i
182         dh_compress -i
183         dh_fixperms -i
184         dh_installdeb -i
185         dh_gencontrol -i
186         dh_md5sums -i
187         dh_builddeb -i
188         
190 binary-arch: build-arch install-arch
191         dh_testdir
192         dh_testroot
193         dh_installchangelogs -a CHANGES
194         dh_installdocs -a -A CONTRIBUTORS
195         dh_installdocs -a
196         echo 'tcl:Depends=tcl$(TCL_VERS) | tclsh' >> debian/rrdtool-tcl.substvars
197         dh_pysupport -ppython-rrdtool
198         dh_perl -a
199         dh_installman -a
200         dh_link -plibrrd2-dev /usr/lib/librrd.so.$(LIB_version) /usr/lib/librrd.so
201         dh_link -plibrrd2-dev /usr/lib/librrd_th.so.$(LIB_TH_version) /usr/lib/librrd_th.so
202         dh_link -plibrrd$(LIB_major) /usr/lib/librrd.so.$(LIB_version) /usr/lib/librrd.so.$(LIB_major)
203         dh_link -plibrrd$(LIB_major) /usr/lib/librrd_th.so.$(LIB_TH_version) /usr/lib/librrd_th.so.$(LIB_TH_major)
204         dh_link -a
205         dh_strip -a
206         dh_compress -a
207         dh_fixperms -a
208         dh_makeshlibs -a
209         dh_installdeb -a
210         dh_shlibdeps -a
211         dh_gencontrol -a
212         dh_md5sums -a
213         dh_builddeb -a
216 binary: binary-arch binary-indep
217 .PHONY: build clean configure \
218         binary-indep binary-arch binary \
219         install install-arch \
220         install-python% clean-python% unpatch