Skip to content

@shirosaki /vim_luajit.patch
Last active

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Add --with-luajit to link vim with luajit
diff --git a/src/Makefile b/src/Makefile
--- a/src/Makefile
+++ b/src/Makefile
@@ -376,18 +376,22 @@ CClink = $(CC)
# Uncomment the next line to fail if one of the requested language interfaces
# cannot be configured. Without this Vim will be build anyway, without
# the failing interfaces.
#CONF_OPT_FAIL = --enable-fail-if-missing
# 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
# MZSCHEME
# Uncomment this when you want to include the MzScheme interface.
#CONF_OPT_MZSCHEME = --enable-mzschemeinterp
# PLT/mrscheme/drscheme Home dir; the PLTHOME environment variable also works
#CONF_OPT_PLTHOME = --with-plthome=/usr/local/plt
diff --git a/src/auto/configure b/src/auto/configure
--- a/src/auto/configure
+++ b/src/auto/configure
@@ -669,16 +669,18 @@ MZSCHEME_PRO
MZSCHEME_OBJ
MZSCHEME_SRC
vi_cv_path_mzscheme
LUA_CFLAGS
LUA_LIBS
LUA_PRO
LUA_OBJ
LUA_SRC
+vi_cv_path_plain_lua
+vi_cv_path_luajit
vi_cv_path_lua
compiledby
dogvimdiff
dovimdiff
QUOTESED
line_break
VIEWNAME
EXNAME
@@ -753,16 +755,17 @@ with_global_runtime
with_modified_by
enable_selinux
with_features
with_compiledby
enable_xsmp
enable_xsmp_interact
enable_luainterp
with_lua_prefix
+with_luajit
enable_mzschemeinterp
with_plthome
enable_perlinterp
enable_pythoninterp
with_python_config_dir
enable_python3interp
with_python3_config_dir
enable_tclinterp
@@ -1464,16 +1467,17 @@ Optional Packages:
--with-vim-name=NAME what to call the Vim executable
--with-ex-name=NAME what to call the Ex executable
--with-view-name=NAME what to call the View executable
--with-global-runtime=DIR global runtime directory in 'runtimepath'
--with-modified-by=NAME name of who modified a release version
--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
--with-tclsh=PATH which tclsh to use (default: tclsh8.0)
--with-ruby-command=RUBY name of the Ruby command (default: ruby)
--with-x use the X Window System
--with-gnome-includes=DIR Specify location of GNOME headers
--with-gnome-libs=DIR Specify location of GNOME libs
@@ -4641,133 +4645,298 @@ fi
vi_cv_path_lua_pfx="$LUA_PREFIX"
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: not set, default to /usr" >&5
$as_echo "not set, default to /usr" >&6; }
vi_cv_path_lua_pfx="/usr"
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.
-set dummy lua; ac_word=$2
+ 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_lua+set}" = set; then :
- $as_echo_n "(cached) " >&6
-else
- case $vi_cv_path_lua in
+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_lua="$vi_cv_path_lua" # Let the user override the test with a path.
+ 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_lua="$as_dir/$ac_word$ac_exec_ext"
+ 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_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; }
-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
+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_plain_lua+set}" = set; then :
+ $as_echo_n "(cached) " >&6
+else
+ case $vi_cv_path_plain_lua in
+ [\\/]* | ?:[\\/]*)
+ 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
+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_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
+done
+ done
+IFS=$as_save_IFS
+
+ ;;
+esac
+fi
+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_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 :
- $as_echo_n "(cached) " >&6
-else
- vi_cv_version_lua=`${vi_cv_path_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; }
+if test "${vi_cv_version_plain_lua+set}" = set; then :
+ $as_echo_n "(cached) " >&6
+else
+ 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_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
-$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 "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; }
- 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_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
-$as_echo "yes" >&6; }
- 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=
+ 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
+$as_echo "yes" >&6; }
+ 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_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
+$as_echo "yes" >&6; }
+ 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=
+ 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
- fi
- if test "$fail_if_missing" = "yes" -a -z "$LUA_SRC"; then
+ 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 "$lua_ok" != "yes"; then
as_fn_error "could not configure lua" "$LINENO" 5
fi
fi
diff --git a/src/configure.in b/src/configure.in
--- a/src/configure.in
+++ b/src/configure.in
@@ -448,84 +448,170 @@ if test "$enable_luainterp" = "yes" -o "
AC_MSG_RESULT("$LUA_PREFIX")
vi_cv_path_lua_pfx="$LUA_PREFIX"
else
AC_MSG_RESULT([not set, default to /usr])
vi_cv_path_lua_pfx="/usr"
fi
fi
+ AC_MSG_CHECKING(--with-luajit)
+ AC_ARG_WITH(luajit,
+ [ --with-luajit Link with LuaJIT instead of Lua.],
+ [vi_cv_with_luajit="$withval"],
+ [vi_cv_with_luajit="no"])
+ AC_MSG_RESULT($vi_cv_with_luajit)
+
LUA_INC=
if test "X$vi_cv_path_lua_pfx" != "X"; then
- dnl -- try to find Lua executable
- AC_PATH_PROG(vi_cv_path_lua, lua)
- if test "X$vi_cv_path_lua" != "X"; then
- dnl -- find Lua version
- AC_CACHE_CHECK(Lua version, vi_cv_version_lua,
- [ vi_cv_version_lua=`${vi_cv_path_lua} -e "print(_VERSION)" | sed 's/.* //'` ])
+ if test "x$vi_cv_with_luajit" != "xno"; then
+ dnl -- try to find LuaJIT executable
+ AC_PATH_PROG(vi_cv_path_luajit, luajit)
+ if test "X$vi_cv_path_luajit" != "X"; then
+ dnl -- find LuaJIT version
+ AC_CACHE_CHECK(LuaJIT version, vi_cv_version_luajit,
+ [ vi_cv_version_luajit=`${vi_cv_path_luajit} -v | sed 's/LuaJIT \([[0-9.]]*\)\.[[0-9]] .*/\1/'` ])
+ AC_CACHE_CHECK(Lua version of LuaJIT, vi_cv_version_lua_luajit,
+ [ vi_cv_version_lua_luajit=`${vi_cv_path_luajit} -e "print(_VERSION)" | sed 's/.* //'` ])
+ vi_cv_path_lua="$vi_cv_path_luajit"
+ vi_cv_version_lua="$vi_cv_version_lua_luajit"
+ fi
+ else
+ dnl -- try to find Lua executable
+ AC_PATH_PROG(vi_cv_path_plain_lua, lua)
+ if test "X$vi_cv_path_plain_lua" != "X"; then
+ dnl -- find Lua version
+ AC_CACHE_CHECK(Lua version, vi_cv_version_plain_lua,
+ [ vi_cv_version_plain_lua=`${vi_cv_path_plain_lua} -e "print(_VERSION)" | sed 's/.* //'` ])
+ fi
+ vi_cv_path_lua="$vi_cv_path_plain_lua"
+ vi_cv_version_lua="$vi_cv_version_plain_lua"
fi
- AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include)
- if test -f $vi_cv_path_lua_pfx/include/lua.h; then
- AC_MSG_RESULT(yes)
- else
- AC_MSG_RESULT(no)
- AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua)
- if test -f $vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua/lua.h; then
- AC_MSG_RESULT(yes)
- LUA_INC=/lua$vi_cv_version_lua
+ if test "x$vi_cv_with_luajit" != "xno" && test "X$vi_cv_version_luajit" != "X"; then
+ AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit)
+ if test -f $vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit/lua.h; then
+ AC_MSG_RESULT(yes)
+ LUA_INC=/luajit-$vi_cv_version_luajit
+ fi
+ fi
+ if test "X$LUA_INC" = "X"; then
+ AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include)
+ if test -f $vi_cv_path_lua_pfx/include/lua.h; then
+ AC_MSG_RESULT(yes)
else
- AC_MSG_RESULT(no)
- vi_cv_path_lua_pfx=
+ AC_MSG_RESULT(no)
+ AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua)
+ if test -f $vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua/lua.h; then
+ AC_MSG_RESULT(yes)
+ LUA_INC=/lua$vi_cv_version_lua
+ else
+ AC_MSG_RESULT(no)
+ 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
- dnl Test alternate location using version
- 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
+ dnl Test alternate location using version
+ 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"
- AC_DEFINE(FEAT_LUA)
if test "$enable_luainterp" = "dynamic"; then
+ lua_ok="yes"
+ else
+ AC_MSG_CHECKING([if link with ${LUA_LIBS} is sane])
+ libs_save=$LIBS
+ LIBS="$LIBS $LUA_LIBS"
+ AC_TRY_LINK(,[ ],
+ AC_MSG_RESULT(yes); lua_ok="yes",
+ AC_MSG_RESULT(no); lua_ok="no"; LUA_LIBS="")
+ 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"
+ AC_DEFINE(FEAT_LUA)
+ 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
dnl Determine the sover for the current version, but fallback to
dnl liblua${vi_cv_version_lua}.so if no sover-versioned file is found.
+ AC_MSG_CHECKING(if liblua${luajit}*.${ext}* can be found in $vi_cv_path_lua_pfx)
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
+ AC_MSG_RESULT(no)
+ lua_ok="no"
+ vi_cv_dll_name_lua="liblua${luajit}.${ext}"
+ else
+ AC_MSG_RESULT(yes)
+ lua_ok="yes"
+ vi_cv_dll_name_lua="liblua${luajit}${sover}$sover2"
+ fi
fi
AC_DEFINE(DYNAMIC_LUA)
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
+ dnl OSX/x64 requires these flags. See http://luajit.org/install.html
+ 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
AC_MSG_ERROR([could not configure lua])
fi
AC_SUBST(LUA_SRC)
AC_SUBST(LUA_OBJ)
AC_SUBST(LUA_PRO)
AC_SUBST(LUA_LIBS)
AC_SUBST(LUA_CFLAGS)
fi
@ichizok

OS X 10.8.4のMacPorts環境で試しました。2つほど問題が。

  1. sedでLuaJITのバージョンを取得している箇所がありますが、ここでシステムデフォルトの /usr/bin/sed (BSD sed) が使われた場合に正しくバージョンが切り出せません。
    sed -E 's/LuaJIT ([0-9.]+)\.[0-9] .*/\1/' でよいかと思います。

  2. Lua 5.2 と LuaJIT (Lua ABI 5.1) を同じprefixでインストールしてある場合、if_lua.cのコンパイルでLua 5.2のヘッダを参照してしまうため、リンク時のシンボル解決に失敗します。
    LuaJITのヘッダが先に探索されるようにMakefileを変更しました。

--- a/src/Makefile
+++ b/src/Makefile
@@ -2552,7 +2552,7 @@        $(CCC) -o $@ if_xcmdsrv.c

 objects/if_lua.o: if_lua.c
-       $(CCC) $(LUA_CFLAGS) -o $@ if_lua.c
+       $(CC) -c -I$(srcdir) $(LUA_CFLAGS) $(ALL_CFLAGS) -o $@ if_lua.c

 objects/if_mzsch.o: if_mzsch.c $(MZSCHEME_EXTRA)
        $(CCC) -o $@ $(MZSCHEME_CFLAGS_EXTRA) if_mzsch.c
@shirosaki
Owner
  1. については、+を使うのをやめて * にしました。私はgnu sedを使っていました。ありがとうございます。
@shirosaki
Owner

2.については、LuaとLuaJITヘッダ(lua.h)のpathはどのようになっているのでしょうか?
コメントにあるpatchはportableなものではない気がします。

Ubuntuのapt-getで入れたものだと下記のようにsub directoryでheaderを分けるようになっています。brewで入れた時も似たような感じです。そのようにしておかないと、luaとluajitでheaderを切り替えるのは難しくなると思います。

/usr/include/luajit-2.0/lua.h
/usr/include/lua5.1/lua.h

@ichizok

デフォルト(ソースからインストール)では、Luaのヘッダファイルは (prefix)/include 直下に、LuaJITのヘッダファイルは (prefix)/include/luajit-2.0 以下に配置されます。

@ichizok

Vimのinstall prefixがLuaのinstall prefixと同じ場合に問題になります。
if_lua.cコンパイル時のinclude search pathに関するオプションは以下のような順番になります。
-I. -Iproto -I(vim_prefix)/include -I(lua_prefix)/include/luajit-2.0
そのため、Luaのheader directory (= (vim_prefix)/include) がLuaJITのheader direcotry (= (lua_prefix)/include/luajit-2.0) より先にinclude search pathに指定され、Luaのlua.hがインクルードされてしまいます。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.