SUMMARY="A color management framework for visual effects and animation"
DESCRIPTION="OpenColorIO (OCIO) is a complete color management solution \
geared towards motion picture production with an emphasis on visual effects \
and computer animation.
OCIO provides a straightforward and consistent user experience \
across all supporting applications while allowing for sophisticated back-end \
configuration options suitable for high-end production usage. OCIO is \
compatible with the Academy Color Encoding Specification (ACES) and is \
LUT-format agnostic, supporting many popular formats."
HOMEPAGE="https://opencolorio.org/"
COPYRIGHT="2003-2010 Sony Pictures Imageworks Inc., et al."
LICENSE="BSD (3-clause)"
REVISION="3"
SOURCE_URI="https://github.com/imageworks/OpenColorIO/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="ff1397b4516fdecd75096d5b575d6a23771d0c876bbcfc7beb5a82af37adcdf9"
SOURCE_FILENAME="opencolorio-$portVersion.tar.gz"
SOURCE_DIR="OpenColorIO-$portVersion"
PATCHES="opencolorio-openexr3.patch
	opencolorio-2.0.1.patchset"

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

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

PROVIDES="
	opencolorio$secondaryArchSuffix = $portVersion
#	cmd:ociobakelut$secondaryArchSuffix
#	cmd:ociocheck$secondaryArchSuffix
	lib:libOpenColorIO$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libexpat$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libGLu$secondaryArchSuffix
	lib:libglew$secondaryArchSuffix
	lib:libIex_3_0$secondaryArchSuffix
	lib:libIlmThread_3_0$secondaryArchSuffix
	lib:libImath_3_0$secondaryArchSuffix
	lib:liblcms2$secondaryArchSuffix
	lib:libOpenEXR_3_0$secondaryArchSuffix
	lib:libOpenEXRUtil_3_0$secondaryArchSuffix
	lib:libpystring$secondaryArchSuffix
	lib:libtinyxml$secondaryArchSuffix
	lib:libyaml_cpp$secondaryArchSuffix
	"

PROVIDES_devel="
	opencolorio${secondaryArchSuffix}_devel = $portVersion
	devel:libOpenColorIO$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	opencolorio$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libboost_system$secondaryArchSuffix >= 1.70.0
	devel:libexpat$secondaryArchSuffix
	devel:libGL$secondaryArchSuffix
	devel:libGLU$secondaryArchSuffix
	devel:libglew$secondaryArchSuffix >= 2.2
	devel:libIex_3_0$secondaryArchSuffix
	devel:libIlmThread_3_0$secondaryArchSuffix
	devel:libImath_3_0$secondaryArchSuffix
	devel:liblcms2$secondaryArchSuffix
	devel:libOpenEXR_3_0$secondaryArchSuffix
	devel:libOpenEXRUtil_3_0$secondaryArchSuffix
	devel:libpystring$secondaryArchSuffix
	devel:libtinyxml$secondaryArchSuffix
	devel:libyaml_cpp$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:git
	cmd:ld$secondaryArchSuffix
	cmd:make
	cmd:patch
	cmd:pkg_config$secondaryArchSuffix
	cmd:python3.7
	"

if [ "$targetArchitecture" != x86_gcc2 ]; then
	USE_SSE=ON
else
	USE_SSE=OFF
fi

BUILD()
{
	# build doesn't respect $cmakeDirArgs (known issue)
	cmake -B build -S . \
		-DCMAKE_BUILD_TYPE=Release \
		-DCMAKE_INSTALL_PREFIX=$prefix \
		-DCMAKE_INSTALL_BINDIR=$binDir \
		-DCMAKE_INSTALL_DATADIR=$dataDir \
		-DCMAKE_INSTALL_LIBDIR=$libDir \
		-DCMAKE_INSTALL_INCLUDEDIR=$includeDir \
		-DBUILD_SHARED_LIBS=ON \
		-DOCIO_BUILD_APPS=OFF \
		-DOCIO_BUILD_GPU_TESTS=OFF \
		-DOCIO_BUILD_PYTHON=OFF \
		-DOCIO_BUILD_TESTS=OFF \
		-DOCIO_USE_SSE=$USE_SSE
	make -C build $jobArgs
}


INSTALL()
{
	make -C build install

	prepareInstalledDevelLib libOpenColorIO
	fixPkgconfig

	# devel package
	packageEntries devel \
		$developDir
}
