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

_realname=eog-plugins
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=3.26.5
pkgrel=2
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
pkgdesc="Eye of GNOME graphics viewer program - plugins (mingw-w64)"
options=(strip staticlibs)
depends=("${MINGW_PACKAGE_PREFIX}-eog"
         "${MINGW_PACKAGE_PREFIX}-libchamplain"
         "${MINGW_PACKAGE_PREFIX}-libexif"
         "${MINGW_PACKAGE_PREFIX}-libgdata"
         "${MINGW_PACKAGE_PREFIX}-gtk-update-icon-cache"
         "${MINGW_PACKAGE_PREFIX}-python")
makedepends=("${MINGW_PACKAGE_PREFIX}-gsettings-desktop-schemas"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection")
options=('strip' 'staticlibs')
license=("GPL 2")
url="https://www.gnome.org"
source=(https://download.gnome.org/sources/${_realname}/${pkgver%.*}/${_realname}-${pkgver}.tar.xz
        001-win.patch
        002-champlain.patch)
sha256sums=('44968e09059272be038c00aaf9796b442a6cd68163a5cb08c98824492a9b5498'
            '7b5a599b0fb719156747627944cae4b1107ffb8f11bcaddf0c8100d89c93548d'
            '3b7fab068ff3739fed247f72abbc18accb409b9008593e806f5c4e3df1d9b32d')

prepare() {
  cd "${srcdir}"/${_realname}-${pkgver}

  patch -p1 -i ${srcdir}/001-win.patch
  patch -p1 -i ${srcdir}/002-champlain.patch

  autoreconf -isf
}

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

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

  make
}

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

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