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 # Work-around an incomplete check for kvm functionality
104 CPPFLAGS += -DHAVE_STRUCT_KINFO_PROC_FREEBSD
105 confflags += --enable-processes=force
107 confflags += \
108 --disable-battery \
109 --disable-conntrack \
110 --disable-contextswitch \
111 --disable-cpufreq \
112 --disable-disk \
113 --disable-entropy \
114 --disable-fscache \
115 --disable-irq \
116 --disable-nfs \
117 --disable-protocols \
118 --disable-serial \
119 --disable-thermal \
120 --disable-vmem \
121 --disable-wireless
122 endif
124 # Build-dependencies of these plugins are (not yet) available for kfreebsd.
125 ifneq (,$(filter kfreebsd-i386 kfreebsd-amd64, $(DEB_BUILD_ARCH)))
126 confflags += \
127 --disable-gmond \
128 --disable-libvirt \
129 --disable-tokyotyrant \
130 --disable-java
131 endif
133 # The hppa buildds currently do not keep up with Java related stuff, thus
134 # prevending testing transitions.
135 ifneq (,$(filter hppa, $(DEB_BUILD_ARCH)))
136 confflags += --disable-java
137 endif
139 config.status: configure $(DPATCH_STAMPFN)
140 dh_testdir
142 ( cd debian/patches/; for patch in *; do \
143 if test "$$patch" != "00list"; then \
144 grep "$$patch" 00list > /dev/null \
145 || ( echo "$$patch not enabled\!"; exit 1 ); \
146 fi; done )
148 # This is a work-around for #474087 (broken openipmi .pc files).
149 mkdir debian/pkgconfig
150 sed -re 's/^(Requires:.*) pthread(.*)$$/\1\2/' \
151 /usr/lib/pkgconfig/OpenIPMIpthread.pc \
152 > debian/pkgconfig/OpenIPMIpthread.pc
154 PKG_CONFIG_PATH="$(CURDIR)/debian/pkgconfig:$$PKG_CONFIG_PATH" \
155 ./configure $(confflags) CPPFLAGS="$(CPPFLAGS)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \
156 JAVAC="$(JAVAC)" JAR="$(JAR)" JAVA_CPPFLAGS="$(JAVA_CPPFLAGS)" \
157 JAVA_LDFLAGS="$(JAVA_LDFLAGS)" \
158 || ( status=$$?; cat config.log; exit $$status )
160 build: build-arch build-indep
161 build-arch: build-stamp
162 build-indep: build-stamp
164 build-stamp: config.status
165 dh_testdir
167 $(MAKE)
168 perl ./debian/bin/check_plugins.pl
170 touch build-stamp
172 clean: unpatch
173 dh_testdir
174 dh_testroot
175 rm -f build-stamp
177 [ ! -f Makefile ] || $(MAKE) distclean
179 rm -f debian/README.Debian.plugins
180 rm -f src/*.1 src/*.5
182 rm -rf debian/pkgconfig
184 dh_clean
185 debconf-updatepo
187 install-indep:
188 dh_testdir
189 dh_testroot
190 dh_clean -k
191 dh_installdirs -i
192 dh_install -i
194 install-arch: build
195 dh_testdir
196 dh_testroot
197 dh_clean -k
198 dh_installdirs -a
200 $(MAKE) install DESTDIR=$(CURDIR)/debian/tmp
202 rm -f debian/tmp/usr/lib/collectd/*.la
203 rm -f debian/tmp/usr/lib/libcollectdclient.la
204 rm -f debian/tmp/etc/collectd.conf
206 dh_install -a --sourcedir=$(CURDIR)/debian/tmp --fail-missing
208 perl ./debian/bin/gen_plugin_deps.pl
210 mkdir -p debian/collectd-core/usr/share/lintian/overrides/
211 cp debian/collectd-core.overrides \
212 debian/collectd-core/usr/share/lintian/overrides/collectd-core
214 binary-indep: install-indep
215 dh_testdir
216 dh_testroot
217 dh_installchangelogs -i ChangeLog
218 dh_installdocs -A -i debian/README.Debian AUTHORS README TODO
219 dh_installexamples -i contrib/examples/myplugin.c \
220 contrib/examples/MyPlugin.pm
221 dh_compress -i -Xexamples/
222 dh_fixperms -i
223 dh_installdeb -i
224 dh_gencontrol -i
225 dh_md5sums -i
226 dh_builddeb -i
228 binary-arch: build install-arch
229 dh_testdir
230 dh_testroot
231 dh_installchangelogs -a ChangeLog
232 dh_installdocs -A -a debian/README.Debian AUTHORS README TODO
233 dh_installdocs -a debian/NEWS.Debian debian/README.Debian.plugins
234 dh_installexamples -a contrib/collectd2html.pl contrib/collection.cgi \
235 contrib/collection3/ contrib/php-collection/ \
236 contrib/exec-munin.conf contrib/exec-munin.px contrib/exec-smartctl \
237 contrib/exec-nagios.conf contrib/exec-nagios.px \
238 contrib/SpamAssassin/ contrib/iptables/ contrib/cussh.pl \
239 contrib/snmp-data.conf contrib/add_rra.sh contrib/network-proxy.py \
240 contrib/collectd_network.py contrib/collectd_unixsock.py \
241 contrib/snmp-probe-host.px contrib/GenericJMX.conf \
242 debian/collectd.conf debian/filters.conf debian/thresholds.conf
243 # some upstream tarballs have been built inside a dirty working dir
244 ( cd debian/collectd-core/ \
245 && cd usr/share/doc/collectd-core/examples/collection3/ \
246 && rm -f bin/foo bin/test_config.px etc/collection4.conf \
247 && rm -f lib/Collectd/Graph.pm lib/Collectd/Graph/Data.pm \
248 && rm -f lib/Collectd/Graph/File.pm lib/Collectd/Graph/Filter.pm \
249 && rm -f lib/Collectd/Graph/MetaData.pm )
250 dh_installdebconf -a
251 dh_installinit -pcollectd-core --name=collectd -- defaults 95
252 dh_link -a
253 dh_strip -a --dbg-package=collectd-dbg
254 dh_compress -a -Xexamples/
255 dh_fixperms -a
256 dh_makeshlibs -a
257 dh_installdeb -a
258 dh_shlibdeps -a -Ncollectd-core -Ncollectd
259 dpkg-shlibdeps -Tdebian/collectd.substvars \
260 -dDepends debian/collectd-core/usr/lib/collectd/rrdtool.so
261 dpkg-shlibdeps -Tdebian/collectd-core.substvars \
262 -dDepends debian/collectd-core/usr/sbin/* \
263 -dSuggests debian/collectd-core/usr/lib/collectd/*.so
264 grep shlibs:Suggests debian/collectd-core.substvars \
265 | sed -e 's/shlibs:Suggests/shlibs:Recommends/' \
266 >> debian/collectd.substvars
267 dh_gencontrol -a
268 dh_md5sums -a
269 dh_builddeb -a
271 binary: binary-arch binary-indep
272 .PHONY: build build-arch build-indep clean binary-indep binary-arch binary install-indep install-arch