summaryrefslogtreecommitdiff
path: root/media-libs/libjxl/libjxl-9999.ebuild
blob: abad6a9afeda3a2b0ea54c00150d4617a194dbc0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# Copyright 2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

CMAKE_ECLASS=cmake
inherit cmake-multilib java-pkg-opt-2 xdg-utils

DESCRIPTION="JPEG XL image format reference implementation"
HOMEPAGE="https://github.com/libjxl/libjxl"

if [[ ${PV} == 9999 ]]; then
	inherit git-r3
	EGIT_REPO_URI="https://github.com/libjxl/libjxl.git"
	EGIT_SUBMODULES=(third_party/lodepng third_party/skcms)
else
	LODEPNG_COMMIT="8c6a9e30576f07bf470ad6f09458a2dcd7a6a84a"
	SKCMS_COMMIT="64374756e03700d649f897dbd98c95e78c30c7da"
	SRC_URI="
		https://github.com/libjxl/libjxl/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz
		https://github.com/lvandeve/lodepng/archive/${LODEPNG_COMMIT}.tar.gz -> lodepng-${LODEPNG_COMMIT}.tar.gz
		https://skia.googlesource.com/skcms/+archive/${SKCMS_COMMIT}.tar.gz -> skcms-${SKCMS_COMMIT}.tar.gz
	"
fi

LICENSE="Apache-2.0"
SLOT="0/7"
if [[ ${PV} != 9999 ]]; then
	KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~riscv ~sparc ~x86 ~amd64-linux ~x86-linux"
fi
IUSE="apng doc gdk-pixbuf gif gimp java +jpeg +man openexr static-libs test +tools viewers"

RDEPEND="app-arch/brotli[${MULTILIB_USEDEP}]
	dev-cpp/highway[${MULTILIB_USEDEP}]
	apng? (
		media-libs/libpng[${MULTILIB_USEDEP}]
		sys-libs/zlib[${MULTILIB_USEDEP}]
	)
	gdk-pixbuf? ( x11-libs/gdk-pixbuf )
	gif? ( media-libs/giflib[${MULTILIB_USEDEP}] )
	gimp? ( media-gfx/gimp:0/2 )
	java? ( >=virtual/jre-1.8:* )
	jpeg? ( virtual/jpeg[${MULTILIB_USEDEP}] )
	openexr? ( media-libs/openexr:= )
	viewers? (
		dev-qt/qtwidgets
		dev-qt/qtx11extras
	)
"
BDEPEND="
	doc? ( app-doc/doxygen )
	man? ( app-text/asciidoc )
	viewers? ( kde-frameworks/extra-cmake-modules )
"
DEPEND="${RDEPEND}
	test? ( dev-cpp/gtest[${MULTILIB_USEDEP}] )
	java? ( >=virtual/jdk-1.8:* )
"

src_prepare() {
	if [[ ${PV} != 9999 ]]; then
		rmdir third_party/lodepng
		ln -sv ../../lodepng-${LODEPNG_COMMIT} third_party/lodepng || die
	fi
	use gdk-pixbuf || sed -i -e '/(gdk-pixbuf)/s/^/#/' plugins/CMakeLists.txt || die
	use gimp || sed -i -e '/(gimp)/s/^/#/' plugins/CMakeLists.txt || die
	cmake_src_prepare
	java-pkg-opt-2_src_prepare
}

multilib_src_configure() {
	local mycmakeargs=(
		-DBUILD_TESTING=$(usex test ON OFF)
		-DJPEGXL_ENABLE_BENCHMARK=OFF
		-DJPEGXL_ENABLE_COVERAGE=OFF
		-DJPEGXL_ENABLE_EXAMPLES=OFF
		-DJPEGXL_ENABLE_FUZZERS=OFF
		-DJPEGXL_ENABLE_TOOLS=$(multilib_native_usex tools)
		-DJPEGXL_ENABLE_JNI=$(multilib_native_usex java)
		-DJPEGXL_ENABLE_MANPAGES=$(multilib_native_usex man)
		-DJPEGXL_ENABLE_OPENEXR=$(multilib_native_usex openexr)
		-DJPEGXL_ENABLE_PLUGINS=$(multilib_is_native_abi && echo ON || echo OFF) # USE=gdk-pixbuf, USE=gimp handled in src_prepare
		-DJPEGXL_ENABLE_SJPEG=OFF
		-DJPEGXL_ENABLE_SKCMS=ON
		-DJPEGXL_ENABLE_TCMALLOC=OFF
		-DJPEGXL_ENABLE_VIEWERS=$(multilib_native_usex viewers)

		-DCMAKE_DISABLE_FIND_PACKAGE_PNG=$(multilib_native_usex apng OFF ON)
		-DCMAKE_DISABLE_FIND_PACKAGE_Doxygen=$(multilib_native_usex doc OFF ON)
		-DCMAKE_DISABLE_FIND_PACKAGE_GIF=$(multilib_native_usex gif OFF ON)
		-DCMAKE_DISABLE_FIND_PACKAGE_JPEG=$(multilib_native_usex jpeg OFF ON)
	)

	cmake_src_configure
}

multilib_src_install() {
	cmake_src_install
	if ! use static-libs; then
		rm "${ED}"/usr/lib*/*.a || die
	fi
	if use java && multilib_is_native_abi; then
		java-pkg_doso tools/libjxl_jni.so
	fi
}

pkg_postinst() {
	xdg_mimeinfo_database_update
}