x_ac_lua.m4 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. ##*****************************************************************************
  2. # AUTHOR:
  3. # Mark Grondona <mgrondona@llnl.gov>
  4. #
  5. # SYNOPSIS:
  6. # AC_LUA
  7. #
  8. # DESCRIPTION:
  9. # Check for presence of lua libs and headers
  10. ##*****************************************************************************
  11. AC_DEFUN([X_AC_LUA],
  12. [
  13. x_ac_lua_pkg_name="lua"
  14. #check for 5.2 if that fails check for 5.1
  15. PKG_CHECK_EXISTS([lua5.2], [x_ac_lua_pkg_name=lua5.2],
  16. [PKG_CHECK_EXISTS([lua5.1], [x_ac_lua_pkg_name=lua5.1], [])])
  17. PKG_CHECK_MODULES([lua], ${x_ac_lua_pkg_name},
  18. [x_ac_have_lua="yes"],
  19. [x_ac_have_lua="no"])
  20. if test "x$x_ac_have_lua" = "xyes"; then
  21. saved_CFLAGS="$CFLAGS"
  22. saved_LIBS="$LIBS"
  23. # -DLUA_COMPAT_ALL is needed to support lua 5.2
  24. lua_CFLAGS="$lua_CFLAGS -DLUA_COMPAT_ALL"
  25. CFLAGS="$CFLAGS $lua_CFLAGS"
  26. LIBS="$LIBS $lua_LIBS"
  27. AC_MSG_CHECKING([for whether we can link to liblua])
  28. AC_TRY_LINK(
  29. [#include <lua.h>
  30. #include <lauxlib.h>
  31. #include <lualib.h>
  32. ],
  33. [lua_State *L = luaL_newstate (); luaL_openlibs(L);
  34. ],
  35. [], [x_ac_have_lua="no"])
  36. AC_MSG_RESULT([$x_ac_have_lua $x_ac_lua_pkg_name])
  37. if test "x$x_ac_have_lua" = "xno"; then
  38. AC_MSG_WARN([unable to link against lua libraries])
  39. fi
  40. CFLAGS="$saved_CFLAGS"
  41. LIBS="$saved_LIBS"
  42. else
  43. AC_MSG_WARN([unable to locate lua package])
  44. fi
  45. AM_CONDITIONAL(HAVE_LUA, test "x$x_ac_have_lua" = "xyes")
  46. if test "x$x_ac_have_lua" = "xyes" ; then
  47. if test "x$x_ac_lua_pkg_name" = "xlua5.2" ; then
  48. AC_DEFINE(HAVE_LUA_5_2, 1, [Compile with Lua 5.2])
  49. elif test "x$x_ac_lua_pkg_name" = "xlua5.1"; then
  50. AC_DEFINE(HAVE_LUA_5_1, 1, [Compile with Lua 5.1])
  51. fi
  52. fi
  53. ])