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

_realname=libgsf
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.14.54
pkgrel=1
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
msys2_references=(
  'archlinux: libgsf'
  "cpe: cpe:/a:gnome:libgsf"
  "cpe: cpe:/a:libgsf:libgsf"
)
pkgdesc="An extensible I/O abstraction library for dealing with structured file formats (mingw-w64)"
depends=("${MINGW_PACKAGE_PREFIX}-bzip2"
         "${MINGW_PACKAGE_PREFIX}-glib2"
         "${MINGW_PACKAGE_PREFIX}-gdk-pixbuf2"
         "${MINGW_PACKAGE_PREFIX}-libxml2"
         "${MINGW_PACKAGE_PREFIX}-zlib")
makedepends=("${MINGW_PACKAGE_PREFIX}-vala"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "${MINGW_PACKAGE_PREFIX}-gtk-doc"
             "${MINGW_PACKAGE_PREFIX}-autotools"
             "${MINGW_PACKAGE_PREFIX}-cc")
license=('spdx:LGPL-2.1-only')
url="https://gitlab.gnome.org/GNOME/libgsf.git"
source=(https://download.gnome.org/sources/${_realname}/${pkgver%.*}/${_realname}-${pkgver}.tar.xz
        002-get-unix-path-for-git.patch)
sha256sums=('d18869264a2513cfb071712486d115dada064ff8a040265b49936bca06f17623'
            'f08db8333d2b4a369737a77969b5896d408a4d9992fab6f1c9c44ddeae25c516')

prepare() {
  cd ${_realname}-${pkgver}
  patch -p1 -i "${srcdir}"/002-get-unix-path-for-git.patch

  autoreconf -fiv
}

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

  mkdir -p doc/html
  cp -rf ../${_realname}-${pkgver}/doc/html/* doc/html

  ../${_realname}-${pkgver}/configure \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --build=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX} \
    --libexecdir=${MINGW_PREFIX}/lib \
    --enable-introspection \
    --disable-gtk-doc

  make
}

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

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