SUMMARY="An open framework for storing and sharing scene data"
DESCRIPTION="Alembic is an open computer graphics interchange framework. \
Alembic distills complex, animated scenes into a non-procedural, \
application-independent set of baked geometric results. This \'distillation\' \
of scenes into baked geometry is exactly analogous to the distillation of \
lighting and rendering scenes into rendered image data."
HOMEPAGE="http://www.alembic.io/"
COPYRIGHT="2009-2016 Sony Pictures Imageworks
	2009-2016 Industrial Light and Magic
	2010-2012 Christopher Horvath
	2011-2012 Luxology LLC
	2011-2013 Autodesk, Inc.
	2011-2018 Side Effects Software Inc.
	2011-2013 Mark Elendt, Senior Mathematician, Side Effects Software Inc.
	2011-2013 Nicholas Yue
	2011 Fabric Engine, Inc.
	2011 Luma Pictures
	2012 Solid Angle S.L.
	2012 Zhicheng YE
	2013 Digital Domain 3.0, Inc.
	2016-2018 Tim Yanalunas
	2016-2018 Blizzard Entertainment, Inc.
	2018 J Cube, Inc."
LICENSE="ALEMBIC"
REVISION="1"
SOURCE_URI="https://github.com/alembic/alembic/archive/$portVersion.tar.gz"
CHECKSUM_SHA256="b0bc74833bff118a869e81e6acb810a58797e77ef63143954b2f8e817c7f65cb"
SOURCE_FILENAME="alembic-$portVersion.tar.gz"
PATCHES="alembic-$portVersion.patchset"

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

commandBinDir=$binDir
if [ "$targetArchitecture" = x86_gcc2 ]; then
	commandBinDir=$prefix/bin
fi

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

PROVIDES="
	alembic$secondaryArchSuffix = $portVersion
	cmd:abcconvert
	cmd:abcdiff
	cmd:abcecho
	cmd:abcechobounds
	cmd:abcls
	cmd:abcstitcher
	cmd:abctree
	lib:libalembic$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libboost_program_options$secondaryArchSuffix
	lib:libhdf5$secondaryArchSuffix
	lib:libIex_3_0$secondaryArchSuffix
	lib:libIlmThread_3_0$secondaryArchSuffix
	lib:libImath_3_0$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	alembic${secondaryArchSuffix}_devel = $portVersion
	devel:libalembic$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	alembic$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libboost_program_options$secondaryArchSuffix
	devel:libhdf5$secondaryArchSuffix
	devel:libIlmThread_3_0$secondaryArchSuffix
	devel:libImath_3_0$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

defineDebugInfoPackage alembic$secondaryArchSuffix \
	$libDir/libAlembic.so.$portVersion \
	$commandBinDir/abcconvert \
	$commandBinDir/abcdiff \
	$commandBinDir/abcecho \
	$commandBinDir/abcechobounds \
	$commandBinDir/abcls \
	$commandBinDir/abcstitcher \
	$commandBinDir/abctree

PATCH()
{
	if [ -n "$secondaryArchSuffix" ]; then
		sed -i \
			-e "s|\(DESTINATION\) lib|\1 $relativeLibDir|;" \
			-e "s|\(ConfigPackageLocation\) lib/cmake/|\1 $relativeLibDir/cmake/|;" \
			lib/Alembic/CMakeLists.txt
	fi
}

BUILD()
{
	mkdir -p build
	cd build

	export ILMBASE_INC_DIR="`finddir B_SYSTEM_DIRECTORY`/$relativeIncludeDir/OpenEXR"

	cmake .. \
		-DCMAKE_BUILD_TYPE=Release \
		-DUSE_HDF5=ON \
		-DALEMBIC_LIB_USES_BOOST=ON \
		$cmakeDirArgs

	make $jobArgs
}

INSTALL()
{
	cd build
	make install

	mkdir -p $includeDir
	mv $prefix/include/* $includeDir/
	rm -rf $prefix/include
	mv $prefix/lib $prefix/lib2
	mkdir -p $libDir/cmake
	mv $prefix/lib2/* $libDir
	rm -rf $prefix/lib2

	prepareInstalledDevelLib libAlembic

	fixPkgconfig

	packageEntries devel \
		$developDir \
		$libDir/cmake
}

TEST()
{
	cd build
	make test
}
