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 # 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 # A PostgreSQL header redefines CACHE_LINE_SIZE on FreeBSD.
34 # Cf. https://bugs.debian.org/760719 and https://bugs.debian.org/763098
35 ifneq (,$(filter kfreebsd-i386 kfreebsd-amd64, $(DEB_BUILD_ARCH)))
36 CPPFLAGS += -Wp,-w
37 endif
39 LDFLAGS = $(shell dpkg-buildflags --get LDFLAGS)
41 # The archdir map has been copied from openjdk-6's debian/rules.
42 JAVA_ARCHDIR = $(shell /usr/share/javahelper/java-arch.sh $(DEB_BUILD_ARCH))
43 ifeq (,$(JAVA_ARCHDIR))
44 JAVA_ARCHDIR = $(DEB_BUILD_ARCH)
45 endif
46 JAVA_HOME = /usr/lib/jvm/default-java
47 JAVA_LIBDIR = $(JAVA_HOME)/jre/lib/$(JAVA_ARCHDIR)/server
49 JAVAC = $(JAVA_HOME)/bin/javac
50 JAR = $(JAVA_HOME)/bin/jar
51 JAVA_CPPFLAGS = -I$(JAVA_HOME)/include
52 JAVA_LDFLAGS = -L$(JAVA_LIBDIR) -Wl,-rpath -Wl,$(JAVA_LIBDIR)
54 confflags = --host=$(DEB_HOST_GNU_TYPE) \
55 --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr \
56 --mandir=\$${prefix}/share/man \
57 --localstatedir=/var --sysconfdir=/etc \
58 --with-perl-bindings="INSTALLDIRS=vendor INSTALL_BASE=" \
59 --without-libstatgrab \
60 --without-included-ltdl \
61 --disable-static \
62 --enable-all-plugins
64 # These plugins do not provide any functionality under Linux.
65 # MacOS only (requires IO Kit):
66 confflags += --disable-apple_sensors
67 # AIX only (requires perfstat):
68 confflags += --disable-lpar
69 # Solaris only (requires devinfo and kstat)
70 confflags += --disable-tape
72 # libaquaero5 is required for the aquaero plugin
73 confflags += --disable-aquaero
75 # libmic is required for the mic plugin
76 confflags += --disable-mic
78 # libnetapp is required for the netapp plugin.
79 confflags += --disable-netapp
81 # libclntsh is required for the oracle plugin.
82 confflags += --disable-oracle
84 # librouteros is required for the routeros plugin.
85 confflags += --disable-routeros
87 # libmongoc is required for the write_mongodb plugin.
88 confflags += --disable-write_mongodb
90 # xmms1 is required for the xmms plugin.
91 confflags += --disable-xmms
93 # These plugins are Linux-specific.
94 ifneq (,$(filter kfreebsd-i386 kfreebsd-amd64, $(DEB_BUILD_ARCH)))
95 confflags += \
96 --disable-cgroups \
97 --disable-ethstat \
98 --disable-iptables \
99 --disable-ipvs \
100 --disable-lvm \
101 --disable-madwifi \
102 --disable-md \
103 --disable-netlink \
104 --disable-numa \
105 --disable-sensors \
106 --disable-vserver
107 endif
109 # This plugin is FreeBSD-specific.
110 ifeq (,$(filter kfreebsd-i386 kfreebsd-amd64, $(DEB_BUILD_ARCH)))
111 confflags += \
112 --disable-pf
113 endif
115 # These plugins have not been ported to FreeBSD yet.
116 ifneq (,$(filter kfreebsd-i386 kfreebsd-amd64, $(DEB_BUILD_ARCH)))
117 # Work-around an incomplete check for kvm functionality
118 CPPFLAGS += -DHAVE_STRUCT_KINFO_PROC_FREEBSD
119 confflags += --enable-processes=force
121 confflags += \
122 --disable-battery \
123 --disable-conntrack \
124 --disable-contextswitch \
125 --disable-cpufreq \
126 --disable-disk \
127 --disable-entropy \
128 --disable-fscache \
129 --disable-irq \
130 --disable-nfs \
131 --disable-protocols \
132 --disable-serial \
133 --disable-thermal \
134 --disable-vmem \
135 --disable-wireless
136 endif
138 # Build-dependencies of these plugins are (not yet) available for kfreebsd.
139 ifneq (,$(filter kfreebsd-i386 kfreebsd-amd64, $(DEB_BUILD_ARCH)))
140 confflags += \
141 --disable-gmond \
142 --disable-virt \
143 --disable-tokyotyrant \
144 --disable-java
145 endif
147 # The hppa buildds currently do not keep up with Java related stuff, thus
148 # prevending testing transitions. sparc is also having trouble building the
149 # java plugin.
150 ifneq (,$(filter hppa sparc, $(DEB_BUILD_ARCH)))
151 confflags += --disable-java
152 endif
154 config.status: configure
155 dh_testdir
157 # This is a work-around for #474087 (broken openipmi .pc files).
158 mkdir debian/pkgconfig
159 sed -re 's/^(Requires:.*) pthread(.*)$$/\1\2/' \
160 /usr/lib/pkgconfig/OpenIPMIpthread.pc \
161 > debian/pkgconfig/OpenIPMIpthread.pc
163 PKG_CONFIG_PATH="$(CURDIR)/debian/pkgconfig:$$PKG_CONFIG_PATH" \
164 ./configure $(confflags) CPPFLAGS="$(CPPFLAGS)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \
165 JAVAC="$(JAVAC)" JAR="$(JAR)" JAVA_CPPFLAGS="$(JAVA_CPPFLAGS)" \
166 JAVA_LDFLAGS="$(JAVA_LDFLAGS)" \
167 || ( status=$$?; cat config.log; exit $$status )
169 build: build-arch build-indep
170 build-arch: build-stamp
171 build-indep: build-stamp
173 build-stamp: config.status
174 dh_testdir
176 $(MAKE)
177 perl ./debian/bin/check_plugins.pl
179 touch build-stamp
181 clean:
182 dh_testdir
183 dh_testroot
184 rm -f build-stamp
186 [ ! -f Makefile ] || $(MAKE) distclean
188 rm -f debian/README.Debian.plugins
189 rm -f src/*.1 src/*.5
191 rm -rf debian/pkgconfig
193 dh_clean
194 debconf-updatepo
196 install-indep:
197 dh_testdir
198 dh_testroot
199 dh_clean -k
200 dh_installdirs -i
201 dh_install -i
203 # update include path for collectd header files
204 ( set -e; \
205 cd $(CURDIR)/debian/collectd-dev/usr/include/collectd/; \
206 for lib in $$(find . -type f -name '*.h'); do \
207 libname=$$(basename $$lib); \
208 fullpath=$$(echo $$lib | sed -r -e 's,^\./,collectd/,'); \
209 for dir in $$(find . -mindepth 1 -type d); do \
210 sed -r -i -e "s,(include\s+)\".*$$libname\",\1\"$$fullpath\"," $$dir/*.h; \
211 done; \
212 done )
214 install-arch: build
215 dh_testdir
216 dh_testroot
217 dh_clean -k
218 dh_installdirs -a
220 $(MAKE) install DESTDIR=$(CURDIR)/debian/tmp
222 rm -f debian/tmp/usr/lib/collectd/*.la
223 rm -f debian/tmp/usr/lib/libcollectdclient.la
224 rm -f debian/tmp/etc/collectd.conf
226 dh_install -a --sourcedir=$(CURDIR)/debian/tmp --fail-missing
228 perl ./debian/bin/gen_plugin_deps.pl
230 mkdir -p debian/collectd-core/usr/share/lintian/overrides/
231 cp debian/collectd-core.overrides \
232 debian/collectd-core/usr/share/lintian/overrides/collectd-core
234 binary-indep: install-indep
235 dh_testdir
236 dh_testroot
237 dh_installchangelogs -i ChangeLog
238 dh_installdocs -A -i debian/README.Debian AUTHORS README TODO
239 dh_installexamples -i contrib/examples/myplugin.c \
240 contrib/examples/MyPlugin.pm
241 dh_compress -i -Xexamples/
242 dh_fixperms -i
243 dh_installdeb -i
244 dh_gencontrol -i
245 dh_md5sums -i
246 dh_builddeb -i
248 binary-arch: build install-arch
249 dh_testdir
250 dh_testroot
251 dh_installchangelogs -a ChangeLog
252 dh_installdocs -A -a debian/README.Debian AUTHORS README TODO
253 dh_installdocs -a debian/NEWS.Debian debian/README.Debian.plugins
254 dh_installexamples -a contrib/collectd2html.pl contrib/collection.cgi \
255 contrib/collection3/ contrib/php-collection/ \
256 contrib/exec-munin.conf contrib/exec-munin.px contrib/exec-smartctl \
257 contrib/exec-nagios.conf contrib/exec-nagios.px contrib/exec-ksm.sh \
258 contrib/SpamAssassin/ contrib/iptables/ contrib/cussh.pl \
259 contrib/snmp-data.conf contrib/add_rra.sh contrib/network-proxy.py \
260 contrib/collectd_network.py contrib/collectd_unixsock.py \
261 contrib/snmp-probe-host.px contrib/GenericJMX.conf \
262 contrib/postgresql \
263 debian/collectd.conf debian/filters.conf debian/thresholds.conf
264 # some upstream tarballs have been built inside a dirty working dir
265 ( cd debian/collectd-core/ \
266 && cd usr/share/doc/collectd-core/examples/collection3/ \
267 && rm -f bin/foo bin/test_config.px etc/collection4.conf \
268 && rm -f lib/Collectd/Graph.pm lib/Collectd/Graph/Data.pm \
269 && rm -f lib/Collectd/Graph/File.pm lib/Collectd/Graph/Filter.pm \
270 && rm -f lib/Collectd/Graph/MetaData.pm )
271 dh_installdebconf -a
272 dh_systemd_enable -pcollectd-core --name=collectd collectd.service
273 dh_installinit -pcollectd-core --name=collectd -- defaults 95
274 dh_systemd_start
275 dh_link -a
276 dh_strip -a --dbg-package=collectd-dbg
277 dh_compress -a -Xexamples/
278 dh_fixperms -a
279 dh_makeshlibs -a
280 dh_installdeb -a
281 dh_shlibdeps -a -Ncollectd-core -Ncollectd
282 dpkg-shlibdeps -Tdebian/collectd.substvars \
283 -dDepends debian/collectd-core/usr/lib/collectd/rrdtool.so
284 dpkg-shlibdeps -Tdebian/collectd-core.substvars \
285 -dDepends debian/collectd-core/usr/sbin/* \
286 -dSuggests debian/collectd-core/usr/lib/collectd/*.so
287 grep shlibs:Suggests debian/collectd-core.substvars \
288 | sed -e 's/shlibs:Suggests/shlibs:Recommends/' \
289 >> debian/collectd.substvars
290 dh_gencontrol -a
291 dh_md5sums -a
292 dh_builddeb -a
294 binary: binary-arch binary-indep
295 .PHONY: build build-arch build-indep clean binary-indep binary-arch binary install-indep install-arch