# Template file for 'libavif'
pkgname=libavif
version=1.4.2
revision=1
build_wrksrc="${pkgname}-${version}"
build_style=cmake
configure_args="-DAVIF_BUILD_APPS=ON -DAVIF_BUILD_GDK_PIXBUF=ON
 -DAVIF_LIBYUV=OFF -DAVIF_CODEC_AOM=SYSTEM -DAVIF_LIBXML2=SYSTEM
 $(vopt_if dav1d -DAVIF_CODEC_DAV1D=SYSTEM) $(vopt_if rav1e -DAVIF_CODEC_RAV1E=SYSTEM)
 $(vopt_if svt -DAVIF_CODEC_SVT=SYSTEM)"
hostmakedepends="gdk-pixbuf-devel pkg-config"
_devdepends="libaom-devel $(vopt_if dav1d "libdav1d-devel")
 $(vopt_if rav1e "rav1e-devel") $(vopt_if svt "libsvt-av1-devel")"
makedepends="gdk-pixbuf-devel libxml2-devel libsharpyuv-devel libjpeg-turbo-devel
 libpng-devel zlib-devel ${_devdepends}"
short_desc="Library for encoding and decoding .avif files"
maintainer="Leah Neukirchen <leah@vuxu.org>"
license="BSD-2-Clause"
homepage="https://github.com/AOMediaCodec/libavif"
changelog="https://raw.githubusercontent.com/AOMediaCodec/libavif/main/CHANGELOG.md"
distfiles="https://github.com/AOMediaCodec/libavif/archive/refs/tags/v${version}.tar.gz
 https://github.com/kmurray/libargparse/archive/ee74d1b53bd680748af14e737378de57e2a0a954.tar.gz>libargparse.tar.gz"
checksum="2b645287340ba5a631d268b551dc2d72bd73ac33335962dd36dcdb6d8366921d
 7727b0498851e5b6a6fcd734eb667a8a231897e2c86a357aec51cc0664813060"

build_options="dav1d rav1e svt"
build_options_default="dav1d rav1e"

desc_option_dav1d="Enable support for DAV1D decoder"
desc_option_rav1e="Enable support for RAV1E encoder"
desc_option_svt="Enable support for SVT-AV1 encoder (64-bit only)"

if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
	build_options_default+=" svt"
fi

post_extract() {
	mv libargparse-* ${build_wrksrc}/ext/libargparse
}

post_install() {
	vlicense LICENSE
}

libavif-devel_package() {
	short_desc+=" - development files"
	depends="${sourcepkg}>=${version}_${revision} ${_devdepends}"
	pkg_install() {
		vmove usr/include
		vmove "usr/lib/*.so"
		vmove usr/lib/pkgconfig
		vmove usr/lib/cmake
	}
}
