# Template file for 'libaom'
pkgname=libaom
version=3.5.0
revision=1
create_wrksrc=yes
build_style=cmake
configure_args="-DENABLE_DOCS=OFF -DBUILD_SHARED_LIBS=ON"
hostmakedepends="yasm doxygen perl"
short_desc="AV1 Codec library implementation"
maintainer="Orphaned <orphan@voidlinux.org>"
license="BSD-2-Clause"
homepage="https://aomedia.org/"
changelog="https://aomedia.googlesource.com/aom/+/master/CHANGELOG"
distfiles="https://aomedia.googlesource.com/aom/+archive/v${version}.tar.gz"
# unstable checksum use content hash
checksum=@adedcb16f6c8e8d82b530c271f2186fb1f9a2d0eebc105c949f9fbecf18a37fa

make_check=ci-skip # takes a lot of time

# aom segfaults with default musl stack size
LDFLAGS="-Wl,-z,stack-size=2097152"

case "$XBPS_TARGET_MACHINE" in
	# no runtime detection
	arm*) configure_args+=" -DENABLE_NEON=0" ;;
	ppc64le*) ;;
	ppc*) configure_args+=" -DENABLE_VSX=0" ;;
esac

if [ -z "$XBPS_CHECK_PKGS" ]; then
	configure_args+=" -DENABLE_TESTS=OFF"
fi

pre_check() {
	export LIBAOM_TEST_DATA_PATH=/host/libaom-test-data
	mkdir -p $LIBAOM_TEST_DATA_PATH
}

do_check() {
	cd build
	ninja ${makejobs} testdata
	../test/examples.sh --bin-path "$PWD"
	if [ "$XBPS_CHECK_PKGS" = full ]; then
		ninja ${makejobs} runtests
	fi
}

post_install() {
	vlicense LICENSE
}

libaom-devel_package() {
	depends="libaom-${version}_${revision}"
	short_desc+=" - development files"
	pkg_install() {
		vmove usr/include
		vmove usr/lib/pkgconfig
		vmove "usr/lib/*.so"
		vmove "usr/lib/*.a"
	}
}

libaom-tools_package() {
	short_desc+=" - utilities for enconding and decoding AV1"
	pkg_install() {
		vmove usr/bin/aomdec
		vmove usr/bin/aomenc
	}
}
