Code

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