SUMMARY="Libs for the efficient manipulation of volumetric data"
DESCRIPTION="The OpenVDB library comprises a hierarchical data structure and \
a suite of tools for the efficient manipulation of sparse, possibly \
time-varying, volumetric data discretized on a three-dimensional grid."
HOMEPAGE="https://www.openvdb.org/"
COPYRIGHT="2012-2019 DreamWorks Animation LLC"
LICENSE="MPL v2.0"
REVISION="1"
SOURCE_URI="https://github.com/AcademySoftwareFoundation/openvdb/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="0c3588c1ca6e647610738654ec2c6aaf41a203fd797f609fbeab1c9f7c3dc116"

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

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

PROVIDES="
	openvdb$secondaryArchSuffix = $portVersion
	lib:libopenvdb$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libblosc$secondaryArchSuffix
	lib:libboost_iostreams$secondaryArchSuffix
	lib:libboost_system$secondaryArchSuffix
	lib:libboost_thread$secondaryArchSuffix
	lib:libcppunit$secondaryArchSuffix
	lib:libHalf_2_4$secondaryArchSuffix
	lib:libtbb$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_tools="
	openvdb${secondaryArchSuffix}_tools = $portVersion
	cmd:vdb_print
	"
REQUIRES_tools="
	haiku$secondaryArchSuffix
	lib:libblosc$secondaryArchSuffix
	lib:libboost_iostreams$secondaryArchSuffix
	lib:libboost_regex$secondaryArchSuffix
	lib:libboost_system$secondaryArchSuffix
	lib:libHalf_2_4$secondaryArchSuffix
	lib:libopenvdb$secondaryArchSuffix
	lib:libtbb$secondaryArchSuffix
	lib:libtbbmalloc$secondaryArchSuffix
	lib:libtbbmalloc_proxy$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	openvdb${secondaryArchSuffix}_devel = $portVersion
	devel:libopenvdb$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	openvdb$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libblosc$secondaryArchSuffix
	devel:libboost_iostreams$secondaryArchSuffix >= 1.69.0
	devel:libboost_system$secondaryArchSuffix >= 1.69.0
	devel:libboost_thread$secondaryArchSuffix >= 1.69.0
	devel:libcppunit$secondaryArchSuffix
	devel:libHalf_2_4$secondaryArchSuffix
	devel:libtbb$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:g++$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

defineDebugInfoPackage openvdb$secondaryArchSuffix \
	$libDir/libopenvdb.so.$libVersion

BUILD()
{
	mkdir -p haiku_build
	cd haiku_build

	cmake .. \
		-DTBB_ROOT="$portPackageLinksDir/devel~libtbb$secondaryArchSuffix/$relativeDevelopDir/" \
		-DTBB_INCLUDEDIR="$portPackageLinksDir/devel~libtbb$secondaryArchSuffix/$relativeIncludeDir/" \
		-DTBB_LIBRARYDIR="$portPackageLinksDir/devel~libtbb$secondaryArchSuffix/$relativeDevelopLibDir/" \
		-DOPENVDB_BUILD_PYTHON_MODULE=OFF \
		$cmakeDirArgs \
		-DCMAKE_INSTALL_BINDIR=$prefix/bin

	make $jobArgs
}

INSTALL()
{
	cd haiku_build
	make install

	prepareInstalledDevelLib libopenvdb

	packageEntries devel \
		$developDir \
		$libDir/cmake

	packageEntries tools $prefix/bin
}

TEST()
{
	cd haiku_build
	make test
}
