# Template file for 'ldb'
pkgname=ldb
version=2.9.0
revision=3
build_style=waf3
build_helper="qemu"
configure_script="buildtools/bin/waf"
configure_args="--sysconfdir=/etc --localstatedir=/var
 --disable-rpath --disable-rpath-install --without-gettext
 --builtin-libraries=replace --bundled-libraries=NONE
 --with-modulesdir=/usr/lib/ldb/modules"
hostmakedepends="pkg-config docbook-xsl libxslt tdb-python3 tevent-python3"
makedepends="python3-devel tdb-devel tevent-devel talloc-devel popt-devel
 lmdb-devel cmocka-devel"
checkdepends="cmocka-devel"
short_desc="LDAP-like database from samba"
maintainer="Yuusha Spacewolf <xyuusha@paranoici.org>"
license="LGPL-3.0-or-later"
homepage="https://www.samba.org/ldb/"
distfiles="https://download.samba.org/pub/ldb/ldb-${version}.tar.gz"
checksum=105aaff71ad881a7faeb582fd416ae28221b6fde338fff82828065062c2507a5
make_check=extended # testsuite takes a long time

export PYTHON_CONFIG="${XBPS_CROSS_BASE}/usr/bin/python3-config"
export PYTHONHASHSEED=1

post_patch() {
	# Look for properly named python support libraries
	vsed -i third_party/waf/waflib/Tools/python.py \
		-e "s|env.pyext_PATTERN = .*$|env.pyext_PATTERN = '%s.so'|"
}

do_check() {
	${configure_script} test ${makejobs}
}

ldb-python3_package() {
	short_desc+=" - Python3 bindings"
	pkg_install() {
		vmove ${py3_lib}
	}
}

libpyldb-util_package() {
	short_desc+=" - Python3 utility library"
	pkg_install() {
		vmove "usr/lib/libpyldb-util.so.*"
	}
}

ldb-devel_package() {
	short_desc+=" - development files"
	depends="${sourcepkg}>=${version}_${revision}
	 libpyldb-util>=${version}_${revision}"
	pkg_install() {
		vmove usr/include
		vmove usr/lib/pkgconfig
		vmove "usr/lib/*.so"
		vmove usr/share/man/man3
	}
}
