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

_realname=libchamplain
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.12.20
pkgrel=2
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
pkgdesc="C library providing ClutterActor to display maps (mingw-w64)"
depends=("${MINGW_PACKAGE_PREFIX}-clutter"
         "${MINGW_PACKAGE_PREFIX}-clutter-gtk"
         "${MINGW_PACKAGE_PREFIX}-cairo"
         "${MINGW_PACKAGE_PREFIX}-libsoup"
         "${MINGW_PACKAGE_PREFIX}-memphis"
         "${MINGW_PACKAGE_PREFIX}-sqlite3")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "${MINGW_PACKAGE_PREFIX}-vala"
             "${MINGW_PACKAGE_PREFIX}-meson"
             "${MINGW_PACKAGE_PREFIX}-gtk-doc"
             "${MINGW_PACKAGE_PREFIX}-ninja")
options=('strip' 'staticlibs')
license=("LGPL 2.1")
url="https://www.gnome.org/"
source=(https://download.gnome.org/sources/${_realname}/${pkgver%.*}/${_realname}-${pkgver}.tar.xz
        001-win.patch)
sha256sums=('0232b4bfcd130a1c5bda7b6aec266bf2d06e701e8093df1886f1e26bc1ba3066'
            '8ac0ee8629c8c575fc11821c35344d8bc775aa7f31dba1bfde3bd060c76c70d2')

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

build() {
  [[ -d "${srcdir}"/build-${MINGW_CHOST} ]] && rm -rf "${srcdir}"/build-${MINGW_CHOST}
  mkdir "${srcdir}"/build-${MINGW_CHOST} && cd "${srcdir}"/build-${MINGW_CHOST}

  MSYS2_ARG_CONV_EXCL="--prefix=" \
  ${MINGW_PREFIX}/bin/meson \
    --prefix="${MINGW_PREFIX}" \
    --buildtype=plain \
    -Dintrospection=true \
    -Dgtk_doc=true \
    -Dvapi=true \
    -Dwidgetry=true \
    ../${_realname}-${pkgver}
  ninja
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  DESTDIR="${pkgdir}" ninja install

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
