# Contributor: William Pitcock <nenolod@dereferenced.org>
# Maintainer: William Pitcock <nenolod@dereferenced.org>
pkgname=talloc
pkgver=2.1.12
pkgrel=0
pkgdesc="Memory pool management library"
url="http://talloc.samba.org"
arch="all"
license="LGPL-3.0-or-later"
replaces="samba-common"
makedepends="docbook-xsl libxslt python2-dev python3-dev"
subpackages="$pkgname-dev py2-$pkgname:_py2 py3-$pkgname:_py3 $pkgname-doc"
source="http://samba.org/ftp/$pkgname/$pkgname-$pkgver.tar.gz
	always-libs.patch
	"
builddir="$srcdir/$pkgname-$pkgver"

build() {
	cd "$builddir"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--localstatedir=/var \
		--bundled-libraries=NONE \
		--builtin-libraries=replace \
		--disable-rpath \
		--disable-rpath-install \
		--without-gettext \
		--extra-python=/usr/bin/python3
	make
}

check() {
	cd "$builddir"
	make check
}

package() {
	make -C "$builddir" DESTDIR="$pkgdir" install
}

_py2() {
	pkgdesc="Python 2 binding for libtalloc"
	replaces="py-talloc"  # for backward compatibility
	provides="py-talloc=$pkgver-r$pkgrel"  # for backward compatibility

	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/libpytalloc-util.so.* \
		"$pkgdir"/usr/lib/python2* "$subpkgdir"/usr/lib/
}

_py3() {
	pkgdesc="Python 3 binding for libtalloc"

	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/libpytalloc-util.cpython* \
		"$pkgdir"/usr/lib/python3* "$subpkgdir"/usr/lib/
}

sha512sums="baf572bc90ba0f0277d1d71cdfe441d4624592ad33e374b65ad9709189afa39fff227710db95e0e7ff2f96154f25b14d3e8d75ef10c8c81f03b3d432e80b63a2  talloc-2.1.12.tar.gz
fa818d6291f6291d193b475af993de4fd34e6133ccacb55203f5c96973c51b2e932523f5f2a8cd38a4959e80d8378841b3b5efd5411b7828a240102b492c16e7  always-libs.patch"
