# Maintainer: Developer <dev@opalos.org>
# Maintainer: Developer <dev@opalos.org>

pkgbase=opus
pkgname=(
  opus
  opus-docs
)
pkgver=%version%
pkgrel=%release%
pkgdesc="Totally open, royalty-free, highly versatile audio codec"
url="https://www.opus-codec.org/"
arch=(x86_64)
license=(BSD-3-Clause)
depends=(
  glibc
)
makedepends=(
  doxygen
  meson
)
source=("https://downloads.xiph.org/releases/opus/opus-$pkgver.tar.gz")
b2sums=('5ba1d6f28594f366b545507bafb22751e15a0e78e152e7cdef456dccb0bc9fc512faa18c90fb4ea5455a9535de89df987dea8a0fabce9a25c285d0c410d4b482')

# https://downloads.xiph.org/releases/opus/SHA256SUMS.txt
sha256sums=('b84610959b8d417b611aa12a22565e0a3732097c6389d19098d844543e340f85')

prepare() {
  ln -s opus-$pkgver opus
  cd opus
}

build() {
  local meson_options=(
    -D asm=disabled
    -D custom-modes=true
    -D enable-deep-plc=true
    -D enable-dred=true
    -D enable-osce=true
  )

  arch-meson opus build "${meson_options[@]}"
  meson compile -C build
}

check() {
  meson test -C build --print-errorlogs
}

package_opus() {
  provides=(libopus.so)

  meson install -C build --destdir "$pkgdir"
  install -Dt "$pkgdir/usr/share/aclocal" -m644 opus/opus.m4

  install -Dt "$pkgdir/usr/share/licenses/$pkgname" -m644 opus/COPYING

  mkdir -p doc/usr/share
  mv {"$pkgdir",doc}/usr/share/doc
}

package_opus-docs() {
  pkgdesc+=" (documentation)"
  depends=()

  mv doc/* "$pkgdir"
}

# vim:set sw=2 sts=-1 et:
