summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2011-11-24 16:17:23 +0100
committerNatanael Copa <ncopa@alpinelinux.org>2011-11-24 16:19:13 +0100
commit94b3e32c2775808bc49ac949615a252b5c636b14 (patch)
treed23e991d641e5385db2dfa969184ae8f8c3ba2c5
parenteb202135397e457baa58423faec4d8d0441c2292 (diff)
downloadlibuniso-94b3e32c2775808bc49ac949615a252b5c636b14.tar.bz2
libuniso-94b3e32c2775808bc49ac949615a252b5c636b14.tar.xz
lua,build: define version
-rw-r--r--Makefile12
-rw-r--r--lua-uniso.c7
2 files changed, 18 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 6eaa516..aaac99a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,15 @@
-include config.mk
+VERSION = 0.1
+GIT_REV := $(shell test -d .git && git describe --always --dirty || echo exported)
+
+ifneq ($(GIT_REV), exported)
+FULL_VERSION := $(GIT_REV)
+FULL_VERSION := $(patsubst v%,%,$(FULL_VERSION))
+else
+FULL_VERSION := $(VERSION)
+endif
+
ABI_VERSION := 0
SONAME := libuniso.so.$(ABI_VERSION)
@@ -9,7 +19,7 @@ INCLUDES := uniso.h
TARGETS = libuniso.a $(progs-y) $(shlibs-y) $(lualibs-y)
CFLAGS ?= -g -Wall -Werror
-CFLAGS += -fPIC
+CFLAGS += -fPIC -I. -DVERSION=\"$(FULL_VERSION)\"
CFLAGS += -I.
LDFLAGS += -L.
diff --git a/lua-uniso.c b/lua-uniso.c
index ec1cb91..58559de 100644
--- a/lua-uniso.c
+++ b/lua-uniso.c
@@ -12,6 +12,10 @@
#define MODULE_NAME "uniso"
+#ifndef VERSION
+#define VERSION "unknown version"
+#endif
+
struct l_uniso_context {
lua_State *L;
int callback_ref;
@@ -77,6 +81,9 @@ static const luaL_reg methods[] = {
LUALIB_API int luaopen_uniso(lua_State *L)
{
luaL_openlib(L, MODULE_NAME, methods, 0);
+ lua_pushliteral(L, "version");
+ lua_pushliteral(L, VERSION);
+ lua_settable(L, -3);
return 1;
}