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 -Wno-error=deprecated-declarations
22 # Upstream defaults to ${sysconfdir}/collectd.conf. Setting ${sysconfdir} to
23 # /etc/collectd would be wrong though.
24 CPPFLAGS += -UCONFIGFILE
25 CPPFLAGS += -DCONFIGFILE='\"/etc/collectd/collectd.conf\"'
27 # A PostgreSQL header redefines CACHE_LINE_SIZE on FreeBSD.
28 # Cf. https://bugs.debian.org/760719 and https://bugs.debian.org/763098
29 ifneq (,$(filter kfreebsd-i386 kfreebsd-amd64, $(DEB_BUILD_ARCH)))
30 CPPFLAGS += -Wp,-w
31 endif
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/default-java
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 confflags = --host=$(DEB_HOST_GNU_TYPE) \
49 --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr \
50 --mandir=\$${prefix}/share/man \
51 --localstatedir=/var --sysconfdir=/etc \
52 --with-perl-bindings="INSTALLDIRS=vendor INSTALL_BASE=" \
53 --without-libstatgrab \
54 --without-included-ltdl \
55 --disable-static \
56 --disable-silent-rules \
57 --enable-all-plugins
59 # These plugins do not provide any functionality under Linux.
60 # MacOS only (requires IO Kit):
61 confflags += --disable-apple_sensors
62 # AIX only (requires perfstat):
63 confflags += --disable-lpar
64 # Solaris only (requires devinfo and kstat)
65 confflags += --disable-tape
67 # libaquaero5 is required for the aquaero plugin
68 confflags += --disable-aquaero
70 # libmic is required for the mic plugin
71 confflags += --disable-mic
73 # libnetapp is required for the netapp plugin.
74 confflags += --disable-netapp
76 # libclntsh is required for the oracle plugin.
77 confflags += --disable-oracle
79 # librouteros is required for the routeros plugin.
80 confflags += --disable-routeros
82 # libsigrok >= 0.2.0 is required for the sigrok plugin
83 confflags += --disable-sigrok
85 # linux-libc-dev >= 3.13 is required for the turbostat plugin.
86 confflags += --disable-turbostat
88 # libmongoc is required for the write_mongodb plugin.
89 confflags += --disable-write_mongodb
91 # librdkafka is required for the write_kafka plugin.
92 confflags += --disable-write_kafka
94 # xmms1 is required for the xmms plugin.
95 confflags += --disable-xmms
97 # These plugins are Linux-specific.
98 ifneq (,$(filter kfreebsd-i386 kfreebsd-amd64, $(DEB_BUILD_ARCH)))
99 confflags += \
100 --disable-cgroups \
101 --disable-ethstat \
102 --disable-iptables \
103 --disable-ipvs \
104 --disable-lvm \
105 --disable-madwifi \
106 --disable-md \
107 --disable-netlink \
108 --disable-numa \
109 --disable-sensors \
110 --disable-vserver
111 endif
113 # This plugin is FreeBSD-specific.
114 ifeq (,$(filter kfreebsd-i386 kfreebsd-amd64, $(DEB_BUILD_ARCH)))
115 confflags += \
116 --disable-pf
117 endif
119 # These plugins have not been ported to FreeBSD yet.
120 ifneq (,$(filter kfreebsd-i386 kfreebsd-amd64, $(DEB_BUILD_ARCH)))
121 # Work-around an incomplete check for kvm functionality
122 CPPFLAGS += -DHAVE_STRUCT_KINFO_PROC_FREEBSD
123 confflags += --enable-processes=force
125 confflags += \
126 --disable-battery \
127 --disable-conntrack \
128 --disable-contextswitch \
129 --disable-cpufreq \
130 --disable-disk \
131 --disable-entropy \
132 --disable-fscache \
133 --disable-irq \
134 --disable-nfs \
135 --disable-protocols \
136 --disable-serial \
137 --disable-thermal \
138 --disable-vmem \
139 --disable-wireless
140 endif
142 # Build-dependencies of these plugins are (not yet) available for kfreebsd.
143 ifneq (,$(filter kfreebsd-i386 kfreebsd-amd64, $(DEB_BUILD_ARCH)))
144 confflags += \
145 --disable-gmond \
146 --disable-virt \
147 --disable-tokyotyrant \
148 --disable-java
149 endif
151 # This plugin is Intel-hardware specific.
152 ifeq (,$(filter amd64 i386, $(DEB_BUILD_ARCH)))
153 confflags += \
154 --disable-turbostat
155 endif
157 # libatasmart isn't available on these platforms.
158 ifneq (,$(filter hurd-i386 kfreebsd-i386 kfreebsd-amd64, $(DEB_BUILD_ARCH)))
159 confflags += --disable-smart
160 endif
162 # The hppa buildds currently do not keep up with Java related stuff, thus
163 # prevending testing transitions. sparc is also having trouble building the
164 # java plugin.
165 ifneq (,$(filter hppa sparc, $(DEB_BUILD_ARCH)))
166 confflags += --disable-java
167 endif
169 config.status: configure
170 dh_testdir
172 # This is a work-around for #474087 (broken openipmi .pc files).
173 mkdir debian/pkgconfig
174 sed -re 's/^(Requires:.*) pthread(.*)$$/\1\2/' \
175 /usr/lib/pkgconfig/OpenIPMIpthread.pc \
176 > debian/pkgconfig/OpenIPMIpthread.pc
178 PKG_CONFIG_PATH="$(CURDIR)/debian/pkgconfig:$$PKG_CONFIG_PATH" \
179 ./configure $(confflags) CPPFLAGS="$(CPPFLAGS)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \
180 JAVAC="$(JAVAC)" JAR="$(JAR)" JAVA_CPPFLAGS="$(JAVA_CPPFLAGS)" \
181 JAVA_LDFLAGS="$(JAVA_LDFLAGS)" \
182 || ( status=$$?; cat config.log; exit $$status )
184 build: build-arch build-indep
185 build-arch: build-stamp
186 build-indep: build-stamp
188 build-stamp: config.status
189 dh_testdir
191 $(MAKE)
192 perl ./debian/bin/check_plugins.pl
194 touch build-stamp
196 clean:
197 dh_testdir
198 dh_testroot
199 rm -f build-stamp
201 [ ! -f Makefile ] || $(MAKE) distclean
203 rm -f debian/README.Debian.plugins
204 rm -f src/*.1 src/*.5
206 rm -rf debian/pkgconfig
208 dh_clean
209 debconf-updatepo
211 install-indep:
212 dh_testdir
213 dh_testroot
214 dh_prep
215 dh_installdirs -i
216 dh_install -i
218 # update include path for collectd header files
219 ( set -e; \
220 cd $(CURDIR)/debian/collectd-dev/usr/include/collectd/; \
221 for lib in $$(find . -type f -name '*.h'); do \
222 libname=$$(basename $$lib); \
223 fullpath=$$(echo $$lib | sed -r -e 's,^\./,collectd/,'); \
224 for dir in $$(find . -mindepth 1 -type d); do \
225 sed -r -i -e "s,(include\s+)\".*$$libname\",\1\"$$fullpath\"," $$dir/*.h; \
226 done; \
227 done )
229 install-arch: build
230 dh_testdir
231 dh_testroot
232 dh_prep
233 dh_installdirs -a
235 $(MAKE) install DESTDIR=$(CURDIR)/debian/tmp
237 rm -f debian/tmp/usr/lib/collectd/*.la
238 rm -f debian/tmp/usr/lib/libcollectdclient.la
239 rm -f debian/tmp/etc/collectd.conf
241 dh_install -a --sourcedir=$(CURDIR)/debian/tmp --fail-missing
243 perl ./debian/bin/gen_plugin_deps.pl
245 mkdir -p debian/collectd-core/usr/share/lintian/overrides/
246 cp debian/collectd-core.overrides \
247 debian/collectd-core/usr/share/lintian/overrides/collectd-core
249 binary-indep: install-indep
250 dh_testdir
251 dh_testroot
252 dh_installchangelogs -i ChangeLog
253 dh_installdocs -A -i debian/README.Debian AUTHORS README TODO
254 dh_installexamples -i contrib/examples/myplugin.c \
255 contrib/examples/MyPlugin.pm
256 dh_compress -i -Xexamples/
257 dh_fixperms -i
258 dh_installdeb -i
259 dh_gencontrol -i
260 dh_md5sums -i
261 dh_builddeb -i
263 binary-arch: build install-arch
264 dh_testdir
265 dh_testroot
266 dh_installchangelogs -a ChangeLog
267 dh_installdocs -A -a debian/README.Debian AUTHORS README TODO
268 dh_installdocs -a debian/NEWS.Debian debian/README.Debian.plugins
269 dh_installexamples -a contrib/collectd2html.pl contrib/collection.cgi \
270 contrib/collection3/ contrib/php-collection/ \
271 contrib/exec-munin.conf contrib/exec-munin.px contrib/exec-smartctl \
272 contrib/exec-nagios.conf contrib/exec-nagios.px contrib/exec-ksm.sh \
273 contrib/SpamAssassin/ contrib/iptables/ contrib/cussh.pl \
274 contrib/snmp-data.conf contrib/add_rra.sh contrib/network-proxy.py \
275 contrib/collectd_network.py contrib/collectd_unixsock.py \
276 contrib/snmp-probe-host.px contrib/GenericJMX.conf \
277 contrib/postgresql \
278 debian/collectd.conf debian/filters.conf debian/thresholds.conf
279 # some upstream tarballs have been built inside a dirty working dir
280 ( cd debian/collectd-core/ \
281 && cd usr/share/doc/collectd-core/examples/collection3/ \
282 && rm -f bin/foo bin/test_config.px etc/collection4.conf \
283 && rm -f lib/Collectd/Graph.pm lib/Collectd/Graph/Data.pm \
284 && rm -f lib/Collectd/Graph/File.pm lib/Collectd/Graph/Filter.pm \
285 && rm -f lib/Collectd/Graph/MetaData.pm )
286 dh_installdebconf -a
287 dh_installinit -pcollectd-core --name=collectd -- defaults 95
288 dh_link -a
289 dh_strip -a --dbg-package=collectd-dbg
290 dh_compress -a -Xexamples/
291 dh_fixperms -a
292 dh_makeshlibs -a
293 dh_installdeb -a
294 dh_shlibdeps -a -Ncollectd-core -Ncollectd
295 dpkg-shlibdeps -Tdebian/collectd.substvars \
296 -dDepends debian/collectd-core/usr/lib/collectd/rrdtool.so
297 dpkg-shlibdeps -Tdebian/collectd-core.substvars \
298 -dDepends debian/collectd-core/usr/sbin/* \
299 -dSuggests debian/collectd-core/usr/lib/collectd/*.so
300 grep shlibs:Suggests debian/collectd-core.substvars \
301 | sed -e 's/shlibs:Suggests/shlibs:Recommends/' \
302 >> debian/collectd.substvars
303 dh_gencontrol -a
304 dh_md5sums -a
305 dh_builddeb -a
307 binary: binary-arch binary-indep
308 .PHONY: build build-arch build-indep clean binary-indep binary-arch binary install-indep install-arch