SUMMARY="A new AV1 cross-platform decoder"
DESCRIPTION="dav1d is a new AV1 cross-platform decoder, open-source, \
and focused on speed and correctness. It supports all features from AV1, \
including all subsampling and bit-depth parameters."
HOMEPAGE="https://code.videolan.org/videolan/dav1d"
COPYRIGHT="2018-2019, VideoLAN and dav1d authors"
LICENSE="BSD (2-clause)"
REVISION="1"
SOURCE_URI="https://code.videolan.org/videolan/dav1d/-/archive/$portVersion/dav1d-$portVersion.tar.bz2"
CHECKSUM_SHA256="0d198c4fe63fe7f0395b1b17de75b21c8c4508cd3204996229355759efa30ef8"

ARCHITECTURES="all !x86_gcc2 ?x86 ?arm ?ppc"
SECONDARY_ARCHITECTURES="x86"

commandBinDir=$binDir
commandSuffix=$secondaryArchSuffix
if [ "$targetArchitecture" = x86_gcc2 ]; then
	commandSuffix=
	commandBinDir=$prefix/bin
fi

libVersion="5.1.1"
libVersionCompat="$libVersion compat >= ${libVersion%%.*}"

PROVIDES="
	dav1d$secondaryArchSuffix = $portVersion
	cmd:dav1d$commandSuffix
	lib:libdav1d$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

PROVIDES_devel="
	dav1d${secondaryArchSuffix}_devel = $portVersion
	devel:libdav1d$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	dav1d$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:gcc$secondaryArchSuffix
	cmd:meson >= 0.49
	cmd:nasm >= 2.13.02
	cmd:ninja
	"

defineDebugInfoPackage dav1d$secondaryArchSuffix \
	"$libDir"/libdav1d.so.$libVersion

BUILD()
{
	unset -f meson
	meson build \
		--buildtype debugoptimized \
		--prefix $prefix \
		--bindir $commandBinDir \
		--libdir $libDir \
		--includedir $includeDir
	ninja -C build $jobArgs
}

INSTALL()
{
	ninja -C build install

	prepareInstalledDevelLib libdav1d
	fixPkgconfig
	packageEntries devel $developDir
}

TEST()
{
	ninja -C build test
}
