SUMMARY="LuaJIT is a Just-In-Time Compiler (JIT) for the Lua programming language."
HOMEPAGE="http://luajit.org/luajit.html"
SRC_URI="http://luajit.org/download/LuaJIT-$portVersion.tar.gz"
CHECKSUM_SHA256="c05202974a5890e777b181908ac237625b499aece026654d7cc33607e3f46c38"
REVISION="2"
ARCHITECTURES="x86 x86_gcc2"
SECONDARY_ARCHITECTURES="x86"
PROVIDES="
	luajit$secondaryArchSuffix = $portVersion compat >= 5.1
	lib:libluajit_5.1$secondaryArchSuffix = $portVersion compat >= 2
	cmd:luajit_$portVersion$secondaryArchSuffix
	cmd:luajit$secondaryArchSuffix
	"

REQUIRES="
	haiku$secondaryArchSuffix >= $haikuVersion
	"
BUILD_PREREQUIRES="
	haiku${secondaryArchSuffix}_devel >= $haikuVersion
	cmd:make
	cmd:gcc$secondaryArchSuffix
	"

PROVIDES_devel="
	luajit${secondaryArchSuffix}_devel = $portVersion compat >= 5.1
	devel:libluajit_5.1$secondaryArchSuffix = $portVersion compat >= 2
	"

REQUIRES_devel="
	luajit$secondaryArchSuffix == $portVersion base
	"

PATCHES="luajit-$portVersion.patchset"

SOURCE_DIR="LuaJIT-$portVersion"
BUILD()
{
	# Use amalg target as recommended on luajit homepage to get better performance
	make $jobArgs amalg PREFIX=$prefix
}

INSTALL()
{
	make install PREFIX=$prefix INSTALL_LIB="$libDir" INSTALL_BIN="$binDir" \
		INSTALL_INC="$includeDir" INSTALL_SHARE="$dataDir" \
		INSTALL_MAN="$manDir/man1" INSTALL_LMOD="$dataDir/lua/5.1"

	ln -s $libDir/libluajit-5.1.so.2.0.2 $libDir/libluajit-5.1.so.2

	# the pkg-config is for 5.1 comapt
	mkdir -p $libDir/pkgconfig
	cp etc/luajit.pc $libDir/pkgconfig/luajit.pc

	prepareInstalledDevelLib libluajit-5.1
	fixPkgconfig

	packageEntries devel $developDir
}
LICENSE="MIT"
COPYRIGHT="2005-2013, Mike Pall"
DESCRIPTION="
LuaJIT is a Just-In-Time Compiler (JIT) for the Lua programming language.

Lua is a powerful, dynamic and light-weight programming language. It may be \
embedded or used as a general-purpose, stand-alone language.
"
