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

_realname=gplugin
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.29.0
pkgrel=6
pkgdesc="A GObject based library that implements a reusable plugin system (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
license=("spdx:LGPL-2.0-or-later")
url="https://keep.imfreedom.org/gplugin/gplugin"
depends=("${MINGW_PACKAGE_PREFIX}-gettext-runtime"
         "${MINGW_PACKAGE_PREFIX}-glib2"
         "${MINGW_PACKAGE_PREFIX}-gtk3")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-meson"
             "${MINGW_PACKAGE_PREFIX}-pkgconf"
             "${MINGW_PACKAGE_PREFIX}-ninja"
             "${MINGW_PACKAGE_PREFIX}-asciidoc"
             "${MINGW_PACKAGE_PREFIX}-vala"
             "${MINGW_PACKAGE_PREFIX}-gettext"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "${MINGW_PACKAGE_PREFIX}-gtk-doc"
             "mercurial")
source=("hg+https://keep.imfreedom.org/$_realname/$_realname#tag=v$pkgver"
        001-win.patch)
sha256sums=('SKIP'
            '97020cd303307dd93d0f84f46542b84d41a32a1d975843e774fe36fb0071008d')

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

build() {
  mkdir -p build-${MSYSTEM} && cd build-${MSYSTEM}

  MSYS2_ARG_CONV_EXCL="--prefix=" \
  ${MINGW_PREFIX}/bin/meson setup \
    --prefix="${MINGW_PREFIX}" \
    --buildtype=plain \
    -Dgtk3=true \
    -Dgobject-introspection=true \
    -Dlua=false \
    -Dperl=false \
    -Dpython=false \
    -Dhelp2man=false \
    "../${_realname}"

  ${MINGW_PREFIX}/bin/meson compile
}

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

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