# Contributor: Stuart Cardall <developer@it-offshore.co.uk>
# Maintainer: Stuart Cardall <developer@it-offshore.co.uk>
pkgname=libteam
pkgver=1.27
pkgrel=0
pkgdesc="Library for controlling team network device"
url="http://libteam.org"
arch="all"
license="LGPL-2.1"
makedepends="autoconf automake libtool libnl3-dev libdaemon-dev jansson-dev
	dbus-dev linux-headers bsd-compat-headers doxygen swig
	python2-dev python3-dev"
subpackages="$pkgname-dev $pkgname-doc py-$pkgname:py"
source="$pkgname-$pkgver.tar.gz::https://github.com/jpirko/$pkgname/archive/v$pkgver.tar.gz
	fix-fd_set.patch
	memcpy-memset-implicit-declaration.patch
	fix-redefinition-struct-ethhdr.patch
	"
builddir="$srcdir/$pkgname-$pkgver"

build() {
	cd "$builddir"
	./autogen.sh
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--mandir=/usr/share/man \
		|| return 1
	make || return 1
}

py() {
	pkgdesc="Python 2/3 Bindings for libteam"

	cd "$builddir"

	mkdir -p "$subpkgdir"
	cp -ar binding/python binding/python3 || return 1

	cd binding/python
	python2 ./setup.py build || return 1

	cd ../python3
	python3 ./setup.py build || return 1

	cd ../python
	python2 ./setup.py install --root "$subpkgdir" -O1 || return 1

	cd ../python3
	python3 ./setup.py install --root "$subpkgdir" -O1 || return 1
}

package() {
	cd "$builddir"
	make DESTDIR="$pkgdir" install || return 1
}

sha512sums="f1c8ca6996aaab73d638ef6ade3fbf4c9f50080eea24d684d594a1e49cedd6fe0920e91a12709e583409dade00e2dfb53be59447be95c397441be0852d7e1ba0  libteam-1.27.tar.gz
83f8dd77cfed0f815bc0cb2aa4af25883a02567dbb35b59016d7f3a30f162e63155996d21216424f0ea4efa8e92f8f9526a018a892533c3c7dd7c7ba12b46a44  fix-fd_set.patch
1279c164960b6215e9bb9f3ee161ef9ac6a38b8066d4a1031996b8067031b9b19404681ebecf3492a26b1215ec2eaaddecae3370ec25e2593dc3ca7dc5f8ead7  memcpy-memset-implicit-declaration.patch
db2f374018a8b60c099e5b41abf5a9d20912bddc0436788b246815459c97498fb47d237376f87a623438f2f48d486d91d65fe5b49aeeabc83cbd41bdb66d7bfc  fix-redefinition-struct-ethhdr.patch"
