# Maintainer: Torsten Keßler <tpkessler at archlinux dot org>
# Maintainer: Christian Heusel <gromit@archlinux.org>

pkgname=hipfft
pkgver=7.2.0
pkgrel=1
pkgdesc='rocFFT marshalling library.'
arch=('x86_64' 'aarch64')
url='https://rocm.docs.amd.com/projects/hipFFT/en/latest/index.html'
license=('MIT')
depends=(
  'gcc-libs'
  'glibc'
  'hip-runtime-amd'
  'rocfft'
  'rocm-core'
)
makedepends=(
  'cmake'
  'git'
  'rocm-cmake'
)
_git='https://github.com/ROCm/rocm-libraries'
source=("$pkgname-$pkgver.tar.gz::https://github.com/ROCm/rocm-libraries/releases/download/rocm-$pkgver/$pkgname.tar.gz")
sha256sums=('cc1a79c2601e98cf88492207ac975a3575eff9f4da4d7d54250de662a9f45da0')
options=(!lto)

build() {
  # -fcf-protection is not supported by HIP, see
  # https://rocm.docs.amd.com/projects/llvm-project/en/latest/reference/rocmcc.html#support-status-of-other-clang-options
  local cmake_args=(
    -Wno-dev
    -S "$pkgname"
    -B build
    -D CMAKE_BUILD_TYPE=None
    -D CMAKE_CXX_COMPILER=amdclang++
    -D CMAKE_CXX_FLAGS="${CXXFLAGS} -fcf-protection=none"
    -D CMAKE_INSTALL_PREFIX=/opt/rocm
  )
  ROCM_PATH=/opt/rocm cmake "${cmake_args[@]}"
  cmake --build build
}

package() {
  DESTDIR="$pkgdir" cmake --install build

  install -Dm644 "$srcdir/$pkgname/LICENSE.md" "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}
