# Maintainer: Ebrahim Byagowi <ebrahim@gnu.org>

_realname=ragel
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=6.10
pkgrel=1
pkgdesc="Compiles finite state machines from regular languages into executable C, C++, Objective-C, or D code (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="https://www.colm.net/open-source/ragel/"
license=('GPL')
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
source=("https://www.colm.net/files/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('5f156edb65d20b856d638dd9ee2dfb43285914d9aa2b6ec779dac0270cd56c3f')

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

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST}

  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"

  make DESTDIR="${pkgdir}" install
  install -m0644 -D ${srcdir}/${_realname}-${pkgver}/ragel.vim "${pkgdir}${MINGW_PREFIX}"/share/vim/vimfiles/syntax/ragel.vim
}
