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

_realname=libvorbis
pkgbase=mingw-w64-jellyfin-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-jellyfin-${_realname}"
pkgver=1.3.7
pkgrel=2
pkgdesc="Vorbis codec library (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://xiph.org/"
msys2_references=(
  "cpe: cpe:/a:xiph.org:libvorbis"
)
license=('custom')
depends=("${MINGW_PACKAGE_PREFIX}-jellyfin-libogg"
         "${MINGW_PACKAGE_PREFIX}-gcc-libs")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-autotools")
options=('strip' 'staticlibs')
source=(https://downloads.xiph.org/releases/vorbis/${_realname}-${pkgver}.tar.gz)
sha256sums=('0e982409a9c3fc82ee06e08205b1355e5c6aa4c36bca58146ef399621b0ce5ab')

export MINGW_TOOLCHAIN_PREFIX="${MINGW_PREFIX}"
export FF_MINGW_PREFIX="${MINGW_TOOLCHAIN_PREFIX}/ffbuild"

build() {
  [[ -d "build-${MINGW_CHOST}" ]] && rm -rf "build-${MINGW_CHOST}"
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  ../${_realname}-${pkgver}/configure \
    --prefix=${FF_MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --disable-shared \
    --enable-static

  make
}

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