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