From b3c7318d799282af7a78fdd4587d86c953b70903 Mon Sep 17 00:00:00 2001
From: Christian Pointner <equinox@helsinki.at>
Date: Sat, 9 May 2015 23:26:48 +0200
Subject: lua version is now selectable via configure


diff --git a/src/configure b/src/configure
index 6cebe01..75ed3e6 100755
--- a/src/configure
+++ b/src/configure
@@ -27,6 +27,7 @@ USE_CLANG=0
 
 LUA_DIR=''
 LUA=''
+LUA_VER=''
 
 PREFIX='/usr/local'
 BINDIR=''
@@ -41,6 +42,7 @@ print_usage() {
   echo "          --sysconfdir=<DIR>        the path to the system configuration directory (default: $PREFIX/etc)"
   echo "          --libdir=<DIR>            the path to the lua library directory (default: $PREFIX/lib/rhnop)"
   echo "          --with-lua=<DIR>          use this lua tree instead of system default"
+  echo "          --lua-version=nnn         set fixed Lua version for automatic detection (501 -> 5.1, 502 -> 5.2)"
   echo "          --use-clang               use clang/llvm as compiler/linker"
 }
 
@@ -68,6 +70,9 @@ do
   --with-lua=*)
     LUA_DIR=${arg#--with-lua=}
   ;;
+  --lua-version=*)
+    LUA_VER=${arg#--lua-version=}
+  ;;
   --ebuild-compat)
     EBUILD_COMPAT=1
   ;;
@@ -124,15 +129,23 @@ test_lua_version()
 
   if [ -z "$LUA_VERSION_MAJ" ]; then
       LUA_VERSION=`cat $1 | grep "#define LUA_VERSION[ 	]" | cut -f2- | tr -d '"' | sed -e 's/Lua \([0-9][0-9.]*\)/\1/'`
-      LUA_RELEASE=`cat $1 | grep "#define LUA_RELEASE[ 	]" | cut -f2-`
+      LUA_RELEASE=`cat $1 | grep "#define LUA_RELEASE[ 	]" | cut -f2- | tr -d '"' | sed -e 's/Lua //'`
   fi
 
   LUA_VERSION_NUM=`cat $1 | grep "#define LUA_VERSION_NUM" | awk '{ print $3 }'`
 
-  if [ $LUA_VERSION_NUM -ge 501 ]; then
-    return 1;
+  if [ -n "$LUA_VER" ]; then
+    if [ "$LUA_VER" -eq $LUA_VERSION_NUM ]; then
+      return 1
+    else
+      return 0
+    fi
   else
-    return 0;
+    if [ $LUA_VERSION_NUM -ge 501 ]; then
+      return 1
+    else
+      return 0
+    fi
   fi
 }
 
-- 
cgit v0.10.2