1 dnl Check for LUA Libraries
2 dnl CHECK_LUA(ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
11 LUA_PKGNAMES="lua5.1 lua-5.1 lua_5.1 lua-51 lua_51 lua51 lua5 lua"
12 LUA_SONAMES="so la sl dll dylib"
19 [AC_HELP_STRING([--with-lua=PATH],[Path to lua prefix or config script])],
20 [test_paths="${with_lua}"],
21 [test_paths="/usr/local/liblua /usr/local/lua /usr/local /opt/liblua /opt/lua /opt /usr"; ])
23 AC_MSG_CHECKING([for liblua config script])
25 for x in ${test_paths}; do
26 dnl # Determine if the script was specified and use it directly
27 if test ! -d "$x" -a -e "$x"; then
32 dnl # Try known config script names/locations
33 for y in $LUA_CONFIG; do
34 if test -e "${x}/bin/${y}"; then
35 LUA_CONFIG="${x}/bin/${y}"
36 lua_config="${LUA_CONFIG}"
38 elif test -e "${x}/${y}"; then
39 LUA_CONFIG="${x}/${y}"
40 lua_config="${LUA_CONFIG}"
44 if test -n "${lua_config}"; then
49 dnl # Try known package names
50 if test -n "${LUA_CONFIG}"; then
52 for x in ${LUA_PKGNAMES}; do
53 if ${LUA_CONFIG} --exists ${x}; then
60 if test -n "${LUA_PKGNAME}"; then
61 AC_MSG_RESULT([${LUA_CONFIG}])
62 LUA_CFLAGS="`${LUA_CONFIG} ${LUA_PKGNAME} --cflags`"
63 if test "$verbose_output" -eq 1; then AC_MSG_NOTICE(lua CFLAGS: $LUA_CFLAGS); fi
64 LUA_LIBS="`${LUA_CONFIG} ${LUA_PKGNAME} --libs`"
65 if test "$verbose_output" -eq 1; then AC_MSG_NOTICE(lua LIBS: $LUA_LIBS); fi
71 dnl Hack to just try to find the lib and include
72 AC_MSG_CHECKING([for lua install])
73 for x in ${test_paths}; do
74 for y in ${LUA_SONAMES}; do
75 if test -e "${x}/liblua5.1.${y}"; then
79 elif test -e "${x}/lib/liblua5.1.${y}"; then
80 lua_lib_path="${x}/lib"
83 elif test -e "${x}/lib64/liblua5.1.${y}"; then
84 lua_lib_path="${x}/lib64"
87 elif test -e "${x}/lib32/liblua5.1.${y}"; then
88 lua_lib_path="${x}/lib32"
91 elif test -e "${x}/liblua51.${y}"; then
95 elif test -e "${x}/lib/liblua51.${y}"; then
96 lua_lib_path="${x}/lib"
99 elif test -e "${x}/lib64/liblua51.${y}"; then
100 lua_lib_path="${x}/lib64"
103 elif test -e "${x}/lib32/liblua51.${y}"; then
104 lua_lib_path="${x}/lib32"
107 elif test -e "${x}/liblua.${y}"; then
111 elif test -e "${x}/lib/liblua.${y}"; then
112 lua_lib_path="${x}/lib"
115 elif test -e "${x}/lib64/liblua.${y}"; then
116 lua_lib_path="${x}/lib64"
119 elif test -e "${x}/lib32/liblua.${y}"; then
120 lua_lib_path="${x}/lib32"
128 if test -n "$lua_lib_path"; then
132 for x in ${test_paths}; do
133 if test -e "${x}/include/lua.h"; then
134 lua_inc_path="${x}/include"
136 elif test -e "${x}/lua.h"; then
141 dnl # Check some sub-paths as well
142 for lua_pkg_name in ${lua_lib_name} ${LUA_PKGNAMES}; do
143 if test -e "${x}/include/${lua_pkg_name}/lua.h"; then
144 lua_inc_path="${x}/include"
146 elif test -e "${x}/${lua_pkg_name}/lua.h"; then
153 if test -n "$lua_inc_path"; then
157 if test -n "${lua_lib_path}" -a -n "${lua_inc_path}"; then
159 AC_MSG_RESULT([${lua_lib_path} ${lua_inc_path}])
160 LUA_CFLAGS="-I${lua_inc_path}"
161 LUA_LIBS="-L${lua_lib_path} -l${lua_lib_name}"
163 LDFLAGS=$save_LDFLAGS
169 if test -n "${LUA_LIBS}"; then
170 LUA_CFLAGS="-DWITH_LUA ${LUA_CFLAGS}"
176 if test "${with_path}" != "no"; then
177 if test -z "${LUA_LIBS}"; then
178 ifelse([$2], , AC_MSG_NOTICE([optional lua library not found]), $2)
180 AC_MSG_NOTICE([using '${LUA_LIBS}' for lua Library])