From 026090e8986e5d5158d54410f1ae3a97bd9e34db Mon Sep 17 00:00:00 2001 From: Pieter Lexis Date: Wed, 4 Apr 2018 18:31:37 +0200 Subject: [PATCH] Re-do Lua detection Detect LuaJIT first, then other implementations. Allows setting `--with-lua` to a specific implementation as well (e.g. `lua51`). Will produce errors appropriately. Fixes #6423. --- build-scripts/build-auth-rpm | 2 +- build-scripts/build-dnsdist-rpm | 2 +- build-scripts/build-recursor-rpm | 2 +- build-scripts/debian-authoritative/rules | 2 +- build-scripts/debian-dnsdist/rules | 2 +- build-scripts/debian-recursor/rules | 2 +- configure.ac | 7 +-- m4/pdns_check_lua_hpp.m4 | 3 +- m4/pdns_with_lua.m4 | 73 ++++++++++++++---------- m4/pdns_with_luajit.m4 | 22 ------- pdns/dnsdistdist/configure.ac | 15 +---- pdns/dnsdistdist/m4/pdns_with_luajit.m4 | 1 - pdns/recursordist/configure.ac | 15 +---- pdns/recursordist/m4/pdns_with_luajit.m4 | 1 - 14 files changed, 57 insertions(+), 92 deletions(-) delete mode 100644 m4/pdns_with_luajit.m4 delete mode 120000 pdns/dnsdistdist/m4/pdns_with_luajit.m4 delete mode 120000 pdns/recursordist/m4/pdns_with_luajit.m4 diff --git a/build-scripts/build-auth-rpm b/build-scripts/build-auth-rpm index 18c0d068b2..37b5693f46 100755 --- a/build-scripts/build-auth-rpm +++ b/build-scripts/build-auth-rpm @@ -696,7 +696,7 @@ export CPPFLAGS="-DLDAP_DEPRECATED" --disable-dependency-tracking \ --disable-silent-rules \ --with-modules='' \ - --with-luajit \ + --with-lua=luajit \ --with-dynmodules='%{backends} random' \ --enable-tools \ --enable-libsodium \ diff --git a/build-scripts/build-dnsdist-rpm b/build-scripts/build-dnsdist-rpm index 5a334628b3..118bf2e2b5 100755 --- a/build-scripts/build-dnsdist-rpm +++ b/build-scripts/build-dnsdist-rpm @@ -46,7 +46,7 @@ SNMP_CONFIGURE='--with-net-snmp \' # CentOS 6 has no luajit LUA_BUILDREQUIRES='BuildRequires: luajit-devel' -LUA_CONFIGURE='--with-luajit \' +LUA_CONFIGURE='--with-lua=luajit \' # These two are the same for sysv and systemd (we don't install defaults files at the moment) DEFAULTS_INSTALL='' diff --git a/build-scripts/build-recursor-rpm b/build-scripts/build-recursor-rpm index b48aab9513..9247884161 100755 --- a/build-scripts/build-recursor-rpm +++ b/build-scripts/build-recursor-rpm @@ -237,7 +237,7 @@ package if you need a dns cache for your network. --with-protobuf \ --enable-libsodium \ --with-net-snmp \ - --with-luajit \ + --with-lua=luajit \ --enable-systemd make %{?_smp_mflags} diff --git a/build-scripts/debian-authoritative/rules b/build-scripts/debian-authoritative/rules index db29abecda..784721f9d8 100755 --- a/build-scripts/debian-authoritative/rules +++ b/build-scripts/debian-authoritative/rules @@ -52,7 +52,7 @@ override_dh_auto_configure: --with-modules="" \ --enable-tools \ --enable-unit-tests \ - --with-luajit \ + --with-lua=luajit \ --enable-experimental-pkcs11 \ $(ENABLE_SYSTEMD) \ $(ENABLE_LIBSODIUM) diff --git a/build-scripts/debian-dnsdist/rules b/build-scripts/debian-dnsdist/rules index cf0c6c704d..db20fe94a7 100755 --- a/build-scripts/debian-dnsdist/rules +++ b/build-scripts/debian-dnsdist/rules @@ -65,7 +65,7 @@ override_dh_auto_configure: --libexecdir='$${prefix}/lib' \ --with-protobuf=yes \ --with-net-snmp \ - --with-luajit \ + --with-lua=luajit \ $(ENABLE_SYSTEMD) \ $(ENABLE_RE2) \ $(ENABLE_LIBSODIUM) diff --git a/build-scripts/debian-recursor/rules b/build-scripts/debian-recursor/rules index 02be156e55..9cd1c5aaf2 100755 --- a/build-scripts/debian-recursor/rules +++ b/build-scripts/debian-recursor/rules @@ -62,7 +62,7 @@ override_dh_auto_configure: --infodir=\$${prefix}/share/info \ --libdir='$${prefix}/lib/$(DEB_HOST_MULTIARCH)' \ --libexecdir='$${prefix}/lib' \ - --with-luajit \ + --with-lua=luajit \ --with-protobuf=yes \ $(ENABLE_NETSNMP) \ $(ENABLE_SYSTEMD) \ diff --git a/configure.ac b/configure.ac index 6f9258ae4d..bb89c9d4fd 100644 --- a/configure.ac +++ b/configure.ac @@ -43,10 +43,7 @@ m4_pattern_forbid([^_?PKG_[A-Z_]+$], [*** pkg.m4 missing, please install pkg-con PDNS_CHECK_OS -PDNS_WITH_LUAJIT -AS_IF([test "x$with_luajit" = "xno"], [ - PDNS_WITH_LUA -]) +PDNS_WITH_LUA PDNS_CHECK_LUA_HPP AX_CXX_COMPILE_STDCXX_11 @@ -207,7 +204,7 @@ for a in $modules $dynmodules; do AS_IF([test "x$with_lua" = "xno"], AC_MSG_ERROR([Lua backend needs lua, run ./configure --with-lua]) ) - AS_IF([test "x$LUAPC" = "x" -a "x$LUAJITPC" = "x"], + AS_IF([test "x$LUAPC" = "x"], AC_MSG_ERROR([Lua backend needs lua but we cannot find it]) ) ;; diff --git a/m4/pdns_check_lua_hpp.m4 b/m4/pdns_check_lua_hpp.m4 index 7317153984..64a3acc9e8 100644 --- a/m4/pdns_check_lua_hpp.m4 +++ b/m4/pdns_check_lua_hpp.m4 @@ -1,7 +1,6 @@ AC_DEFUN([PDNS_CHECK_LUA_HPP],[ AC_REQUIRE([PDNS_WITH_LUA]) - AC_REQUIRE([PDNS_WITH_LUAJIT]) - AS_IF([test "x$LUAPC" != "x" -o "x$LUAJITPC" != "x" ], [ + AS_IF([test "x$LUAPC" != "x" ], [ AC_CHECK_HEADER([lua.hpp], [ have_lua_hpp=y ]) ]) AM_CONDITIONAL([HAVE_LUA_HPP], [ test x"$have_lua_hpp" = "xy" ]) diff --git a/m4/pdns_with_lua.m4 b/m4/pdns_with_lua.m4 index 18bb1b9d8b..50d8d40227 100644 --- a/m4/pdns_with_lua.m4 +++ b/m4/pdns_with_lua.m4 @@ -1,36 +1,51 @@ AC_DEFUN([PDNS_WITH_LUA],[ - AC_MSG_CHECKING([whether we will be linking in Lua]) - AC_ARG_WITH([lua], - [AS_HELP_STRING([--with-lua], [build Lua Bindings @<:@default=auto@:>@])], - [with_lua=$withval], - [with_lua=auto] - ) + AC_MSG_CHECKING([which Lua implementation to use]) + AC_ARG_WITH([lua], [ + AS_HELP_STRING([--with-lua], [select Lua implementation @<:@default=auto@:>@]) + ], [ + with_lua=$withval + ], [ + with_lua=auto + ]) AC_MSG_RESULT([$with_lua]) - AS_IF([test "x$with_lua" != "xno"],[ - AS_IF([test "x$with_lua" = "xyes" -o "x$with_lua" = "xauto"], - [for LUAPC in lua5.3 lua-5.3 lua53 lua5.2 lua-5.2 lua52 lua5.1 lua-5.1 lua51 lua; do - PKG_CHECK_MODULES([LUA], $LUAPC >= 5.1, [ - AC_DEFINE([HAVE_LUA], [1], [Define to 1 if you have lua]) - with_lua=yes - ], [LUAPC=""]) # otherwise pkg_check will fail - if test "x$LUA_LIBS" != "x"; then break; fi - done - ], - [LUAPC="$with_lua" - PKG_CHECK_MODULES([LUA], $LUAPC >= 5.1, [ - AC_DEFINE([HAVE_LUA], [1], [Define to 1 if you have lua]) - with_lua=yes + AS_IF([test "x$with_lua" = "xno" -a "$1" = "mandatory"], [ + AC_MSG_ERROR([--without-lua specified, but Lua is not optional]) + ]) + + LUAPC="" + + AS_IF([test "x$with_lua" != "xno"], [ + AS_IF([test "x$with_lua" != "xauto"], [ + PKG_CHECK_MODULES([LUA], $with_lua >= 5.1, [ + AC_DEFINE([HAVE_LUA], [1], [Define to 1 if you have Lua]) + LUAPC=$with_lua + ], [ + AC_MSG_ERROR([Selected Lua not found]) + ]) + ], [ + PKG_CHECK_MODULES([LUA], [luajit], [ + LUAPC=luajit + AC_DEFINE([HAVE_LUA], [1], [Define to 1 if you have Lua]) + ], [ : ]) + AS_IF([test -z "$LUAPC"], [ + 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], [ + AC_DEFINE([HAVE_LUA], [1], [Define to 1 if you have lua]) + found_lua=y + LUAPC=luapc + ], [ : ]) + ]) ]) - ]) - AC_MSG_CHECKING([for chosen LUA]) - AS_IF([test "x$LUAPC" = "x"], [ - AS_IF([test "x$with_lua" = "xyes"], - [AC_MSG_ERROR([cannot find lua])], - [AC_MSG_RESULT([not found])] - )],[ - AC_MSG_RESULT([$LUAPC]) ]) ]) - AM_CONDITIONAL([LUA], [test "x$with_lua" = "xyes"]) + ]) + + AS_IF([test -z "$LUAPC" -a "$1" = "mandatory"], [ + AC_MSG_ERROR([No Lua not found, but is mandatory]) + ]) + + AM_CONDITIONAL([LUA], [test -n "x$LUAPC"]) ]) diff --git a/m4/pdns_with_luajit.m4 b/m4/pdns_with_luajit.m4 deleted file mode 100644 index 66394732d9..0000000000 --- a/m4/pdns_with_luajit.m4 +++ /dev/null @@ -1,22 +0,0 @@ -AC_DEFUN([PDNS_WITH_LUAJIT],[ - AC_MSG_CHECKING([whether we will be linking in LuaJIT]) - AC_ARG_WITH([luajit], - [AS_HELP_STRING([--with-luajit], [build LuaJIT bindings @<:@default=auto@:>@])], - [with_luajit=$withval], - [with_luajit=no] - ) - AC_MSG_RESULT([$with_luajit]) - - AS_IF([test "x$with_luajit" = "xyes"], [ - LUAJITPC="$with_luajit" - PKG_CHECK_MODULES([LUA], [luajit], - [AC_DEFINE([HAVE_LUA], [1], [Define to 1 if you have LuaJIT])], - [LUAJITPC=""] - ) - AS_IF([test "x$LUAJITPC" = "x"], [ - AC_MSG_ERROR([LuaJIT not found])] - ) - ]) - - AM_CONDITIONAL([LUA], [test "x$with_luajit" = "xyes"]) -]) diff --git a/pdns/dnsdistdist/configure.ac b/pdns/dnsdistdist/configure.ac index 96b841f124..9bc010e3ff 100644 --- a/pdns/dnsdistdist/configure.ac +++ b/pdns/dnsdistdist/configure.ac @@ -42,13 +42,7 @@ AM_CONDITIONAL([HAVE_SYSTEMD], [ test x"$systemd" = "xy" ]) AC_SUBST([YAHTTP_CFLAGS], ['-I$(top_srcdir)/ext/yahttp']) AC_SUBST([YAHTTP_LIBS], ['$(top_builddir)/ext/yahttp/yahttp/libyahttp.la']) -PDNS_WITH_LUAJIT -AS_IF([test "x$with_luajit" = "xno"], [ - PDNS_WITH_LUA -]) -AS_IF([test "x$LUAPC" = "x" -a "x$LUAJITPC" = "x"], [ - AC_MSG_ERROR([Neither Lua nor LuaJIT found, Lua support is not optional]) -]) +PDNS_WITH_LUA([mandatory]) PDNS_CHECK_LUA_HPP DNSDIST_ENABLE_DNS_OVER_TLS @@ -125,12 +119,7 @@ AC_MSG_NOTICE([BOOST_CPPFLAGS: $BOOST_CPPFLAGS]) AC_MSG_NOTICE([]) AC_MSG_NOTICE([Features enabled]) AC_MSG_NOTICE([----------------]) -AS_IF([test "x$LUAPC" != "x"], - [AC_MSG_NOTICE([Lua: $LUAPC])], - [AS_IF([test "x$LUAJITPC" != "x"], - [AC_MSG_NOTICE([LuaJit: $LUAJITPC])], - [AC_MSG_NOTICE([Lua/LuaJit: no])]) -]) +AC_MSG_NOTICE([Lua: $LUAPC]) AS_IF([test "x$PROTOBUF_LIBS" != "x" -a x"$PROTOC" != "x"], [AC_MSG_NOTICE([Protobuf: yes])], [AC_MSG_NOTICE([Protobuf: no])] diff --git a/pdns/dnsdistdist/m4/pdns_with_luajit.m4 b/pdns/dnsdistdist/m4/pdns_with_luajit.m4 deleted file mode 120000 index 2f9477d62b..0000000000 --- a/pdns/dnsdistdist/m4/pdns_with_luajit.m4 +++ /dev/null @@ -1 +0,0 @@ -../../../m4/pdns_with_luajit.m4 \ No newline at end of file diff --git a/pdns/recursordist/configure.ac b/pdns/recursordist/configure.ac index 08ed1f51c3..ec41468250 100644 --- a/pdns/recursordist/configure.ac +++ b/pdns/recursordist/configure.ac @@ -99,13 +99,7 @@ PDNS_SELECT_CONTEXT_IMPL PDNS_ENABLE_UNIT_TESTS PDNS_ENABLE_REPRODUCIBLE -PDNS_WITH_LUAJIT -AS_IF([test "x$with_luajit" = "xno"], [ - PDNS_WITH_LUA -]) -AS_IF([test "x$LUAPC" = "x" -a "x$LUAJITPC" = "x"], [ - AC_MSG_ERROR([Neither Lua nor LuaJIT found, Lua support is not optional]) -]) +PDNS_WITH_LUA([mandatory]) PDNS_CHECK_LUA_HPP PDNS_ENABLE_VERBOSE_LOGGING @@ -206,12 +200,7 @@ AC_MSG_NOTICE([BOOST_CPPFLAGS: $BOOST_CPPFLAGS]) AC_MSG_NOTICE([]) AC_MSG_NOTICE([Features enabled]) AC_MSG_NOTICE([----------------]) -AS_IF([test "x$LUAPC" != "x"], - [AC_MSG_NOTICE([Lua: $LUAPC])], - [AS_IF([test "x$LUAJITPC" != "x"], - [AC_MSG_NOTICE([LuaJit: $LUAJITPC])], - [AC_MSG_NOTICE([Lua/LuaJit: no])]) -]) +AC_MSG_NOTICE([Lua: $LUAPC]) AC_MSG_NOTICE([OpenSSL ECDSA: $libcrypto_ecdsa]) AS_IF([test "x$LIBSODIUM_LIBS" != "x"], [AC_MSG_NOTICE([libsodium ed25519: yes])], diff --git a/pdns/recursordist/m4/pdns_with_luajit.m4 b/pdns/recursordist/m4/pdns_with_luajit.m4 deleted file mode 120000 index 2f9477d62b..0000000000 --- a/pdns/recursordist/m4/pdns_with_luajit.m4 +++ /dev/null @@ -1 +0,0 @@ -../../../m4/pdns_with_luajit.m4 \ No newline at end of file -- 2.47.2