Code

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