
_realname=byacc
pkgname=btyacc
pkgver=20230521
pkgrel=1
pkgdesc="btyacc - an LALR(1) parser generator with support for backtracking"
arch=('i686' 'x86_64')
url="https://invisible-island.net/byacc"
license=('Public Domain')
makedepends=('autotools' 'gcc')
source=("${_realname}-${pkgver}.tar.gz::https://github.com/ThomasDickey/byacc-snapshots/archive/t${pkgver}.tar.gz")
sha256sums=('bbdc8cb6efd4b1f080e0a290adfdc85428a998f368f5954d6cd8fdfbe0254356')


prepare() {
  autoreconf -vfi ${_realname}-snapshots-t${pkgver}
}

build() {
  mkdir -p build-${MSYSTEM_CHOST}
  pushd build-${MSYSTEM_CHOST}
  ../${_realname}-snapshots-t${pkgver}/configure -C \
    --enable-btyacc \
    --program-prefix=bt \
    --with-max-table-size=18000 \
    --program-transform-name='s,\^,bt,'
  make
  popd
}

check() {
  make check -C build-${MSYSTEM_CHOST}
}

package() {
  make install DESTDIR="${pkgdir}" -C build-${MSYSTEM_CHOST}
  install -Dv -t "${pkgdir}/usr/share/licenses/${pkgname}" \
    "${_realname}-snapshots-t${pkgver}/package/debian/copyright"
}
