Code

7ccd1118e89e76aa0483bfe134f1a3435519e5b2
[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
113         dh_clean
115 clean-python%:
116         cd bindings/python && python$* setup.py clean
117         rm -f build-python$*
119 install: install-indep install-arch
120 install-indep:
121         dh_testdir
122         dh_testroot
123         dh_clean -k -s
124         dh_installdirs -s
127         dh_install -s
129 install-arch: $(PY_VERS:%=install-python%)
130         dh_testdir
131         dh_testroot
132         dh_clean -k -s
133         dh_installdirs -s
135         make install DESTDIR=$(CURDIR)/debian/tmp
137         #build and install ruby
138         set -e; \
139         cd bindings/ruby ;\
140         for rbv in $(RUBY_VERS); do \
141           ruby$$rbv extconf.rb ;\
142           make ;\
143           make install sitelibdir=$(CURDIR)/debian/librrd-ruby$$rbv`ruby$$rbv -r rbconfig -e 'print Config::CONFIG["rubylibdir"]'` \
144                        sitearchdir=$(CURDIR)/debian/librrd-ruby$$rbv`ruby$$rbv -r rbconfig -e 'print Config::CONFIG["archdir"]'` ;\
145           make distclean ;\
146         done
148 install-python%:
149         cd bindings/python && python$* setup.py install --root=$(CURDIR)/debian/python-rrd
152 binary-indep:
153         dh_testdir
154         dh_testroot
155         echo 'rubydefault:Depends=librrd-ruby$(RUBY_DEFAULT_VERS)' >> debian/librrd-ruby.substvars
156         dh_link -plibrrd-ruby /usr/share/doc/librrd-ruby$(RUBY_DEFAULT_VERS) /usr/share/doc/librrd-ruby
157         dh_installchangelogs
158         dh_installdocs -s -Nlibrrd-ruby
159         dh_link -s -Nlibrrd-ruby
160         dh_perl -s
161         dh_compress -s
162         dh_fixperms -s
163         dh_installdeb -s
164         dh_gencontrol -s
165         dh_md5sums -s
166         dh_builddeb -s
167         
169 binary-arch: build-arch install-arch
170         dh_testdir
171         dh_testroot
172         dh_installchangelogs -a CHANGES
173         dh_installdocs -a
174 #       dh_installexamples -a
175         dh_pysupport -ppython-rrd
176         dh_perl -a
177         dh_installman -a
178         dh_link -a
179         dh_strip -a
180         dh_compress -a
181         dh_fixperms -a
182         dh_makeshlibs -a
183         dh_installdeb -a
184         dh_shlibdeps -a
185         dh_gencontrol -a
186         dh_md5sums -a
187         dh_builddeb -a
190 binary: binary-arch binary-indep
191 .PHONY: build clean binary-indep binary-arch binary install install-arch install-indep configure install-python% clean-python%