From 0d050815788bf1dfdac1bc417a801f69684079c8 Mon Sep 17 00:00:00 2001 From: the lemons Date: Mon, 20 Mar 2023 22:55:39 -0500 Subject: improve makefile --- Makefile | 9 +++------ lmdb.c | 6 +++--- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 21d3629..805c98f 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,8 @@ -LUA_VER=5.3 +LUA_VER_MAJOR=5 +LUA_VER_MINOR=3 CC = cc LD = ld -MORE_CFLAGS= -ifeq ($(LUA_VER),5.1) - MORE_CFLAGS=-DLUA_5_1 -endif -CFLAGS = $(MORE_CFLAGS) -std=c99 -Wall -O2 -fPIC -I/usr/include/lua$(LUA_VER) +CFLAGS = -DLUA_VER=$(LUA_VER_MAJOR)$(LUA_VER_MINOR) -std=c99 -Wall -O2 -fPIC -I/usr/include/lua$(LUA_VER_MAJOR).$(LUA_VER_MINOR) LFLAGS = -shared -llmdb lmdb.so: lmdb.o diff --git a/lmdb.c b/lmdb.c index f81d555..60ddca2 100644 --- a/lmdb.c +++ b/lmdb.c @@ -53,7 +53,7 @@ static int version(lua_State *L) { return 3; } -#ifdef LUA_5_1 +#if LUA_VER == 51 lua_Integer lua_tointegerx(lua_State *L, int index, int *isnum) { if (isnum != NULL) *isnum = lua_isnumber(L,index); @@ -382,7 +382,7 @@ static const struct luaL_Reg lmdb_db[] = { static void mt(lua_State *L, const char *name, const struct luaL_Reg l[]) { luaL_newmetatable(L, name); -#ifdef LUA_5_1 +#if LUA_VER == 51 luaL_register(L, NULL, l); #else luaL_setfuncs(L, l, 0); @@ -432,7 +432,7 @@ int luaopen_lmdb(lua_State *L) { lua_setmetatable(L, -2); lua_setfield(L, LUA_REGISTRYINDEX, "lmdb.parentmap"); -#ifdef LUA_5_1 +#if LUA_VER == 51 lua_newtable(L); luaL_register(L, NULL, lmdb); #else -- cgit v1.2.3