From af5f680e46ed348a840ceec67d021040d622a029 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sun, 20 Oct 2024 11:42:34 +0300 Subject: [PATCH] chore(build): Update Lua macros again as submitted upstream to autoconf-archive --- build-aux/ax_lua.m4 | 62 +++++++++++++++++++++++++++----------- build-aux/ax_lua_module.m4 | 2 +- configure.ac | 11 ++----- 3 files changed, 48 insertions(+), 27 deletions(-) diff --git a/build-aux/ax_lua.m4 b/build-aux/ax_lua.m4 index 14a1bd63a..4e82e454e 100644 --- a/build-aux/ax_lua.m4 +++ b/build-aux/ax_lua.m4 @@ -4,7 +4,9 @@ # # SYNOPSIS # -# AX_PROG_LUA[([MINIMUM-VERSION], [TOO-BIG-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])] +# AX_PROG_LUA[([MINIMUM-VERSION], [TOO-BIG-VERSION], +# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], +# [ENABLE_LUAJIT])] # AX_LUA_HEADERS[([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])] # AX_LUA_LIBS[([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])] # AX_LUA_READLINE[([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])] @@ -49,20 +51,22 @@ # interpreter. If LUA is blank, the user's path is searched for an # suitable interpreter. # -# Optionally a LUAJIT option may be set ahead of time to look for and -# validate a LuaJIT install instead of PUC Lua. Usage might look like: -# -# AC_ARG_WITH(luajit, [AS_HELP_STRING([--with-luajit], -# [Prefer LuaJIT over PUC Lua, even if the latter is newer. Default: no]) -# ]) -# AM_CONDITIONAL([LUAJIT], [test "x$with_luajit" != 'xno']) -# # If MINIMUM-VERSION is supplied, then only Lua interpreters with a # version number greater or equal to MINIMUM-VERSION will be accepted. If # TOO-BIG-VERSION is also supplied, then only Lua interpreters with a # version number greater or equal to MINIMUM-VERSION and less than # TOO-BIG-VERSION will be accepted. # +# Optionally, the fifth argument ENABLE_LUAJIT can be set to control whether +# LuaJIT or PUC Lua should be considered during discovery. An empty value or +# 'never' means only PUC Lua installations will be considered; a value of +# 'always' means PUC is not even considered and only LuaJIT is discovered; +# 'prefer' means LuaJIT should be used if found but allow PUC , and finally +# 'allow' means it should not be chosen if any PUC Lua version is found but +# it could be used as a last resort. For 'default' and 'allow' a new +# configure flag will be provided to the user --with-luajit with the default +# option being either 'yes' or 'no' respectively. +# # The Lua version number, LUA_VERSION, is found from the interpreter, and # substituted. LUA_PLATFORM is also found, but not currently supported (no # standard representation). @@ -190,11 +194,12 @@ # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. -#serial 45 +#serial 48 dnl ========================================================================= dnl AX_PROG_LUA([MINIMUM-VERSION], [TOO-BIG-VERSION], -dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND] +dnl [ENABLE_LUAJIT]) dnl ========================================================================= AC_DEFUN([AX_PROG_LUA], [ @@ -205,10 +210,35 @@ AC_DEFUN([AX_PROG_LUA], dnl Make LUA a precious variable. AC_ARG_VAR([LUA], [The Lua interpreter, e.g. /usr/bin/lua5.1]) + dnl Figure out whether we should expose LuaJIT as a user facing configure flag + AS_CASE(["m4_default([$5], [never])"], + [never], [ default_luajit=no; with_luajit=no ], + [always], [ default_luajit=yes; with_luajit=yes ], + [allow], [ + default_luajit=no + m4_if([$5], [allow], [ + AC_ARG_WITH([luajit], + [AS_HELP_STRING([--with-luajit], + [prefer LuaJIT over PUC Lua, even if the latter is newer])]) + ]) + test "x$with_luajit" != 'xyes' && with_luajit=no + ], + [prefer], [ + default_luajit=yes + m4_if([$5], [prefer], [ + AC_ARG_WITH([luajit], + [AS_HELP_STRING([--without-luajit], + [prefer PUC Lua over LuaJIT])]) + ]) + test "x$with_luajit" != 'xno' && with_luajit=yes + ], + [AC_MSG_ERROR([Unrecognized value for ENABLE_LUAJIT])]) + AM_CONDITIONAL([LUAJIT], [test "x$with_luajit" == "xyes"]) + dnl Find a Lua interpreter. AM_COND_IF([LUAJIT], - [_ax_lua_interpreter_list='luajit luajit-2.1.0-beta3 luajit-2.0.5 luajit-2.0.4 luajit-2.0.3'], - [_ax_lua_interpreter_list='lua lua5.4 lua54 lua5.3 lua53 lua5.2 lua52 lua5.1 lua51 lua5.0 lua50']) + [_ax_lua_interpreter_list='luajit luajit-2.1.0-beta3 luajit-2.0.5 luajit-2.0.4 luajit-2.0.3'], + [_ax_lua_interpreter_list='lua lua5.4 lua54 lua5.3 lua53 lua5.2 lua52 lua5.1 lua51 lua5.0 lua50']) m4_if([$1], [], [ dnl No version check is needed. Find any Lua interpreter. @@ -371,11 +401,7 @@ AC_DEFUN([AX_PROG_LUA], ]) dnl AX_WITH_LUA is now the same thing as AX_PROG_LUA. -AC_DEFUN([AX_WITH_LUA], -[ - AC_MSG_WARN([[$0 is deprecated, please use AX_PROG_LUA instead]]) - AX_PROG_LUA -]) +AU_DEFUN([AX_WITH_LUA], [AX_PROG_LUA], [$0 is deprecated, please use AX_PROG_LUA instead]) dnl ========================================================================= diff --git a/build-aux/ax_lua_module.m4 b/build-aux/ax_lua_module.m4 index a1e518f98..ef4b2e57b 100644 --- a/build-aux/ax_lua_module.m4 +++ b/build-aux/ax_lua_module.m4 @@ -2,7 +2,7 @@ AC_DEFUN([AX_LUA_MODULE], [ - AX_PROG_LUA([5.1]) + AX_PROG_LUA([5.1], [], [], [], [prefer]) AC_MSG_CHECKING([whether Lua can load module $1]) AS_IF([$LUA -e 'require("$1")' 2>/dev/null], [ AC_MSG_RESULT([loaded]) diff --git a/configure.ac b/configure.ac index 5b7b9362e..77abc60c0 100644 --- a/configure.ac +++ b/configure.ac @@ -81,11 +81,6 @@ AC_ARG_WITH([system-lua-sources], AM_CONDITIONAL([SYSTEM_LUA_SOURCES], [test "x$with_system_lua_sources" = "xyes"]) AC_SUBST([SYSTEM_LUA_SOURCES]) -AC_ARG_WITH([luajit], - AS_HELP_STRING([--without-luajit], - [Prefer LuaJIT over PUC Lua, even if the latter is newer])) -AM_CONDITIONAL([LUAJIT], [test "x$with_luajit" != "xno"]) - AC_ARG_WITH([manual], AS_HELP_STRING([--with-manual], [Rebuild manual and install to system’s PDF documentation directory])) @@ -186,7 +181,7 @@ AM_COND_IF([DEVELOPER_MODE], [ QUE_PROGVAR([typos]) ]) -AX_PROG_LUA([5.1]) +AX_PROG_LUA([5.1], [], [], [], [prefer]) AX_LUA_HEADERS AX_LUA_LIBS @@ -197,9 +192,9 @@ AM_COND_IF([SYSTEM_LUAROCKS], [ ]) ]) AX_LUA_MODULE([cassowary], [cassowary]) - AS_IF([test "$LUA_SHORT_VERSION" -lt 53], + AS_IF([test "$LUA_SHORT_VERSION" -lt 53], [ AX_LUA_MODULE([compat53], [compat53]) - ) + ]) AX_LUA_MODULE([cldr], [cldr]) AX_LUA_MODULE([fluent], [fluent]) AX_LUA_MODULE([linenoise], [linenoise])