# Maintainer: Some One <some.one@some.email.com>

_realname=spdylay
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.4.0
pkgrel=4
pkgdesc="The experimental SPDY protocol version 2, 3 and 3.1 implementation in C (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://tatsuhiro-t.github.io/spdylay/"
msys2_repository_url="https://github.com/tatsuhiro-t/spdylay"
license=('spdx:MIT')
depends=("${MINGW_PACKAGE_PREFIX}-zlib")
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-cc"
  "${MINGW_PACKAGE_PREFIX}-autotools"
  "${MINGW_PACKAGE_PREFIX}-libxml2")
source=("https://github.com/tatsuhiro-t/spdylay/releases/download/v${pkgver}/spdylay-${pkgver}.tar.gz"
         spdylay-1.4.0-fix-zlib.patch)
sha256sums=('f45641df48f0f8e13fe80166437828201b46f56681b11cd93a614a82ebd5dcba'
            'a5d3f3be9ad333771c61aa11dfc18dcd0670bb76fe401493fb1ecb80a5d1217f')

prepare() {
  cd $srcdir/${_realname}-${pkgver}
  patch -p1 -i "${srcdir}"/spdylay-1.4.0-fix-zlib.patch
  # autoreconf to get updated libtool files with clang support
  autoreconf -fiv
}

build() {
  mkdir -p "${srcdir}"/build-${MSYSTEM} && cd "${srcdir}"/build-${MSYSTEM}

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-static \
    --enable-shared \
    --enable-src=no \
    --enable-examples=no
  make
}

chec() {
  "${srcdir}"/build-${MSYSTEM}
  make test
}

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