# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Greg Erwin <first name last name 256 at gmail dot com>

pkgname=libgpiod
pkgver=2.2.3
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=('x86_64' 'aarch64')
license=('LGPL-2.1-or-later AND GPL-2.0-or-later')
depends=('python')
makedepends=('git' 'autoconf-archive' 'doxygen' 'help2man' 'python-build' 'python-setuptools' 'python-pip')
source=(
  "git+$url#tag=v$pkgver"
  "libgpiod.patch"
)
sha256sums=('f5e40c84369ef910220fa17adf842e92a6e490ca29098d06ea2f7064169d20f1'
            '4d82aa1a46c4c604bb857589a15968924389166b105a1777bcc2a4204dc0468b')

build() {
  cd $pkgname
  patch -Np1 -i ../libgpiod.patch

  ./autogen.sh \
    --prefix=/usr \
    --enable-tools=yes \
    --enable-bindings-cxx \
    --enable-bindings-python
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}

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