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

_realname=virt-viewer
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=9.0
pkgrel=1
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
pkgdesc="Displaying the graphical console of a virtual machine (mingw-w64)"
depends=("${MINGW_PACKAGE_PREFIX}-spice-gtk"
         "${MINGW_PACKAGE_PREFIX}-gtk-vnc"
         "${MINGW_PACKAGE_PREFIX}-libvirt"
         "${MINGW_PACKAGE_PREFIX}-libvirt-glib"
         "${MINGW_PACKAGE_PREFIX}-libxml2"
         "${MINGW_PACKAGE_PREFIX}-opus")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-gtk-doc"
             "${MINGW_PACKAGE_PREFIX}-icoutils"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "${MINGW_PACKAGE_PREFIX}-shared-mime-info"
             "${MINGW_PACKAGE_PREFIX}-spice-protocol")
options=('strip' 'staticlibs')
license=("LGPL 2.1")
url="https://virt-manager.org/"
source=(https://virt-manager.org/download/sources/virt-viewer/virt-viewer-${pkgver}.tar.gz{,.asc})
sha256sums=('91b43383a0bd4cf3173269e674d65fd205f7c34bc5a8cb4fb3640deb7f1d4825'
            'SKIP')
validpgpkeys=('DAF3A6FDB26B62912D0E8E3FBE86EBB415104FDF') # Daniel P. Berrange

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

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

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

  make
}

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

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