# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=speexdsp
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.2.1
pkgrel=1
pkgdesc="DSP library derived from Speex (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
license=('BSD')
url="https://www.speex.org/"
depends=("${MINGW_PACKAGE_PREFIX}-cc-libs")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc" "${MINGW_PACKAGE_PREFIX}-autotools")
source=("https://gitlab.xiph.org/xiph/speexdsp/-/archive/SpeexDSP-${pkgver}/speexdsp-SpeexDSP-${pkgver}.tar.gz"
        "0001-include-stdint-in-resample-neon-h.patch")
sha256sums=('d17ca363654556a4ff1d02cc13d9eb1fc5a8642c90b40bd54ce266c3807b91a7'
            'a61da81d79a1233e9d3636eb738b06314d51c55941e25b0ece9e49cb746e48c3')

prepare() {
  mv "speexdsp-SpeexDSP-${pkgver}" "${_realname}-${pkgver}"
  cd "${srcdir}"/${_realname}-${pkgver}

  patch -p 1 -i "${srcdir}/0001-include-stdint-in-resample-neon-h.patch"

  ./autogen.sh
}

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

  #export lt_cv_deplibs_check_method='pass_all'

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --enable-shared \
    --enable-static

  make
}

package() {
  cd "${srcdir}"/build-${MSYSTEM}
  make DESTDIR="${pkgdir}" install
  install -Dm644 "${srcdir}"/${_realname}-${pkgver}/COPYING "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
