# Maintainer: Balló György <ballogyor+arch at gmail dot com>
# Contributor: Jan de Groot <jgc@archlinux.org>
# Contributor: Ionut Biru <ibiru@archlinux.org>

pkgname=liblouis
pkgver=3.36.0
pkgrel=2
pkgdesc='Braille translator and back-translator library'
arch=(x86_64 aarch64)
url='https://liblouis.io/'
license=('GPL-3.0-or-later AND LGPL-2.1-or-later')
depends=(
  glibc
  libyaml
)
makedepends=(
  git
  help2man
  python-build
  python-installer
  python-setuptools
  python-wheel
)
optdepends=('python: Python bindings')
source=("git+https://github.com/liblouis/liblouis.git#tag=v$pkgver")
b2sums=(afd5cb3b71390f4d1522575ca2a9b0c95b1cae1f6750c84ac205df7e94b2953472634b9796353f5e25a40dec71ea71d5380933e28770aacf68198ec9c6603220)
validpgpkeys=(E9DDC8901A42F78B79CDC46042A55BD5EA40AB1A) # Christian Egli <christian.egli@sbs.ch>

prepare() {
  cd $pkgname
  autoreconf -fi
}

build() {
  cd $pkgname
  ./configure \
    --prefix=/usr \
    --sysconfdir=/etc \
    --localstatedir=/var \
    --enable-ucs4
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make

  cd python
  python -m build --wheel --no-isolation
}

check() {
  cd $pkgname
  make check
}

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

  cd python
  python -m installer --destdir="$pkgdir" dist/*.whl
}
