# Maintainer: David Runge <dvzrv@archlinux.org>

pkgname=roc-toolkit
pkgver=0.3.0
pkgrel=1
pkgdesc="Real-time audio streaming over the network"
arch=(x86_64 aarch64)
url="https://github.com/roc-streaming/roc-toolkit/"
license=(
  CC0-1.0
  MPL-2.0
)
depends=(
  glibc
  gcc-libs
  libunwind
  libuv
)
makedepends=(
  alsa-lib
  cpputest
  gengetopt
  libpulse
  openfec
  ragel
  scons
  sox
  speexdsp
)
optdepends=(
  'libpulse: for roc-conv, roc-receive and roc-send'
  'sox: for roc-conv, roc-receive and roc-send'
)
provides=(libroc.so)
source=($url/archive/v$pkgver/$pkgname-v$pkgver.tar.gz)
sha512sums=('447532862dc1714054ebd03ce7fd101525c213a87bc7198a55c8e6068c28db318d59389bafd83681a4e6b34a61e68ac305c66b84e417a3f791b02340a821e6ec')
b2sums=('31775d330bdfb3c42278d1ecbbbb5e14f695ca82f22929e435b6c9bf10c2e25c3367d11cf2913a81e6469876c255193be11eb78b775fad3b17f57c5be9c4bb39')

build() {
  local scons_options=(
    --prefix=/usr
    --libdir=/usr/lib
    --disable-openssl  # disable as it is not yet used
    --enable-tests
    --enable-examples
  )

  cd $pkgname-$pkgver
  scons "${scons_options[@]}"
}

check() {
  local scons_options=(
    --prefix=/usr
    --libdir=/usr/lib
    --disable-openssl  # disable as it is not yet used
    --enable-tests
    --enable-examples
  )

  cd $pkgname-$pkgver
  scons test "${scons_options[@]}"
}

package() {
  local scons_options=(
    --prefix=/usr
    --libdir=/usr/lib
  )
  depends+=(
    openfec libopenfec.so
    speexdsp libspeexdsp.so
  )

  cd $pkgname-$pkgver
  scons DESTDIR="$pkgdir/" "${scons_options[@]}" install

  install -vDm 644 3rdparty/hedley/COPYING -t "$pkgdir/usr/share/licenses/$pkgname/hedley.COPYING"
}
