aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile31
-rw-r--r--lua-cjson.spec48
-rw-r--r--lua_cjson.c4
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 @@
1CJSON_VERSION = 1.0
2LUA_VERSION = 5.1
3
4PREFIX ?= /usr/local
5LUA_INCLUDE_DIR ?= $(PREFIX)/include
6LUA_LIB_DIR ?= $(PREFIX)/lib/lua/$(LUA_VERSION)
7
8#CFLAGS ?= -g -Wall -pedantic -fno-inline
9CFLAGS ?= -g -O2 -Wall -pedantic
10override CFLAGS += -fpic -I$(LUA_INCLUDE_DIR) -DVERSION=\"$(CJSON_VERSION)\"
11LDFLAGS += -shared -lm
12
13INSTALL ?= install
14
15.PHONY: all clean install package
16
17all: cjson.so
18
19cjson.so: lua_cjson.o strbuf.o
20 $(CC) $(LDFLAGS) -o $@ $^
21
22install:
23 $(INSTALL) -d $(DESTDIR)/$(LUA_LIB_DIR)
24 $(INSTALL) cjson.so $(DESTDIR)/$(LUA_LIB_DIR)
25
26clean:
27 rm -f *.o *.so
28
29package:
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
4Name: lua-cjson
5Version: 1.0
6Release: 1%{?dist}
7Summary: JSON support for the Lua language
8
9Group: Development/Libraries
10License: MIT
11URL: http://www.kyne.com.au/~mark/software/lua-cjson/
12Source0: http://www.kyne.com.au/~mark/software/lua-cjson/lua-cjson-%{version}.tar.gz
13BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
14
15BuildRequires: lua >= %{luaver}, lua-devel >= %{luaver}
16Requires: lua >= %{luaver}
17
18%description
19CJSON provides fast JSON parsing and encoding functions for Lua. It
20allows a Lua application to quickly serialise a data structure to
21JSON, or deserialise from JSON to Lua.
22
23%prep
24%setup -q
25
26
27%build
28make %{?_smp_mflags} CFLAGS="%{optflags}" LUA_INCLUDE_DIR="%{_includedir}"
29
30
31%install
32rm -rf "$RPM_BUILD_ROOT"
33make install DESTDIR="$RPM_BUILD_ROOT" LUA_LIB_DIR="%{lualibdir}"
34
35
36%clean
37rm -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}