# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=gtkimageview
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.6.4
pkgrel=4
pkgdesc="Simple image viewer widget for GTK2 (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url="https://projects-old.gnome.org/gtkimageview/"
license=("LGPL2.1")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
depends=("${MINGW_PACKAGE_PREFIX}-gtk2")
options=('strip' 'staticlibs')
source=("${_realname}-${pkgver}.tar.gz"
        "resources.tar.bz2"
        01-resource.patch
        02-g_mem_set_vtable.patch
        03-update-obsolete-gnome-common-and-automake.patch
        04-gcc9-identation-error.patch)
sha256sums=('4c681d38d127ee3950a29bce9aa7aa8a2abe3b4d915f7a0c88e526999c1a46f2'
            'bb255c8786e2039168801a9f49eb0f1fe38321842cd4967ec67f698883a90d86'
            '438c3c45f24cb367a9ba8567d9aa85775be9b1edda03a7101d6023a4dd04942c'
            'f2ba3dd4b6d1ad8f81953e2d51e43396df6606dab84211aec1095329514ebd5e'
            '89a214a265c2dfd7a555cc17640e5e73f397fd043ffbbbf22e395c5a6afb27dd'
            'fd0437cbce60004ed58c287c359ecebc6fa693ec75d88a906a7c4c01eccd8d0a')

prepare() {
  mv -f *.png ${_realname}-${pkgver}/src/
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -p1 -i ${srcdir}/01-resource.patch
  patch -p1 -i ${srcdir}/02-g_mem_set_vtable.patch
  patch -p1 -i ${srcdir}/03-update-obsolete-gnome-common-and-automake.patch
  patch -p1 -i ${srcdir}/04-gcc9-identation-error.patch
  
  autoreconf -fiv
}

build() {
  export lt_cv_deplibs_check_method='pass_all'
  rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST}

  make
}

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