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

_realname=libserdes
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=6.2.0
_pkgver_suffix=beta201023193458
pkgrel=1
pkgdesc="Avro library with Confluent schema-registry support (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url="https://github.com/confluentinc/libserdes"
license=('Apache')
makedepends=("${MINGW_PACKAGE_PREFIX}-cmake"
             "${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-librdkafka")
depends=("${MINGW_PACKAGE_PREFIX}-curl"
         "${MINGW_PACKAGE_PREFIX}-libavro")
optdepends=("${MINGW_PACKAGE_PREFIX}-librdkafka")
source=("${_realname}-${pkgver}.tar.gz::https://github.com/confluentinc/libserdes/archive/v${pkgver}-${_pkgver_suffix}.tar.gz"
        "001-libserdes-6.2.0-fix-mingw-build.patch"
        "queue.h")
sha256sums=('51893801a737bfdd57066bdaef04fcbdc81ed8a1f10d1e14060d4a7558e8a3ea'
            '154ed2112cffd294371bd9b772cad4aebd278e2c12383f0e333d9b7677aa0725'
            '4ca3b88b0f21641e9abc2a46345b942480cb81bfcdb515279654b27044d5a7a7')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}-${_pkgver_suffix}"
  patch -Np1 -i "${srcdir}/001-libserdes-6.2.0-fix-mingw-build.patch"
  cp "${srcdir}/queue.h" src
}

build() {
  cd "${srcdir}/${_realname}-${pkgver}-${_pkgver_suffix}"
  ./configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST}
  make GEN_PKG_CONFIG=y
}

package() {
  cd "${srcdir}/${_realname}-${pkgver}-${_pkgver_suffix}"
  make DESTDIR="${pkgdir}" install
}
