SUMMARY="A Just-In-Time Compiler (JIT) for the Lua programming language"
DESCRIPTION="Lua is a powerful, dynamic and light-weight programming \
language. It may be embedded or used as a general-purpose, stand-alone \
language. LuaJIT is a Just-In-Time Compiler (JIT) for it."
HOMEPAGE="http://luajit.org/luajit.html"
COPYRIGHT="2005-2015 Mike Pall"
LICENSE="MIT"
REVISION="3"
SOURCE_URI="http://luajit.org/download/LuaJIT-$portVersion.tar.gz"
CHECKSUM_SHA256="620fa4eb12375021bef6e4f237cbd2dd5d49e56beb414bee052c746beef1807d"
SOURCE_DIR="LuaJIT-$portVersion"
PATCHES="luajit-$portVersion.diff"

ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="x86"

PROVIDES="
	luajit$secondaryArchSuffix = $portVersion
	cmd:luajit$secondaryArchSuffix
	cmd:luajit_$portVersion$secondaryArchSuffix
	lib:libluajit_5.1$secondaryArchSuffix = $portVersion compat >= 2
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

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

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:gcc$secondaryArchSuffix
	cmd:make
	"

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.${portVersion} $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
}
