# Maintainer: Pellegrino Prevete <pellegrinoprevete@gmail.com>

_realname=libhandy
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.2.2
pkgrel=1
pkgdesc="A library full of GTK+ widgets for mobile phones (mingw-w64)"
url="https://gitlab.gnome.org/GNOME/libhandy"
license=("LGPL2.1+")
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
depends=("${MINGW_PACKAGE_PREFIX}-glib2"
         "${MINGW_PACKAGE_PREFIX}-gtk3")
makedepends=("${MINGW_PACKAGE_PREFIX}-glade"
             "${MINGW_PACKAGE_PREFIX}-meson"
             "${MINGW_PACKAGE_PREFIX}-ninja"
             "${MINGW_PACKAGE_PREFIX}-pkg-config"
             "${MINGW_PACKAGE_PREFIX}-vala"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection")
options=('strip' 'staticlibs' '!debug')
source=("https://download.gnome.org/sources/libhandy/${pkgver:0:3}/libhandy-${pkgver}.tar.xz")
sha256sums=('47ffd2865d02bd1ca579522deadd7e2f95362f1f202462fd5eeae2b81668b048')

prepare() {
  cd libhandy-${pkgver}
}

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

  MSYS2_ARG_CONV_EXCL="--prefix=" \
  ${MINGW_PREFIX}/bin/meson \
    --prefix="${MINGW_PREFIX}" \
    --buildtype=plain \
    -Dexamples=false \
    -Dgtk_doc=false \
    -Dglade_catalog=enabled \
    ../"libhandy-${pkgver}"

  ${MINGW_PREFIX}/bin/ninja
}

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