# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: Torsten Keßler <tpkessler at archlinux dot org>

pkgname=rocm-core
_rocm_major=6
_rocm_minor=2
_rocm_patch=2
_pkgver_magic=116
pkgver=$_rocm_major.$_rocm_minor.$_rocm_patch
pkgrel=1
pkgdesc='AMD ROCm core package (version files)'
license=('Unlicense')
arch=(any)
source=('LICENSE'
        'rocm-ld.conf'
        'rocm-profile.sh')
b2sums=('e4c94a21ea352227919ba41e0e461b61b700cfb469a0cc1019d7daee85b009410edb4078987dc163d0504b0385162c0f4988ba6c4d5cab23c059486f8bdb4db3'
        'd045c357d8e7e8a4840ab137404f12cd08419444ffc478046c13ed3bd13a5d33358c1443bf76ee571a7a062454e2bdda1a5507a70edbd001bce004f18775e4b2'
        'f1600ae357f820df116524bf1f69f12227b00ac482273f73df33c4d16bd0bae47914c5500fafd2c88a10b1f162c4afc1a3c47de6a7ba33244cf599b6043dee36')
url='https://rocm.docs.amd.com/'

package() {
  # AMD hasn't released the complete source code of the package,
  # so we only package the version file that is required by some libraries.
  echo "$pkgver-$_pkgver_magic" > version-rocm
  install -Dm644 version-rocm "$pkgdir/opt/rocm/.info/version"
  install -Dm644 version-rocm "$pkgdir/opt/rocm/.info/version-dev"

  install -Dm644 rocm-ld.conf "$pkgdir/etc/ld.so.conf.d/rocm.conf"
  install -Dm644 rocm-profile.sh "$pkgdir/etc/profile.d/rocm.sh"

  echo "#pragma once" > rocm_version.h
  echo "#define ROCM_VERSION_MAJOR $_rocm_major" >> rocm_version.h
  echo "#define ROCM_VERSION_MINOR $_rocm_minor" >> rocm_version.h
  echo "#define ROCM_VERSION_PATCH $_rocm_patch" >> rocm_version.h
  echo "#define ROCM_BUILD_INFO \"$_rocm_major.$_rocm_minor.$_rocm_patch.0-$_pkgver_magic\"" >> rocm_version.h
  install -Dm644 rocm_version.h "$pkgdir/opt/rocm/include/rocm_version.h"
  install -Dm644 rocm_version.h "$pkgdir/opt/rocm/include/rocm-core/rocm_version.h"
  install -Dm644 "$srcdir/LICENSE" "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}
