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="4"
SOURCE_URI="https://github.com/imageworks/OpenColorIO/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="c9b5b9def907e1dafb29e37336b702fff22cc6306d445a13b1621b8a754c14c8"
SOURCE_FILENAME="opencolorio-$portVersion.tar.gz"
SOURCE_DIR="OpenColorIO-$portVersion"
PATCHES="opencolorio1-$portVersion.patchset"

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

PROVIDES="
	opencolorio$secondaryArchSuffix = $portVersion compat >= 1
	cmd:ociobakelut$secondaryArchSuffix
	cmd:ociocheck$secondaryArchSuffix
	lib:libopencolorio$secondaryArchSuffix = $portVersion compat >= 1
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:liblcms2$secondaryArchSuffix
	lib:libtinyxml$secondaryArchSuffix
	"

PROVIDES_devel="
	opencolorio${secondaryArchSuffix}_devel = $portVersion compat >= 1
	devel:libopencolorio$secondaryArchSuffix = $portVersion compat >= 1
	"
REQUIRES_devel="
	opencolorio$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libboost_system$secondaryArchSuffix >= 1.69.0
	devel:liblcms2$secondaryArchSuffix
	devel:libtinyxml$secondaryArchSuffix
	devel:libyaml_cpp$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make
	cmd:patch
	cmd:pkg_config$secondaryArchSuffix
	"

BUILD()
{
	cmake . -DCMAKE_BUILD_TYPE=Release \
		-DOCIO_BUILD_NUKE=OFF \
		-DOCIO_BUILD_STATIC=OFF \
		-DOCIO_BUILD_SHARED=ON \
		-DUSE_EXTERNAL_LCMS=ON \
		-DUSE_EXTERNAL_TINYXML=ON \
		-DUSE_EXTERNAL_YAML=ON \
		-DCMAKE_INSTALL_PREFIX:PATH=$prefix/build
	make $jobArgs
}

INSTALL()
{
	make install

	mkdir -p $binDir $includeDir $libDir
	mv $prefix/build/include/* $includeDir
	mv $prefix/build/lib/* $libDir
	mv $prefix/build/bin/* $binDir
	rm -rf $prefix/build

	sed -i "s|^\(prefix=\).*|\1$prefix|" $libDir/pkgconfig/OpenColorIO.pc
	sed -i "s|^\(exec_prefix=\).*|\1$prefix|" $libDir/pkgconfig/OpenColorIO.pc

	prepareInstalledDevelLibs libOpenColorIO
	fixPkgconfig

	# devel package
	packageEntries devel \
		$developDir
}
