# Maintainer: Martell Malone <martellmalone@gmail.com>

_realname=onig
_fullname=oniguruma
pkgbase=mingw-w64-${_fullname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_fullname}"
pkgver=6.9.6
pkgrel=1
pkgdesc="A regular expressions library (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
license=('BSD')
url="https://github.com/kkos/oniguruma"
options=('staticlibs')
source=("https://github.com/kkos/${_fullname}/releases/download/v${pkgver}/${_realname}-${pkgver}.tar.gz")
sha256sums=('bd0faeb887f748193282848d01ec2dad8943b5dfcb8dc03ed52dcc963549e819')

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

build() {
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir -p "${srcdir}/build-${MINGW_CHOST}" && cd "${srcdir}/build-${MINGW_CHOST}"

  ../${_realname}-${pkgver}/configure \
      --prefix=${MINGW_PREFIX} \
      --build=${MINGW_CHOST} \
      --host=${MINGW_CHOST} \
      --target=${MINGW_CHOST} \
      --enable-shared \
      --enable-static \
      --enable-posix-api

  make
}

check() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make check || true
}

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