aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Pulford <mark@kyne.com.au>2011-12-08 20:57:12 +1030
committerMark Pulford <mark@kyne.com.au>2011-12-08 20:57:12 +1030
commitbd994cd7976ac93c530792e3c0d6f45a33c757b4 (patch)
tree6e5a4dd5d1b01e71d66f3cfe3d8e8c39d1410480
parentbea23facc1644cffa53ecc84fa236806e9c94dfd (diff)
downloadlua-cjson-bd994cd7976ac93c530792e3c0d6f45a33c757b4.tar.gz
lua-cjson-bd994cd7976ac93c530792e3c0d6f45a33c757b4.tar.bz2
lua-cjson-bd994cd7976ac93c530792e3c0d6f45a33c757b4.zip
Fix Makefile for use with non-GNU make
- Remove GNU make "override" statements. - Add OBJS variable since there is no portable way to specify all targets for linking. Also: - Put build defaults at the top to avoid potential confusion. - Don't assume a Linux platform. Default to USE_POSIX_SETLOCALE. - Change "install -d" to mkdir/install since the former isn't available on some platforms (Solaris).
-rw-r--r--Makefile45
-rw-r--r--NEWS3
-rw-r--r--README10
-rw-r--r--lua-cjson.spec5
-rwxr-xr-xruntests.sh11
5 files changed, 38 insertions, 36 deletions
diff --git a/Makefile b/Makefile
index f32e4b1..1eb1090 100644
--- a/Makefile
+++ b/Makefile
@@ -12,54 +12,55 @@ LUA_VERSION = 5.1
12# 12#
13# USE_INTERNAL_ISINF: Workaround for Solaris platforms missing isinf(). 13# USE_INTERNAL_ISINF: Workaround for Solaris platforms missing isinf().
14 14
15## Common build defaults 15## Build defaults
16PREFIX = /usr/local 16PREFIX = /usr/local
17CFLAGS_EXTRA = -DUSE_POSIX_SETLOCALE 17#CFLAGS = -g -Wall -pedantic -fno-inline
18LDFLAGS_EXTRA = -shared 18CFLAGS = -O3 -Wall -pedantic
19CJSON_CFLAGS = -DUSE_POSIX_SETLOCALE
20CJSON_LDFLAGS = -shared
21LUA_INCLUDE_DIR = $(PREFIX)/include
22LUA_MODULE_DIR = $(PREFIX)/lib/lua/$(LUA_VERSION)
23INSTALL_CMD = install
19 24
20## Platform overrides 25## Platform overrides
21# 26#
22# Tweaking one of the platform sections below to suit your situation. 27# Tweak one of the platform sections below to suit your situation.
23# 28#
24# See http://lua-users.org/wiki/BuildingModules for further platform 29# See http://lua-users.org/wiki/BuildingModules for further platform
25# specific details. 30# specific details.
26 31
27## Linux 32## Linux
28CFLAGS_EXTRA = -DUSE_POSIX_USELOCALE 33#CJSON_CFLAGS = -DUSE_POSIX_USELOCALE
29 34
30## FreeBSD 35## FreeBSD
31#LUA_INCLUDE_DIR = $(PREFIX)/include/lua51 36#LUA_INCLUDE_DIR = $(PREFIX)/include/lua51
32 37
33## MacOSX (Macports) 38## MacOSX (Macports)
34#PREFIX = /opt/local 39#PREFIX = /opt/local
35#CFLAGS_EXTRA = -DUSE_POSIX_USELOCALE 40#CJSON_CFLAGS = -DUSE_POSIX_USELOCALE
36#LDFLAGS_EXTRA = -bundle -undefined dynamic_lookup 41#CJSON_LDFLAGS = -bundle -undefined dynamic_lookup
37 42
38## Solaris 43## Solaris
39#CFLAGS_EXTRA = -DUSE_POSIX_SETLOCALE -DUSE_INTERNAL_ISINF 44#CJSON_CFLAGS = -DUSE_POSIX_SETLOCALE -DUSE_INTERNAL_ISINF
40 45
41## End platform specific section 46## End platform specific section
42 47
43LUA_INCLUDE_DIR ?= $(PREFIX)/include 48CJSON_CFLAGS += -fpic -I$(LUA_INCLUDE_DIR) -DVERSION=\"$(CJSON_VERSION)\"
44LUA_LIB_DIR ?= $(PREFIX)/lib/lua/$(LUA_VERSION) 49OBJS := lua_cjson.o strbuf.o
45
46#CFLAGS ?= -g -Wall -pedantic -fno-inline
47CFLAGS ?= -O3 -Wall -pedantic
48override CFLAGS += $(CFLAGS_EXTRA) -fpic -I$(LUA_INCLUDE_DIR) -DVERSION=\"$(CJSON_VERSION)\"
49override LDFLAGS += $(LDFLAGS_EXTRA)
50
51INSTALL ?= install
52 50
53.PHONY: all clean install package 51.PHONY: all clean install package
54 52
55all: cjson.so 53all: cjson.so
56 54
57cjson.so: lua_cjson.o strbuf.o 55.c.o:
58 $(CC) $(LDFLAGS) -o $@ $^ 56 $(CC) -c $(CFLAGS) $(CPPFLAGS) $(CJSON_CFLAGS) -o $@ $<
57
58cjson.so: $(OBJS)
59 $(CC) $(LDFLAGS) $(CJSON_LDFLAGS) -o $@ $(OBJS)
59 60
60install: 61install: cjson.so
61 $(INSTALL) -d $(DESTDIR)/$(LUA_LIB_DIR) 62 mkdir -p $(DESTDIR)/$(LUA_MODULE_DIR)
62 $(INSTALL) cjson.so $(DESTDIR)/$(LUA_LIB_DIR) 63 $(INSTALL_CMD) cjson.so $(DESTDIR)/$(LUA_MODULE_DIR)
63 64
64clean: 65clean:
65 rm -f *.o *.so 66 rm -f *.o *.so
diff --git a/NEWS b/NEWS
index 3b34ff0..26ab879 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,6 @@
1Version 1.0.5 (?)
2* Updated Makefile for compatibility with non-GNU make implementations
3
1Version 1.0.4 (Nov 30 2011) 4Version 1.0.4 (Nov 30 2011)
2* Fixed numeric conversion under locales with a comma decimal separator 5* Fixed numeric conversion under locales with a comma decimal separator
3 6
diff --git a/README b/README
index 4907359..36c9a64 100644
--- a/README
+++ b/README
@@ -37,19 +37,19 @@ Or:
37- LuaJIT (http://www.luajit.org/) 37- LuaJIT (http://www.luajit.org/)
38 38
39There are 3 build methods available: 39There are 3 build methods available:
40- Gmake: POSIX, OSX 40- Make: POSIX, OSX
41- RPM: Various Linux distributions 41- RPM: Various Linux distributions
42- LuaRocks (http://www.luarocks.org/): POSIX, OSX, Windows 42- LuaRocks (http://www.luarocks.org/): POSIX, OSX, Windows
43 43
44 44
45Gmake 45Make
46----- 46----
47 47
48Review and update the included Makefile to suit your platform. Next, 48Review and update the included Makefile to suit your platform. Next,
49build and install the module: 49build and install the module:
50 50
51 # gmake 51 # make
52 # gmake install 52 # make install
53 OR 53 OR
54 # cp cjson.so [your_module_directory] 54 # cp cjson.so [your_module_directory]
55 55
diff --git a/lua-cjson.spec b/lua-cjson.spec
index ca502b3..07064e9 100644
--- a/lua-cjson.spec
+++ b/lua-cjson.spec
@@ -24,12 +24,13 @@ Lua CJSON provides fast, standards compliant JSON support for Lua.
24 24
25 25
26%build 26%build
27make %{?_smp_mflags} CFLAGS="%{optflags}" LUA_INCLUDE_DIR="%{_includedir}" 27make %{?_smp_mflags} CFLAGS="%{optflags}" CJSON_CFLAGS="-DUSE_POSIX_USELOCALE" \
28 LUA_INCLUDE_DIR="%{_includedir}"
28 29
29 30
30%install 31%install
31rm -rf "$RPM_BUILD_ROOT" 32rm -rf "$RPM_BUILD_ROOT"
32make install DESTDIR="$RPM_BUILD_ROOT" LUA_LIB_DIR="%{lualibdir}" 33make install DESTDIR="$RPM_BUILD_ROOT" LUA_MODULE_DIR="%{lualibdir}"
33 34
34 35
35%clean 36%clean
diff --git a/runtests.sh b/runtests.sh
index 1e0a5cd..ed78cc5 100755
--- a/runtests.sh
+++ b/runtests.sh
@@ -1,8 +1,5 @@
1#!/bin/sh 1#!/bin/sh
2 2
3MAKE=make
4#MAKE=gmake
5
6EGREP="grep -E" 3EGREP="grep -E"
7#EGREP="egrep" 4#EGREP="egrep"
8 5
@@ -28,18 +25,18 @@ echo "===== Building UTF-8 test data ====="
28( cd tests && ./genutf8.pl; ) 25( cd tests && ./genutf8.pl; )
29 26
30echo "===== Cleaning old build data =====" 27echo "===== Cleaning old build data ====="
31$MAKE clean 28make clean
32rm -f tests/cjson.so 29rm -f tests/cjson.so
33 30
34echo "===== Testing LuaRocks build =====" 31echo "===== Testing LuaRocks build ====="
35luarocks make --local 32luarocks make --local
36do_tests 33do_tests
37luarocks remove --local lua-cjson 34luarocks remove --local lua-cjson
38$MAKE clean 35make clean
39 36
40echo "===== Testing Makefile build =====" 37echo "===== Testing Makefile build ====="
41$MAKE 38make
42cp cjson.so tests 39cp cjson.so tests
43do_tests 40do_tests
44$MAKE clean 41make clean
45rm -f tests/cjson.so 42rm -f tests/cjson.so