# Contributor: Alexander Georgievskiy <galeksandrp@gmail.com>

_realname=polipo
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.1.1
pkgrel=2
pkgdesc='The Polipo caching HTTP proxy (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
license=('MIT')
url="https://github.com/jech/${_realname}"
source=("${url}/archive/${_realname}-${pkgver}.tar.gz"
        '416e59f75934cd1c42fcf043f118b2d1a4e4e8d4.patch'
        'a532fc1ceee6cb6ecb5dd04cb360a757bb037dfe.patch'
        'd2df61dcde8079e1f7e5f8bcffefefa10277540f.patch'
        'fix-install-folders.patch'
        'fix-poll-redefinition.patch')
sha256sums=('de0afeeaa47df776420e59b69e9a78f68e8a7bc4a46b739772e1d91119ed2405'
            '4e7960d27948b2e351d238e923110d796892d97ed52f4eb62c156fd7873b0bd2'
            '4d293afc404048e75cabf845e146757efafe23db7b2a627d693a10a438e7f1c8'
            '89d9bc2ffb596a7a18f50e22373cd77f29fc6086d718ddce156c16c8d8eb805b'
            'cf6dd8cc8edfd3130bedbbb3d334005370386955040cd993191ac6a4ae9d6a0e'
            '93c87ee7e27a8bb2bffaf92ef59a5ad469265492ac9bf6993c2dd009307393ec')

prepare() {
  cd ${srcdir}/${_realname}-${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/416e59f75934cd1c42fcf043f118b2d1a4e4e8d4.patch
  patch -p1 -i ${srcdir}/a532fc1ceee6cb6ecb5dd04cb360a757bb037dfe.patch
  patch -p1 -i ${srcdir}/d2df61dcde8079e1f7e5f8bcffefefa10277540f.patch
  patch -p1 -i ${srcdir}/fix-install-folders.patch
  patch -p1 -i ${srcdir}/fix-poll-redefinition.patch
}

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

  make EXE=.exe LDLIBS=-lwsock32
}

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

  make PREFIX=${pkgdir}${MINGW_PREFIX} install
}
