# Maintainer: Jeff Hubbard <musikernel@gmail.com>

_realname=rubberband
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.9.0
pkgrel=1
pkgdesc="High quality software library for audio time-stretching and pitch-shifting. (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url="https://breakfastquay.com/rubberband/"
license=("GPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-pkg-config")
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
         "${MINGW_PACKAGE_PREFIX}-fftw"
         "${MINGW_PACKAGE_PREFIX}-libsamplerate"
         "${MINGW_PACKAGE_PREFIX}-libsndfile"
         "${MINGW_PACKAGE_PREFIX}-ladspa-sdk"
         "${MINGW_PACKAGE_PREFIX}-vamp-plugin-sdk")
source=("https://breakfastquay.com/files/releases/${_realname}-${pkgver}.tar.bz2"
        01-mingw-shared.patch)
sha256sums=('4f5b9509364ea876b4052fc390c079a3ad4ab63a2683aad09662fb905c2dc026'
            '9eeadba674f708bbd76af9524f1bc8084f44a0f901d9004fe5ed31a77aa36c57')

prepare() {
  cd ${srcdir}/${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/01-mingw-shared.patch
}

build() {
  [[ -d "build-${MINGW_CHOST}" ]] && rm -rf "build-${MINGW_CHOST}"
  cp -rf "${_realname}-${pkgver}" "build-${MINGW_CHOST}"
  cd build-${MINGW_CHOST}

  ./configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST}

  make
}

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