Code

rules: Use dpkg-buildflags to determine compiler/linker flags.
[pkg-collectd.git] / debian / rules
1 #! /usr/bin/make -f
2 # debian/rules for collectd
3 #
4 # Written by Sebastian Harl <tokkee@debian.org>.
6 # Uncomment this to turn on verbose mode.
7 #export DH_VERBOSE=1
9 # These are used for cross-compiling and for saving the configure script
10 # from having to guess our platform (since we know it already)
11 DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
12 DEB_BUILD_ARCH      ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH)
13 DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
15 CPPFLAGS = `dpkg-buildflags --get CPPFLAGS`
16 CPPFLAGS += -I$(CURDIR)/debian/include
17 CFLAGS = `dpkg-buildflags --get CFLAGS`
18 CFLAGS += -Wall
20 # There is no way to tell lt_dlopen() to use the RTLD_GLOBAL flag which is
21 # however required by the perl plugin (which would otherwise be unable to find
22 # symbols defined in libperl when loading perl modules that require such
23 # symbols). This is a workaround for this issue.
24 CPPFLAGS += -DLT_LAZY_OR_NOW='RTLD_LAZY|RTLD_GLOBAL'
26 # Upstream defaults to ${sysconfdir}/collectd.conf. Setting ${sysconfdir} to
27 # /etc/collectd would be wrong though.
28 CPPFLAGS += -UCONFIGFILE
29 CPPFLAGS += -DCONFIGFILE='\"/etc/collectd/collectd.conf\"'
31 LDFLAGS = `dpkg-buildflags --get LDFLAGS`
33 # The archdir map has been copied from openjdk-6's debian/rules.
34 JAVA_ARCHDIR_MAP = armel=arm hppa=parisc lpia=i386 powerpc=ppc powerpcspe=ppc sh4=sh
35 JAVA_ARCHDIR = $(strip $(patsubst $(DEB_BUILD_ARCH)=%, %, \
36                         $(filter $(DEB_BUILD_ARCH)=%, $(JAVA_ARCHDIR_MAP))))
37 ifeq (,$(JAVA_ARCHDIR))
38         JAVA_ARCHDIR = $(DEB_BUILD_ARCH)
39 endif
40 JAVA_HOME = /usr/lib/jvm/java-6-openjdk-$(DEB_BUILD_ARCH)
41 JAVA_LIBDIR = $(JAVA_HOME)/jre/lib/$(JAVA_ARCHDIR)/server
43 JAVAC = $(JAVA_HOME)/bin/javac
44 JAR = $(JAVA_HOME)/bin/jar
45 JAVA_CPPFLAGS = -I$(JAVA_HOME)/include
46 JAVA_LDFLAGS = -L$(JAVA_LIBDIR) -Wl,-rpath -Wl,$(JAVA_LIBDIR)
48 include /usr/share/dpatch/dpatch.make
50 confflags = --host=$(DEB_HOST_GNU_TYPE) \
51                         --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr \
52                         --mandir=\$${prefix}/share/man \
53                         --localstatedir=/var --sysconfdir=/etc \
54                         --with-perl-bindings="INSTALLDIRS=vendor" \
55                         --without-libstatgrab \
56                         --without-included-ltdl \
57                         --disable-static \
58                         --enable-all-plugins
60 # These plugins do not provide any functionality under Linux.
61 confflags += --disable-apple_sensors --disable-tape
63 # libmodbus is required for the modbus plugin.
64 confflags += --disable-modbus
66 # libnetapp is required for the netapp plugin.
67 confflags += --disable-netapp
69 # libowcapi is required for the onewire plugin.
70 confflags += --disable-onewire
72 # libclntsh is required for the oracle plugin.
73 confflags += --disable-oracle
75 # librouteros is required for the routeros plugin.
76 confflags += --disable-routeros
78 # xmms1 is required for the xmms plugin.
79 confflags += --disable-xmms
81 # libkstat is required for the xfs_arc plugin.
82 confflags += --disable-zfs-arc
84 # The static library netstat cannot be linked into shared objects on some
85 # architectures (see bugs #358637, #419684 and #524593 for more details).
86 ifneq (,$(filter alpha amd64 hppa ia64 ppc64 mips mipsel, $(DEB_BUILD_ARCH)))
87         confflags += --disable-netlink
88 endif
90 # These plugins are Linux-specific.
91 ifneq (,$(filter kfreebsd-i386 kfreebsd-amd64, $(DEB_BUILD_ARCH)))
92         confflags += \
93                 --disable-iptables \
94                 --disable-ipvs \
95                 --disable-madwifi \
96                 --disable-netlink \
97                 --disable-sensors \
98                 --disable-vserver
99 else
100         # configure is not currently able to correctly check for ip_vs.h.
101         # ipvs_h_include.dpatch takes care of using the right one. Overwriting
102         # KERNEL_DIR makes sure we don't use any kernel headers directly.
103         confflags += --enable-ipvs=force KERNEL_DIR=/usr
104 endif
106 # These plugins have not been ported to FreeBSD yet.
107 ifneq (,$(filter kfreebsd-i386 kfreebsd-amd64, $(DEB_BUILD_ARCH)))
108         confflags += \
109                 --disable-battery \
110                 --disable-conntrack \
111                 --disable-contextswitch \
112                 --disable-cpufreq \
113                 --disable-disk \
114                 --disable-entropy \
115                 --disable-fscache \
116                 --disable-irq \
117                 --disable-nfs \
118                 --disable-protocols \
119                 --disable-serial \
120                 --disable-thermal \
121                 --disable-vmem \
122                 --disable-wireless
123 endif
125 # Build-dependencies of these plugins are (not yet) available for kfreebsd.
126 ifneq (,$(filter kfreebsd-i386 kfreebsd-amd64, $(DEB_BUILD_ARCH)))
127         confflags += \
128                 --disable-gmond \
129                 --disable-libvirt \
130                 --disable-tokyotyrant \
131                 --disable-java
132 endif
134 # The hppa buildds currently do not keep up with Java related stuff, thus
135 # prevending testing transitions.
136 ifneq (,$(filter hppa, $(DEB_BUILD_ARCH)))
137         confflags += --disable-java
138 endif
140 config.status: configure $(DPATCH_STAMPFN)
141         dh_testdir
142         
143         ( cd debian/patches/; for patch in *; do \
144                 if test "$$patch" != "00list"; then \
145                         grep "$$patch" 00list > /dev/null \
146                                 || ( echo "$$patch not enabled\!"; exit 1 ); \
147                 fi; done )
148         
149         # This is a work-around for #474087 (broken openipmi .pc files).
150         mkdir debian/pkgconfig
151         sed -re 's/^(Requires:.*) pthread(.*)$$/\1\2/' \
152                 /usr/lib/pkgconfig/OpenIPMIpthread.pc \
153                 > debian/pkgconfig/OpenIPMIpthread.pc
154         
155         PKG_CONFIG_PATH="$(CURDIR)/debian/pkgconfig:$$PKG_CONFIG_PATH" \
156         ./configure $(confflags) CPPFLAGS="$(CPPFLAGS)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \
157                 JAVAC="$(JAVAC)" JAR="$(JAR)" JAVA_CPPFLAGS="$(JAVA_CPPFLAGS)" \
158                 JAVA_LDFLAGS="$(JAVA_LDFLAGS)" \
159                 || ( status=$$?; cat config.log; exit $$status )
161 build: build-arch build-indep
162 build-arch: build-stamp
163 build-indep: build-stamp
165 build-stamp: config.status
166         dh_testdir
167         
168         $(MAKE)
169         perl ./debian/bin/check_plugins.pl
170         
171         touch build-stamp
173 clean: unpatch
174         dh_testdir
175         dh_testroot
176         rm -f build-stamp
177         
178         [ ! -f Makefile ] || $(MAKE) distclean
179         
180         rm -f debian/README.Debian.plugins
181         rm -f src/*.1 src/*.5
182         
183         rm -rf debian/pkgconfig
184         
185         dh_clean
186         debconf-updatepo
188 install-indep:
189         dh_testdir
190         dh_testroot
191         dh_clean -k
192         dh_installdirs -i
193         dh_install -i
195 install-arch: build
196         dh_testdir
197         dh_testroot
198         dh_clean -k
199         dh_installdirs -a
200         
201         $(MAKE) install DESTDIR=$(CURDIR)/debian/tmp
202         
203         rm -f debian/tmp/usr/lib/collectd/*.la
204         rm -f debian/tmp/usr/lib/libcollectdclient.la
205         rm -f debian/tmp/etc/collectd.conf
206         
207         dh_install -a --sourcedir=$(CURDIR)/debian/tmp --fail-missing
208         
209         perl ./debian/bin/gen_plugin_deps.pl
210         
211         mkdir -p debian/collectd-core/usr/share/lintian/overrides/
212         cp debian/collectd-core.overrides \
213                 debian/collectd-core/usr/share/lintian/overrides/collectd-core
215 binary-indep: install-indep
216         dh_testdir
217         dh_testroot
218         dh_installchangelogs -i ChangeLog
219         dh_installdocs -A -i debian/README.Debian AUTHORS README TODO
220         dh_installexamples -i contrib/examples/myplugin.c \
221                 contrib/examples/MyPlugin.pm
222         dh_compress -i -Xexamples/
223         dh_fixperms -i
224         dh_installdeb -i
225         dh_gencontrol -i
226         dh_md5sums -i
227         dh_builddeb -i
229 binary-arch: build install-arch
230         dh_testdir
231         dh_testroot
232         dh_installchangelogs -a ChangeLog
233         dh_installdocs -A -a debian/README.Debian AUTHORS README TODO
234         dh_installdocs -a debian/NEWS.Debian debian/README.Debian.plugins
235         dh_installexamples -a contrib/collectd2html.pl contrib/collection.cgi \
236                 contrib/collection3/ contrib/php-collection/ \
237                 contrib/exec-munin.conf contrib/exec-munin.px contrib/exec-smartctl \
238                 contrib/exec-nagios.conf contrib/exec-nagios.px \
239                 contrib/SpamAssassin/ contrib/iptables/ contrib/cussh.pl \
240                 contrib/snmp-data.conf contrib/add_rra.sh contrib/network-proxy.py \
241                 contrib/collectd_network.py contrib/collectd_unixsock.py \
242                 contrib/snmp-probe-host.px contrib/GenericJMX.conf \
243                 debian/collectd.conf debian/filters.conf debian/thresholds.conf
244         # some upstream tarballs have been built inside a dirty working dir
245         ( cd debian/collectd-core/ \
246                 && cd usr/share/doc/collectd-core/examples/collection3/ \
247                 && rm -f bin/foo bin/test_config.px etc/collection4.conf \
248                 && rm -f lib/Collectd/Graph.pm lib/Collectd/Graph/Data.pm \
249                 && rm -f lib/Collectd/Graph/File.pm lib/Collectd/Graph/Filter.pm \
250                 && rm -f lib/Collectd/Graph/MetaData.pm )
251         dh_installdebconf -a
252         dh_installinit -pcollectd-core --name=collectd -- defaults 95
253         dh_link -a
254         dh_strip -a --dbg-package=collectd-dbg
255         dh_compress -a -Xexamples/
256         dh_fixperms -a
257         dh_makeshlibs -a
258         dh_installdeb -a
259         dh_shlibdeps -a -Ncollectd-core -Ncollectd
260         dpkg-shlibdeps -Tdebian/collectd.substvars \
261                 -dDepends debian/collectd-core/usr/lib/collectd/rrdtool.so
262         dpkg-shlibdeps -Tdebian/collectd-core.substvars \
263                 -dDepends debian/collectd-core/usr/sbin/* \
264                 -dSuggests debian/collectd-core/usr/lib/collectd/*.so
265         grep shlibs:Suggests debian/collectd-core.substvars \
266                 | sed -e 's/shlibs:Suggests/shlibs:Recommends/' \
267                 >> debian/collectd.substvars
268         dh_gencontrol -a
269         dh_md5sums -a
270         dh_builddeb -a
272 binary: binary-arch binary-indep
273 .PHONY: build build-arch build-indep clean binary-indep binary-arch binary install-indep install-arch