# Maintainer: Ignacio Casal Quinteiro <icq@gnome.org>

_realname=libgee
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.20.8
pkgrel=2
pkgdesc="A collection library providing GObject-based interfaces and classes for commonly used data structures (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://wiki.gnome.org/Projects/Libgee"
msys2_references=(
  "cpe: cpe:2.3:a:gnome:libgee"
)
license=('spdx:LGPL-2.1-or-later')
depends=("${MINGW_PACKAGE_PREFIX}-glib2")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-autotools"
             "${MINGW_PACKAGE_PREFIX}-vala"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection")
source=("https://download.gnome.org/sources/${_realname}/${pkgver%.*}/${_realname}-${pkgver}.tar.xz"
        0001-change-pkg-config-invocation.patch)
sha256sums=('189815ac143d89867193b0c52b7dc31f3aa108a15f04d6b5dca2b6adfad0b0ee'
            'c581568b4538666d6f35b3b159184c244b58ffcd8cf6fc5f7809842478f2d01d')
msys2_repository_url="https://gitlab.gnome.org/GNOME/libgee"

prepare() {
  cd "${srcdir}"/${_realname}-${pkgver}
  patch -p1 -i "${srcdir}"/0001-change-pkg-config-invocation.patch

  # Get proper unprefixed directories for gobject-introspection files
  autoreconf -fiv
}

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

  ../${_realname}-${pkgver}/configure \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --build=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX} \
    --libexecdir=${MINGW_PREFIX}/lib

  make -j1
}

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

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