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
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 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/java-6-openjdk-$(DEB_BUILD_ARCH)
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 include /usr/share/dpatch/dpatch.make
50 confflags = --host=$(DEB_HOST_GNU_TYPE) \
51 --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr \
52 --mandir=\$${prefix}/share/man \
53 --localstatedir=/var --sysconfdir=/etc \
54 --with-perl-bindings="INSTALLDIRS=vendor" \
55 --without-libstatgrab \
56 --without-included-ltdl \
57 --disable-static \
58 --enable-all-plugins
60 # These plugins do not provide any functionality under Linux.
61 # MacOS only (requires IO Kit):
62 confflags += --disable-apple_sensors
63 # AIX only (requires perfstat):
64 confflags += --disable-lpar
65 # Solaris only (requires devinfo and kstat)
66 confflags += --disable-tape
68 # libmodbus is required for the modbus plugin.
69 confflags += --disable-modbus
71 # libnetapp is required for the netapp plugin.
72 confflags += --disable-netapp
74 # libowcapi is required for the onewire plugin.
75 confflags += --disable-onewire
77 # libclntsh is required for the oracle plugin.
78 confflags += --disable-oracle
80 # libcredis is required for the *redis plugins.
81 confflags += --disable-redis --disable-write_redis
83 # librouteros is required for the routeros plugin.
84 confflags += --disable-routeros
86 # libmongoc is required for the write_mongodb plugin.
87 confflags += --disable-write_mongodb
89 # xmms1 is required for the xmms plugin.
90 confflags += --disable-xmms
92 # libkstat is required for the xfs_arc plugin.
93 confflags += --disable-zfs-arc
95 # The static library netstat cannot be linked into shared objects on some
96 # architectures (see bugs #358637, #419684 and #524593 for more details).
97 ifneq (,$(filter alpha amd64 hppa ia64 ppc64 mips mipsel, $(DEB_BUILD_ARCH)))
98 confflags += --disable-netlink
99 endif
101 # These plugins are Linux-specific.
102 ifneq (,$(filter kfreebsd-i386 kfreebsd-amd64, $(DEB_BUILD_ARCH)))
103 confflags += \
104 --disable-ethstat \
105 --disable-iptables \
106 --disable-ipvs \
107 --disable-madwifi \
108 --disable-md \
109 --disable-netlink \
110 --disable-numa \
111 --disable-sensors \
112 --disable-vserver
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-libvirt \
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.
149 ifneq (,$(filter hppa, $(DEB_BUILD_ARCH)))
150 confflags += --disable-java
151 endif
153 config.status: configure $(DPATCH_STAMPFN)
154 dh_testdir
156 ( cd debian/patches/; for patch in *; do \
157 if test "$$patch" != "00list"; then \
158 grep "$$patch" 00list > /dev/null \
159 || ( echo "$$patch not enabled\!"; exit 1 ); \
160 fi; done )
162 # This is a work-around for #474087 (broken openipmi .pc files).
163 mkdir debian/pkgconfig
164 sed -re 's/^(Requires:.*) pthread(.*)$$/\1\2/' \
165 /usr/lib/pkgconfig/OpenIPMIpthread.pc \
166 > debian/pkgconfig/OpenIPMIpthread.pc
168 PKG_CONFIG_PATH="$(CURDIR)/debian/pkgconfig:$$PKG_CONFIG_PATH" \
169 ./configure $(confflags) CPPFLAGS="$(CPPFLAGS)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \
170 JAVAC="$(JAVAC)" JAR="$(JAR)" JAVA_CPPFLAGS="$(JAVA_CPPFLAGS)" \
171 JAVA_LDFLAGS="$(JAVA_LDFLAGS)" \
172 || ( status=$$?; cat config.log; exit $$status )
174 build: build-arch build-indep
175 build-arch: build-stamp
176 build-indep: build-stamp
178 build-stamp: config.status
179 dh_testdir
181 $(MAKE)
182 perl ./debian/bin/check_plugins.pl
184 touch build-stamp
186 clean: unpatch
187 dh_testdir
188 dh_testroot
189 rm -f build-stamp
191 [ ! -f Makefile ] || $(MAKE) distclean
193 rm -f debian/README.Debian.plugins
194 rm -f src/*.1 src/*.5
196 rm -rf debian/pkgconfig
198 dh_clean
199 debconf-updatepo
201 install-indep:
202 dh_testdir
203 dh_testroot
204 dh_clean -k
205 dh_installdirs -i
206 dh_install -i
208 install-arch: build
209 dh_testdir
210 dh_testroot
211 dh_clean -k
212 dh_installdirs -a
214 $(MAKE) install DESTDIR=$(CURDIR)/debian/tmp
216 rm -f debian/tmp/usr/lib/collectd/*.la
217 rm -f debian/tmp/usr/lib/libcollectdclient.la
218 rm -f debian/tmp/etc/collectd.conf
220 dh_install -a --sourcedir=$(CURDIR)/debian/tmp --fail-missing
222 perl ./debian/bin/gen_plugin_deps.pl
224 mkdir -p debian/collectd-core/usr/share/lintian/overrides/
225 cp debian/collectd-core.overrides \
226 debian/collectd-core/usr/share/lintian/overrides/collectd-core
228 binary-indep: install-indep
229 dh_testdir
230 dh_testroot
231 dh_installchangelogs -i ChangeLog
232 dh_installdocs -A -i debian/README.Debian AUTHORS README TODO
233 dh_installexamples -i contrib/examples/myplugin.c \
234 contrib/examples/MyPlugin.pm
235 dh_compress -i -Xexamples/
236 dh_fixperms -i
237 dh_installdeb -i
238 dh_gencontrol -i
239 dh_md5sums -i
240 dh_builddeb -i
242 binary-arch: build install-arch
243 dh_testdir
244 dh_testroot
245 dh_installchangelogs -a ChangeLog
246 dh_installdocs -A -a debian/README.Debian AUTHORS README TODO
247 dh_installdocs -a debian/NEWS.Debian debian/README.Debian.plugins
248 dh_installexamples -a contrib/collectd2html.pl contrib/collection.cgi \
249 contrib/collection3/ contrib/php-collection/ \
250 contrib/exec-munin.conf contrib/exec-munin.px contrib/exec-smartctl \
251 contrib/exec-nagios.conf contrib/exec-nagios.px contrib/exec-ksm.sh \
252 contrib/SpamAssassin/ contrib/iptables/ contrib/cussh.pl \
253 contrib/snmp-data.conf contrib/add_rra.sh contrib/network-proxy.py \
254 contrib/collectd_network.py contrib/collectd_unixsock.py \
255 contrib/snmp-probe-host.px contrib/GenericJMX.conf \
256 debian/collectd.conf debian/filters.conf debian/thresholds.conf
257 # some upstream tarballs have been built inside a dirty working dir
258 ( cd debian/collectd-core/ \
259 && cd usr/share/doc/collectd-core/examples/collection3/ \
260 && rm -f bin/foo bin/test_config.px etc/collection4.conf \
261 && rm -f lib/Collectd/Graph.pm lib/Collectd/Graph/Data.pm \
262 && rm -f lib/Collectd/Graph/File.pm lib/Collectd/Graph/Filter.pm \
263 && rm -f lib/Collectd/Graph/MetaData.pm )
264 dh_installdebconf -a
265 dh_installinit -pcollectd-core --name=collectd -- defaults 95
266 dh_link -a
267 dh_strip -a --dbg-package=collectd-dbg
268 dh_compress -a -Xexamples/
269 dh_fixperms -a
270 dh_makeshlibs -a
271 dh_installdeb -a
272 dh_shlibdeps -a -Ncollectd-core -Ncollectd
273 dpkg-shlibdeps -Tdebian/collectd.substvars \
274 -dDepends debian/collectd-core/usr/lib/collectd/rrdtool.so
275 dpkg-shlibdeps -Tdebian/collectd-core.substvars \
276 -dDepends debian/collectd-core/usr/sbin/* \
277 -dSuggests debian/collectd-core/usr/lib/collectd/*.so
278 grep shlibs:Suggests debian/collectd-core.substvars \
279 | sed -e 's/shlibs:Suggests/shlibs:Recommends/' \
280 >> debian/collectd.substvars
281 dh_gencontrol -a
282 dh_md5sums -a
283 dh_builddeb -a
285 binary: binary-arch binary-indep
286 .PHONY: build build-arch build-indep clean binary-indep binary-arch binary install-indep install-arch