summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile5
-rw-r--r--lua-posixtz.c9
2 files changed, 9 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index b5405a3..25a65ba 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,5 @@
-LUALIBS := -llua
+LUAPC ?= lua5.2
+LUA_CFLAGS := $(shell pkg-config --cflags $(LUAPC))
TARGETS := posixtz core.so
all: $(TARGETS)
@@ -10,5 +11,5 @@ posixtz: main.c posixtz.c
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
core.so: lua-posixtz.c posixtz.c
- $(CC) -fPIC $(CFLAGS) $(LDFLAGS) $(LUALIBS) -shared -o $@ $^
+ $(CC) -fPIC $(CFLAGS) $(LUA_CFLAGS) $(LDFLAGS) -shared -o $@ $^
diff --git a/lua-posixtz.c b/lua-posixtz.c
index a641ac6..b87f2e9 100644
--- a/lua-posixtz.c
+++ b/lua-posixtz.c
@@ -6,6 +6,10 @@
#define MYNAME "posixtz"
+#if LUA_VERSION_NUM < 502
+# define luaL_newlib(L,l) (lua_newtable(L), luaL_register(L,NULL,l))
+#endif
+
static int Pfrom_file(lua_State *L)
{
const char *s = luaL_checkstring(L, 1);
@@ -13,15 +17,14 @@ static int Pfrom_file(lua_State *L)
return 1;
}
-static const luaL_reg R[] =
+static const luaL_Reg R[] =
{
{"from_file", Pfrom_file},
NULL, NULL
};
-
LUALIB_API int luaopen_posixtz_core(lua_State *L)
{
- luaL_register(L,MYNAME,R);
+ luaL_newlib(L, R);
return 1;
}