Code

rules: Use $(shell …) rather than `…`.
[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 export DEB_BUILD_MAINT_OPTIONS=hardening=+all
17 CPPFLAGS = $(shell dpkg-buildflags --get CPPFLAGS)
18 CPPFLAGS += -I$(CURDIR)/debian/include
19 CFLAGS = $(shell dpkg-buildflags --get CFLAGS)
20 CFLAGS += -Wall
22 # There is no way to tell lt_dlopen() to use the RTLD_GLOBAL flag which is
23 # however required by the perl plugin (which would otherwise be unable to find
24 # symbols defined in libperl when loading perl modules that require such
25 # symbols). This is a workaround for this issue.
26 CPPFLAGS += -DLT_LAZY_OR_NOW='RTLD_LAZY|RTLD_GLOBAL'
28 # Upstream defaults to ${sysconfdir}/collectd.conf. Setting ${sysconfdir} to
29 # /etc/collectd would be wrong though.
30 CPPFLAGS += -UCONFIGFILE
31 CPPFLAGS += -DCONFIGFILE='\"/etc/collectd/collectd.conf\"'
33 LDFLAGS = $(shell dpkg-buildflags --get LDFLAGS)
35 # The archdir map has been copied from openjdk-6's debian/rules.
36 JAVA_ARCHDIR = $(shell /usr/share/javahelper/java-arch.sh $(DEB_BUILD_ARCH))
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 endif
101 # These plugins have not been ported to FreeBSD yet.
102 ifneq (,$(filter kfreebsd-i386 kfreebsd-amd64, $(DEB_BUILD_ARCH)))
103         confflags += \
104                 --disable-battery \
105                 --disable-conntrack \
106                 --disable-contextswitch \
107                 --disable-cpufreq \
108                 --disable-disk \
109                 --disable-entropy \
110                 --disable-fscache \
111                 --disable-irq \
112                 --disable-nfs \
113                 --disable-protocols \
114                 --disable-serial \
115                 --disable-thermal \
116                 --disable-vmem \
117                 --disable-wireless
118 endif
120 # Build-dependencies of these plugins are (not yet) available for kfreebsd.
121 ifneq (,$(filter kfreebsd-i386 kfreebsd-amd64, $(DEB_BUILD_ARCH)))
122         confflags += \
123                 --disable-gmond \
124                 --disable-libvirt \
125                 --disable-tokyotyrant \
126                 --disable-java
127 endif
129 # The hppa buildds currently do not keep up with Java related stuff, thus
130 # prevending testing transitions.
131 ifneq (,$(filter hppa, $(DEB_BUILD_ARCH)))
132         confflags += --disable-java
133 endif
135 config.status: configure $(DPATCH_STAMPFN)
136         dh_testdir
137         
138         ( cd debian/patches/; for patch in *; do \
139                 if test "$$patch" != "00list"; then \
140                         grep "$$patch" 00list > /dev/null \
141                                 || ( echo "$$patch not enabled\!"; exit 1 ); \
142                 fi; done )
143         
144         # This is a work-around for #474087 (broken openipmi .pc files).
145         mkdir debian/pkgconfig
146         sed -re 's/^(Requires:.*) pthread(.*)$$/\1\2/' \
147                 /usr/lib/pkgconfig/OpenIPMIpthread.pc \
148                 > debian/pkgconfig/OpenIPMIpthread.pc
149         
150         PKG_CONFIG_PATH="$(CURDIR)/debian/pkgconfig:$$PKG_CONFIG_PATH" \
151         ./configure $(confflags) CPPFLAGS="$(CPPFLAGS)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \
152                 JAVAC="$(JAVAC)" JAR="$(JAR)" JAVA_CPPFLAGS="$(JAVA_CPPFLAGS)" \
153                 JAVA_LDFLAGS="$(JAVA_LDFLAGS)" \
154                 || ( status=$$?; cat config.log; exit $$status )
156 build: build-arch build-indep
157 build-arch: build-stamp
158 build-indep: build-stamp
160 build-stamp: config.status
161         dh_testdir
162         
163         $(MAKE)
164         perl ./debian/bin/check_plugins.pl
165         
166         touch build-stamp
168 clean: unpatch
169         dh_testdir
170         dh_testroot
171         rm -f build-stamp
172         
173         [ ! -f Makefile ] || $(MAKE) distclean
174         
175         rm -f debian/README.Debian.plugins
176         rm -f src/*.1 src/*.5
177         
178         rm -rf debian/pkgconfig
179         
180         dh_clean
181         debconf-updatepo
183 install-indep:
184         dh_testdir
185         dh_testroot
186         dh_clean -k
187         dh_installdirs -i
188         dh_install -i
190 install-arch: build
191         dh_testdir
192         dh_testroot
193         dh_clean -k
194         dh_installdirs -a
195         
196         $(MAKE) install DESTDIR=$(CURDIR)/debian/tmp
197         
198         rm -f debian/tmp/usr/lib/collectd/*.la
199         rm -f debian/tmp/usr/lib/libcollectdclient.la
200         rm -f debian/tmp/etc/collectd.conf
201         
202         dh_install -a --sourcedir=$(CURDIR)/debian/tmp --fail-missing
203         
204         perl ./debian/bin/gen_plugin_deps.pl
205         
206         mkdir -p debian/collectd-core/usr/share/lintian/overrides/
207         cp debian/collectd-core.overrides \
208                 debian/collectd-core/usr/share/lintian/overrides/collectd-core
210 binary-indep: install-indep
211         dh_testdir
212         dh_testroot
213         dh_installchangelogs -i ChangeLog
214         dh_installdocs -A -i debian/README.Debian AUTHORS README TODO
215         dh_installexamples -i contrib/examples/myplugin.c \
216                 contrib/examples/MyPlugin.pm
217         dh_compress -i -Xexamples/
218         dh_fixperms -i
219         dh_installdeb -i
220         dh_gencontrol -i
221         dh_md5sums -i
222         dh_builddeb -i
224 binary-arch: build install-arch
225         dh_testdir
226         dh_testroot
227         dh_installchangelogs -a ChangeLog
228         dh_installdocs -A -a debian/README.Debian AUTHORS README TODO
229         dh_installdocs -a debian/NEWS.Debian debian/README.Debian.plugins
230         dh_installexamples -a contrib/collectd2html.pl contrib/collection.cgi \
231                 contrib/collection3/ contrib/php-collection/ \
232                 contrib/exec-munin.conf contrib/exec-munin.px contrib/exec-smartctl \
233                 contrib/exec-nagios.conf contrib/exec-nagios.px \
234                 contrib/SpamAssassin/ contrib/iptables/ contrib/cussh.pl \
235                 contrib/snmp-data.conf contrib/add_rra.sh contrib/network-proxy.py \
236                 contrib/collectd_network.py contrib/collectd_unixsock.py \
237                 contrib/snmp-probe-host.px contrib/GenericJMX.conf \
238                 debian/collectd.conf debian/filters.conf debian/thresholds.conf
239         # some upstream tarballs have been built inside a dirty working dir
240         ( cd debian/collectd-core/ \
241                 && cd usr/share/doc/collectd-core/examples/collection3/ \
242                 && rm -f bin/foo bin/test_config.px etc/collection4.conf \
243                 && rm -f lib/Collectd/Graph.pm lib/Collectd/Graph/Data.pm \
244                 && rm -f lib/Collectd/Graph/File.pm lib/Collectd/Graph/Filter.pm \
245                 && rm -f lib/Collectd/Graph/MetaData.pm )
246         dh_installdebconf -a
247         dh_installinit -pcollectd-core --name=collectd -- defaults 95
248         dh_link -a
249         dh_strip -a --dbg-package=collectd-dbg
250         dh_compress -a -Xexamples/
251         dh_fixperms -a
252         dh_makeshlibs -a
253         dh_installdeb -a
254         dh_shlibdeps -a -Ncollectd-core -Ncollectd
255         dpkg-shlibdeps -Tdebian/collectd.substvars \
256                 -dDepends debian/collectd-core/usr/lib/collectd/rrdtool.so
257         dpkg-shlibdeps -Tdebian/collectd-core.substvars \
258                 -dDepends debian/collectd-core/usr/sbin/* \
259                 -dSuggests debian/collectd-core/usr/lib/collectd/*.so
260         grep shlibs:Suggests debian/collectd-core.substvars \
261                 | sed -e 's/shlibs:Suggests/shlibs:Recommends/' \
262                 >> debian/collectd.substvars
263         dh_gencontrol -a
264         dh_md5sums -a
265         dh_builddeb -a
267 binary: binary-arch binary-indep
268 .PHONY: build build-arch build-indep clean binary-indep binary-arch binary install-indep install-arch