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