# Template file for 'ldb'
pkgname=ldb
version=2.3.2
revision=2
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 docbook2x tdb-python3 tevent-python3"
makedepends="python3-devel tdb-devel tevent-devel talloc-devel
 popt-devel lmdb-devel libxslt gettext-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=1416c949dc4326e41c0d8a5ecf8ef784f8c0b6e9d3dad8fa971e84ad56227603

# workaround for cmocka's broken uintptr_t definition on musl
if [ "$XBPS_TARGET_WORDSIZE" = "64" -a "$XBPS_TARGET_LIBC" = "musl" ]; then
	CFLAGS+=" -D__WORDSIZE=64"
fi

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

post_patch() {
	# Avoid Python shlib extension noise in libpyldb-util.so
	vsed -e "/env.pyext_PATTERN/s/dct\['SO'\]/'.so'/" \
		-i third_party/waf/waflib/Tools/python.py
}

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
	}
}
