# Description: libclc is an implementation of the library requirements of the OpenCL C programming language
# URL: https://libclc.llvm.org/
# Maintainer: Tim Biermann, tbier at posteo dot de
# Depends on: clang lld spirv-llvm-translator

name=libclc
version=18.1.4
release=1
source=(https://github.com/llvm/llvm-project/releases/download/llvmorg-$version/libclc-$version.src.tar.xz)

build() {
  # libclc is intended to be used with the Clang compiler's OpenCL frontend
  # https://libclc.llvm.org/
  export CC=clang CXX=clang++ AR=llvm-ar NM=llvm-nm RANLIB=llvm-ranlib LDFLAGS+=' -fuse-ld=lld'

  cmake -S $name-$version.src -B build -G Ninja \
    -D CMAKE_INSTALL_PREFIX=/usr \
    -D CMAKE_INSTALL_LIBDIR=lib \
    -D CMAKE_BUILD_TYPE=Release \
    -D CMAKE_CXX_FLAGS_RELEASE="$CXXFLAGS" \
    -D CMAKE_C_FLAGS_RELEASE="$CFLAGS" \
    -Wno-dev

  cmake --build build
  DESTDIR=$PKG cmake --install build
}
