# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: Evangelos Foutras <foutrelis@archlinux.org>

pkgname=openmp
pkgver=18.1.8
pkgrel=1.1
pkgdesc="LLVM OpenMP Runtime Library"
arch=(x86_64 powerpc64le powerpc64 riscv64)
url="https://openmp.llvm.org/"
license=('Apache-2.0 WITH LLVM-exception')
depends=('llvm-libs' 'libelf' 'libffi')
makedepends=('llvm' 'clang' 'cmake' 'ninja')
optdepends_powerpc64le=('hsa-rocr: offloading to AMD GPUs')
optdepends_x86_64=(
  'cuda: offloading to NVIDIA GPUs'
  'hsa-rocr: offloading to AMD GPUs'
)
options=('!lto') # https://bugzilla.redhat.com/show_bug.cgi?id=1988155
_source_base=https://github.com/llvm/llvm-project/releases/download/llvmorg-$pkgver
source=($_source_base/openmp-$pkgver.src.tar.xz{,.sig}
        $_source_base/cmake-$pkgver.src.tar.xz{,.sig})
sha256sums=('60ed57245e73894e4a2a89b15889f367bd906abfe6d3f92e1718223d4b496150'
            'SKIP'
            '59badef592dd34893cd319d42b323aaa990b452d05c7180ff20f23ab1b41e837'
            'SKIP')
validpgpkeys=('474E22316ABF4785A88C6E8EA2C794A986419D8A') # Tom Stellard <tstellar@redhat.com>

prepare() {
  mv cmake{-$pkgver.src,}
  cd openmp-$pkgver.src
  mkdir build
}

build() {
  cd openmp-$pkgver.src/build

  local cmake_args=(
    -G Ninja
    -DCMAKE_BUILD_TYPE=Release
    -DCMAKE_INSTALL_PREFIX=/usr
    -DLIBOMP_INSTALL_ALIASES=OFF
  )
  cmake .. "${cmake_args[@]}"
  ninja
}

package() {
  cd openmp-$pkgver.src/build

  DESTDIR="$pkgdir" ninja install
  install -Dm644 ../LICENSE.TXT "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  rm "$pkgdir/usr/lib/libarcher_static.a"
}

# vim:set ts=2 sw=2 et:
