# Contributor: vinymeuh <vinymeuh@gmail.com>
# Maintainer: Luca Weiss <luca@lucaweiss.eu>
pkgname=libgpiod
pkgver=2.2
pkgrel=1
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
	0001-temporary-compat-with-libgpiod-1.x.patch"

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="
41e7a2b8cbd6f5766f34134c589876b6130bb3a5143be6868e8d2d6c7522ef7d5b78bf2d95da873451b82ad5abaaff2f92d61bb86e53634cf683230006612952  libgpiod-2.2.tar.gz
0ea9c622521a066bfff3dc520c0631aef8017e90de21f7f04ed438d8fa4fb5e90317c423ecf7a511f4b0d675701565e8c6901185f8d56cb18e24a94be02bec4c  0001-temporary-compat-with-libgpiod-1.x.patch
"
