Skip to content

Commit 36f5fb3

Browse files
committed
configure: add --with-lua=PATH; --with-lua implies --enable-lua
1 parent ac73877 commit 36f5fb3

1 file changed

Lines changed: 80 additions & 24 deletions

File tree

configure.ac

Lines changed: 80 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,47 +1572,103 @@ AC_SUBST([LIBTRE_LIBS])
15721572
#
15731573
# liblua
15741574
#
1575-
# Detection strategy: try pkg-config first (versioned names in preference
1576-
# order), then fall back to AC_SEARCH_LIBS for systems without pkg-config.
1577-
# The user can pass LUA_CFLAGS and LUA_LIBS on the command line to override.
1575+
# --enable-lua: enable Lua scripting support (auto-detect location)
1576+
# --with-lua=PATH: enable Lua and use this install prefix
1577+
# --with-lua implies --enable-lua; either flag alone is sufficient.
1578+
#
1579+
# Detection: if a path is given, search flat and versioned include layouts
1580+
# (handles BSD systems that install headers under include/lua54/ etc.).
1581+
# Otherwise try pkg-config, then a manual search of common prefixes.
15781582
#
15791583
# Note: we evaluated AX_PROG_LUA from the GNU Autoconf Archive but it
15801584
# requires a Lua interpreter to be present at configure time in order to
15811585
# determine the version. OpenDKIM embeds Lua as a library; build systems
15821586
# may have only the development headers and library installed (e.g.
1583-
# liblua5.4-dev) with no interpreter. The pkg-config + AC_SEARCH_LIBS
1584-
# approach below covers that case without the interpreter dependency.
1587+
# liblua5.4-dev) with no interpreter. The approach below covers that case
1588+
# without the interpreter dependency.
15851589
#
1590+
AC_ARG_WITH([lua],
1591+
AS_HELP_STRING([--with-lua=PATH],
1592+
[prefix where Lua is installed (implies --enable-lua)]),
1593+
[luapath="$withval"], [luapath=""])
1594+
15861595
AC_ARG_ENABLE([lua],
15871596
AS_HELP_STRING([--enable-lua],
15881597
[enable Lua scripting support]),
15891598
[enable_lua="$enableval"], [enable_lua="no"])
15901599

1600+
if test x"$luapath" != x"" -a x"$luapath" != x"no"
1601+
then
1602+
enable_lua="yes"
1603+
fi
1604+
15911605
lua_found="no"
15921606

15931607
AS_IF([test x"$enable_lua" = x"yes"], [
1594-
AS_IF([test x"$PKG_CONFIG" != x""], [
1595-
for luapkg in lua lua5.4 lua-5.4 lua5.3 lua-5.3 lua5.2 lua-5.2 lua5.1 lua-5.1
1608+
if test x"$luapath" != x"" -a x"$luapath" != x"yes" -a x"$luapath" != x"no"
1609+
then
1610+
AC_MSG_CHECKING([for Lua headers under $luapath])
1611+
lua_incdir=""
1612+
for d in "$luapath/include" \
1613+
"$luapath/include/lua54" \
1614+
"$luapath/include/lua5.4" \
1615+
"$luapath/include/lua53" \
1616+
"$luapath/include/lua5.3" \
1617+
"$luapath/include/lua52" \
1618+
"$luapath/include/lua5.2" \
1619+
"$luapath/include/lua51" \
1620+
"$luapath/include/lua5.1"
15961621
do
1597-
AS_IF([test x"$lua_found" != x"yes"], [
1598-
PKG_CHECK_MODULES([LUA], [$luapkg], [lua_found="yes"], [:])
1599-
])
1622+
if test -f "$d/lua.h"
1623+
then
1624+
lua_incdir="$d"
1625+
break
1626+
fi
16001627
done
1601-
AS_IF([test x"$lua_found" = x"no"],
1602-
[AC_MSG_WARN([pkg-config for Lua not found, trying manual search...])])
1603-
])
1604-
1605-
AS_IF([test x"$lua_found" != x"yes"], [
1628+
if test x"$lua_incdir" = x""
1629+
then
1630+
AC_MSG_RESULT([no])
1631+
AC_MSG_ERROR([Lua headers not found under $luapath])
1632+
fi
1633+
AC_MSG_RESULT([$lua_incdir])
1634+
LUA_CFLAGS="-I$lua_incdir"
1635+
saved_CPPFLAGS="$CPPFLAGS"
1636+
saved_LDFLAGS="$LDFLAGS"
1637+
CPPFLAGS="$outer_CPPFLAGS $LUA_CFLAGS"
1638+
LDFLAGS="$outer_LDFLAGS -L$luapath/lib"
16061639
AC_SEARCH_LIBS([lua_load],
1607-
[lua lua5.4 lua-5.4 lua5.3 lua-5.3 lua5.2 lua-5.2 lua5.1 lua-5.1],
1608-
[ lua_found="yes"
1609-
AS_IF([test "x$ac_cv_search_lua_load" != "xnone required"],
1610-
[LUA_LIBS="$ac_cv_search_lua_load"])
1611-
])
1612-
])
1613-
1614-
AS_IF([test x"$lua_found" != x"yes"],
1615-
[AC_MSG_ERROR([Lua enabled but not found])])
1640+
[lua lua5.4 lua-5.4 lua54 lua5.3 lua-5.3 lua5.2 lua-5.2 lua5.1 lua-5.1],
1641+
[lua_found="yes"
1642+
AS_IF([test "x$ac_cv_search_lua_load" != "xnone required"],
1643+
[LUA_LIBS="-L$luapath/lib $ac_cv_search_lua_load"],
1644+
[LUA_LIBS="-L$luapath/lib"])],
1645+
[AC_MSG_ERROR([Lua library not found under $luapath])])
1646+
CPPFLAGS="$saved_CPPFLAGS"
1647+
LDFLAGS="$saved_LDFLAGS"
1648+
else
1649+
AS_IF([test x"$PKG_CONFIG" != x""], [
1650+
for luapkg in lua lua5.4 lua-5.4 lua5.3 lua-5.3 lua5.2 lua-5.2 lua5.1 lua-5.1
1651+
do
1652+
AS_IF([test x"$lua_found" != x"yes"], [
1653+
PKG_CHECK_MODULES([LUA], [$luapkg], [lua_found="yes"], [:])
1654+
])
1655+
done
1656+
AS_IF([test x"$lua_found" = x"no"],
1657+
[AC_MSG_WARN([pkg-config for Lua not found, trying manual search...])])
1658+
])
1659+
1660+
AS_IF([test x"$lua_found" != x"yes"], [
1661+
AC_SEARCH_LIBS([lua_load],
1662+
[lua lua5.4 lua-5.4 lua5.3 lua-5.3 lua5.2 lua-5.2 lua5.1 lua-5.1],
1663+
[ lua_found="yes"
1664+
AS_IF([test "x$ac_cv_search_lua_load" != "xnone required"],
1665+
[LUA_LIBS="$ac_cv_search_lua_load"])
1666+
])
1667+
])
1668+
1669+
AS_IF([test x"$lua_found" != x"yes"],
1670+
[AC_MSG_ERROR([Lua enabled but not found])])
1671+
fi
16161672
])
16171673

16181674
AS_IF([test x"$lua_found" = x"yes"], [

0 commit comments

Comments
 (0)