# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: Daurnimator <daurnimator@archlinux.org>
# Maintainer: Lukas Fleischer <lfleischer@archlinux.org>
# Contributor: Bartłomiej Piotrowski <bpiotrowski@archlinux.org>
# Contributor: Chris Brannon <chris@the-brannons.com>
# Contributor: Paulo Matias <matiasΘarchlinux-br·org>
# Contributor: Anders Bergh <anders1@gmail.com>

pkgname=luajit
# LuaJIT has abandoned versioned releases and now advises using git HEAD
# https://github.com/LuaJIT/LuaJIT/issues/665#issuecomment-784452583
_commit=1401cfb2b3d9270f5e6e6c899eb9deb43eaddab6
pkgver="2.1.0.beta3.g${_commit::8}"
pkgrel=1
pkgdesc='Just-in-time compiler and drop-in replacement for Lua 5.1'
arch=(x86_64 powerpc64le powerpc)
url='https://luajit.org/'
license=('MIT')
depends=('gcc-libs')
makedepends=('git')
source=("LuaJIT-PPC64::git+https://github.com/PPC64/LuaJIT.git#commit=${_commit}")
md5sums=('SKIP')
sha256sums=('SKIP')
b2sums=('SKIP')

build() {
  cd "LuaJIT-PPC64"
  # Avoid early stripping
  make amalg PREFIX=/usr BUILDMODE=dynamic TARGET_STRIP=" @:"
}

package() {
  cd "LuaJIT-PPC64"

  make install DESTDIR="$pkgdir" PREFIX=/usr
  install -Dm644 COPYRIGHT "$pkgdir/usr/share/licenses/$pkgname/COPYRIGHT"

  ln -sf luajit-2.1.0-beta3 "$pkgdir/usr/bin/luajit"
}
