SUMMARY="A stream based reader and writer library for COLLADA files"
DESCRIPTION="COLLADA defines an open standard XML schema for exchanging \
digital assets among various graphics software applications that might \
otherwise store their assets in incompatible file formats. COLLADA documents \
that describe digital assets are XML files, usually identified with a .dae \
(digital asset exchange) filename extension."
HOMEPAGE="http://www.opencollada.org/"
COPYRIGHT="2013 The Khronos Group Inc."
LICENSE="MIT"
REVISION="1"
SOURCE_URI="https://github.com/KhronosGroup/OpenCOLLADA/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="3b70781168f83482e69982f3904806242238b350162fea874e49343ea04da583"
SOURCE_FILENAME="opencollada-$portVersion.tar.gz"
SOURCE_DIR="OpenCOLLADA-$portVersion"
PATCHES="opencollada-$portVersion.patchset"

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

PROVIDES="
	opencollada$secondaryArchSuffix = $portVersion
	lib:libbuffer$secondaryArchSuffix = $portVersion
	lib:libftoa$secondaryArchSuffix = $portVersion
	lib:libGeneratedSaxParser$secondaryArchSuffix = $portVersion
	lib:libMathMLSolver$secondaryArchSuffix = $portVersion
	lib:libOpenCOLLADABaseUtils$secondaryArchSuffix = $portVersion
	lib:libOpenCOLLADAFramework$secondaryArchSuffix = $portVersion
	lib:libOpenCOLLADASaxFrameworkLoader$secondaryArchSuffix = $portVersion
	lib:libOpenCOLLADAStreamWriter$secondaryArchSuffix = $portVersion
	lib:libUTF$secondaryArchSuffix = $portVersion
	lib:libzlib$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libpcre$secondaryArchSuffix
	lib:libpcreposix$secondaryArchSuffix
	lib:libxml2$secondaryArchSuffix
	"

PROVIDES_devel="
	opencollada${secondaryArchSuffix}_devel = $portVersion
	devel:libbuffer$secondaryArchSuffix = $portVersion
	devel:libftoa$secondaryArchSuffix = $portVersion
	devel:libGeneratedSaxParser$secondaryArchSuffix = $portVersion
	devel:libMathMLSolver$secondaryArchSuffix = $portVersion
	devel:libOpenCOLLADABaseUtils$secondaryArchSuffix = $portVersion
	devel:libOpenCOLLADAFramework$secondaryArchSuffix = $portVersion
	devel:libOpenCOLLADASaxFrameworkLoader$secondaryArchSuffix = $portVersion
	devel:libOpenCOLLADAStreamWriter$secondaryArchSuffix = $portVersion
	devel:libUTF$secondaryArchSuffix = $portVersion
	devel:libzlib$secondaryArchSuffix = $portVersion
	"
REQUIRES_devel="
	opencollada$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libpcre$secondaryArchSuffix
	devel:libpcreposix$secondaryArchSuffix
	devel:libxml2$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

defineDebugInfoPackage opencollada$secondaryArchSuffix \
	$libDir/libbuffer.so \
	$libDir/libftoa.so \
	$libDir/libGeneratedSaxParser.so \
	$libDir/libMathMLSolver.so \
	$libDir/libOpenCOLLADABaseUtils.so \
	$libDir/libOpenCOLLADAFramework.so \
	$libDir/libOpenCOLLADASaxFrameworkLoader.so \
	$libDir/libOpenCOLLADAStreamWriter.so \
	$libDir/libUTF.so \
	$libDir/libzlib.so

PATCH()
{
	sed -i 's,${CMAKE_INSTALL_PREFIX}/include',$includeDir, CMakeLists.txt
	sed -i 's,${CMAKE_INSTALL_PREFIX}/lib/opencollada',$libDir, CMakeLists.txt
}

BUILD()
{
	mkdir -p build
	cd build
	cmake  .. \
		-DCMAKE_CXX_FLAGS="-D_BSD_SOURCE" \
		-DUSE_SHARED=ON \
		$cmakeDirArgs

	make $jobArgs
}

INSTALL()
{
	cd build
	make install $jobArgs

	prepareInstalledDevelLibs \
		libbuffer \
		libftoa \
		libGeneratedSaxParser \
		libMathMLSolver \
		libOpenCOLLADABaseUtils \
		libOpenCOLLADAFramework \
		libOpenCOLLADASaxFrameworkLoader \
		libOpenCOLLADAStreamWriter \
		libUTF \
		libzlib

	packageEntries devel \
		$developDir \
		$libDir/cmake
}
