SUMMARY="A library to read and write images"
DESCRIPTION="OpenImageIO is a library for reading and writing images, and a \
bunch of related classes, utilities, and applications. There is a particular \
emphasis on formats and functionality used in professional, large-scale \
animation and visual effects work for film.
OpenImageIO is used extensively in animation and VFX studios all over the \
world, and is also incorporated into several commercial products."
HOMEPAGE="https://github.com/OpenImageIO/"
COPYRIGHT="2008-present Contributors to the OpenImageIO project."
LICENSE="BSD (3-clause)"
REVISION="1"
SOURCE_URI="$HOMEPAGE/oiio/archive/Release-$portVersion.tar.gz"
CHECKSUM_SHA256="d1a59f32dbba3ba71ad2e62e107034d1c5287bca1b0696474e927d504cd05ef4"
SOURCE_FILENAME="openimageio-$portVersion.tar.gz"
SOURCE_DIR="oiio-Release-$portVersion"
PATCHES="openimageio-$portVersion.patchset"

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

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

PROVIDES="
	openimageio$secondaryArchSuffix = $portVersion
	cmd:iconvert$secondaryArchSuffix
	cmd:idiff$secondaryArchSuffix
	cmd:igrep$secondaryArchSuffix
	cmd:iinfo$secondaryArchSuffix
	cmd:maketx$secondaryArchSuffix
	cmd:oiiotool$secondaryArchSuffix
	lib:libOpenImageIO$secondaryArchSuffix = $libVersionCompat
	lib:libOpenImageIO_Util$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libboost_atomic$secondaryArchSuffix
	lib:libboost_chrono$secondaryArchSuffix
	lib:libboost_date_time$secondaryArchSuffix
	lib:libboost_filesystem$secondaryArchSuffix
	lib:libboost_system$secondaryArchSuffix
	lib:libboost_thread$secondaryArchSuffix
	lib:libbz2$secondaryArchSuffix
	lib:libcrypto$secondaryArchSuffix
	lib:libfreetype$secondaryArchSuffix
	lib:libfmt$secondaryArchSuffix
	lib:libgif$secondaryArchSuffix
	lib:libglew$secondaryArchSuffix
	lib:libheif$secondaryArchSuffix
	lib:libIex_3_0$secondaryArchSuffix
	lib:libIlmThread_3_0$secondaryArchSuffix
	lib:libImath_3_0$secondaryArchSuffix
	lib:libjpeg$secondaryArchSuffix
	lib:libOpenColorIO$secondaryArchSuffix
	lib:libOpenEXR_3_0$secondaryArchSuffix
	lib:libOpenEXRUtil_3_0$secondaryArchSuffix
	lib:libpng16$secondaryArchSuffix
	lib:libpugixml$secondaryArchSuffix
	lib:libraw$secondaryArchSuffix
	lib:libssl$secondaryArchSuffix
	lib:libtiff$secondaryArchSuffix
	lib:libwebp$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	openimageio${secondaryArchSuffix}_devel = $portVersion
	devel:libOpenImageIO$secondaryArchSuffix = $libVersionCompat
	devel:libOpenImageIO_Util$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	openimageio$secondaryArchSuffix == $portVersion base
	devel:libboost_system$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libboost_system$secondaryArchSuffix >= 1.70.0
	devel:libbz2$secondaryArchSuffix
	devel:libcrypto$secondaryArchSuffix
	devel:libfreetype$secondaryArchSuffix
	devel:libfmt$secondaryArchSuffix
	devel:libgif$secondaryArchSuffix
	devel:libglew$secondaryArchSuffix
	devel:libheif$secondaryArchSuffix
	devel:libIex_3_0$secondaryArchSuffix
	devel:libIlmThread_3_0$secondaryArchSuffix
	devel:libImath_3_0$secondaryArchSuffix
	devel:libjpeg$secondaryArchSuffix
	devel:libOpenColorIO$secondaryArchSuffix
	devel:libOpenEXR_3_0$secondaryArchSuffix
	devel:libOpenEXRUtil_3_0$secondaryArchSuffix
	devel:libpng16$secondaryArchSuffix
	devel:libpugixml$secondaryArchSuffix
	devel:libraw$secondaryArchSuffix
	devel:libssl$secondaryArchSuffix
	devel:libtiff$secondaryArchSuffix
	devel:libwebp$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	devel:robin_map
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:python3
	"

defineDebugInfoPackage openimageio$secondaryArchSuffix \
	$binDir/iconvert \
	$binDir/idiff \
	$binDir/igrep \
	$binDir/iinfo \
	$binDir/maketx \
	$binDir/oiiotool \
	$libDir/libOpenImageIO.so.$libVersion \
	$libDir/libOpenImageIO_Util.so.$libVersion

BUILD()
{
	cmake -B build -S . \
		$cmakeDirArgs \
		-DUSE_PYTHON=OFF \
		-DUSE_EXTERNAL_PUGIXML=ON \
		-DOIIO_BUILD_TESTS=OFF \
		-DBUILD_TESTING=OFF
	make -C build $jobArgs
}

INSTALL()
{
	make -C build install

	prepareInstalledDevelLibs libOpenImageIO libOpenImageIO_Util
	fixPkgconfig

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

TEST()
{
	# tests fail (also previous version)
	# enable TESTS in BUILD to check this
	make -C build test
}
