diff options
Diffstat (limited to 'src')
-rwxr-xr-x | src/configure | 50 |
1 files changed, 47 insertions, 3 deletions
diff --git a/src/configure b/src/configure index fdc1e0c..49562cf 100755 --- a/src/configure +++ b/src/configure @@ -138,10 +138,54 @@ case $CRYPTO_LIB in ;; esac +test_lua_version() +{ + LUA_VERSION=`cat $1 | grep "#define LUA_VERSION[ ]" | cut -f2- | tr -d '"' | sed -e 's/Lua \([0-9][0-9.]*\)/\1/'` + LUA_VERSION_NUM=`cat $1 | grep "#define LUA_VERSION_NUM" | awk '{ print $3 }'` + LUA_RELEASE=`cat $1 | grep "#define LUA_RELEASE[ ]" | cut -f2-` + + if [ $LUA_VERSION_NUM -ge 500 ]; then + return 1; + else + return 0; + fi +} + if [ -z "$LUA_DIR" ]; then - CFLAGS="$CFLAGS -I/usr/include/lua5.1" - LDFLAGS="$LDFLAGS -llua5.1" - LUAC=luac5.1 + for prefix in /usr /usr/local; do + if [ -e $prefix/include/lua.h ]; then + test_lua_version $prefix/include/lua.h + if [ $? -eq 1 ]; then + echo "using Lua $LUA_VERSION ($LUA_RELEASE) found at $prefix/include" + CFLAGS="$CFLAGS -I$prefix/include" + LDFLAGS="$LDFLAGS -L$prefix/lib -llua" + LUAC=$prefix/luac + break + fi + else + for dir in $prefix/include/lua*; do + if [ -e $dir/lua.h ]; then + test_lua_version $dir/lua.h + if [ $? -eq 1 ]; then + echo "using Lua $LUA_VERSION ($LUA_RELEASE) found at $dir" + CFLAGS="$CFLAGS -I$dir" + LDFLAGS="$LDFLAGS -L$prefix/lib -llua$LUA_VERSION" + LUAC=$prefix/bin/luac$LUA_VERSION + break + fi + fi + done + if [ -n $LUAC ]; then + break + fi + fi + done + + if [ -z $LUAC ]; then + echo "ERROR: no suitable lua found .. please install lua 5.1 or higher or use --with-lua" + return 1 + fi + else CFLAGS="$CFLAGS -I$LUA_DIR/include" LDFLAGS="$LDFLAGS $LUA_DIR/lib/liblua.a" |