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-2017 Larry Gritz et al."
LICENSE="BSD (3-clause)"
REVISION="4"
SOURCE_URI="$HOMEPAGE/oiio/archive/Release-$portVersion.tar.gz"
CHECKSUM_SHA256="669c59d06399dd882c3e2469bb3a4b33d537db150f6fe056495c3429b5c3838f"
SOURCE_FILENAME="openimageio-$portVersion.tar.gz"
SOURCE_DIR="oiio-Release-$portVersion"
PATCHES="openimageio-$portVersion.patchset"

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

PROVIDES="
	openimageio$secondaryArchSuffix = $portVersion
	cmd:iconvert
	cmd:idiff
	cmd:igrep
	cmd:iinfo
	cmd:maketx
	cmd:oiiotool
	lib:libopenimageio$secondaryArchSuffix = $portVersion compat >= 1.8
	lib:libopenimageio_util$secondaryArchSuffix = $portVersion compat >= 1.8
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libboost_atomic$secondaryArchSuffix
	lib:libboost_chrono$secondaryArchSuffix
	lib:libboost_date_time$secondaryArchSuffix
	lib:libboost_filesystem$secondaryArchSuffix
	lib:libboost_regex$secondaryArchSuffix
	lib:libboost_system$secondaryArchSuffix
	lib:libboost_thread$secondaryArchSuffix
	lib:libbz2$secondaryArchSuffix
	lib:libcrypto$secondaryArchSuffix
	lib:libfreetype$secondaryArchSuffix
	lib:libgif$secondaryArchSuffix
	lib:libglew$secondaryArchSuffix
	lib:libhalf$secondaryArchSuffix
	lib:libilmimf$secondaryArchSuffix
	lib:libjpeg$secondaryArchSuffix
	lib:libopencolorio$secondaryArchSuffix
	lib:libpng16$secondaryArchSuffix
	lib:libssl$secondaryArchSuffix #yeah, really
	lib:libtiff$secondaryArchSuffix
	lib:libwebp$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	openimageio${secondaryArchSuffix}_devel = $portVersion
	devel:libopenimageio$secondaryArchSuffix = $portVersion compat >= 1.8
	devel:libopenimageio_util$secondaryArchSuffix = $portVersion compat >= 1.8
	"
REQUIRES_devel="
	openimageio$secondaryArchSuffix == $portVersion base
	devel:libboost_system$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libboost_system$secondaryArchSuffix
	devel:libbz2$secondaryArchSuffix
	devel:libcrypto$secondaryArchSuffix
	devel:libfreetype$secondaryArchSuffix
	devel:libgif$secondaryArchSuffix
	devel:libglew$secondaryArchSuffix
	devel:libhalf$secondaryArchSuffix
	devel:libilmimf$secondaryArchSuffix
	devel:libjpeg$secondaryArchSuffix
	devel:libopencolorio$secondaryArchSuffix
	devel:libpng16$secondaryArchSuffix
	devel:libssl$secondaryArchSuffix
	devel:libtiff$secondaryArchSuffix
	devel:libwebp$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make
	"

BUILD()
{
	mkdir -p build
	cd build
	cmake .. \
		-DUSE_OPENSSL=ON \
		-DUSE_PYTHON=OFF \
		-DCMAKE_CXX_FLAGS="-DBOOST_NO_CXX11_CONSTEXPR" \
		-DDOC_INSTALL_DIR=$docDir \
		-DFONTS_INSTALL_DIR="$fontsDir/ttfonts" \
		-DINCLUDE_INSTALL_DIR=$includeDir \
		-DMAN_INSTALL_DIR=$manDir \
		$cmakeDirArgs
	make $jobArgs
}

INSTALL()
{
	cd build
	make install

	prepareInstalledDevelLibs libOpenImageIO libOpenImageIO_Util
	fixPkgconfig

	# devel package
	packageEntries devel \
		$developDir
}
