From 6728a324ed37280c664fcf4ae20b01adc2a947dd Mon Sep 17 00:00:00 2001 From: Pieter Lexis Date: Mon, 9 Apr 2018 15:02:39 +0200 Subject: [PATCH] Lua detection: make more robust Ensure `--with-lua=luajit` actually works and ensure we detect minimum versions for LuaJit and plain Lua correctly. --- m4/pdns_with_lua.m4 | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/m4/pdns_with_lua.m4 b/m4/pdns_with_lua.m4 index 50d8d4022..e69d0deb8 100644 --- a/m4/pdns_with_lua.m4 +++ b/m4/pdns_with_lua.m4 @@ -1,4 +1,5 @@ AC_DEFUN([PDNS_WITH_LUA],[ + AC_PROG_GREP()dnl Ensure we have grep AC_MSG_CHECKING([which Lua implementation to use]) AC_ARG_WITH([lua], [ AS_HELP_STRING([--with-lua], [select Lua implementation @<:@default=auto@:>@]) @@ -14,17 +15,21 @@ AC_DEFUN([PDNS_WITH_LUA],[ ]) LUAPC="" + luajit_min_version='2.0.3' + lua_min_version='5.1' AS_IF([test "x$with_lua" != "xno"], [ AS_IF([test "x$with_lua" != "xauto"], [ - PKG_CHECK_MODULES([LUA], $with_lua >= 5.1, [ + with_lua_version=${lua_min_version} + AS_IF([echo "x$with_lua" | ${GREP} 'jit' >/dev/null 2>&1], [with_lua_version=${luajit_min_version}]) + PKG_CHECK_MODULES([LUA], $with_lua >= $with_lua_version, [ AC_DEFINE([HAVE_LUA], [1], [Define to 1 if you have Lua]) LUAPC=$with_lua ], [ - AC_MSG_ERROR([Selected Lua not found]) + AC_MSG_ERROR([Selected Lua ($with_lua) not found]) ]) ], [ - PKG_CHECK_MODULES([LUA], [luajit], [ + PKG_CHECK_MODULES([LUA], [luajit >= ${luajit_min_version}], [ LUAPC=luajit AC_DEFINE([HAVE_LUA], [1], [Define to 1 if you have Lua]) ], [ : ]) @@ -32,7 +37,7 @@ AC_DEFUN([PDNS_WITH_LUA],[ found_lua=n m4_foreach_w([luapc], [lua5.3 lua-5.3 lua53 lua5.2 lua-5.2 lua52 lua5.1 lua-5.1 lua51 lua], [ AS_IF([test "$found_lua" != "y"], [ - PKG_CHECK_MODULES([LUA], [luapc >= 5.1], [ + PKG_CHECK_MODULES([LUA], [luapc >= ${lua_min_version}], [ AC_DEFINE([HAVE_LUA], [1], [Define to 1 if you have lua]) found_lua=y LUAPC=luapc -- 2.40.0