# Maintainer: Ricky Wu <rickleaf.wu@gmail.com>

_realname=gtksourceviewmm
pkgbase="mingw-w64-${_realname}2"
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}2"
pkgver=2.10.3
pkgrel=3
pkgdesc="A text widget adding syntax highlighting and more to GNOME (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url="https://www.gnome.org"
license=("GPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-pkg-config"
             "intltool")
depends=("${MINGW_PACKAGE_PREFIX}-gtk2>=2.22.0"
         "${MINGW_PACKAGE_PREFIX}-gtkmm"
         "${MINGW_PACKAGE_PREFIX}-gtksourceview2"
         "${MINGW_PACKAGE_PREFIX}-libxml2>=2.7.7")
options=(!libtool strip staticlibs)
source=("https://download.gnome.org/sources/gtksourceviewmm/${pkgver%.*}/gtksourceviewmm-${pkgver}.tar.xz"
        000-C11.patch)
sha256sums=('0000df1b582d7be2e412020c5d748f21c0e6e5074c6b2ca8529985e70479375b'
            '5311dccfc287947e4cd708823f82a8b185953495dfab8d32fcba2441d9f9037a')

prepare() {
  cd ${_realname}-${pkgver}
  patch -b -V simple -p1 -i ${srcdir}/000-C11.patch
}

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} \
    --enable-shared \
    --disable-static

  make
}

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