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

pkgname=libgpiod
pkgver=2.2.4
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' '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=('40dddc2922d8a0a3dba357c16b135e1e6ee8b695285aaaf8e474c2eae3b46f32'
            '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
}
