# Maintainer: Andrea Zagli <andrea.zagli.free@gmail.com>

_realname=gspell
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.8.4
pkgrel=2
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
pkgdesc="Spell-checking library for GTK applications (mingw-w64)"
options=(strip staticlibs)
depends=("${MINGW_PACKAGE_PREFIX}-gtk3"
         "${MINGW_PACKAGE_PREFIX}-iso-codes"
         "${MINGW_PACKAGE_PREFIX}-enchant")
makedepends=("${MINGW_PACKAGE_PREFIX}-vala"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "${MINGW_PACKAGE_PREFIX}-gtk-doc")
license=("LGPL 2.1")
url="https://www.gnome.org"
source=(https://download.gnome.org/sources/${_realname}/${pkgver%.*}/${_realname}-${pkgver}.tar.xz)
sha256sums=('cf4d16a716e813449bd631405dc1001ea89537b8cdae2b8abfb3999212bd43b4')

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

  autoreconf -fiv
}

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

  mkdir -p docs/reference/html
  cp -rf ../${_realname}-${pkgver}/docs/reference/html/* docs/reference/html

  ../${_realname}-${pkgver}/configure \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --build=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX} \
    --libexecdir=${MINGW_PREFIX}/lib \
    --enable-introspection
  make
}

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

  make DESTDIR=${pkgdir} install

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
