Code

Less ugly setup.py calls for python.
[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
8 #library versions
9 LIB_version := $(shell grep '^librrd_la_LDFLAGS' src/Makefile.am | \
10                            sed 's,^[^0-9]*,,g;s,:,.,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,:,.,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-indep install-arch
125 install-indep:
126         dh_testdir
127         dh_testroot
128         dh_clean -k -ppython-rrd
129         dh_installdirs -s
132         dh_install -s
134 install-arch: $(PY_VERS:%=install-python%)
135         dh_testdir
136         dh_testroot
137         dh_clean -k -s -Npython-rrd
138         dh_installdirs -s
140         make install DESTDIR=$(CURDIR)/debian/tmp
142         #build and install ruby
143         set -e; \
144         cd bindings/ruby ;\
145         for rbv in $(RUBY_VERS); do \
146           ruby$$rbv extconf.rb ;\
147           make ;\
148           make install sitelibdir=$(CURDIR)/debian/librrd-ruby$$rbv`ruby$$rbv -r rbconfig -e 'print Config::CONFIG["rubylibdir"]'` \
149                        sitearchdir=$(CURDIR)/debian/librrd-ruby$$rbv`ruby$$rbv -r rbconfig -e 'print Config::CONFIG["archdir"]'` ;\
150           make distclean ;\
151         done
153         dh_install -s --sourcedir=$(CURDIR)/debian/tmp
154         dh_installexamples -s
156 install-python%:
157         dh_testdir
158         dh_testroot
159         dh_clean -k -s
160         set -e ;\
161          cd bindings/python ;\
162          python$* setup.py install --root=$(CURDIR)/debian/python-rrd
165 binary-indep:
166         dh_testdir
167         dh_testroot
168         echo 'rubydefault:Depends=librrd-ruby$(RUBY_DEFAULT_VERS)' >> debian/librrd-ruby.substvars
169         dh_link -plibrrd-ruby /usr/share/doc/librrd-ruby$(RUBY_DEFAULT_VERS) /usr/share/doc/librrd-ruby
170         dh_link -plibrrd2-dev /usr/share/doc/librrd-dev /usr/share/doc/librrd2-dev
171         dh_installchangelogs
172         dh_installdocs -s -Nlibrrd-ruby -Nlibrrd2-dev
173         dh_link -s -Nlibrrd-ruby -Nlibrrd2-dev
174         dh_perl -s
175         dh_compress -s
176         dh_fixperms -s
177         dh_installdeb -s
178         dh_gencontrol -s
179         dh_md5sums -s
180         dh_builddeb -s
181         
183 binary-arch: build-arch install-arch
184         dh_testdir
185         dh_testroot
186         dh_installchangelogs -a CHANGES
187         dh_installdocs -a
188 #       dh_installexamples -a
189         dh_pysupport -ppython-rrd
190         dh_perl -a
191         dh_installman -a
192         dh_link -plibrrd-dev librrd.so.$(LIB_version) /usr/lib/librrd.so
193         dh_link -plibrrd-dev librrd_th.so.$(LIB_TH_version) /usr/lib/librrd_th.so
194         dh_link -plibrrd$(LIB_major) librrd.so.$(LIB_version) /usr/lib/librrd.so.$(LIB_major)
195         dh_link -plibrrd$(LIB_major) librrd_th.so.$(LIB_TH_version) /usr/lib/librrd_th.so.$(LIB_TH_major)
196         dh_link -a
197         dh_strip -a
198         dh_compress -a
199         dh_fixperms -a
200         dh_makeshlibs -a
201         dh_installdeb -a
202         dh_shlibdeps -a
203         dh_gencontrol -a
204         dh_md5sums -a
205         dh_builddeb -a
208 binary: binary-arch binary-indep
209 .PHONY: build clean configure \
210         binary-indep binary-arch binary \
211         install install-arch install-indep \
212         install-python% clean-python%