# $Id: PKGBUILD 138663 2015-08-23 04:26:43Z bisson $
# Maintainer: Gaetan Bisson <bisson@archlinux.org>
# Contributor: Gerhard Brauer <gerhard.brauer@web.de>

pkgname=collectd
pkgver=5.5.0
pkgrel=3
pkgdesc='Daemon which collects system performance statistics periodically'
url='http://collectd.org/'
arch=('i686' 'x86_64')
license=('GPL')

optdepends=('curl: apache, ascent, curl, nginx, and write_http plugins'
            'libdbi: dbi plugin'
            'libesmtp: notify_email plugin'
            'libgcrypt: encryption and authentication for network plugin'
            'libmemcached: memcachec plugin'
            'libmariadbclient: mysql plugin'
            'iproute2: netlink plugin'
            'net-snmp: snmp plugin'
            'libnotify: notify_desktop plugin'
            'liboping: ping plugin'
            'libpcap: dns plugin'
            'perl: perl plugin'
            'postgresql-libs: postgresql plugin'
            'python2: python plugin'
            'rrdtool: rrdtool and rrdcached plugins'
            'lm_sensors: lm_sensors and sensors plugins'
            'libvirt: libvirt plugin'
            'libxml2: ascent and libvirt plugins'
            'yajl: curl_json plugin'
            'libatasmart: smart plugin'
            'lvm2: lvm plugin')

makedepends=('curl' 'libdbi' 'libesmtp' 'libgcrypt' 'libmemcached'
             'libmariadbclient' 'iproute2' 'net-snmp' 'libnotify' 'liboping'
             'libpcap' 'postgresql-libs' 'python2' 'rrdtool' 'lm_sensors'
             'libvirt' 'libxml2' 'yajl' 'libatasmart' 'lvm2')

depends=('libltdl' 'iptables')

source=("${url}files/${pkgname}-${pkgver}.tar.bz2"
        'service')
sha1sums=('ef97838e249814ad96a2edc0410326efbb4f3d08'
          '04f676d0b76c34df0bbf94629813e035b1febe04')

backup=('etc/collectd.conf')

prepare() {
	cd "${srcdir}/${pkgname}-${pkgver}"
	sed 's/-Werror//g' -i *.ac */*.{am,in} */*/*.{am,in}
	autoreconf
}

build() {
	cd "${srcdir}/${pkgname}-${pkgver}"
	export MAKEFLAGS='-j1'
	./configure \
		--prefix=/usr \
		--sysconfdir=/etc \
		--localstatedir=/var \
		--sbindir=/usr/bin \
		--with-python=/usr/bin/python2 \
		--with-perl-bindings='INSTALLDIRS=vendor'
	make all
}

package() {
	cd "${srcdir}/${pkgname}-${pkgver}"
	make DESTDIR="${pkgdir}" install
	rmdir "${pkgdir}/var/run" # FS#30201
	install -Dm644 ../service "${pkgdir}"/usr/lib/systemd/system/collectd.service
	install -Dm644 contrib/collectd2html.pl "${pkgdir}"/usr/share/collectd/collectd2html.pl
}
