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

_realname=goocanvas
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=3.0.0
pkgrel=1
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
pkgdesc="Canvas widget for GTK+ that uses the Cairo 2D library (mingw-w64)"
license=("LGPL 2")
url="https://www.gnome.org"
depends=("${MINGW_PACKAGE_PREFIX}-gtk3")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-python"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "${MINGW_PACKAGE_PREFIX}-gtk-doc"
             "${MINGW_PACKAGE_PREFIX}-gettext"
             "make"
             "libtool"
             "automake-wrapper"
             "autoconf"
             "patch")
options=('strip' '!debug' 'staticlibs')
source=(https://download.gnome.org/sources/${_realname}/${pkgver:0:3}/${_realname}-${pkgver}.tar.xz
             001-convert-python-path-to-unix.patch
             002-fix-introspection.patch
             003-Use-gettext-0.19.patch)
sha256sums=('670a7557fe185c2703a14a07506156eceb7cea3b4bf75076a573f34ac52b401a'
            '9740420cd1e2cf2362e5170ead007685686656e3764c905f7b0313b62ed41298'
            '34016cb7b1b485193074f0af4cb715775dafea5c861356853fe6cc0b08983317'
            '5b6628c39d048d391f1af40295d2d1029ec643ceae174e97f7bd045666b93ee8')

prepare() {
  cd ${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/001-convert-python-path-to-unix.patch
  patch -p1 -i ${srcdir}/002-fix-introspection.patch
  patch -p1 -i ${srcdir}/003-Use-gettext-0.19.patch
  autoreconf -fi
}

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

  # an argument passed to glib-mkenums starts with a c++ comment
  export MSYS2_ARG_CONV_EXCL="/*"
  export CC=gcc
  PYTHON=${MINGW_PREFIX}/bin/python \
  ./configure \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --build=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX} \
    --libexecdir=${MINGW_PREFIX}/lib \
    --enable-introspection=yes

  make
}

package() {
  cd "${srcdir}/${_realname}-${pkgver}"
  make DESTDIR=${pkgdir} install
}
