]> git.ipfire.org Git - thirdparty/pdns.git/blob - m4/pdns_with_lua.m4
Merge pull request #9134 from omoerbeek/secpoll-cleanup
[thirdparty/pdns.git] / m4 / pdns_with_lua.m4
1 AC_DEFUN([PDNS_WITH_LUA],[
2 AC_PROG_GREP()dnl Ensure we have grep
3 AC_MSG_CHECKING([which Lua implementation to use])
4 AC_ARG_WITH([lua],
5 [AS_HELP_STRING([--with-lua], [select Lua implementation @<:@default=auto@:>@])
6 ], [
7 with_lua=$withval
8 ], [
9 with_lua=auto
10 ])
11
12 AS_IF([test "x$with_lua" = "xyes"], [
13 dnl --with-lua was passed, make it auto
14 with_lua=auto
15 ])
16
17 AC_MSG_RESULT([$with_lua])
18
19 AS_IF([test "x$with_lua" = "xno" -a "$1" = "mandatory"], [
20 AC_MSG_ERROR([--without-lua specified, but Lua is not optional])
21 ])
22
23 LUAPC=""
24 luajit_min_version='2.0.2'
25 lua_min_version='5.1'
26
27 AS_IF([test "x$with_lua" != "xno"], [
28 AS_IF([test "x$with_lua" != "xauto"], [
29 with_lua_version=${lua_min_version}
30 AS_IF([echo "x$with_lua" | ${GREP} 'jit' >/dev/null 2>&1], [with_lua_version=${luajit_min_version}])
31 PKG_CHECK_MODULES([LUA], $with_lua >= $with_lua_version, [
32 AC_DEFINE([HAVE_LUA], [1], [Define to 1 if you have Lua])
33 LUAPC=$with_lua
34 ], [
35 AC_MSG_ERROR([Selected Lua ($with_lua) not found])
36 ])
37 ], [
38 PKG_CHECK_MODULES([LUA], [luajit >= ${luajit_min_version}], [
39 LUAPC=luajit
40 AC_DEFINE([HAVE_LUA], [1], [Define to 1 if you have Lua])
41 ], [ : ])
42 AS_IF([test -z "$LUAPC"], [
43 found_lua=n
44 m4_foreach_w([luapc], [lua5.3 lua-5.3 lua53 lua5.2 lua-5.2 lua52 lua5.1 lua-5.1 lua51 lua], [
45 AS_IF([test "$found_lua" != "y"], [
46 PKG_CHECK_MODULES([LUA], [luapc >= ${lua_min_version}], [
47 AC_DEFINE([HAVE_LUA], [1], [Define to 1 if you have lua])
48 found_lua=y
49 LUAPC=luapc
50 ], [ : ])
51 ])
52 ])
53 ])
54 ])
55 ])
56
57 AS_IF([test -z "$LUAPC" -a "$1" = "mandatory"], [
58 AC_MSG_ERROR([No Lua not found, but is mandatory])
59 ])
60
61 AM_CONDITIONAL([LUA], [test -n "x$LUAPC"])
62 ])