From: Florian Forster Date: Thu, 25 Nov 2010 11:36:33 +0000 (+0100) Subject: Build system, lua plugin: Update for Lua 5.1 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=d04be065523bf73e220664adab166b61ae5410c8;p=collectd.git Build system, lua plugin: Update for Lua 5.1 I realized I used Lua 5.0 which has been superseeded by Lua 5.1 in 2006. The build system now uses pkg-config to check for Lua 5.1. Minor adjustments had to be made to the plugin to work with the new version. --- diff --git a/configure.in b/configure.in index 146fe5ce..3610f263 100644 --- a/configure.in +++ b/configure.in @@ -1967,78 +1967,48 @@ AM_CONDITIONAL(BUILD_WITH_JAVA, test "x$with_java" = "xyes") # }}} # --with-liblua {{{ -with_liblua_config="lua-config50" with_liblua_cppflags="" with_liblua_ldflags="" with_liblua_libs="" -AC_ARG_WITH(liblua, [AS_HELP_STRING([--with-liblua@<:@=lua-config50@:>@], [Path to the Lua config script.])], -[ - if test "x$withval" = "xno" || test "x$withval" = "xyes" - then - with_liblua="$withval" - else - if test -f "$withval" && test -x "$withval" - then - with_liblua_config="$withval" - with_liblua="yes" - else if test -x "$withval/bin/lua-config50" - then - with_liblua_config="$withval/bin/lua-config50" - with_liblua="yes" - else - AC_MSG_ERROR("not an executable: $withval") - fi; fi - fi -], -[ - with_liblua="yes" -]) +with_liblua="yes" + if test "x$with_liblua" = "xyes" then - with_liblua_cppflags=`$with_liblua_config --include 2>/dev/null` + $PKG_CONFIG --exists lua5.1 2>/dev/null lua_config_status=$? - if test $lua_config_status -ne 0 + if test 0 -ne $lua_config_status then - with_liblua="no ($with_liblua_config failed)" - else - SAVE_CPPFLAGS="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS $with_liblua_cppflags" - - AC_CHECK_HEADERS(lua.h, [], [with_liblua="no (lua.h not found)"], []) - - CPPFLAGS="$SAVE_CPPFLAGS" + with_liblua="no" fi fi + if test "x$with_liblua" = "xyes" then - with_liblua_ldflags=`$with_liblua_config --libs-only-L 2>/dev/null` - lua_config_status=$? - - if test $lua_config_status -ne 0 - then - with_liblua="no ($with_liblua_config failed)" - fi + with_liblua_cppflags=`$PKG_CONFIG --cflags-only-I lua5.1` || with_liblua="no" + with_liblua_ldflags=`$PKG_CONFIG --libs-only-L lua5.1` || with_liblua="no" + with_liblua_libs=`$PKG_CONFIG --libs-only-l lua5.1` || with_liblua="no" fi if test "x$with_liblua" = "xyes" then - with_liblua_libs=`$with_liblua_config --libs-only-l 2>/dev/null` - lua_config_status=$? + SAVE_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $with_liblua_cppflags" - if test $lua_config_status -ne 0 - then - with_liblua="no ($with_liblua_config failed)" - else - SAVE_LDFLAGS="$LDFLAGS" - SAVE_LIBS="$LIBS" - LDFLAGS="$SAVE_LDFLAGS $with_liblua_ldflags" - LIBS="$LIBS $with_liblua_libs" + AC_CHECK_HEADERS(lua.h lauxlib.h lualib.h, [], [with_liblua="no (header not found)"], []) - AC_CHECK_FUNC(lua_settop, [with_liblua="yes"], [with_liblua="no (symbol 'lua_settop' not found)"]) + CPPFLAGS="$SAVE_CPPFLAGS" +fi +if test "x$with_liblua" = "xyes" +then + SAVE_LDFLAGS="$LDFLAGS" + SAVE_LIBS="$LIBS" + LDFLAGS="$SAVE_LDFLAGS $with_liblua_ldflags" + LIBS="$LIBS $with_liblua_libs" - LDFLAGS="$SAVE_LDFLAGS" - LIBS="$SAVE_LIBS" - fi + AC_CHECK_FUNC(lua_settop, [with_liblua="yes"], [with_liblua="no (symbol 'lua_settop' not found)"]) + + LDFLAGS="$SAVE_LDFLAGS" + LIBS="$SAVE_LIBS" fi if test "x$with_liblua" = "xyes" then diff --git a/src/lua.c b/src/lua.c index b79e0b13..4ea5da77 100644 --- a/src/lua.c +++ b/src/lua.c @@ -22,6 +22,10 @@ * Florian Forster **/ +/* defines a macro using "sprintf". Although not used here, + * GCC will complain about the macro definition. */ +#define DONT_POISON_SPRINTF_YET + #include "collectd.h" #include "plugin.h" #include "common.h" @@ -33,6 +37,11 @@ #include #include +#if defined(COLLECT_DEBUG) && COLLECT_DEBUG && defined(__GNUC__) && __GNUC__ +# undef sprintf +# pragma GCC poison sprintf +#endif + typedef struct lua_script_s { char *script_path; lua_State *lua_state; @@ -322,7 +331,7 @@ static int lua_script_load (const char *script_path) /* {{{ */ return (-1); } - status = lua_dofile (script->lua_state, script->script_path); + status = luaL_dofile (script->lua_state, script->script_path); if (status != 0) { const char *errmsg;