public
Last active

Add --with-luajit to link vim with luajit

  • Download Gist
vim_luajit.patch
Diff
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654
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

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
  1. については、+を使うのをやめて * にしました。私はgnu sedを使っていました。ありがとうございます。

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

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

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がインクルードされてしまいます。

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.