# Template file for 'libjxl'
pkgname=libjxl
version=0.10.3
revision=2
_testdata_hash=ff8d743aaba05b3014f17e5475e576242fa979fc
build_style=cmake
configure_args="-DJPEGXL_ENABLE_BENCHMARK=OFF -DJPEGXL_ENABLE_EXAMPLES=OFF
 -DJPEGXL_ENABLE_SJPEG=OFF -DJPEGXL_ENABLE_PLUGINS=ON -DJPEGXL_VERSION=${version}
 -DJPEGXL_ENABLE_SKCMS=OFF"
hostmakedepends="tar pkg-config asciidoc"
makedepends="brotli-devel highway-devel libpng-devel giflib-devel libjpeg-turbo-devel
 libopenexr-devel libwebp-devel gdk-pixbuf-devel gimp-devel lcms2-devel"
checkdepends="gtest-devel xdg-utils"
short_desc="JPEG XL image format reference implementation"
maintainer="Joshua Krämer <joshua@kraemer.link>"
license="BSD-3-Clause, custom:Patent grant"
homepage="https://jpeg.org/jpegxl/"
changelog="https://raw.githubusercontent.com/libjxl/libjxl/main/CHANGELOG.md"
distfiles="https://github.com/libjxl/libjxl/archive/v${version}.tar.gz
 https://github.com/libjxl/testdata/archive/${_testdata_hash}.tar.gz>testdata-${_testdata_hash}.tar.gz"
checksum="e0191411cfcd927eebe5392d030fe4283fe27ba1685ab7265104936e0b4283a6
 9c45a108df32a002a69465df896d33acf77d97c88fb59dffa0dff5628370e96f"
skip_extraction="testdata-${_testdata_hash}.tar.gz"

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

post_extract() {
	vsrcextract -C testdata "testdata-${_testdata_hash}.tar.gz"
}

post_install() {
	vlicense LICENSE
	vlicense PATENTS
}

post_install() {
	# Remove devel symlink for internal library only used for tools. (headers don't get installed)
	rm ${DESTDIR}/usr/lib/libjxl_extras_codec.so
}

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

libjxl-tools_package() {
	short_desc+=" - tools"
	pkg_install() {
		vmove "usr/lib/libjxl_extras_codec*"
		vmove usr/bin
		vmove usr/share/man/man1
	}
}

libjxl-plugins_package() {
	short_desc+=" - plugins"
	depends="desktop-file-utils"
	pkg_install() {
		vmove usr/lib/gdk-pixbuf-2.0
		vmove usr/lib/gimp
		vmove usr/share/mime
		vmove usr/share/thumbnailers
	}
}
