Skip to content

Commit

Permalink
ax_lua.m4: Add 5th argument to make LuaJIT option configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed Nov 13, 2024
1 parent fadde16 commit b5d2ad0
Showing 1 changed file with 44 additions and 13 deletions.
57 changes: 44 additions & 13 deletions m4/ax_lua.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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])]
Expand Down Expand Up @@ -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).
Expand Down Expand Up @@ -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 47
#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],
[
Expand All @@ -205,10 +210,36 @@ 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
dnl flag and if so whether the default option should be with or without.
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.
Expand Down

0 comments on commit b5d2ad0

Please sign in to comment.