Code

Adding Ruby example
[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 Makefile.am:librrd_la_LDFLAGS         = -version-info 2:12:0
8 Makefile.am:librrd_th_la_LDFLAGS         = $(MULTITHREAD_LDFLAGS) -version-info 2:11:0
12 #library versions
13 LIB_version := $(shell grep '^librrd_la_LDFLAGS' src/Makefile.am | \
14                            sed 's,^[^0-9]*,,g;s,:,.,g')
15 LIB_major := $(shell echo $(LIB_version) | sed 's,\..*,,g')
16 LIB_TH_version := $(shell grep '^librrd_th_la_LDFLAGS' src/Makefile.am | \
17                            sed 's,^[^0-9]*,,g;s,:,.,g')
18 LIB_major := $(shell echo $(LIB_th_version) | sed 's,\..*,,g')
22 #Ruby versions to build for
23 RUBY_VERS := 1.8 1.9
24 RUBY_DEFAULT_VERS := 1.8
26 #Python versions to build for. The work-around-doko way.
27 PY_VERS := $(shell set -e; \
28                    for py in `pysupport-parseversions debian/pyversions`; do \
29                        if [ -x /usr/bin/python$$py ]; then echo $$py; fi;    \
30                    done)
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
53 #let's take care of optimization + debug builds
54 CFLAGS += -Wall -g
55 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
56         CFLAGS += -O0
57 else
58         CFLAGS += -O2
59 endif
61 LDFLAGS="-Wl,-z,defs"
63 configure: config.status
64 config.status:
66 ifneq "$(wildcard /usr/share/misc/config.sub)" ""
67         cp -f /usr/share/misc/config.sub config.sub
68 endif
69 ifneq "$(wildcard /usr/share/misc/config.guess)" ""
70         cp -f /usr/share/misc/config.guess config.guess
71 endif
73         LDFLAGS="$(LDFLAGS)"
74         CFLAGS="$(CFLAGS)" \
75         RRDDOCDIR=/usr/share/doc/rrdtool \
76           ./configure $(CONFFLAGS)
78 build: build-arch build-indep 
80 build-arch: build-arch-stamp $(PY_VERS:%=build-python%)
81 build-arch-stamp: config.status 
83         #configure forgets to set TCL_INC_DIR.
84         make TCL_INC_DIR=/usr/include/tcl
85         touch $@
87 build-python%: build-arch-stamp
88         cd bindings/python && env BUILDLIBDIR=../../src/.libs LIBDIR=../../src/.libs python$* setup.py build
89         touch $@
91 build-indep: build-indep-stamp
92 build-indep-stamp: config.status
94 clean: $(PY_VERS:%=clean-python%)
95         dh_testdir
96         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
111         find . -name \*.pyc | xargs rm -f
112         rm -rf bindings/python/build
114         rm -rf bindings/perl-piped/blib bindings/perl-shared/blib
116         dh_clean
118 clean-python%:
119         cd bindings/python && python$* setup.py clean
120         rm -f build-python$*
122 install: install-indep install-arch
123 install-indep:
124         dh_testdir
125         dh_testroot
126         dh_clean -k -s
127         dh_installdirs -s
130         dh_install -s
132 install-arch: $(PY_VERS:%=install-python%)
133         dh_testdir
134         dh_testroot
135         dh_clean -k -s
136         dh_installdirs -s
138         make install DESTDIR=$(CURDIR)/debian/tmp
140         #build and install ruby
141         set -e; \
142         cd bindings/ruby ;\
143         for rbv in $(RUBY_VERS); do \
144           ruby$$rbv extconf.rb ;\
145           make ;\
146           make install sitelibdir=$(CURDIR)/debian/librrd-ruby$$rbv`ruby$$rbv -r rbconfig -e 'print Config::CONFIG["rubylibdir"]'` \
147                        sitearchdir=$(CURDIR)/debian/librrd-ruby$$rbv`ruby$$rbv -r rbconfig -e 'print Config::CONFIG["archdir"]'` ;\
148           make distclean ;\
149         done
151         dh_install -s --sourcedir=$(CURDIR)/debian/tmp
152         dh_installexamples -s
154 install-python%:
155         cd bindings/python && python$* setup.py install --root=$(CURDIR)/debian/python-rrd
158 binary-indep:
159         dh_testdir
160         dh_testroot
161         echo 'rubydefault:Depends=librrd-ruby$(RUBY_DEFAULT_VERS)' >> debian/librrd-ruby.substvars
162         dh_link -plibrrd-ruby /usr/share/doc/librrd-ruby$(RUBY_DEFAULT_VERS) /usr/share/doc/librrd-ruby
163         dh_installchangelogs
164         dh_installdocs -s -Nlibrrd-ruby
165         dh_link -s -Nlibrrd-ruby
166         dh_perl -s
167         dh_compress -s
168         dh_fixperms -s
169         dh_installdeb -s
170         dh_gencontrol -s
171         dh_md5sums -s
172         dh_builddeb -s
173         
175 binary-arch: build-arch install-arch
176         dh_testdir
177         dh_testroot
178         dh_installchangelogs -a CHANGES
179         dh_installdocs -a
180 #       dh_installexamples -a
181         dh_pysupport -ppython-rrd
182         dh_perl -a
183         dh_installman -a
184         dh_link -a
185         dh_strip -a
186         dh_compress -a
187         dh_fixperms -a
188         dh_makeshlibs -a
189         dh_installdeb -a
190         dh_shlibdeps -a
191         dh_gencontrol -a
192         dh_md5sums -a
193         dh_builddeb -a
196 binary: binary-arch binary-indep
197 .PHONY: build clean binary-indep binary-arch binary install install-arch install-indep configure install-python% clean-python%