summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@anylike.org>2009-12-27 05:18:37 +0000
committerChristian Pointner <equinox@anylike.org>2009-12-27 05:18:37 +0000
commita17575b8fc714a04c602223e75023b9345bb2a2b (patch)
tree0684eaf5e9d4e2beb250bf703b26fdebde6bbe1d
parentadded --with-lua to build system (diff)
added lua detection to configure
-rwxr-xr-xsrc/configure50
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"