# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
# Contributor: Bartłomiej Piotrowski <nospam@bpiotrowski.pl>
pkgname=luajit
_pkgname=LuaJIT
pkgver=2.1.0_beta3
_pkgver=${pkgver/_/-}
pkgrel=4
pkgdesc='Just-in-time compiler and replacement for Lua 5.1'
url='http://luajit.org'
arch="all !s390x"
license="MIT"
makedepends="$depends_dev paxmark"
provides="lua"
subpackages="$pkgname-dev $pkgname-doc"
source="http://luajit.org/download/$_pkgname-$_pkgver.tar.gz
	enable-support-for-ppc64le.patch
	module-paths.patch"
builddir="$srcdir/$_pkgname-$_pkgver"

build() {
	cd "$builddir"

	make amalg PREFIX=/usr
}

check() {
	cd "$builddir"

	./src/luajit -v
	./src/luajit -e 'print("Hello, world!")'
}

package() {
	cd "$builddir"

	make install DESTDIR="$pkgdir" PREFIX=/usr

	local paxflags="-m"
	[ "$CARCH" = "x86" ] && paxflags="-msp"
	paxmark $paxflags "$pkgdir"/usr/bin/luajit-$_pkgver

	ln -s luajit-$_pkgver "$pkgdir"/usr/bin/luajit

	install -Dm644 COPYRIGHT \
		"$pkgdir"/usr/share/licenses/$pkgname/COPYRIGHT
}

sha512sums="c44e967a0f671ed32b55aee810bc8b3b63737a2d7363b8984ae1949b24f98dbb3f9be7c1e10239fdeb96a3e3c836f606342cbd61838cf9bcadb077443eb5bc12  LuaJIT-2.1.0-beta3.tar.gz
c2b1a39fe19dfe1817811015ef1fea24b0966ff791fcbde1090527331c2b9ceab9b923960c01cfb8aa81bab40aa437eb0f285385378e7eaa83016abf36beae27  enable-support-for-ppc64le.patch
9c6c410e142838c5128c70570e66beb53cc5422df5ecfb8ab0b5f362637b21ab5978c00f19bc1759165df162fd6438a2ed43e25020400011b7bb14014d87c62e  module-paths.patch"
