# Maintainer: Sven-Hendrik Haase <svenstaro@archlinux.org>
# Maintainer: Bruno Pagani <archange@archlinux.org>
# Contributor: Lukas Jirkovsky <l.jirkovsky@gmail.com>

pkgname=embree
pkgver=4.4.0
pkgrel=1
pkgdesc="Collection of high-performance ray tracing kernels"
arch=('x86_64' 'aarch64')
url="https://embree.github.io/"
license=('Apache')
depends=('gcc-libs' 'glibc' 'intel-tbb')
makedepends=('cmake' 'ispc' 'freeglut' 'libxmu' 'ninja')
source=(https://github.com/embree/embree/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz)
sha256sums=('acb517b0ea0f4b442235d5331b69f96192c28da6aca5d5dde0cbe40799638d5c')

build() {
    # Embree detects actual ISA at runtime but we have to set a high maximum
    # buildtime version as it would otherwise default to the builder processor.
    cmake \
      -B build \
      -G Ninja \
      -S ${pkgname}-${pkgver} \
      -DCMAKE_INSTALL_PREFIX=/usr \
      -DCMAKE_BUILD_TYPE=Release \
      -DEMBREE_ISPC_SUPPORT=ON \
      -DEMBREE_TUTORIALS=OFF \
      -DEMBREE_MAX_ISA="AVX512SKX" \
      -DEMBREE_BACKFACE_CULLING=OFF
    ninja -C build
    # Maybe enable these later once they are out of beta:
      # -DEMBREE_SYCL_SUPPORT=ON \
      # -DEMBREE_SYCL_LARGEGRF=ON
}

package() {
    DESTDIR="${pkgdir}" ninja -C build install

    mkdir "${pkgdir}"/usr/bin/
    mv "${pkgdir}"/usr/embree-vars.* "${pkgdir}"/usr/bin/
}
