configure
changeset 9421 44a2609d1535
parent 9420 f5a471303e6a
child 9422 78c58a1089ea
equal deleted inserted replaced
9420:f5a471303e6a 9421:44a2609d1535
    90 }
    90 }
    91 
    91 
    92 # Helper functions
    92 # Helper functions
    93 
    93 
    94 find_program() {
    94 find_program() {
    95    prog=`command -v "$1" 2>/dev/null`
    95    prog=$(command -v "$1" 2>/dev/null)
    96    if [ -n "$prog" ]
    96    if [ -n "$prog" ]
    97    then
    97    then
    98       dirname "$prog"
    98       dirname "$prog"
    99    fi
    99    fi
   100 }
   100 }
   122 
   122 
   123 # Parse options
   123 # Parse options
   124 
   124 
   125 while [ -n "$1" ]
   125 while [ -n "$1" ]
   126 do
   126 do
   127    value="`echo $1 | sed 's/[^=]*.\(.*\)/\1/'`"
   127    value=$(echo "$1" | sed 's/[^=]*.\(.*\)/\1/')
   128    key="`echo $1 | sed 's/=.*//'`"
   128    key=$(echo "$1" | sed 's/=.*//')
   129    if `echo "$value" | grep "~" >/dev/null 2>/dev/null`
   129    if echo "$value" | grep "~" >/dev/null 2>/dev/null
   130    then
   130    then
   131       echo
   131       echo
   132       echo '*WARNING*: the "~" sign is not expanded in flags.'
   132       echo '*WARNING*: the "~" sign is not expanded in flags.'
   133       echo 'If you mean the home directory, use $HOME instead.'
   133       echo 'If you mean the home directory, use $HOME instead.'
   134       echo
   134       echo
   336 then
   336 then
   337    LIBDIR=$PREFIX/lib
   337    LIBDIR=$PREFIX/lib
   338 fi
   338 fi
   339 
   339 
   340 detect_lua_version() {
   340 detect_lua_version() {
   341    detected_lua=`$1 -e 'print(_VERSION:match(" (5%.[123])$"))' 2> /dev/null`
   341    detected_lua=$("$1" -e 'print(_VERSION:match(" (5%.[123])$"))' 2> /dev/null)
   342    if [ "$detected_lua" != "nil" ]
   342    if [ "$detected_lua" != "nil" ]
   343    then
   343    then
   344       if [ "$LUA_VERSION_SET" != "yes" ]
   344       if [ "$LUA_VERSION_SET" != "yes" ]
   345       then
   345       then
   346          echo "Lua version detected: $detected_lua"
   346          echo "Lua version detected: $detected_lua"
   365       if [ -f "$LUA_BINDIR/lua$suffix" ]
   365       if [ -f "$LUA_BINDIR/lua$suffix" ]
   366       then
   366       then
   367          find_lua="$LUA_BINDIR"
   367          find_lua="$LUA_BINDIR"
   368       fi
   368       fi
   369    else
   369    else
   370       find_lua=`find_program lua$suffix`
   370       find_lua=$(find_program lua"$suffix")
   371    fi
   371    fi
   372    if [ -n "$find_lua" -a -x "$find_lua/lua$suffix" ]
   372    if [ -n "$find_lua" -a -x "$find_lua/lua$suffix" ]
   373    then
   373    then
   374       if detect_lua_version "$find_lua/lua$suffix"
   374       if detect_lua_version "$find_lua/lua$suffix"
   375       then
   375       then
   378          then
   378          then
   379             LUA_BINDIR="$find_lua"
   379             LUA_BINDIR="$find_lua"
   380          fi
   380          fi
   381          if [ "$LUA_DIR_SET" != "yes" ]
   381          if [ "$LUA_DIR_SET" != "yes" ]
   382          then
   382          then
   383             LUA_DIR=`dirname "$find_lua"`
   383             LUA_DIR=$(dirname "$find_lua")
   384          fi
   384          fi
   385          LUA_SUFFIX="$suffix"
   385          LUA_SUFFIX="$suffix"
   386          return 0
   386          return 0
   387       fi
   387       fi
   388    fi
   388    fi