Code

Merge branch 'master' of git@apu.snow-crash.org:pkg-rrdtool
[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         #Fix library path to tcl bindings
84         sed -i -e 's|lib/|lib/tcltk/rrdtool-tcl/|' bindings/tcl/pkgIndex.tcl
85         touch $@
87 build-python%: build-arch-stamp
88         set -e ;\
89          cd bindings/python ;\
90          BUILDLIBDIR=../../src/.libs LIBDIR=../../src/.libs python$* setup.py build
91         touch $@
93 build-indep: build-arch-stamp
94         #indep stuff is built in build-arch-stamp, too.
96 clean: clean-patched
97 clean-patched: unpatch $(PY_VERS:%=clean-python%)
98         dh_testdir
99         dh_testroot
100         #sanity check if debian/control lists the right package name
101         grep -q '^Package: librrd$(LIB_major)' debian/control
103         [ ! -f Makefile ] || make distclean
105 ifneq "$(wildcard /usr/share/misc/config.sub)" ""
106         rm -f config.sub
107 endif
108 ifneq "$(wildcard /usr/share/misc/config.guess)" ""
109         rm -f config.guess
110 endif
111         rm -f build-arch-stamp build-indep-stamp config.status install-common-stamp
112         find . -name \*.pyc | xargs rm -f
113         rm -rf bindings/python/build
115         #clean what the Makefiles do not clean....
116         rm -rf bindings/perl-piped/blib bindings/perl-shared/blib \
117                bindings/perl-piped/Makefile.old bindings/perl-shared/Makefile.old
118         rm -f bindings/tcl/pkgIndex.tcl bindings/tcl/tclrrd*.so
119         rm -f examples/cgi-demo.cgi
121         dh_clean
123 clean-python%: unpatch
124         set -e ;\
125          cd bindings/python ;\
126          python$* setup.py clean
127         rm -f build-python$*
130 install: install-arch install-indep
132 install-indep: build-indep install-common-stamp
133         #nothing to do
135 install-common-stamp: build-arch-stamp
136         dh_testdir
137         dh_testroot
138         dh_clean -k
140         make install DESTDIR=$(CURDIR)/debian/tmp
141         dh_install --sourcedir=$(CURDIR)/debian/tmp
143         touch $@
145 install-arch: install-common-stamp $(PY_VERS:%=install-python%)
146         #build and install ruby
147         set -e; \
148         cd bindings/ruby ;\
149         for rbv in $(RUBY_VERS); do \
150           ruby$$rbv extconf.rb ;\
151           make ;\
152           make install sitelibdir=$(CURDIR)/debian/librrd-ruby$$rbv`ruby$$rbv -r rbconfig -e 'print Config::CONFIG["rubylibdir"]'` \
153                        sitearchdir=$(CURDIR)/debian/librrd-ruby$$rbv`ruby$$rbv -r rbconfig -e 'print Config::CONFIG["archdir"]'` ;\
154           make distclean ;\
155         done
157         dh_installexamples -s
159 install-python%: install-common-stamp
160         dh_testdir
161         dh_testroot
162         set -e ;\
163          cd bindings/python ;\
164          python$* setup.py install --root=$(CURDIR)/debian/python-rrdtool
167 binary-indep: build-indep install-indep
168         dh_testdir
169         dh_testroot
170         dh_link -plibrrd-ruby /usr/share/doc/librrd-ruby$(RUBY_DEFAULT_VERS) /usr/share/doc/librrd-ruby
171         dh_link -ppython-rrd /usr/share/doc/python-rrdtool /usr/share/doc/python-rrd
172         dh_installchangelogs -i -Nlibrrd-ruby -Npython-rrd
173         dh_installdocs -i -Nlibrrd-ruby -Npython-rrd
174         dh_link -i -Nlibrrd-ruby -Npython-rrd
175         echo 'rubydefault:Depends=librrd-ruby$(RUBY_DEFAULT_VERS)' >> debian/librrd-ruby.substvars
176         dh_perl -i
177         dh_compress -i
178         dh_fixperms -i
179         dh_installdeb -i
180         dh_gencontrol -i
181         dh_md5sums -i
182         dh_builddeb -i
183         
185 binary-arch: build-arch install-arch
186         dh_testdir
187         dh_testroot
188         dh_installchangelogs -a CHANGES
189         dh_installdocs -A CONTRIBUTORS
190         dh_installdocs -a
191 #       dh_installexamples -a
192         dh_pysupport -ppython-rrdtool
193         dh_perl -a
194         dh_installman -a
195         dh_link -plibrrd-dev /usr/lib/librrd.so.$(LIB_version) /usr/lib/librrd.so
196         dh_link -plibrrd-dev /usr/lib/librrd_th.so.$(LIB_TH_version) /usr/lib/librrd_th.so
197         dh_link -plibrrd$(LIB_major) /usr/lib/librrd.so.$(LIB_version) /usr/lib/librrd.so.$(LIB_major)
198         dh_link -plibrrd$(LIB_major) /usr/lib/librrd_th.so.$(LIB_TH_version) /usr/lib/librrd_th.so.$(LIB_TH_major)
199         dh_link -a
200         dh_strip -a
201         dh_compress -a
202         dh_fixperms -a
203         dh_makeshlibs -a
204         dh_installdeb -a
205         dh_shlibdeps -a
206         dh_gencontrol -a
207         dh_md5sums -a
208         dh_builddeb -a
211 binary: binary-arch binary-indep
212 .PHONY: build clean configure \
213         binary-indep binary-arch binary \
214         install install-arch \
215         install-python% clean-python% unpatch