Code

Renamed global definition of LDFLAGS to LINKER_FLAGS.
[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')
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 #tcl version we're building for
29 TCL_VERS := $(shell dpkg -s tcl | grep ^Depends | sed 's,.*tcl\([0-9.]*\).*,\1,')
32 #let's help configure to figure out our host/build system
33 DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
34 DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
35 ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
36   CONFFLAGS += --build $(DEB_HOST_GNU_TYPE)
37 else
38   CONFFLAGS += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
39 endif
41 #we build the bindings manually from debian/rules
42 CONFFLAGS += --disable-python --disable-ruby
44 #set the right paths
45 CONFFLAGS += --prefix=/usr --docdir=/usr/share/doc/rrdtool
47 #install perl libs in vendor mode
48 CONFFLAGS += --with-perl-options=INSTALLDIRS=vendor 
50 #path to our ttf font
51 CONFFLAGS += --with-rrd-default-font=/usr/share/rrdtool/librrd$(LIB_major)/DejaVuSansMono-Roman.ttf
54 #let's take care of optimization + debug builds
55 CFLAGS += -Wall -g
56 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
57         CFLAGS += -O0
58 else
59 #don't optimize on arm for now - #447041
60 ifneq ($(DEB_HOST_GNU_TYPE), arm)
61         CFLAGS += -O2
62 endif
63 endif
65 # work-around for a broken dpkg - do not rename this to LDFLAGS :-/
66 LINKER_FLAGS=-Wl,-z,defs
68 configure: config.status
69 config.status: $(QUILT_STAMPFN)
71 ifneq "$(wildcard /usr/share/misc/config.sub)" ""
72         cp -f /usr/share/misc/config.sub config.sub
73 endif
74 ifneq "$(wildcard /usr/share/misc/config.guess)" ""
75         cp -f /usr/share/misc/config.guess config.guess
76 endif
78         LDFLAGS="$(LINKER_FLAGS)" \
79         CFLAGS="$(CFLAGS)" \
80         RRDDOCDIR=/usr/share/doc/rrdtool \
81           ./configure $(CONFFLAGS)
83 build: build-arch build-indep 
85 build-arch: build-arch-stamp $(PY_VERS:%=build-python%)
86 build-arch-stamp: config.status 
88         #configure forgets to set TCL_INC_DIR.
89         make TCL_INC_DIR=/usr/include/tcl
90         #Fix library path to tcl bindings
91         sed -i -e 's|lib/|lib/tcltk/rrdtool-tcl/|' bindings/tcl/pkgIndex.tcl
92         touch $@
94 build-python%: build-arch-stamp
95         set -e ;\
96          cd bindings/python ;\
97          BUILDLIBDIR=../../src/.libs LIBDIR=../../src/.libs python$* setup.py build
98         touch $@
100 build-indep: build-arch-stamp
101         #indep stuff is built in build-arch-stamp, too.
103 clean: clean-patched
104 clean-patched: unpatch $(PY_VERS:%=clean-python%)
105         dh_testdir
106         dh_testroot
107         #sanity check if debian/control lists the right package name
108         grep -q '^Package: librrd$(LIB_major)' debian/control
110         [ ! -f Makefile ] || make distclean
112 ifneq "$(wildcard /usr/share/misc/config.sub)" ""
113         rm -f config.sub
114 endif
115 ifneq "$(wildcard /usr/share/misc/config.guess)" ""
116         rm -f config.guess
117 endif
118         rm -f build-arch-stamp build-indep-stamp config.status install-common-stamp
119         find . -name \*.pyc | xargs rm -f
120         rm -rf bindings/python/build
122         #clean what the Makefiles do not clean....
123         rm -rf bindings/perl-piped/blib bindings/perl-shared/blib \
124                bindings/perl-piped/Makefile.old bindings/perl-shared/Makefile.old
125         rm -f bindings/tcl/pkgIndex.tcl bindings/tcl/tclrrd*.so
126         rm -f examples/cgi-demo.cgi
127         rm -rf src/.libs src/.deps doc/*.html doc/*.1 doc/*.txt
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         dh_install --sourcedir=$(CURDIR)/debian/tmp --list-missing
151         touch $@
153 install-arch: install-common-stamp $(PY_VERS:%=install-python%)
154         #build and install ruby
155         set -e; \
156         cd bindings/ruby ;\
157         for rbv in $(RUBY_VERS); do \
158           ruby$$rbv extconf.rb ;\
159           make ;\
160           make install sitelibdir=$(CURDIR)/debian/librrd-ruby$$rbv`ruby$$rbv -r rbconfig -e 'print Config::CONFIG["rubylibdir"]'` \
161                        sitearchdir=$(CURDIR)/debian/librrd-ruby$$rbv`ruby$$rbv -r rbconfig -e 'print Config::CONFIG["archdir"]'` ;\
162           make distclean ;\
163         done
165         dh_installexamples -s
167 install-python%: install-common-stamp
168         dh_testdir
169         dh_testroot
170         set -e ;\
171          cd bindings/python ;\
172          python$* setup.py install --root=$(CURDIR)/debian/python-rrdtool
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_link -ppython-rrd /usr/share/doc/python-rrdtool /usr/share/doc/python-rrd
180         dh_installchangelogs -i -Nlibrrd-ruby -Npython-rrd
181         dh_installdocs -i -Nlibrrd-ruby -Npython-rrd -A CONTRIBUTORS
182         dh_link -i -Nlibrrd-ruby -Npython-rrd
183         echo 'rubydefault:Depends=librrd-ruby$(RUBY_DEFAULT_VERS)' >> debian/librrd-ruby.substvars
184         dh_perl -i
185         dh_compress -i
186         dh_fixperms -i
187         dh_installdeb -i
188         dh_gencontrol -i
189         dh_md5sums -i
190         dh_builddeb -i
191         
193 binary-arch: build-arch install-arch
194         dh_testdir
195         dh_testroot
196         dh_installchangelogs -a CHANGES
197         dh_installdocs -a -A CONTRIBUTORS
198         dh_installdocs -a
199         echo 'tcl:Depends=tcl$(TCL_VERS) | tclsh' >> debian/rrdtool-tcl.substvars
200         dh_pysupport -ppython-rrdtool
201         dh_perl -a
202         dh_installman -a
203         dh_link -a
204         dh_strip -a
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