From d48e6c8380ebd1f8d4d4f2c80237dc1488da4721 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Wed, 16 Apr 2008 15:13:25 +0300 Subject: [PATCH] Start phasing out internal copy of Lua - don't build internal copy of Lua - move 3rd party extensions (posix and rexlib) to toplevel luaext/ directory, built by default (unless --without-lua specified) - auto*foo checks for external Lua - minimal tweaks to lposix.c and rpmlua.c to get them build with Lua 5.1 --- Makefile.am | 7 +++++-- configure.ac | 18 +++++++++++++++--- luaext/Makefile.am | 15 +++++++++++++++ {lua/local => luaext}/linit.c | 0 {lua/local => luaext}/linit.h | 0 {lua/local => luaext}/linit.lch | 0 {lua/local => luaext}/linit.lua | 0 {lua/local => luaext}/lposix.c | 2 +- {lua/local => luaext}/lposix.h | 0 {lua/local => luaext}/lrexlib.c | 0 {lua/local => luaext}/lrexlib.h | 0 {lua/local => luaext}/modemuncher.c | 0 {lua/local => luaext}/userconfig.c | 0 rpmio/rpmlua.c | 2 ++ 14 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 luaext/Makefile.am rename {lua/local => luaext}/linit.c (100%) rename {lua/local => luaext}/linit.h (100%) rename {lua/local => luaext}/linit.lch (100%) rename {lua/local => luaext}/linit.lua (100%) rename {lua/local => luaext}/lposix.c (99%) rename {lua/local => luaext}/lposix.h (100%) rename {lua/local => luaext}/lrexlib.c (100%) rename {lua/local => luaext}/lrexlib.h (100%) rename {lua/local => luaext}/modemuncher.c (100%) rename {lua/local => luaext}/userconfig.c (100%) diff --git a/Makefile.am b/Makefile.am index 6e98eed..361c795 100644 --- a/Makefile.am +++ b/Makefile.am @@ -16,9 +16,12 @@ SUBDIRS = po misc if WITH_INTERNAL_DB SUBDIRS += db3 endif -SUBDIRS += lua rpmio rpmdb lib build python scripts doc . tests +if WITH_LUAEXT +SUBDIRS += luaext +endif +SUBDIRS += rpmio rpmdb lib build python scripts doc . tests -DIST_SUBDIRS = po misc lua rpmio rpmdb lib build python scripts doc tests +DIST_SUBDIRS = po misc luaext rpmio rpmdb lib build python scripts doc tests pkgconfigdir = $(libdir)/pkgconfig diff --git a/configure.ac b/configure.ac index fae5bf6..d471f3a 100644 --- a/configure.ac +++ b/configure.ac @@ -803,12 +803,24 @@ WITH_LUA_LIB= WITH_LUA_INCLUDE= AC_ARG_WITH(lua, [ --with-lua build with lua support ],,[with_lua=yes]) AS_IF([test "$with_lua" = yes],[ + AC_CHECK_HEADER([lua.h],[ + AC_CHECK_LIB(lua,[luaL_openlibs],[with_lua=yes],[ + AC_MSG_ERROR([--with-lua given, but liblua not found]) + ], + [-lm]) + ],[ + AC_MSG_ERROR([--with-lua given, but lua.h not found]) + ]) +]) + +AS_IF([test "$with_lua" = yes],[ AC_DEFINE(WITH_LUA, 1, [Build with lua support?]) - WITH_LUA_INCLUDE="-I\${top_srcdir}/lua/include -I\${top_srcdir}/lua/local" - WITH_LUA_LIB="\$(top_builddir)/lua/liblua.la" + WITH_LUA_INCLUDE="-I\${top_srcdir}/luaext" + WITH_LUA_LIB="-llua -lm \$(top_builddir)/luaext/libluaext.la" ]) AC_SUBST(WITH_LUA_LIB) AC_SUBST(WITH_LUA_INCLUDE) +AM_CONDITIONAL(WITH_LUAEXT,[test "$with_lua" = yes]) with_dmalloc=no AC_ARG_WITH(dmalloc, [ --with-dmalloc build with dmalloc debugging support ]) @@ -1060,7 +1072,7 @@ AC_CONFIG_FILES([Makefile misc/Makefile doc/Makefile python/Makefile - lua/Makefile + luaext/Makefile tests/Makefile ]) AC_OUTPUT diff --git a/luaext/Makefile.am b/luaext/Makefile.am new file mode 100644 index 0000000..13219b4 --- /dev/null +++ b/luaext/Makefile.am @@ -0,0 +1,15 @@ +noinst_LTLIBRARIES = libluaext.la + +AM_CPPFLAGS = -I$(top_builddir) +AM_CPPFLAGS += -I$(srcdir)/include -I. + +libluaext_la_CPPFLAGS = $(AM_CPPFLAGS) -DWITH_POSIX +libluaext_la_LIBADD = -llua -lm +libluaext_la_SOURCES = \ + lposix.h \ + lposix.c \ + lrexlib.h \ + lrexlib.c + +linit.lch: linit.lua + bin2c linit.lua > linit.lch diff --git a/lua/local/linit.c b/luaext/linit.c similarity index 100% rename from lua/local/linit.c rename to luaext/linit.c diff --git a/lua/local/linit.h b/luaext/linit.h similarity index 100% rename from lua/local/linit.h rename to luaext/linit.h diff --git a/lua/local/linit.lch b/luaext/linit.lch similarity index 100% rename from lua/local/linit.lch rename to luaext/linit.lch diff --git a/lua/local/linit.lua b/luaext/linit.lua similarity index 100% rename from lua/local/linit.lua rename to luaext/linit.lua diff --git a/lua/local/lposix.c b/luaext/lposix.c similarity index 99% rename from lua/local/lposix.c rename to luaext/lposix.c index 7c7cbac..7f30514 100644 --- a/lua/local/lposix.c +++ b/luaext/lposix.c @@ -66,7 +66,7 @@ static int doselection(lua_State *L, int i, const char *const S[], Selector F, c } else { - int j=luaL_findstring(luaL_checkstring(L, i), S); + int j=luaL_checkoption(L, i, NULL, S); if (j==-1) luaL_argerror(L, i, "unknown selector"); return F(L, j, data); } diff --git a/lua/local/lposix.h b/luaext/lposix.h similarity index 100% rename from lua/local/lposix.h rename to luaext/lposix.h diff --git a/lua/local/lrexlib.c b/luaext/lrexlib.c similarity index 100% rename from lua/local/lrexlib.c rename to luaext/lrexlib.c diff --git a/lua/local/lrexlib.h b/luaext/lrexlib.h similarity index 100% rename from lua/local/lrexlib.h rename to luaext/lrexlib.h diff --git a/lua/local/modemuncher.c b/luaext/modemuncher.c similarity index 100% rename from lua/local/modemuncher.c rename to luaext/modemuncher.c diff --git a/lua/local/userconfig.c b/luaext/userconfig.c similarity index 100% rename from lua/local/userconfig.c rename to luaext/userconfig.c diff --git a/rpmio/rpmlua.c b/rpmio/rpmlua.c index c609d7c..e21aef4 100644 --- a/rpmio/rpmlua.c +++ b/rpmio/rpmlua.c @@ -46,7 +46,9 @@ rpmlua rpmluaNew() {"io", luaopen_io}, {"string", luaopen_string}, {"debug", luaopen_debug}, +#if 0 {"loadlib", luaopen_loadlib}, +#endif {"posix", luaopen_posix}, {"rex", luaopen_rex}, {"rpm", luaopen_rpm}, -- 2.7.4