#Maintainer: George Vlahavas <vlahavas~at~gmail~dot~com>

pkgname=lua
pkgver=5.1.4
pkgrel=5gv
source=("http://www.lua.org/ftp/lua-$pkgver.tar.gz" "util.lua" "lua-5.1.pc" "lua.sh" "lua.csh")
docs=("readme" "install" "copying" "changelog" "authors" "news" "todo" "copyright" "history")
url=http://www.lua.org/
options=('noautodotnew')

slackdesc=\
(
#|-----handy-ruler------------------------------------------------------|
"lua (a powerful, fast, lightweight, embeddable scripting language)"
"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."
)


build() {
	cd $startdir/src/$pkgname-$pkgver
	sed -i "s|(INSTALL_TOP)/lib|(INSTALL_TOP)/lib${LIBDIRSUFFIX}|" Makefile
	make linux CFLAGS="$CFLAGS -DLUA_USE_LINUX" || return 1
	make install INSTALL_TOP=$startdir/pkg/usr/
	
	mkdir -p $startdir/pkg/etc/profile.d
	install -m 755 $startdir/src/lua.sh $startdir/pkg/etc/profile.d/
	install -m 755 $startdir/src/lua.csh $startdir/pkg/etc/profile.d/

	# we shouldn't have to do these manually...
	cp $startdir/src/util.lua $startdir/pkg/usr/lib${LIBDIRSUFFIX}/lua/5.1/
	mkdir -p $startdir/pkg/usr/lib${LIBDIRSUFFIX}/pkgconfig
	cp $startdir/src/lua-5.1.pc $startdir/pkg/usr/lib${LIBDIRSUFFIX}/pkgconfig/
	( 
	cd $startdir/pkg/usr/lib${LIBDIRSUFFIX}/pkgconfig
	ln -s lua-5.1.pc lua.pc
	)

	mkdir -p $startdir/pkg/usr/doc/$pkgname-$pkgver
	cp -a COPYRIGHT HISTORY INSTALL README doc/*.html doc/*.css doc/*.gif \
		$startdir/pkg/usr/doc/$pkgname-$pkgver
}