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

_realname=goocanvas
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=3.0.0
pkgrel=6
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://wiki.gnome.org/Projects/GooCanvas"
msys2_repository_url="https://gitlab.gnome.org/Archive/goocanvas"
license=("spdx:LGPL-2.0-or-later")
depends=("${MINGW_PACKAGE_PREFIX}-atk"
         "${MINGW_PACKAGE_PREFIX}-cairo"
         "${MINGW_PACKAGE_PREFIX}-gdk-pixbuf2"
         "${MINGW_PACKAGE_PREFIX}-glib2"
         "${MINGW_PACKAGE_PREFIX}-gtk3"
         "${MINGW_PACKAGE_PREFIX}-pango")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-autotools"
             "${MINGW_PACKAGE_PREFIX}-python"
             "${MINGW_PACKAGE_PREFIX}-gettext-tools"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "${MINGW_PACKAGE_PREFIX}-gtk-doc")
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'
            'b9e3815c1384e62b6745d52ee4ef69f2fe008bf7368e4ec7ab4809845650428d'
            '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="/*;\n/*"
  export lt_cv_deplibs_check_method='pass_all'

  CFLAGS+=" -Wno-incompatible-pointer-types" \
  PYTHON=${MINGW_PREFIX}/bin/python \
  ./configure \
    --prefix=${MINGW_PREFIX} \
    --libexecdir=${MINGW_PREFIX}/lib \
    --enable-introspection=yes

  make
}

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