diff --git a/3rd/Makefile.am b/3rd/Makefile.am index 2070eb4..bad5c4b 100644 --- a/3rd/Makefile.am +++ b/3rd/Makefile.am @@ -1,7 +1,7 @@ EXTRA_DIST = lua-5.3.4/*.c lua-5.3.4/*.h lua-5.3.4/Makefile all: - cd lua-5.3.4 && make linux + cd $(top_srcdir)/3rd/lua-5.3.4 && make linux clean-local: - cd lua-5.3.4 && make clean \ No newline at end of file + cd $(top_srcdir)/3rd/lua-5.3.4 && make clean \ No newline at end of file diff --git a/3rd/lua-5.3.4/Makefile b/3rd/lua-5.3.4/Makefile index 116bb0b..d55993d 100644 --- a/3rd/lua-5.3.4/Makefile +++ b/3rd/lua-5.3.4/Makefile @@ -27,7 +27,7 @@ MYOBJS= # == END OF USER SETTINGS -- NO NEED TO CHANGE ANYTHING BELOW THIS LINE ======= PLATS= aix bsd c89 freebsd generic linux macosx mingw posix solaris - +LUA_SO = core.so LUA_A= liblua.a CORE_O= lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o \ lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o \ @@ -43,8 +43,8 @@ LUAC_T= luac LUAC_O= luac.o ALL_O= $(BASE_O) $(LUA_O) $(LUAC_O) -ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T) -ALL_A= $(LUA_A) +ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T) $(LUA_SO) +ALL_A= $(LUA_A) $(LUA_SO) # Targets start here. default: $(PLAT) @@ -59,6 +59,9 @@ $(LUA_A): $(BASE_O) $(AR) $@ $(BASE_O) $(RANLIB) $@ +$(LUA_SO): $(BASE_O) + gcc -shared $(BASE_O) -o $@ + $(LUA_T): $(LUA_O) $(LUA_A) $(CC) -o $@ $(LDFLAGS) $(LUA_O) $(LUA_A) $(LIBS) diff --git a/Makefile.am b/Makefile.am index 1ee5b19..4b2c847 100644 --- a/Makefile.am +++ b/Makefile.am @@ -21,7 +21,6 @@ lua_la_SOURCES = plugin-wrapper.c\ array-wrapper.c \ json-wrapper.c \ lua-api.c -lua_la_LIBADD = $(srcdir)/3rd/lua-5.3.4/liblua.a # lua libraris & modules SUBDIRS = 3rd . lib @@ -34,4 +33,5 @@ EXTRA_DIST = README.md 3rd/jsmn/jsmn.h APIs lua-api.h install-data-local: mkdir -p $(prefix)/lib/lua - cp -v APIs/* $(prefix)/lib/lua \ No newline at end of file + cp -v APIs/* $(prefix)/lib/lua + cp -v 3rd/lua-5.3.4/core.so $(prefix)/lib/lua \ No newline at end of file diff --git a/dist/lua-0.5.2b.tar.gz b/dist/lua-0.5.2b.tar.gz index b78a188..862885e 100644 Binary files a/dist/lua-0.5.2b.tar.gz and b/dist/lua-0.5.2b.tar.gz differ diff --git a/lua-api.c b/lua-api.c index 628626c..fd4ca91 100644 --- a/lua-api.c +++ b/lua-api.c @@ -1,6 +1,9 @@ #define PLUGIN_IMPLEMENT 1 +#include #include "lua-api.h" +static void* core_handle = NULL; + static const struct luaL_Reg modules [] = { #ifdef USE_DB {"sqlite", luaopen_sqlite}, @@ -14,7 +17,17 @@ static const struct luaL_Reg modules [] = { void init() { - LOG("%s \n","INIT LUA HANDLER"); + char* path = __s("%s/lua/core.so", __plugin__.pdir); + core_handle = dlopen(path, RTLD_NOW| RTLD_GLOBAL); + if(!core_handle) + { + ERROR("Cannot load Lua core; %s", dlerror()); + } + else + { + LOG("Lua core loaded"); + } + free(path); } /** @@ -111,5 +124,7 @@ void* handle(void* data) } void destroy() { - LOG("%s \n","Exit LUA Handle"); + if(core_handle) + dlclose(core_handle); + LOG("Exit LUA Handle"); }