Code

8ddd00286d7d8a1bedaafd4864b46687b57cbc87
[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
10 #needed to build with Python 2.6
11 -include /usr/share/python/python.mk
12 ifeq (,$(py_sitename))
13   py_sitename = site-packages
14   py_libdir = /usr/lib/python$(subst python,,$(1))/site-packages
15   py_sitename_sh = $(py_sitename)
16   py_libdir_sh = $(py_libdir)
17   py_setup_install_args = 
18 endif
22 PY_VERS := $(shell pyversions -vr)
24 #tcl version we're building for
25 TCL_VERS := $(shell dpkg -s tcl-dev | grep '^Depends' \
26         | sed 's,.*\<tcl\([0-9.]*\)-dev\>.*,\1,')
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 DEB_HOST_ARCH_CPU   ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_CPU)
33 ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
34   CONFFLAGS += --build $(DEB_HOST_GNU_TYPE)
35 else
36   CONFFLAGS += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
37 endif
39 #we build the bindings manually from debian/rules
40 CONFFLAGS += --disable-python --disable-ruby
42 #set the right paths
43 CONFFLAGS += --prefix=/usr --docdir=/usr/share/doc/rrdtool
45 #install perl libs in vendor mode
46 CONFFLAGS += --with-perl-options="INSTALLDIRS=vendor INSTALL_BASE="
48 #path to tcl
49 CONFFLAGS += --with-tcllib=/usr/lib/tcl$(TCL_VERS)
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 #don't optimize on arm for now - #447041
57 ifneq ($(DEB_HOST_ARCH_CPU), arm)
58         CFLAGS += -O2
59 endif
60 endif
62 # work-around for a broken dpkg - do not rename this to LDFLAGS :-/
63 LINKER_FLAGS=-Wl,-z,defs
65 configure: config.status
66 config.status: $(QUILT_STAMPFN)
68 ifneq "$(wildcard /usr/share/misc/config.sub)" ""
69         cp -f /usr/share/misc/config.sub config.sub
70 endif
71 ifneq "$(wildcard /usr/share/misc/config.guess)" ""
72         cp -f /usr/share/misc/config.guess config.guess
73 endif
75         dh_autoreconf
77         LDFLAGS="$(LINKER_FLAGS)" \
78         CFLAGS="$(CFLAGS)" \
79         RRDDOCDIR=/usr/share/doc/rrdtool \
80           ./configure $(CONFFLAGS)
82 build: build-arch build-indep 
84 build-arch: build-arch-stamp $(PY_VERS:%=build-python%) $(PY_VERS:%=build-python%-dbg)
85 build-arch-stamp: config.status 
86         make
87         #Fix library path to tcl bindings
88         sed -i -e 's|lib/|lib/tcltk/rrdtool-tcl/|' bindings/tcl/pkgIndex.tcl
89         #sanity check if debian/control lists the right package name
90         LIB_major=`grep '^dlname=' src/librrd.la \
91                         | sed -e "s/^dlname='librrd\.so\.\\([0-9]\+\\)'\$$/\\1/"` \
92                 && test -n "$$LIB_major" \
93                 && grep -q "^Package: librrd$$LIB_major\\>" debian/control
94         touch $@
96 build-python%: build-arch-stamp
97         set -e ;\
98          cd bindings/python ;\
99          BUILDLIBDIR=../../src/.libs LIBDIR=../../src/.libs python$* setup.py build ;\
100          touch $@
102 build-indep: build-arch-stamp
103         #indep stuff is built in build-arch-stamp, too.
105 clean: clean-patched
106 clean-patched: unpatch $(PY_VERS:%=clean-python%) $(PY_VERS:%=clean-python%-dbg)
107         dh_testdir
108         dh_testroot
110         [ ! -f Makefile ] || make distclean
112 ifneq "$(wildcard /usr/share/misc/config.sub)" ""
113         rm -f config.sub
114 endif
115 ifneq "$(wildcard /usr/share/misc/config.guess)" ""
116         rm -f config.guess
117 endif
118         rm -f build-arch-stamp build-indep-stamp config.status install-common-stamp
119         find . -name \*.pyc | xargs rm -f
120         rm -rf bindings/python/build
122         # clean what the Makefiles do not clean ...
123         rm -rf bindings/perl-piped/blib bindings/perl-shared/blib \
124                bindings/perl-piped/Makefile.old bindings/perl-shared/Makefile.old
125         rm -f bindings/perl-shared/MYMETA.yml bindings/perl-shared/MYMETA.json
126         rm -f bindings/tcl/pkgIndex.tcl bindings/tcl/tclrrd*.so
127         rm -f examples/cgi-demo.cgi
128         rm -rf src/.libs src/.deps doc/*.html doc/*.1 doc/*.txt
129         rm -f intltool-extract intltool-merge intltool-update
130         rm -f src/librrd.sym
131         rm -f config.h
133         dh_autoreconf_clean
135         dh_clean
137 clean-python%: unpatch
138         set -e ;\
139          cd bindings/python ;\
140          python$* setup.py clean ;\
141          rm -f build-python$*
144 install: install-arch install-indep
146 install-indep: build-indep install-common-stamp
147         #nothing to do
149 install-common-stamp: build-arch-stamp
150         dh_testdir
151         dh_testroot
152         dh_clean -k
154         make install DESTDIR=$(CURDIR)/debian/tmp
155         # we don't want .txt and .pod documentation in the package
156         rm -rf debian/tmp/usr/share/doc/rrdtool/txt
157         dh_install --sourcedir=$(CURDIR)/debian/tmp -X.la --fail-missing
158         # remove duplicates
159         rm debian/rrdtool/usr/bin/rrdcached
160         rm debian/rrdtool/usr/share/man/man1/rrdcached.1
161         rm debian/rrdtool/usr/share/doc/rrdtool/html/rrdcached.html
163         touch $@
165 install-arch: install-common-stamp $(PY_VERS:%=install-python%)
166         #build and install ruby
167         dh_ruby --install
169         dh_installexamples -s
170         chmod 644 debian/rrdcached/usr/share/doc/rrdcached/examples/RRDCached.pm
172 install-python%: install-common-stamp
173         dh_testdir
174         dh_testroot
175         set -e ;\
176          cd bindings/python ;\
177          python$* setup.py install --root=$(CURDIR)/debian/python-rrdtool \
178                 $(py_setup_install_args) ;\
179          python$*-dbg setup.py install --root=$(CURDIR)/debian/rrdtool-dbg \
180                 $(py_setup_install_args)
182         find $(CURDIR)/debian/rrdtool-dbg -type f -name '*.egg-info' -print0 |\
183                  xargs -0r rm -f
186 binary-indep: build-indep install-indep
187         dh_testdir
188         dh_testroot
189         dh_installchangelogs -i CHANGES
190         dh_installdocs -i -A CONTRIBUTORS NEWS
191         dh_link -i
192         dh_perl -i
193         dh_compress -i
194         dh_fixperms -i
195         dh_installdeb -i
196         dh_gencontrol -i
197         dh_md5sums -i
198         dh_builddeb -i
199         
201 binary-arch: build-arch install-arch
202         dh_testdir
203         dh_testroot
204         dh_installchangelogs -a CHANGES
205         dh_installdocs -a -A CONTRIBUTORS NEWS
206         dh_installdocs -a
207         echo 'tcl:Depends=tcl$(TCL_VERS) | tclsh' >> debian/rrdtool-tcl.substvars
208         dh_python2 -ppython-rrdtool
209         dh_python2 -prrdtool-dbg
210         dh_perl -a
211         dh_installman -a
212         dh_installinit -prrdcached
213         dh_link -a
214         dh_strip -a --dbg-package=rrdtool-dbg
215         dh_compress -a
216         dh_fixperms -a
217         dh_makeshlibs -a -Nliblua5.1-rrd0 -Nliblua5.1-rrd-dev
218         dh_makeshlibs -pliblua5.1-rrd0 -pliblua5.1-rrd-dev -n
219         dh_installdeb -a
220         dh_shlibdeps -a
221         dh_gencontrol -a
222         dh_md5sums -a
223         dh_builddeb -a
226 binary: binary-arch binary-indep
227 .PHONY: build clean configure \
228         binary-indep binary-arch binary \
229         install install-arch \
230         install-python% clean-python% unpatch