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 # protobuf-compiler >= 3.0.0 and libgrpc++ are required for the grpc plugin.
98 confflags += --disable-grpc
100 # libqpos is required for the intel_rdt plugin.
101 confflags += --disable-intel_rdt
103 # These plugins are Linux-specific.
104 ifneq (,$(filter kfreebsd-i386 kfreebsd-amd64, $(DEB_BUILD_ARCH)))
105 confflags += \
106 --disable-barometer \
107 --disable-cgroups \
108 --disable-cpusleep \
109 --disable-drbd \
110 --disable-ethstat \
111 --disable-fhcount \
112 --disable-hugepages \
113 --disable-ipc \
114 --disable-iptables \
115 --disable-ipvs \
116 --disable-lvm \
117 --disable-madwifi \
118 --disable-md \
119 --disable-netlink \
120 --disable-numa \
121 --disable-sensors \
122 --disable-vserver
123 # libsigrok >= 0.2.0 is required for the sigrok plugin,
124 # only available on Linux.
125 confflags += \
126 --disable-sigrok
127 endif
129 # This plugin is FreeBSD-specific.
130 ifeq (,$(filter kfreebsd-i386 kfreebsd-amd64, $(DEB_BUILD_ARCH)))
131 confflags += \
132 --disable-pf
133 endif
135 # This plugin is Solaris-specific.
136 confflags += \
137 --disable-zone
139 # These plugins have not been ported to FreeBSD yet.
140 ifneq (,$(filter kfreebsd-i386 kfreebsd-amd64, $(DEB_BUILD_ARCH)))
141 # Work-around an incomplete check for kvm functionality
142 CPPFLAGS += -DHAVE_STRUCT_KINFO_PROC_FREEBSD
143 confflags += --enable-processes=force
145 confflags += \
146 --disable-battery \
147 --disable-conntrack \
148 --disable-contextswitch \
149 --disable-cpufreq \
150 --disable-entropy \
151 --disable-fscache \
152 --disable-irq \
153 --disable-nfs \
154 --disable-protocols \
155 --disable-serial \
156 --disable-thermal \
157 --disable-vmem \
158 --disable-wireless
159 endif
161 # Build-dependencies of these plugins are (not yet) available for kfreebsd.
162 ifneq (,$(filter kfreebsd-i386 kfreebsd-amd64, $(DEB_BUILD_ARCH)))
163 confflags += \
164 --disable-gmond \
165 --disable-virt \
166 --disable-tokyotyrant \
167 --disable-java
168 endif
170 # These plugins are Intel-hardware specific.
171 ifeq (,$(filter amd64 i386, $(DEB_BUILD_ARCH)))
172 confflags += \
173 --disable-dpdkstat \
174 --disable-turbostat
175 endif
177 # This plugin is x86 and arm specific.
178 ifeq (,$(filter amd64 arm64 armhf i386, $(DEB_BUILD_ARCH)))
179 confflags += \
180 --disable-xencpu
181 endif
183 # libatasmart isn't available on these platforms.
184 ifneq (,$(filter hurd-i386 kfreebsd-i386 kfreebsd-amd64, $(DEB_BUILD_ARCH)))
185 confflags += --disable-smart
186 endif
188 # The hppa buildds currently do not keep up with Java related stuff, thus
189 # prevending testing transitions. sparc is also having trouble building the
190 # java plugin.
191 ifneq (,$(filter hppa sparc, $(DEB_BUILD_ARCH)))
192 confflags += --disable-java
193 endif
195 build: build-arch build-indep
196 build-arch: build-stamp
197 build-indep: build-stamp
199 build-stamp:
200 dh_testdir
202 dh_autoreconf
204 # This is a work-around for #474087 (broken openipmi .pc files).
205 mkdir debian/pkgconfig
206 sed -re 's/^(Requires:.*) pthread(.*)$$/\1\2/' \
207 /usr/lib/pkgconfig/OpenIPMIpthread.pc \
208 > debian/pkgconfig/OpenIPMIpthread.pc
210 PKG_CONFIG_PATH="$(CURDIR)/debian/pkgconfig:$$PKG_CONFIG_PATH" \
211 ./configure $(confflags) CPPFLAGS="$(CPPFLAGS)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \
212 JAVAC="$(JAVAC)" JAR="$(JAR)" JAVA_CPPFLAGS="$(JAVA_CPPFLAGS)" \
213 JAVA_LDFLAGS="$(JAVA_LDFLAGS)" \
214 || ( status=$$?; cat config.log; exit $$status )
216 $(MAKE)
217 dh_auto_test
218 perl ./debian/bin/check_plugins.pl
220 touch build-stamp
222 clean:
223 dh_testdir
224 dh_testroot
225 rm -f build-stamp
227 [ ! -f Makefile ] || $(MAKE) distclean
229 rm -f debian/README.Debian.plugins
230 rm -f src/*.1 src/*.5
232 rm -rf debian/pkgconfig
234 dh_autoreconf_clean
235 dh_clean
236 debconf-updatepo
238 install-indep:
239 dh_testdir
240 dh_testroot
241 dh_prep
242 dh_installdirs -i
243 dh_install -i
245 # update include path for collectd header files
246 ( set -e; \
247 cd $(CURDIR)/debian/collectd-dev/usr/include/collectd/; \
248 for lib in $$(find . -type f -name '*.h'); do \
249 libname=$$(basename $$lib); \
250 fullpath=$$(echo $$lib | sed -r -e 's,^\./,collectd/,'); \
251 for dir in $$(find . -mindepth 1 -type d); do \
252 sed -r -i -e "s,(include\s+)\".*\<$$libname\",\1\"$$fullpath\"," $$dir/*.h; \
253 done; \
254 done )
256 install-arch: build
257 dh_testdir
258 dh_testroot
259 dh_prep
260 dh_installdirs -a
262 $(MAKE) install DESTDIR=$(CURDIR)/debian/tmp
264 rm -f debian/tmp/usr/lib/collectd/*.la
265 rm -f debian/tmp/usr/lib/libcollectdclient.la
266 rm -f debian/tmp/etc/collectd.conf
268 dh_install -a --sourcedir=$(CURDIR)/debian/tmp --fail-missing
270 perl ./debian/bin/gen_plugin_deps.pl
272 mkdir -p debian/collectd-core/usr/share/lintian/overrides/
273 cp debian/collectd-core.overrides \
274 debian/collectd-core/usr/share/lintian/overrides/collectd-core
276 binary-indep: install-indep
277 dh_testdir
278 dh_testroot
279 dh_installchangelogs -i ChangeLog
280 dh_installdocs -A -i debian/README.Debian AUTHORS README
281 dh_installexamples -i contrib/examples/myplugin.c \
282 contrib/examples/MyPlugin.pm
283 dh_compress -i -Xexamples/
284 dh_fixperms -i
285 dh_installdeb -i
286 dh_gencontrol -i
287 dh_md5sums -i
288 dh_builddeb -i
290 binary-arch: build install-arch
291 dh_testdir
292 dh_testroot
293 dh_installchangelogs -a ChangeLog
294 dh_installdocs -A -a debian/README.Debian AUTHORS README
295 dh_installdocs -a debian/NEWS.Debian debian/README.Debian.plugins
296 dh_installexamples -a contrib/collectd2html.pl contrib/collection.cgi \
297 contrib/collection3/ contrib/php-collection/ \
298 contrib/exec-munin.conf contrib/exec-munin.px contrib/exec-smartctl \
299 contrib/exec-nagios.conf contrib/exec-nagios.px contrib/exec-ksm.sh \
300 contrib/SpamAssassin/ contrib/iptables/ contrib/cussh.pl \
301 contrib/snmp-data.conf contrib/add_rra.sh contrib/network-proxy.py \
302 contrib/collectd_network.py contrib/collectd_unixsock.py \
303 contrib/snmp-probe-host.px contrib/GenericJMX.conf \
304 contrib/postgresql \
305 debian/collectd.conf debian/filters.conf debian/thresholds.conf
306 # some upstream tarballs have been built inside a dirty working dir
307 ( cd debian/collectd-core/ \
308 && cd usr/share/doc/collectd-core/examples/collection3/ \
309 && rm -f bin/foo bin/test_config.px etc/collection4.conf \
310 && rm -f lib/Collectd/Graph.pm lib/Collectd/Graph/Data.pm \
311 && rm -f lib/Collectd/Graph/File.pm lib/Collectd/Graph/Filter.pm \
312 && rm -f lib/Collectd/Graph/MetaData.pm )
313 dh_installdebconf -a
314 dh_installinit -pcollectd-core --name=collectd -- defaults 95
315 dh_link -a
316 dh_strip -a --dbg-package=collectd-dbg
317 dh_compress -a -Xexamples/
318 dh_fixperms -a
319 dh_makeshlibs -a
320 dh_installdeb -a
321 dh_shlibdeps -a -Ncollectd-core -Ncollectd
322 dpkg-shlibdeps -Tdebian/collectd.substvars \
323 -dDepends debian/collectd-core/usr/lib/collectd/rrdtool.so
324 dpkg-shlibdeps -Tdebian/collectd-core.substvars \
325 -dDepends debian/collectd-core/usr/sbin/* \
326 -dSuggests debian/collectd-core/usr/lib/collectd/*.so
327 grep shlibs:Suggests debian/collectd-core.substvars \
328 | sed -e 's/shlibs:Suggests/shlibs:Recommends/' \
329 >> debian/collectd.substvars
330 dh_gencontrol -a
331 dh_md5sums -a
332 dh_builddeb -a
334 binary: binary-arch binary-indep
335 .PHONY: build build-arch build-indep clean binary-indep binary-arch binary install-indep install-arch