# Maintainer: Bjoern Lemke <lemke@lemke-it.com>

_realname=dragon
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.5.2
pkgrel=1
pkgdesc="Dragon parser generator (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url='http://www.lemke-it.com/'
license=('GPL3')

# makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-pkg-config")
depends=("${MINGW_PACKAGE_PREFIX}-lfcbase")
# validpgpkeys=('gpg_KEY')
source=("http://www.lemke-it.com/${_realname}-${pkgver}.tar.gz")

sha256sums=("8d3e37632bb3fb89c915891bef821f52991903dc6d18193eab70576ae0d2aeb2")

prepare() {
  cd $srcdir/${_realname}-${pkgver}
}

build() {
  cd "$srcdir"/${_realname}-${pkgver}
  [[ -d "${srcdir}"/build-${CARCH} ]] && rm -rf "${srcdir}"/build-${CARCH}
  mkdir -p "${srcdir}"/build-${CARCH} && cd "${srcdir}"/build-${CARCH}
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-static \
    --enable-shared

  make
}

check() {
  cd "${srcdir}"/build-${CARCH}
  make check
}

package() {
  cd "${srcdir}"/build-${CARCH}
  make install DESTDIR="${pkgdir}"
}
