SUMMARY="A high dynamic-range (HDR) image file format"
DESCRIPTION="OpenEXR is a high dynamic-range (HDR) image file format developed \
by Industrial Light & Magic for use in computer imaging applications. OpenEXR \
is used by ILM on all motion pictures currently in production. The first \
movies to employ OpenEXR were Harry Potter and the Sorcerers Stone, Men in \
Black II, Gangs of New York, and Signs. Since then, OpenEXR has become ILM's \
main image file format."
HOMEPAGE="https://www.openexr.com/"
COPYRIGHT="Contributors to the OpenEXR Project."
LICENSE="BSD (3-clause)"
REVISION="1"
SOURCE_URI="https://github.com/AcademySoftwareFoundation/openexr/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="7aa6645da70e9a0cce8215d25030cfd4f4b17b4abf1ceec314f7eae15674e8e4"
SOURCE_FILENAME="openexr-$portVersion.tar.gz"
SOURCE_DIR="openexr-$portVersion"
PATCHES="openexr-$portVersion.patchset"

ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="x86"

libVersion="29.0.0"
libVersionCompat="$libVersion compat >= ${libVersion%%.*}"
libImathVersion="28.0.2"
libImathVersionCompat="$libImathVersion compat >= ${libImathVersion%%.*}"

PROVIDES="
	openexr30$secondaryArchSuffix = $portVersion
	lib:libIex_3_0$secondaryArchSuffix = $libVersionCompat
	lib:libIlmThread_3_0$secondaryArchSuffix = $libVersionCompat
	lib:libImath_3_0$secondaryArchSuffix = $libImathVersionCompat
	lib:libOpenEXR_3_0$secondaryArchSuffix = $libVersionCompat
	lib:libOpenEXRUtil_3_0$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"
CONFLICTS="
	ilmbase$secondaryArchSuffix
	"

PROVIDES_tools="
	openexr30${secondaryArchSuffix}_tools = $portVersion
	cmd:exr2aces$secondaryArchSuffix = $portVersion
	cmd:exrenvmap$secondaryArchSuffix = $portVersion
	cmd:exrheader$secondaryArchSuffix = $portVersion
	cmd:exrmakepreview$secondaryArchSuffix = $portVersion
	cmd:exrmaketiled$secondaryArchSuffix = $portVersion
	cmd:exrmultipart$secondaryArchSuffix = $portVersion
	cmd:exrmultiview$secondaryArchSuffix = $portVersion
	cmd:exrstdattr$secondaryArchSuffix = $portVersion
	"
REQUIRES_tools="
	$REQUIRES
	openexr30$secondaryArchSuffix == $portVersion base
	"

PROVIDES_devel="
	openexr30${secondaryArchSuffix}_devel = $portVersion
	devel:libIex_3_0$secondaryArchSuffix = $libVersionCompat
	devel:libIlmThread_3_0$secondaryArchSuffix = $libVersionCompat
	devel:libImath_3_0$secondaryArchSuffix = $libImathVersionCompat
	devel:libOpenEXR_3_0$secondaryArchSuffix = $libVersionCompat
	devel:libOpenEXRUtil_3_0$secondaryArchSuffix = $libVersionCompat
	devel:libIex$secondaryArchSuffix = $libVersionCompat
	devel:libIlmThread$secondaryArchSuffix = $libVersionCompat
	devel:libImath$secondaryArchSuffix = $libImathVersionCompat
	devel:libOpenEXR$secondaryArchSuffix = $libVersionCompat
	devel:libOpenEXRUtil$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	openexr30$secondaryArchSuffix == $portVersion base
	"
CONFLICTS_devel="
	openexr${secondaryArchSuffix}_devel
	openexr25${secondaryArchSuffix}_devel
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:git
	cmd:ld$secondaryArchSuffix
	cmd:make
	"

BUILD()
{
	cmake -B build -S . \
		$cmakeDirArgs \
		-DCMAKE_BUILD_TYPE=Release
	make -C build $jobArgs
}

INSTALL()
{
	make -C build install

	mkdir -p $developDocDir
	mv $docDir/* $developDocDir
	rm -rf $docDir

	packageEntries tools $binDir

	# prepare development lib links
	prepareInstalledDevelLibs \
		libIex-3_0 libIlmThread-3_0 libImath-3_0 \
		libOpenEXR-3_0 libOpenEXRUtil-3_0 \
		libIex libIlmThread libImath libOpenEXR libOpenEXRUtil
	fixPkgconfig

	# devel package
	packageEntries devel $developDir $libDir/cmake
}

TEST()
{
	# most of the tests fail
	make -C build test
}
