SUMMARY="A C++ 3D modeling library"
DESCRIPTION="Open CASCADE Technology (OCCT) is an object-oriented C++ class \
library designed for rapid production of sophisticated domain-specific \
CAD/CAM/CAE applications."
HOMEPAGE="https://github.com/tpaviot/oce/"
COPYRIGHT="1993-1999 Matra Datavision
	1999-2014 OPEN CASCADE SAS"
LICENSE="GNU LGPL v2.1
	Open CASCADE exception v1.0"
REVISION="2"
SOURCE_URI="https://github.com/tpaviot/oce/archive/OCE-$portVersion.tar.gz"
CHECKSUM_SHA256="c553d6a7bf52f790abc3b6bb7a1e91a65947e92a426bb1a88a11960c31f0966c"
SOURCE_DIR="oce-OCE-$portVersion"
PATCHES="opencascade-$portVersion.patchset"

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

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

PROVIDES="
	opencascade$secondaryArchSuffix = $portVersion
	lib:libFWOSPlugin$secondaryArchSuffix = $libVersionCompat
	lib:libPTKernel$secondaryArchSuffix = $libVersionCompat
	lib:libTKBinL$secondaryArchSuffix = $libVersionCompat
	lib:libTKBO$secondaryArchSuffix = $libVersionCompat
	lib:libTKBool$secondaryArchSuffix = $libVersionCompat
	lib:libTKBRep$secondaryArchSuffix = $libVersionCompat
	lib:libTKCDF$secondaryArchSuffix = $libVersionCompat
	lib:libTKernel$secondaryArchSuffix = $libVersionCompat
	lib:libTKFeat$secondaryArchSuffix = $libVersionCompat
	lib:libTKFillet$secondaryArchSuffix = $libVersionCompat
	lib:libTKG2d$secondaryArchSuffix = $libVersionCompat
	lib:libTKG3d$secondaryArchSuffix = $libVersionCompat
	lib:libTKGeomAlgo$secondaryArchSuffix = $libVersionCompat
	lib:libTKGeomBase$secondaryArchSuffix = $libVersionCompat
	lib:libTKHLR$secondaryArchSuffix = $libVersionCompat
	lib:libTKIGES$secondaryArchSuffix = $libVersionCompat
	lib:libTKLCAF$secondaryArchSuffix = $libVersionCompat
	lib:libTKMath$secondaryArchSuffix = $libVersionCompat
	lib:libTKMesh$secondaryArchSuffix = $libVersionCompat
	lib:libTKOffset$secondaryArchSuffix = $libVersionCompat
	lib:libTKPLCAF$secondaryArchSuffix = $libVersionCompat
	lib:libTKPrim$secondaryArchSuffix = $libVersionCompat
	lib:libTKPShape$secondaryArchSuffix = $libVersionCompat
	lib:libTKShapeSchema$secondaryArchSuffix = $libVersionCompat
	lib:libTKShHealing$secondaryArchSuffix = $libVersionCompat
	lib:libTKStdLSchema$secondaryArchSuffix = $libVersionCompat
	lib:libTKSTEP$secondaryArchSuffix = $libVersionCompat
	lib:libTKSTEP209$secondaryArchSuffix = $libVersionCompat
	lib:libTKSTEPAttr$secondaryArchSuffix = $libVersionCompat
	lib:libTKSTEPBase$secondaryArchSuffix = $libVersionCompat
	lib:libTKSTL$secondaryArchSuffix = $libVersionCompat
	lib:libTKTObj$secondaryArchSuffix = $libVersionCompat
	lib:libTKTopAlgo$secondaryArchSuffix = $libVersionCompat
	lib:libTKXMesh$secondaryArchSuffix = $libVersionCompat
	lib:libTKXmlL$secondaryArchSuffix = $libVersionCompat
	lib:libTKXSBase$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libgomp$secondaryArchSuffix
	"

PROVIDES_devel="
	opencascade${secondaryArchSuffix}_devel = $portVersion
	devel:libFWOSPlugin$secondaryArchSuffix = $libVersionCompat
	devel:libPTKernel$secondaryArchSuffix = $libVersionCompat
	devel:libTKBinL$secondaryArchSuffix = $libVersionCompat
	devel:libTKBO$secondaryArchSuffix = $libVersionCompat
	devel:libTKBool$secondaryArchSuffix = $libVersionCompat
	devel:libTKBRep$secondaryArchSuffix = $libVersionCompat
	devel:libTKCDF$secondaryArchSuffix = $libVersionCompat
	devel:libTKernel$secondaryArchSuffix = $libVersionCompat
	devel:libTKFeat$secondaryArchSuffix = $libVersionCompat
	devel:libTKFillet$secondaryArchSuffix = $libVersionCompat
	devel:libTKG2d$secondaryArchSuffix = $libVersionCompat
	devel:libTKG3d$secondaryArchSuffix = $libVersionCompat
	devel:libTKGeomAlgo$secondaryArchSuffix = $libVersionCompat
	devel:libTKGeomBase$secondaryArchSuffix = $libVersionCompat
	devel:libTKHLR$secondaryArchSuffix = $libVersionCompat
	devel:libTKIGES$secondaryArchSuffix = $libVersionCompat
	devel:libTKLCAF$secondaryArchSuffix = $libVersionCompat
	devel:libTKMath$secondaryArchSuffix = $libVersionCompat
	devel:libTKMesh$secondaryArchSuffix = $libVersionCompat
	devel:libTKOffset$secondaryArchSuffix = $libVersionCompat
	devel:libTKPLCAF$secondaryArchSuffix = $libVersionCompat
	devel:libTKPrim$secondaryArchSuffix = $libVersionCompat
	devel:libTKPShape$secondaryArchSuffix = $libVersionCompat
	devel:libTKShapeSchema$secondaryArchSuffix = $libVersionCompat
	devel:libTKShHealing$secondaryArchSuffix = $libVersionCompat
	devel:libTKStdLSchema$secondaryArchSuffix = $libVersionCompat
	devel:libTKSTEP$secondaryArchSuffix = $libVersionCompat
	devel:libTKSTEP209$secondaryArchSuffix = $libVersionCompat
	devel:libTKSTEPAttr$secondaryArchSuffix = $libVersionCompat
	devel:libTKSTEPBase$secondaryArchSuffix = $libVersionCompat
	devel:libTKSTL$secondaryArchSuffix = $libVersionCompat
	devel:libTKTObj$secondaryArchSuffix = $libVersionCompat
	devel:libTKTopAlgo$secondaryArchSuffix = $libVersionCompat
	devel:libTKXMesh$secondaryArchSuffix = $libVersionCompat
	devel:libTKXmlL$secondaryArchSuffix = $libVersionCompat
	devel:libTKXSBase$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	opencascade$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libgomp$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:g++$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:sed
	"

defineDebugInfoPackage opencascade$secondaryArchSuffix \
	"$libDir"/libFWOSPlugin.so.$libVersion \
	"$libDir"/libPTKernel.so.$libVersion \
	"$libDir"/libTKBinL.so.$libVersion \
	"$libDir"/libTKBO.so.$libVersion \
	"$libDir"/libTKBool.so.$libVersion \
	"$libDir"/libTKBRep.so.$libVersion \
	"$libDir"/libTKCDF.so.$libVersion \
	"$libDir"/libTKernel.so.$libVersion \
	"$libDir"/libTKFeat.so.$libVersion \
	"$libDir"/libTKFillet.so.$libVersion \
	"$libDir"/libTKG2d.so.$libVersion \
	"$libDir"/libTKG3d.so.$libVersion \
	"$libDir"/libTKGeomAlgo.so.$libVersion \
	"$libDir"/libTKGeomBase.so.$libVersion \
	"$libDir"/libTKHLR.so.$libVersion \
	"$libDir"/libTKIGES.so.$libVersion \
	"$libDir"/libTKLCAF.so.$libVersion \
	"$libDir"/libTKMath.so.$libVersion \
	"$libDir"/libTKMesh.so.$libVersion \
	"$libDir"/libTKOffset.so.$libVersion \
	"$libDir"/libTKPLCAF.so.$libVersion \
	"$libDir"/libTKPrim.so.$libVersion \
	"$libDir"/libTKPShape.so.$libVersion \
	"$libDir"/libTKShapeSchema.so.$libVersion \
	"$libDir"/libTKShHealing.so.$libVersion \
	"$libDir"/libTKStdLSchema.so.$libVersion \
	"$libDir"/libTKSTEP.so.$libVersion \
	"$libDir"/libTKSTEP209.so.$libVersion \
	"$libDir"/libTKSTEPAttr.so.$libVersion \
	"$libDir"/libTKSTEPBase.so.$libVersion \
	"$libDir"/libTKSTL.so.$libVersion \
	"$libDir"/libTKTObj.so.$libVersion \
	"$libDir"/libTKTopAlgo.so.$libVersion \
	"$libDir"/libTKXMesh.so.$libVersion \
	"$libDir"/libTKXmlL.so.$libVersion \
	"$libDir"/libTKXSBase.so.$libVersion

BUILD()
{
	mkdir -p build && cd "$_"

	cmake .. \
		-DOCE_MULTITHREAD_LIBRARY=OPENMP \
		-DOCE_DISABLE_X11=ON \
		-DOCE_INSTALL_PREFIX=$prefix \
		-DOCE_INSTALL_LIB_DIR=$libDir \
		-DOCE_INSTALL_INCLUDE_DIR=$includeDir \
		-Wno-dev

	make $jobArgs
}

INSTALL()
{
	cd build
	make install

	prepareInstalledDevelLibs libFWOSPlugin libPTKernel libTKBinL libTKBO \
		libTKBool libTKBRep libTKCDF libTKernel libTKFeat libTKFillet libTKG2d \
		libTKG3d libTKGeomAlgo libTKGeomBase libTKHLR libTKIGES libTKLCAF \
		libTKMath libTKMesh libTKOffset libTKPLCAF libTKPrim libTKPShape \
		libTKShapeSchema libTKShHealing libTKStdLSchema libTKSTEP libTKSTEP209 \
		libTKSTEPAttr libTKSTEPBase libTKSTL libTKTObj libTKTopAlgo libTKXMesh \
		libTKXmlL libTKXSBase

	fixPkgconfig

	packageEntries devel \
		$developDir \
		$libDir/cmake
}

TEST()
{
	cd build
	make test
}
