# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=gtkspell3
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=3.0.10
pkgrel=4
pkgdesc="Provides word-processor-style highlighting and replacement of misspelled words in a GtkTextView widget (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://gtkspell.sourceforge.io/"
license=("GPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "${MINGW_PACKAGE_PREFIX}-iso-codes"
             "${MINGW_PACKAGE_PREFIX}-autotools"
             "${MINGW_PACKAGE_PREFIX}-vala"
             "intltool")
depends=("${MINGW_PACKAGE_PREFIX}-gtk3"
         "${MINGW_PACKAGE_PREFIX}-enchant")
source=(https://sourceforge.net/projects/gtkspell/files/${pkgver}/${_realname}-${pkgver}.tar.xz
        001-win.patch)
sha256sums=('b040f63836b347eb344f5542443dc254621805072f7141d49c067ecb5a375732'
            '658a15a3a34c39632ce0700b9d709b634e5b166498f053d235416bd3e11b29c0')

prepare() {
  cd ${_realname}-${pkgver}
  patch -p1 -i "${srcdir}"/001-win.patch

  WANT_AUTOMAKE=latest autoreconf -fi
}

build() {
  mkdir -p "${srcdir}/build-${MSYSTEM}" && cd "${srcdir}/build-${MSYSTEM}"

  export lt_cv_deplibs_check_method='pass_all'

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --enable-shared \
    --disable-static \
    --disable-gtk2 \
    --disable-gtk-doc

  make
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"
  make DESTDIR="${pkgdir}" install
  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
