SUMMARY="A powerful, fast, light-weight, embeddable scripting language"
DESCRIPTION="Lua combines simple procedural syntax with powerful data \
description constructs based on associative arrays and extensible semantics. \
Lua is dynamically typed, runs by interpreting bytecode for a register-based \
virtual machine, and has automatic memory management with incremental garbage \
collection, making it ideal for configuration, scripting, and rapid \
prototyping."
HOMEPAGE="http://www.lua.org"
LICENSE="MIT"
REVISION="7"

ARCHITECTURES="x86 x86_gcc2"
SECONDARY_ARCHITECTURES="x86"

SOURCE_URI="http://www.lua.org/ftp/lua-$portVersion.tar.gz"
CHECKSUM_SHA256="64304da87976133196f9e4c15250b70f444467b6ed80d7cfd7b3b982b5177be5"
COPYRIGHT="1994-2012, Lua.org, PUC-Rio"
PATCHES="lua-$portVersion.patchset"

PROVIDES="
	lua$secondaryArchSuffix = $portVersion compat >= 5.2
	cmd:lua$secondaryArchSuffix = $portVersion compat >= 5.2
	cmd:lua5.2$secondaryArchSuffix = $portVersion compat >= 5.2
	cmd:luac$secondaryArchSuffix = $portVersion compat >= 5.2
	lib:liblua$secondaryArchSuffix = $portVersion compat >= 5.2
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"
PROVIDES_devel="
	lua${secondaryArchSuffix}_devel = $portVersion compat >= 5.2
	devel:liblua$secondaryArchSuffix = $portVersion compat >= 5.2
	devel:liblua52$secondaryArchSuffix = $portVersion compat >= 5.2
	"
REQUIRES_devel="
	lua$secondaryArchSuffix == $portVersion
	"
BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:make
	cmd:gcc$secondaryArchSuffix
	"

BUILD()
{
	make haiku MYCFLAGS="-DLUA_ROOT='\"$prefix/\"' -DLUA_LDIR='\"$dataDir/lua/5.2/\"'"
}

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

	ln -s liblua.so $libDir/liblua.so.5.2
	ln -s liblua.a $libDir/liblua52.a

	mv $binDir/lua $binDir/lua5.2
	ln -s $binDir/lua5.2 $binDir/lua

	prepareInstalledDevelLib liblua
	prepareInstalledDevelLib liblua52
	packageEntries devel $developDir
}
