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

_realname=libserdes
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=8.0.0
pkgrel=2
pkgdesc="Avro library with Confluent schema-registry support (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://github.com/confluentinc/libserdes"
license=('spdx:Apache-2.0')
depends=("${MINGW_PACKAGE_PREFIX}-curl"
         "${MINGW_PACKAGE_PREFIX}-jansson"
         "${MINGW_PACKAGE_PREFIX}-libavro")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-librdkafka"
             "${MINGW_PACKAGE_PREFIX}-autotools"
             "${MINGW_PACKAGE_PREFIX}-boost")
optdepends=("${MINGW_PACKAGE_PREFIX}-librdkafka")
source=("https://github.com/confluentinc/libserdes/archive/v${pkgver}/${_realname}-${pkgver}.tar.gz"
        "001-libserdes-6.2.0-fix-mingw-build.patch"
        "queue.h")
sha256sums=('90c00e2e64eefc9b054d959dbb719f3758b61087a28246b1f0d4881f893e68b1'
            '154ed2112cffd294371bd9b772cad4aebd278e2c12383f0e333d9b7677aa0725'
            '4ca3b88b0f21641e9abc2a46345b942480cb81bfcdb515279654b27044d5a7a7')

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

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

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