SUMMARY="High Performance Ray Tracing Kernels"
DESCRIPTION="Embree is a collection of high-performance ray tracing kernels, \
developed at Intel. The target user of Embree are graphics application \
engineers that want to improve the performance of their application by \
leveraging the optimized ray tracing kernels of Embree. The kernels \
are optimized for photo-realistic rendering on the latest Intel (R) \
processors with support for SSE, AVX, AVX2, and AVX-512. Embree \
supports runtime code selection to choose the traversal and build \
algorithms that best matches the instruction set of your CPU"
HOMEPAGE="https://embree.github.io"
COPYRIGHT="2013-2021 Intel Corporation"
LICENSE="Apache v2"
REVISION="2"
SOURCE_URI="https://github.com/embree/embree/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="22a527622497e07970e733f753cc9c10b2bd82c3b17964e4f71a5fd2cdfca210"
SOURCE_FILENAME="embree-v$portVersion.tar.gz"
PATCHES="embree-$portVersion.patchset"

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

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

PROVIDES="
	embree$secondaryArchSuffix = $portVersion
	lib:libembree3$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libgl$secondaryArchSuffix
	lib:libglu$secondaryArchSuffix
	lib:libjpeg$secondaryArchSuffix
	lib:libMagick++_7.Q16HDRI$secondaryArchSuffix
	lib:libpng16$secondaryArchSuffix
	"

PROVIDES_devel="
	embree${secondaryArchSuffix}_devel = $portVersion
	devel:libembree3$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	embree$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libgl$secondaryArchSuffix
	devel:libglu$secondaryArchSuffix
	devel:libjpeg$secondaryArchSuffix
	devel:libMagick++_7.Q16HDRI$secondaryArchSuffix
	devel:libpng16$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:grep
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:sed
	"
defineDebugInfoPackage embree$secondaryArchSuffix \
	"$libDir"/libembree3.so.$libVersion

BUILD()
{
	mkdir -p haiku_build
	cd haiku_build

	cmake $cmakeDirArgs \
			.. \
			-DCMAKE_BUILD_TYPE=RelWithDebInfo \
			-DEMBREE_MAX_ISA=DEFAULT \
			-DEMBREE_TUTORIALS=OFF \
			-DEMBREE_ISPC_SUPPORT=OFF \
			-DEMBREE_TASKING_SYSTEM=OFF \
			-DBUILD_TESTING=ON
	make $jobArgs
}

INSTALL()
{
	cd haiku_build
	make install

	prepareInstalledDevelLib libembree3

	fixPkgconfig

	# devel package
	packageEntries devel \
		$developDir \
		$libDir/cmake \
		$docDir \
		$manDir
}

TEST()
{
	cd haiku_build
	make test
}
