# Maintainer: Diego Sogari <diego.sogari@gmail.com>

_realname=winsparkle
pkgbase="mingw-w64-${_realname}"
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
replaces=("${MINGW_PACKAGE_PREFIX}-${_realname}-git")
conflicts=("${MINGW_PACKAGE_PREFIX}-${_realname}-git")
pkgver=0.6.0
pkgrel=1
pkgdesc='App update framework for Windows, inspired by Sparkle for OS X (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url='https://winsparkle.org/'
license=('MIT')
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
depends=("${MINGW_PACKAGE_PREFIX}-expat"
         "${MINGW_PACKAGE_PREFIX}-openssl"
         "${MINGW_PACKAGE_PREFIX}-wxWidgets") # gcc-libs not needed?
source=("${_realname}-${pkgver}.tar.gz::https://github.com/vslavik/winsparkle/archive/v${pkgver}.tar.gz"
        001-compile-fixes.patch
        Makefile)
sha256sums=('875f1bb0d7afbc1c5ad49c18ea64691050ad5034b15f5e0cba1e6d0cccb7b64f'
            'a36b4fa968c7b46116e2cfca9b1f30b6e7679b6cdc57c0d19ffc48f0b4060113'
            '675a631487a720f64e8bdf139c1ca7127a992f3acd0f8bcdb009bd4658d7df03')

consolidate() {
  cp ../Makefile src
}

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  consolidate
  patch -p1 < "${srcdir}"/001-compile-fixes.patch
}

build() {
  cd "${srcdir}/${_realname}-${pkgver}/src"
  make
}

package() {
  cd "${srcdir}/${_realname}-${pkgver}"
  install -D -m644 include/winsparkle.h         "${pkgdir}${MINGW_PREFIX}/include/winsparkle.h"
  install -D -m644 include/winsparkle-version.h "${pkgdir}${MINGW_PREFIX}/include/winsparkle-version.h"
  install -D -m644 src/libwinsparkle.a          "${pkgdir}${MINGW_PREFIX}/lib/libwinsparkle.a"
  install -D -m644 src/libwinsparkle.dll.a      "${pkgdir}${MINGW_PREFIX}/lib/libwinsparkle.dll.a"
  install -D -m755 src/libwinsparkle.dll        "${pkgdir}${MINGW_PREFIX}/bin/libwinsparkle.dll"
  install -D -m644 COPYING                      "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
