### this file is sourced not run
PKGVER=5.2.3
PKGBUILD=1
PKGARCH=i686

# source: BLFS 7.5
TARBALL=lua-$PKGVER.tar.gz
MD5SUM=dc7f94ec6ff15c985d2d6ad0f1b35654 
SRC_URL=http://www.lua.org/ftp/$TARBALL
BUNDLE=

SLACKREQ=
SLACKDESC="lua: lua $PKGVER (Lua scripting language)  
lua:  
lua: Lua is a powerful light-weight programming language designed for 
lua: extending applications. It is also frequently used as a general-purpose, 
lua: stand-alone language. Lua is implemented as a small library of C 
lua: functions, written in ANSI C, and compiles unmodified in all known 
lua: platforms. The implementation goals are simplicity, efficiency, 
lua: portability, and low embedding cost. The result is a fast language engine 
lua: with small footprint, making it ideal in embedded systems too.  
lua: 
lua:
"

### default pkg_download
### prepare
pkg_prepare() {
	pkg_prepare_default &&
	cd tmp/lua* &&
	patch -Np1 -i ../pkg/lua-5.2.3-shared_library-1.patch
	sed -i '/#define LUA_ROOT/s:/usr/local/:/usr/:' src/luaconf.h
}

### package - only collect the libraries
pkg_package() {
	rm -rf bin sbin usr/bin usr/sbin usr/include usr/share
	mkdir -p usr/include &&
	install -m644 tmp/luaconf-32.h usr/include
}

### build
pkg_build() {
	cd /tmp/lua* &&
	
	# patch for $LIBDIR
	sed -i -e "/#define LUA_CDIR/ s|lib/lua|$LIBDIR/lua|" src/luaconf.h &&
	make $MAKEFLAGS linux &&
	make INSTALL_TOP=/usr INSTALL_LIB=/usr/$LIBDIR INSTALL_CMOD=/usr/$LIBDIR/lua/5.2 \
		 TO_LIB="liblua.so liblua.so.5.2 liblua.so.$PKGVER" \
		 INSTALL_DATA="cp -d" INSTALL_MAN=/usr/share/man/man1 install &&
	mkdir -pv /usr/share/doc/lua-$PKGVER &&
	cp -v doc/*.{html,css,gif,png} /usr/share/doc/lua-$PKGVER &&
	install -m644 /tmp/pkg/lua.pc /usr/$LIBDIR/pkgconfig/lua.pc &&
	pkg_build_slackdesc &&

	# multilib
	mv /usr/include/luaconf.h /tmp/luaconf-32.h
}


