PKGNAME=pocl
PKGSEC=libs
PKGDEP="hwloc llvm opencl-registry-api"
PKGDES="An OpenCL implementation that allows running kernels on the host (CPU)"

ABTYPE=cmakeninja
CMAKE_AFTER=(
    # Enable cl_khr_fp16 on platforms where llvm can handle fp16 operations.
    "-DENABLE_CONFORMANCE=OFF"
    # CUDA and rusticl have provided OpenCL support on NVIDIA GPUs.
    "-DENABLE_CUDA:BOOL=OFF"
    # Examples are not required to use the library.
    "-DENABLE_EXAMPLES:BOOL=OFF"
    "-DENABLE_ICD:BOOL=ON"
    "-DENABLE_TESTS:BOOL=OFF"
    "-DPOCL_ICD_ABSOLUTE_PATH=OFF"
)

# On x86_64 and ppc64el, bitcode can be generated for a few pre-selected targets for better coverage.
# e.g., SSE2, AVX2, ... on x86_64.
CMAKE_AFTER__AMD64=(
    "${CMAKE_AFTER[@]}"
    "-DKERNELLIB_HOST_CPU_VARIANTS=distro"
)

CMAKE_AFTER__PPC64EL=(
    "${CMAKE_AFTER[@]}"
    "-DKERNELLIB_HOST_CPU_VARIANTS=distro"
)

# A CPU model with less advanced ISA is specified for better compatibility.
CMAKE_AFTER__ARM64=(
    "${CMAKE_AFTER[@]}"
    "-DLLC_HOST_CPU=cortex-a53"
)

# Three CPU models below are specified since they can't be determined automatically.
CMAKE_AFTER__LOONGARCH64=(
    "${CMAKE_AFTER[@]}"
    "-DLLC_HOST_CPU=loongarch64"
)

CMAKE_AFTER__LOONGSON3=(
    "${CMAKE_AFTER[@]}"
    "-DLLC_HOST_CPU=mips64r2"
)

CMAKE_AFTER__RISCV64=(
    "${CMAKE_AFTER[@]}"
    "-DLLC_HOST_CPU=sifive-u74"
)

# FIXME: LLVM config specifies "pocl<=1:1.6-1" for an old version dropped previously.
# Thus, the EPOCH has to be bumped to avoid dependency issues.
PKGEPOCH=1
