# Maintainer: Alexey Pavlov <alexpux@gmail.com>
# Contributor: Renato Silva <br.renatosilva@gmail.com>
# Contributor: Eduard Braun <eduard.braun2@gmx.de>

_realname=gtkspell
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.0.16
pkgrel=10
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/"
msys2_repository_url="https://sourceforge.net/p/gtkspell/gtkspell/ci/master/tree"
license=(GPL2)
depends=("${MINGW_PACKAGE_PREFIX}-gettext-runtime"
         "${MINGW_PACKAGE_PREFIX}-glib2"
         "${MINGW_PACKAGE_PREFIX}-gtk2"
         "${MINGW_PACKAGE_PREFIX}-enchant")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-autotools"
             "${MINGW_PACKAGE_PREFIX}-gtk-doc"
             "intltool")
source=(https://gtkspell.sourceforge.io/download/${_realname}-${pkgver}.tar.gz
        gtkspell-no-undefined.patch
        001-localedir-relocation.patch
        enchant-2.diff)
sha256sums=('8fc7dc560167b2cb7193e76aca625a152dc19b0ebf49816b78539cbb90d80d02'
            'cb6978c914d5a20544cad2ba6b3a58096daadc420d21f99797949c7f3a02e57b'
            '1b4c6400c19eef9e36cb85fcb6c9a97a49d474bdd24ba4e8bfb29f3bacefa868'
            '52e693590161bc285ec46a2beece802f47c7ede65ec0b72ffa224ab0db176bad')

prepare() {
  cd ${_realname}-${pkgver}
  patch -p1 -i "${srcdir}"/gtkspell-no-undefined.patch
  patch -p1 -i "${srcdir}"/001-localedir-relocation.patch
  patch -p1 -i "${srcdir}"/enchant-2.diff

  gtkdocize
  WANT_AUTOMAKE=latest autoreconf -fi
}

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

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --enable-shared \
    --disable-static

  make
}

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