
_realname=byacc
pkgname=btyacc
pkgver=20210619
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')
groups=('base-devel')

source=("${_realname}-${pkgver}.tar.gz::https://github.com/ThomasDickey/byacc-snapshots/archive/t${pkgver}.tar.gz")
sha256sums=('d19fc22dd1d5e5b18a4abfd2470a1513a2b8b2962f7fb94c21e6109ea571bfc0')


prepare() {
  cd ${_realname}-snapshots-t${pkgver}

  autoreconf -vfi
}

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

check() {
  cd ${_realname}-snapshots-t${pkgver}/build-${MSYSTEM_CHOST}
  make check
}

package() {
  cd ${_realname}-snapshots-t${pkgver}
  mkdir -p "${pkgdir}/usr/share/licenses/${pkgname}"
  cp -pv package/debian/copyright "${pkgdir}/usr/share/licenses/${pkgname}"
  cd build-${MSYSTEM_CHOST}
  make DESTDIR=${pkgdir} install
}
