Skip to content

Commit

Permalink
Re-do Lua detection
Browse files Browse the repository at this point in the history
Detect LuaJIT first, then other implementations. Allows setting
`--with-lua` to a specific implementation as well (e.g. `lua51`). Will
produce errors appropriately.

Fixes PowerDNS#6423.
  • Loading branch information
pieterlexis committed Apr 5, 2018
1 parent db77630 commit 0373298
Show file tree
Hide file tree
Showing 14 changed files with 54 additions and 92 deletions.
2 changes: 1 addition & 1 deletion build-scripts/build-auth-rpm
Expand Up @@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion build-scripts/build-dnsdist-rpm
Expand Up @@ -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=''
Expand Down
2 changes: 1 addition & 1 deletion build-scripts/build-recursor-rpm
Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion build-scripts/debian-authoritative/rules
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion build-scripts/debian-dnsdist/rules
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion build-scripts/debian-recursor/rules
Expand Up @@ -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) \
Expand Down
7 changes: 2 additions & 5 deletions configure.ac
Expand Up @@ -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
Expand Down Expand Up @@ -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])
)
;;
Expand Down
3 changes: 1 addition & 2 deletions 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" ])
Expand Down
70 changes: 41 additions & 29 deletions m4/pdns_with_lua.m4
@@ -1,36 +1,48 @@
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], [ : ])
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"])
])
22 changes: 0 additions & 22 deletions m4/pdns_with_luajit.m4

This file was deleted.

15 changes: 2 additions & 13 deletions pdns/dnsdistdist/configure.ac
Expand Up @@ -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
Expand Down Expand Up @@ -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])]
Expand Down
1 change: 0 additions & 1 deletion pdns/dnsdistdist/m4/pdns_with_luajit.m4

This file was deleted.

15 changes: 2 additions & 13 deletions pdns/recursordist/configure.ac
Expand Up @@ -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
Expand Down Expand Up @@ -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])],
Expand Down
1 change: 0 additions & 1 deletion pdns/recursordist/m4/pdns_with_luajit.m4

This file was deleted.

0 comments on commit 0373298

Please sign in to comment.