Skip to content

Commit

Permalink
updated for version 7.4a.045
Browse files Browse the repository at this point in the history
Problem:    Configure does not always find the right library for Lua.  Missing
            support for LuaJit.
Solution:   Improve the configure detection of Lua. (Hiroshi Shirosaki)
  • Loading branch information
brammool committed Jul 28, 2013
1 parent e2db695 commit e855ccf
Show file tree
Hide file tree
Showing 4 changed files with 339 additions and 78 deletions.
4 changes: 4 additions & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,12 @@ CClink = $(CC)
# LUA
# Uncomment one of these when you want to include the Lua interface.
# First one is for static linking, second one for dynamic loading.
# Use --with-luajit if you want to use LuaJIT instead of Lua.
# Set PATH environment variable to find lua or luajit executable.
#CONF_OPT_LUA = --enable-luainterp
#CONF_OPT_LUA = --enable-luainterp=dynamic
#CONF_OPT_LUA = --enable-luainterp --with-luajit
#CONF_OPT_LUA = --enable-luainterp=dynamic --with-luajit
# Lua installation dir (when not set uses $LUA_PREFIX or defaults to /usr)
#CONF_OPT_LUA_PREFIX = --with-lua-prefix=/usr/local

Expand Down
257 changes: 213 additions & 44 deletions src/auto/configure
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,8 @@ LUA_LIBS
LUA_PRO
LUA_OBJ
LUA_SRC
vi_cv_path_plain_lua
vi_cv_path_luajit
vi_cv_path_lua
compiledby
dogvimdiff
Expand Down Expand Up @@ -758,6 +760,7 @@ enable_xsmp
enable_xsmp_interact
enable_luainterp
with_lua_prefix
with_luajit
enable_mzschemeinterp
with_plthome
enable_perlinterp
Expand Down Expand Up @@ -1469,6 +1472,7 @@ Optional Packages:
--with-features=TYPE tiny, small, normal, big or huge (default: normal)
--with-compiledby=NAME name to show in :version message
--with-lua-prefix=PFX Prefix where Lua is installed.
--with-luajit Link with LuaJIT instead of Lua.
--with-plthome=PLTHOME Use PLTHOME.
--with-python-config-dir=PATH Python's config directory
--with-python3-config-dir=PATH Python's config directory
Expand Down Expand Up @@ -4646,18 +4650,95 @@ $as_echo "not set, default to /usr" >&6; }
fi
fi

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking --with-luajit" >&5
$as_echo_n "checking --with-luajit... " >&6; }

# Check whether --with-luajit was given.
if test "${with_luajit+set}" = set; then :
withval=$with_luajit; vi_cv_with_luajit="$withval"
else
vi_cv_with_luajit="no"
fi

{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $vi_cv_with_luajit" >&5
$as_echo "$vi_cv_with_luajit" >&6; }

LUA_INC=
if test "X$vi_cv_path_lua_pfx" != "X"; then
# Extract the first word of "lua", so it can be a program name with args.
if test "x$vi_cv_with_luajit" != "xno"; then
# Extract the first word of "luajit", so it can be a program name with args.
set dummy luajit; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_path_vi_cv_path_luajit+set}" = set; then :
$as_echo_n "(cached) " >&6
else
case $vi_cv_path_luajit in
[\\/]* | ?:[\\/]*)
ac_cv_path_vi_cv_path_luajit="$vi_cv_path_luajit" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_path_vi_cv_path_luajit="$as_dir/$ac_word$ac_exec_ext"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS

;;
esac
fi
vi_cv_path_luajit=$ac_cv_path_vi_cv_path_luajit
if test -n "$vi_cv_path_luajit"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $vi_cv_path_luajit" >&5
$as_echo "$vi_cv_path_luajit" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi


if test "X$vi_cv_path_luajit" != "X"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking LuaJIT version" >&5
$as_echo_n "checking LuaJIT version... " >&6; }
if test "${vi_cv_version_luajit+set}" = set; then :
$as_echo_n "(cached) " >&6
else
vi_cv_version_luajit=`${vi_cv_path_luajit} -v | sed 's/LuaJIT \([0-9.]*\)\.[0-9] .*/\1/'`
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $vi_cv_version_luajit" >&5
$as_echo "$vi_cv_version_luajit" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Lua version of LuaJIT" >&5
$as_echo_n "checking Lua version of LuaJIT... " >&6; }
if test "${vi_cv_version_lua_luajit+set}" = set; then :
$as_echo_n "(cached) " >&6
else
vi_cv_version_lua_luajit=`${vi_cv_path_luajit} -e "print(_VERSION)" | sed 's/.* //'`
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $vi_cv_version_lua_luajit" >&5
$as_echo "$vi_cv_version_lua_luajit" >&6; }
vi_cv_path_lua="$vi_cv_path_luajit"
vi_cv_version_lua="$vi_cv_version_lua_luajit"
fi
else
# Extract the first word of "lua", so it can be a program name with args.
set dummy lua; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_path_vi_cv_path_lua+set}" = set; then :
if test "${ac_cv_path_vi_cv_path_plain_lua+set}" = set; then :
$as_echo_n "(cached) " >&6
else
case $vi_cv_path_lua in
case $vi_cv_path_plain_lua in
[\\/]* | ?:[\\/]*)
ac_cv_path_vi_cv_path_lua="$vi_cv_path_lua" # Let the user override the test with a path.
ac_cv_path_vi_cv_path_plain_lua="$vi_cv_path_plain_lua" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
Expand All @@ -4667,7 +4748,7 @@ do
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_path_vi_cv_path_lua="$as_dir/$ac_word$ac_exec_ext"
ac_cv_path_vi_cv_path_plain_lua="$as_dir/$ac_word$ac_exec_ext"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
Expand All @@ -4678,91 +4759,179 @@ IFS=$as_save_IFS
;;
esac
fi
vi_cv_path_lua=$ac_cv_path_vi_cv_path_lua
if test -n "$vi_cv_path_lua"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $vi_cv_path_lua" >&5
$as_echo "$vi_cv_path_lua" >&6; }
vi_cv_path_plain_lua=$ac_cv_path_vi_cv_path_plain_lua
if test -n "$vi_cv_path_plain_lua"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $vi_cv_path_plain_lua" >&5
$as_echo "$vi_cv_path_plain_lua" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi


if test "X$vi_cv_path_lua" != "X"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Lua version" >&5
if test "X$vi_cv_path_plain_lua" != "X"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Lua version" >&5
$as_echo_n "checking Lua version... " >&6; }
if test "${vi_cv_version_lua+set}" = set; then :
if test "${vi_cv_version_plain_lua+set}" = set; then :
$as_echo_n "(cached) " >&6
else
vi_cv_version_lua=`${vi_cv_path_lua} -e "print(_VERSION)" | sed 's/.* //'`
vi_cv_version_plain_lua=`${vi_cv_path_plain_lua} -e "print(_VERSION)" | sed 's/.* //'`
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $vi_cv_version_lua" >&5
$as_echo "$vi_cv_version_lua" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $vi_cv_version_plain_lua" >&5
$as_echo "$vi_cv_version_plain_lua" >&6; }
fi
vi_cv_path_lua="$vi_cv_path_plain_lua"
vi_cv_version_lua="$vi_cv_version_plain_lua"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if lua.h can be found in $vi_cv_path_lua_pfx/include" >&5
if test "x$vi_cv_with_luajit" != "xno" && test "X$vi_cv_version_luajit" != "X"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if lua.h can be found in $vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit" >&5
$as_echo_n "checking if lua.h can be found in $vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit... " >&6; }
if test -f $vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit/lua.h; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
LUA_INC=/luajit-$vi_cv_version_luajit
fi
fi
if test "X$LUA_INC" = "X"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if lua.h can be found in $vi_cv_path_lua_pfx/include" >&5
$as_echo_n "checking if lua.h can be found in $vi_cv_path_lua_pfx/include... " >&6; }
if test -f $vi_cv_path_lua_pfx/include/lua.h; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
if test -f $vi_cv_path_lua_pfx/include/lua.h; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if lua.h can be found in $vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua" >&5
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if lua.h can be found in $vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua" >&5
$as_echo_n "checking if lua.h can be found in $vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua... " >&6; }
if test -f $vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua/lua.h; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
if test -f $vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua/lua.h; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
LUA_INC=/lua$vi_cv_version_lua
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
LUA_INC=/lua$vi_cv_version_lua
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
vi_cv_path_lua_pfx=
vi_cv_path_lua_pfx=
fi
fi
fi
fi

if test "X$vi_cv_path_lua_pfx" != "X"; then
if test "X$LUA_INC" != "X"; then
LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua$vi_cv_version_lua"
if test "x$vi_cv_with_luajit" != "xno"; then
multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
if test "X$multiarch" != "X"; then
lib_multiarch="lib/${multiarch}"
else
lib_multiarch="lib"
fi
if test "X$vi_cv_version_lua" = "X"; then
LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit"
else
LUA_LIBS="-L${vi_cv_path_lua_pfx}/${lib_multiarch} -lluajit-$vi_cv_version_lua"
fi
else
LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua"
if test "X$LUA_INC" != "X"; then
LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua$vi_cv_version_lua"
else
LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua"
fi
fi
LUA_CFLAGS="-I${vi_cv_path_lua_pfx}/include${LUA_INC}"
LUA_SRC="if_lua.c"
LUA_OBJ="objects/if_lua.o"
LUA_PRO="if_lua.pro"
$as_echo "#define FEAT_LUA 1" >>confdefs.h
if test "$enable_luainterp" = "dynamic"; then
lua_ok="yes"
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if link with ${LUA_LIBS} is sane" >&5
$as_echo_n "checking if link with ${LUA_LIBS} is sane... " >&6; }
libs_save=$LIBS
LIBS="$LIBS $LUA_LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }; lua_ok="yes"
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }; lua_ok="no"; LUA_LIBS=""
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$libs_save
fi
if test "x$lua_ok" = "xyes"; then
LUA_CFLAGS="-I${vi_cv_path_lua_pfx}/include${LUA_INC}"
LUA_SRC="if_lua.c"
LUA_OBJ="objects/if_lua.o"
LUA_PRO="if_lua.pro"
$as_echo "#define FEAT_LUA 1" >>confdefs.h

fi
if test "$enable_luainterp" = "dynamic"; then
if test "x$vi_cv_with_luajit" != "xno"; then
luajit="jit"
fi
if test -f "${vi_cv_path_lua_pfx}/bin/cyglua-${vi_cv_version_lua}.dll"; then
vi_cv_dll_name_lua="cyglua-${vi_cv_version_lua}.dll"
else
multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
if test "X$multiarch" != "X"; then
lib_multiarch="lib/${multiarch}"
if test "x$MACOSX" = "xyes"; then
ext="dylib"
indexes=""
else
ext="so"
indexes=".0 .1 .2 .3 .4 .5 .6 .7 .8 .9"
multiarch=`dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null`
if test "X$multiarch" != "X"; then
lib_multiarch="lib/${multiarch}"
fi
fi
for subdir in "${lib_multiarch}" lib64 lib; do
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if liblua${luajit}*.${ext}* can be found in $vi_cv_path_lua_pfx" >&5
$as_echo_n "checking if liblua${luajit}*.${ext}* can be found in $vi_cv_path_lua_pfx... " >&6; }
for subdir in "${lib_multiarch}" lib64 lib; do
if test -z "$subdir"; then
continue
fi
for sover in "${vi_cv_version_lua}.so" "-${vi_cv_version_lua}.so" ".so.${vi_cv_version_lua}"; do
for i in .0 .1 .2 .3 .4 .5 .6 .7 .8 .9 ""; do
if test -f "${vi_cv_path_lua_pfx}/${subdir}/liblua${sover}$i"; then
for sover in "${vi_cv_version_lua}.${ext}" "-${vi_cv_version_lua}.${ext}" \
".${vi_cv_version_lua}.${ext}" ".${ext}.${vi_cv_version_lua}"; do
for i in $indexes ""; do
if test -f "${vi_cv_path_lua_pfx}/${subdir}/liblua${luajit}${sover}$i"; then
sover2="$i"
break 3
fi
done
done
sover=""
done
vi_cv_dll_name_lua="liblua${sover}$sover2"
if test "X$sover" = "X"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
lua_ok="no"
vi_cv_dll_name_lua="liblua${luajit}.${ext}"
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
lua_ok="yes"
vi_cv_dll_name_lua="liblua${luajit}${sover}$sover2"
fi
fi
$as_echo "#define DYNAMIC_LUA 1" >>confdefs.h

LUA_LIBS=""
LUA_CFLAGS="-DDYNAMIC_LUA_DLL=\\\"${vi_cv_dll_name_lua}\\\" $LUA_CFLAGS"
fi
if test "X$LUA_CFLAGS$LUA_LIBS" != "X" && \
test "x$MACOSX" = "xyes" && test "x$vi_cv_with_luajit" != "xno" && \
test "`(uname -m) 2>/dev/null`" = "x86_64"; then
LUA_LIBS="-pagezero_size 10000 -image_base 100000000 $LUA_LIBS"
fi
fi
if test "$fail_if_missing" = "yes" -a -z "$LUA_SRC"; then
if test "$fail_if_missing" = "yes" -a "$lua_ok" != "yes"; then
as_fn_error "could not configure lua" "$LINENO" 5
fi

Expand Down
Loading

0 comments on commit e855ccf

Please sign in to comment.