# Template file for 'collectd'
pkgname=collectd
version=5.12.0
revision=12
build_style=gnu-configure
configure_args="$(vopt_enable rrdtool rrdtool) $(vopt_enable perl perl)
 $(vopt_enable notify notify_desktop) --with-libiptc --enable-virt
 --sysconfdir=/etc --disable-static --with-fp-layout=nothing
 --with-python=/usr/bin/python3 --disable-werror
 $(vopt_with prometheus "libmicrohttpd protobuf-c")
 $(vopt_enable prometheus write_prometheus)"
conf_files="/etc/collectd.conf"
hostmakedepends="automake pkg-config libtool libltdl-devel glib-devel"
makedepends="libcurl-devel iptables-devel openssl-devel libsensors-devel
 libesmtp-devel zlib-devel yajl-devel python3-devel libxml2-devel net-snmp-devel
 libgcrypt-devel libmariadbclient-devel libltdl-devel libvirt-devel
 $(vopt_if notify libnotify-devel) $(vopt_if rrdtool rrdtool-devel)
 $(vopt_if prometheus 'protobuf-c-devel libmicrohttpd-devel')"
short_desc="Daemon which collects system performance statistics periodically"
maintainer="Orphaned <orphan@voidlinux.org>"
license="GPL-2.0-only, MIT"
homepage="https://collectd.org"
distfiles="https://storage.googleapis.com/collectd-tarballs/${pkgname}-${version}.tar.bz2"
checksum=5bae043042c19c31f77eb8464e56a01a5454e0b39fa07cf7ad0f1bfc9c3a09d6
LDFLAGS="-lgcrypt"

if [ "$XBPS_TARGET_LIBC" = "glibc" ]; then
	makedepends+=" libxcrypt-devel"
fi

build_options="rrdtool perl notify prometheus"
desc_option_rrdtool="Enable support for RRDTool"
desc_option_prometheus="Enable write_prometheus plugin"

if [ -z "$CROSS_BUILD" ]; then
	build_options_default="rrdtool perl"
fi

pre_configure() {
	autoreconf -fi
}

post_install() {
	vsv collectd
	vlicense COPYING
}

collectd-utils_package() {
	short_desc+=" - utilities"
	pkg_install() {
		for util in collectd-nagios collectd-tg collectdctl; do
			vmove usr/bin/${util}
			vmove usr/share/man/man1/${util}.1
		done
	}
}

libcollectdclient_package() {
	short_desc+=" - shared libraries"
	pkg_install() {
		vmove "usr/lib/libcollectdclient.so*"
	}
}

libcollectdclient-devel_package() {
	short_desc+=" - development files"
	depends="libcollectdclient>=${version}_${revision}"
	pkg_install() {
		vmove usr/include
		vmove usr/lib/pkgconfig
		vmove "usr/lib/*.so"
	}
}
