# Contributor: vinymeuh <vinymeuh@gmail.com>
# Maintainer: Luca Weiss <luca@lucaweiss.eu>
pkgname=libgpiod
pkgver=2.2.1
pkgrel=0
pkgdesc="C library and tools for interacting with the linux GPIO character device"
url="https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/"
arch="all"
license="LGPL-2.1-or-later"
options="!check" # no test suite
makedepends="
	autoconf
	autoconf-archive
	automake
	doxygen
	help2man
	libtool
	linux-headers
	py3-build
	py3-pip
	python3-dev
	"
subpackages="$pkgname-dev $pkgname-doc py3-$pkgname:_py3"
source="https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/snapshot/libgpiod-$pkgver.tar.gz"

prepare() {
	default_prepare
	autoreconf -vfi
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--enable-tools=yes \
		--disable-static \
		--enable-bindings-python
	make
}

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

_py3() {
	pkgdesc="Python bindings for libgpiod"
	depends="python3"
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/python* "$subpkgdir"/usr/lib/
}

sha512sums="
73462e3a4c7f52bddf62dbc655b692a9c4b30605a7340e82a28f557c5b76fee43b0690b8f110f24999f8aa2234da94f2c455e0f0c5a7576500dd6a82bf5d6c21  libgpiod-2.2.1.tar.gz
"
