SUMMARY="Library for encoding and decoding .avif files"
DESCRIPTION="This library aims to be a friendly, portable C implementation of \
the AV1 Image File Format, as described here: \
https://aomediacodec.github.io/av1-avif/
It is a work-in-progress, but can already encode and decode all AOM supported \
YUV formats and bit depths (with alpha).
For now, it is recommended that you checkout/use tagged releases instead of \
just using the master branch. I will regularly create new versions as \
bugfixes and features are added."
HOMEPAGE="https://github.com/AOMediaCodec/libavif"
COPYRIGHT="2019 Joe Drago"
LICENSE="BSD (2-clause)"
REVISION="1"
SOURCE_URI="https://github.com/AOMediaCodec/libavif/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="116b46a9a497c6ef178c5a20b912d8ac02f888dc8c537e40b5d16700823a9b16"
SOURCE_DIR="libavif-$portVersion"

ARCHITECTURES="all !x86_gcc2 ?x86 ?arm ?riscv64 ?sparc ?m68k"
SECONDARY_ARCHITECTURES="x86"

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

PROVIDES="
	libavif9$secondaryArchSuffix = $portVersion
	lib:libavif$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libdav1d$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libdav1d$secondaryArchSuffix >= 5
	devel:libz$secondaryArchSuffix
	devel:libpng16$secondaryArchSuffix
	devel:libjpeg$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:make
	"

BUILD()
{
	mkdir -p build && cd build
	cmake .. \
		-DCMAKE_BUILD_TYPE=Release \
		-DAVIF_BUILD_APPS=ON \
		-DAVIF_CODEC_DAV1D=ON \
		$cmakeDirArgs
	make $jobArgs
}

INSTALL()
{
	make -C build install

	prepareInstalledDevelLib libavif
	fixPkgconfig
	rm -rf $developDir
	rm -rf $binDir
}
