diff options
Diffstat (limited to '')
| -rw-r--r-- | Makefile | 31 | ||||
| -rw-r--r-- | lua-cjson.spec | 48 | ||||
| -rw-r--r-- | lua_cjson.c | 4 |
3 files changed, 83 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..14d5a06 --- /dev/null +++ b/Makefile | |||
| @@ -0,0 +1,31 @@ | |||
| 1 | CJSON_VERSION = 1.0 | ||
| 2 | LUA_VERSION = 5.1 | ||
| 3 | |||
| 4 | PREFIX ?= /usr/local | ||
| 5 | LUA_INCLUDE_DIR ?= $(PREFIX)/include | ||
| 6 | LUA_LIB_DIR ?= $(PREFIX)/lib/lua/$(LUA_VERSION) | ||
| 7 | |||
| 8 | #CFLAGS ?= -g -Wall -pedantic -fno-inline | ||
| 9 | CFLAGS ?= -g -O2 -Wall -pedantic | ||
| 10 | override CFLAGS += -fpic -I$(LUA_INCLUDE_DIR) -DVERSION=\"$(CJSON_VERSION)\" | ||
| 11 | LDFLAGS += -shared -lm | ||
| 12 | |||
| 13 | INSTALL ?= install | ||
| 14 | |||
| 15 | .PHONY: all clean install package | ||
| 16 | |||
| 17 | all: cjson.so | ||
| 18 | |||
| 19 | cjson.so: lua_cjson.o strbuf.o | ||
| 20 | $(CC) $(LDFLAGS) -o $@ $^ | ||
| 21 | |||
| 22 | install: | ||
| 23 | $(INSTALL) -d $(DESTDIR)/$(LUA_LIB_DIR) | ||
| 24 | $(INSTALL) cjson.so $(DESTDIR)/$(LUA_LIB_DIR) | ||
| 25 | |||
| 26 | clean: | ||
| 27 | rm -f *.o *.so | ||
| 28 | |||
| 29 | package: | ||
| 30 | git archive --prefix="lua-cjson-$(CJSON_VERSION)/" master | \ | ||
| 31 | gzip -9 > "lua-cjson-$(CJSON_VERSION).tar.gz" | ||
diff --git a/lua-cjson.spec b/lua-cjson.spec new file mode 100644 index 0000000..d5eb0c2 --- /dev/null +++ b/lua-cjson.spec | |||
| @@ -0,0 +1,48 @@ | |||
| 1 | %define luaver 5.1 | ||
| 2 | %define lualibdir %{_libdir}/lua/%{luaver} | ||
| 3 | |||
| 4 | Name: lua-cjson | ||
| 5 | Version: 1.0 | ||
| 6 | Release: 1%{?dist} | ||
| 7 | Summary: JSON support for the Lua language | ||
| 8 | |||
| 9 | Group: Development/Libraries | ||
| 10 | License: MIT | ||
| 11 | URL: http://www.kyne.com.au/~mark/software/lua-cjson/ | ||
| 12 | Source0: http://www.kyne.com.au/~mark/software/lua-cjson/lua-cjson-%{version}.tar.gz | ||
| 13 | BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) | ||
| 14 | |||
| 15 | BuildRequires: lua >= %{luaver}, lua-devel >= %{luaver} | ||
| 16 | Requires: lua >= %{luaver} | ||
| 17 | |||
| 18 | %description | ||
| 19 | CJSON provides fast JSON parsing and encoding functions for Lua. It | ||
| 20 | allows a Lua application to quickly serialise a data structure to | ||
| 21 | JSON, or deserialise from JSON to Lua. | ||
| 22 | |||
| 23 | %prep | ||
| 24 | %setup -q | ||
| 25 | |||
| 26 | |||
| 27 | %build | ||
| 28 | make %{?_smp_mflags} CFLAGS="%{optflags}" LUA_INCLUDE_DIR="%{_includedir}" | ||
| 29 | |||
| 30 | |||
| 31 | %install | ||
| 32 | rm -rf "$RPM_BUILD_ROOT" | ||
| 33 | make install DESTDIR="$RPM_BUILD_ROOT" LUA_LIB_DIR="%{lualibdir}" | ||
| 34 | |||
| 35 | |||
| 36 | %clean | ||
| 37 | rm -rf "$RPM_BUILD_ROOT" | ||
| 38 | |||
| 39 | |||
| 40 | %files | ||
| 41 | %defattr(-,root,root,-) | ||
| 42 | %doc LICENSE rfc4627.txt | ||
| 43 | %{lualibdir}/* | ||
| 44 | |||
| 45 | |||
| 46 | %changelog | ||
| 47 | * Sun May 1 2011 Mark Pulford <mark@kyne.com.au> - 1.0-1 | ||
| 48 | - Initial package | ||
diff --git a/lua_cjson.c b/lua_cjson.c index aaf476d..2cef3a8 100644 --- a/lua_cjson.c +++ b/lua_cjson.c | |||
| @@ -1004,6 +1004,10 @@ int luaopen_cjson(lua_State *l) | |||
| 1004 | lua_pushlightuserdata(l, NULL); | 1004 | lua_pushlightuserdata(l, NULL); |
| 1005 | lua_setfield(l, -2, "null"); | 1005 | lua_setfield(l, -2, "null"); |
| 1006 | 1006 | ||
| 1007 | /* Set cjson.version */ | ||
| 1008 | lua_pushliteral(l, VERSION); | ||
| 1009 | lua_setfield(l, -2, "version"); | ||
| 1010 | |||
| 1007 | /* Return cjson table */ | 1011 | /* Return cjson table */ |
| 1008 | return 1; | 1012 | return 1; |
| 1009 | } | 1013 | } |
