# Contributor: Oleg Titov <oleg.titov@gmail.com>
# Maintainer: Oleg Titov <oleg.titov@gmail.com>
pkgname=svt-av1
pkgver=2.2.1
pkgrel=0
pkgdesc="Scalable Vector Technology for AV1 encoder (SVT-AV1 Encoder)"
url="https://gitlab.com/AOMediaCodec/SVT-AV1"
# 32-bit is not supported upstream
# https://gitlab.com/AOMediaCodec/SVT-AV1/-/blob/master/CMakeLists.txt#L40
arch="all !x86 !armhf !armv7"
license="BSD-3-Clause-Clear"
options="!check" # No test suite from upstream
makedepends="cmake samurai nasm"
subpackages="
	$pkgname-dev
	libSvtAv1Enc:enclib
	"
source="https://gitlab.com/AOMediaCodec/SVT-AV1/-/archive/v$pkgver/SVT-AV1-v$pkgver.tar.bz2"
builddir="$srcdir/SVT-AV1-v$pkgver"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	export LDFLAGS="$LDFLAGS -Wl,-z,stack-size=1048576"
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=Release \
		$CMAKE_CROSSOPTS .
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

enclib() {
	amove usr/lib/libSvtAv1Enc.so.*
}

sha512sums="
4e0b92ae49b31da0e77ece7bf037b1ef7a040df9103a9ceea2cd54d1a28a7c878b439fdec95a778c584d29a3a32eff779aa7550cc9b7fb68b47e5aba42d44435  SVT-AV1-v2.2.1.tar.bz2
"
