Browse Source

Conditionally build Lua plugin only if --with-lua is given to configure; Currently we look for Lua lib and headers only in the standard search path. If they're somewhere else - the user will have to specify that by passing appropriate CPPFLAGS and/or LDFLAGS to configure

Stanislav Galabov 11 years ago
parent
commit
5b8f69a6bd
3 changed files with 56 additions and 3 deletions
  1. 51 0
      configure.ac
  2. 3 3
      plugins/lua/module.am
  3. 2 0
      plugins/module.am

+ 51 - 0
configure.ac

@@ -39,6 +39,57 @@ AC_ARG_ENABLE(debug,
               [enable_debug=no])
 AM_CONDITIONAL(DEBUG,test x$enable_debug = xyes)
 
+################################
+# Check for Lua support
+################################
+AC_ARG_WITH(lua,
+            [AS_HELP_STRING([--with-lua=DIR],
+                            [Build Lua ACTION plugin [default=no]])],
+            [use_lua=$withval],
+            [use_lua=no])
+AM_CONDITIONAL(WITH_LUA,test x$use_lua != xno)
+
+LUA_LDFLAGS=""
+LUA_CFLAGS=""
+LUA_LIBS=""
+
+if test x$use_lua = xyes; then
+    AC_CHECK_LIB([lua],
+                 [lua_close],
+                 [lua_lib_found=yes],
+                 [lua_lib_found=no],
+                 [])
+    if test x$lua_lib_found = xno; then
+        AC_MSG_ERROR([cannot find Lua library])
+    fi
+    LUA_LIBS="-llua -lm"
+    AC_CHECK_HEADER([lua.h],
+                    [lua_h_found=yes],
+                    [lua_h_found=no],
+                    [/* force include check */])
+    if test x$lua_h_found = xno; then
+        AC_MSG_ERROR([cannot find <lua.h> header file])
+    fi
+    AC_CHECK_HEADER([lualib.h],
+                    [lualib_h_found=yes],
+                    [lualib_h_found=no],
+                    [/* force include check */])
+    if test x$lualib_h_found = xno; then
+        AC_MSG_ERROR([cannot find <lualib.h> header file])
+    fi
+    AC_CHECK_HEADER([lauxlib.h],
+                    [lauxlib_h_found=yes],
+                    [lauxlib_h_found=no],
+                    [/* force include check */])
+    if test x$lauxlib_h_found = xno; then
+        AC_MSG_ERROR([cannot find <lauxlib.h> header file])
+    fi
+fi
+
+AC_SUBST(LUA_LDFLAGS)
+AC_SUBST(LUA_CFLAGS)
+AC_SUBST(LUA_LIBS)
+
 ################################
 # Check for the roxml library
 ################################

+ 3 - 3
plugins/lua/module.am

@@ -1,11 +1,11 @@
 lib_LTLIBRARIES			+= clish_plugin_lua.la
 clish_plugin_lua_la_SOURCES	 = 
-clish_plugin_lua_la_LIBADD	 =
+clish_plugin_lua_la_LIBADD	 = @LUA_LIBS@
 clish_plugin_lua_la_LDFLAGS	 = -avoid-version -module -shared
 clish_plugin_lua_la_LDFLAGS	+= -export-symbols-regex "^clish_plugin_lua_"
 
-clish_plugin_lua_la_LDFLAGS	+= -L/usr/local/lib -llua-5.1
-clish_plugin_lua_la_CFLAGS	 = -I/usr/local/include/lua51
+clish_plugin_lua_la_LDFLAGS	+= @LUA_LDFLAGS@
+clish_plugin_lua_la_CFLAGS	 = @LUA_CFLAGS@
 
 clish_plugin_lua_la_LIBADD	+= \
 	liblub.la \

+ 2 - 0
plugins/module.am

@@ -5,4 +5,6 @@ EXTRA_DIST += \
 	plugins/default/module.am
 
 include $(top_srcdir)/plugins/default/module.am
+if WITH_LUA
 include $(top_srcdir)/plugins/lua/module.am
+endif