# Template file for 'kea'
pkgname=kea
version=3.1.8
revision=1
build_style=meson
build_helper=qemu
configure_args="-Dcpp_std=gnu++20
 $(vopt_feature mysql) $(vopt_feature pgsql postgresql)"
hostmakedepends="flex bison perl pkg-config
 doxygen elinks libxslt docbook-xsl python3-Sphinx python3-sphinx_rtd_theme"
_devel_depends="log4cplus-devel $(vopt_if botan botan-devel openssl-devel)
 $(vopt_if mysql libmariadbclient-devel) $(vopt_if pgsql postgresql-libs-devel)"
makedepends="boost-headers log4cplus-devel python3-devel gtest-devel
 $_devel_depends"
checkdepends="procps-ng" # needs pgrep
conf_files="/etc/kea/*.conf"
short_desc="Next generation DHCPv4/v6 server"
maintainer="Orphaned <orphan@voidlinux.org>"
license="MPL-2.0, Apache-2.0"
homepage="https://kea.isc.org"
changelog="https://gitlab.isc.org/isc-projects/kea/-/wikis/Release-Notes/release-notes-${version}"
distfiles="https://ftp.isc.org/isc/kea/${version/.P/-P}/kea-${version/.P/-P}.tar.xz"
checksum=fcf91984d61f84353618a66970e39398d22b1ec56ebc5e5bf775dde3f2b9d11d

build_options="botan mysql pgsql"
desc_option_botan="With Botan SSL support"
desc_option_mysql="With MySQL lease information database"
desc_option_pgsql="With PostgreSQL lease information database"
build_options_default="pgsql"

make_dirs="/var/kea 755 root root"

post_install() {
	vsv kea-dhcp4
	vsv kea-dhcp6
	vsv kea-dhcp-ddns

	rm -f ${DESTDIR}/usr/lib64
	rmdir ${DESTDIR}/var/run/kea
	rmdir ${DESTDIR}/var/run

	# Modify the logging output to stdout
	sed -i ${DESTDIR}/etc/kea/*.conf \
		-e 's;"output": "/var/log/.*";"output": "stdout";'
}

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

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