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