# Contributor: Bart Ribbers <bribbers@disroot.org>
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=roc-toolkit
pkgver=0.4.0
pkgrel=1
pkgdesc="Real-time audio streaming over the network"
url="https://roc-streaming.org/"
arch="all"
license="MPL-2.0"
depends_dev="
	libsndfile-dev
	libunwind-dev
	libuv-dev
	openssl-dev
	speexdsp-dev
	"
makedepends="
	$depends_dev
	cpputest
	gengetopt
	ragel
	scons
	cmake
	"
checkdepends="python3"
subpackages="$pkgname-libs $pkgname-dev $pkgname-doc"
source="https://github.com/roc-streaming/roc-toolkit/archive/v$pkgver/roc-toolkit-$pkgver.tar.gz"
options="net" # Required for tests

case $CARCH in
	# CHECK(backend_device != NULL) failed
	# https://github.com/roc-streaming/roc-toolkit/issues/744
	s390x) options="$options !check" ;;
esac

_run_scons() {
	scons \
		--prefix=/usr \
		--with-libraries=/usr/lib \
		--enable-tests \
		--disable-sox \
		--build-3rdparty=openfec \
		--disable-pulseaudio \
		"$@"
}

build() {
	export CFLAGS="$CFLAGS -O2 -flto=auto"
	export CXXFLAGS="$CXXFLAGS -O2 -flto=auto"
	_run_scons
}

check() {
	_run_scons test
}

package() {
	export DESTDIR="$pkgdir"
	_run_scons install
}

sha512sums="
51763287ee825b6617273ededd9e77560f4223b8ba4a577855c3225908e848895a4f925163862cf6d19a8215245ec26f33d07d6cb80c51768d37eaa06ac02063  roc-toolkit-0.4.0.tar.gz
"
