Code

cc67b8aaee87e7433777f84763d1b4a30a12694e
[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 #let's help configure to figure out our host/build system
32 DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
33 DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
34 ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
35   CONFFLAGS += --build $(DEB_HOST_GNU_TYPE)
36 else
37   CONFFLAGS += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
38 endif
40 #we build the bindings manually from debian/rules
41 CONFFLAGS += --disable-python --disable-ruby
43 #set the right paths
44 CONFFLAGS += --prefix=/usr --docdir=/usr/share/doc/rrdtool
46 #install perl libs in vendor mode
47 CONFFLAGS += --with-perl-options=INSTALLDIRS=vendor 
51 #let's take care of optimization + debug builds
52 CFLAGS += -Wall -g
53 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
54         CFLAGS += -O0
55 else
56         CFLAGS += -O2
57 endif
59 LDFLAGS="-Wl,-z,defs"
61 configure: config.status
62 config.status: $(QUILT_STAMPFN)
64 ifneq "$(wildcard /usr/share/misc/config.sub)" ""
65         cp -f /usr/share/misc/config.sub config.sub
66 endif
67 ifneq "$(wildcard /usr/share/misc/config.guess)" ""
68         cp -f /usr/share/misc/config.guess config.guess
69 endif
71         LDFLAGS="$(LDFLAGS)"
72         CFLAGS="$(CFLAGS)" \
73         RRDDOCDIR=/usr/share/doc/rrdtool \
74           ./configure $(CONFFLAGS)
76 build: build-arch build-indep 
78 build-arch: build-arch-stamp $(PY_VERS:%=build-python%)
79 build-arch-stamp: config.status 
81         #configure forgets to set TCL_INC_DIR.
82         make TCL_INC_DIR=/usr/include/tcl
83         touch $@
85 build-python%: build-arch-stamp
86         set -e ;\
87          cd bindings/python ;\
88          BUILDLIBDIR=../../src/.libs LIBDIR=../../src/.libs python$* setup.py build
89         touch $@
91 build-indep: build-arch-stamp
92         #indep stuff is built in build-arch-stamp, too.
94 clean: clean-patched
95 clean-patched: unpatch $(PY_VERS:%=clean-python%)
96         dh_testdir
97         dh_testroot
98         #sanity check if debian/control lists the right package name
99         grep -q '^Package: librrd$(LIB_major)' debian/control
101         [ ! -f Makefile ] || make distclean
103 ifneq "$(wildcard /usr/share/misc/config.sub)" ""
104         rm -f config.sub
105 endif
106 ifneq "$(wildcard /usr/share/misc/config.guess)" ""
107         rm -f config.guess
108 endif
109         rm -f build-arch-stamp build-indep-stamp config.status install-common-stamp
110         find . -name \*.pyc | xargs rm -f
111         rm -rf bindings/python/build
113         #clean what the Makefiles do not clean....
114         rm -rf bindings/perl-piped/blib bindings/perl-shared/blib \
115                bindings/perl-piped/Makefile.old bindings/perl-shared/Makefile.old
116         rm -f bindings/tcl/pkgIndex.tcl bindings/tcl/tclrrd*.so
117         rm -f examples/cgi-demo.cgi
119         dh_clean
121 clean-python%: unpatch
122         set -e ;\
123          cd bindings/python ;\
124          python$* setup.py clean
125         rm -f build-python$*
128 install: install-arch install-indep
130 install-indep: build-indep install-common-stamp
131         #nothing to do
133 install-common-stamp: build-arch-stamp
134         dh_testdir
135         dh_testroot
136         dh_clean -k
138         make install DESTDIR=$(CURDIR)/debian/tmp
139         dh_install --sourcedir=$(CURDIR)/debian/tmp
141         touch $@
143 install-arch: install-common-stamp $(PY_VERS:%=install-python%)
144         #build and install ruby
145         set -e; \
146         cd bindings/ruby ;\
147         for rbv in $(RUBY_VERS); do \
148           ruby$$rbv extconf.rb ;\
149           make ;\
150           make install sitelibdir=$(CURDIR)/debian/librrd-ruby$$rbv`ruby$$rbv -r rbconfig -e 'print Config::CONFIG["rubylibdir"]'` \
151                        sitearchdir=$(CURDIR)/debian/librrd-ruby$$rbv`ruby$$rbv -r rbconfig -e 'print Config::CONFIG["archdir"]'` ;\
152           make distclean ;\
153         done
155         dh_installexamples -s
157 install-python%: install-common-stamp
158         dh_testdir
159         dh_testroot
160         set -e ;\
161          cd bindings/python ;\
162          python$* setup.py install --root=$(CURDIR)/debian/python-rrdtool
165 binary-indep: build-indep install-indep
166         dh_testdir
167         dh_testroot
168         dh_link -plibrrd-ruby /usr/share/doc/librrd-ruby$(RUBY_DEFAULT_VERS) /usr/share/doc/librrd-ruby
169         dh_link -ppython-rrd /usr/share/doc/python-rrdtool /usr/share/doc/python-rrd
170         dh_installchangelogs -i -Nlibrrd-ruby -Npython-rrd
171         dh_installdocs -i -Nlibrrd-ruby -Npython-rrd
172         dh_link -i -Nlibrrd-ruby -Npython-rrd
173         echo 'rubydefault:Depends=librrd-ruby$(RUBY_DEFAULT_VERS)' >> debian/librrd-ruby.substvars
174         dh_perl -i
175         dh_compress -i
176         dh_fixperms -i
177         dh_installdeb -i
178         dh_gencontrol -i
179         dh_md5sums -i
180         dh_builddeb -i
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-rrdtool
190         dh_perl -a
191         dh_installman -a
192         dh_link -plibrrd-dev /usr/lib/librrd.so.$(LIB_version) /usr/lib/librrd.so
193         dh_link -plibrrd-dev /usr/lib/librrd_th.so.$(LIB_TH_version) /usr/lib/librrd_th.so
194         dh_link -plibrrd$(LIB_major) /usr/lib/librrd.so.$(LIB_version) /usr/lib/librrd.so.$(LIB_major)
195         dh_link -plibrrd$(LIB_major) /usr/lib/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 \
212         install-python% clean-python% unpatch