diff options
author | Mark Pulford <mark@kyne.com.au> | 2011-12-08 20:57:12 +1030 |
---|---|---|
committer | Mark Pulford <mark@kyne.com.au> | 2011-12-08 20:57:12 +1030 |
commit | bd994cd7976ac93c530792e3c0d6f45a33c757b4 (patch) | |
tree | 6e5a4dd5d1b01e71d66f3cfe3d8e8c39d1410480 | |
parent | bea23facc1644cffa53ecc84fa236806e9c94dfd (diff) | |
download | lua-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-- | Makefile | 45 | ||||
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | README | 10 | ||||
-rw-r--r-- | lua-cjson.spec | 5 | ||||
-rwxr-xr-x | runtests.sh | 11 |
5 files changed, 38 insertions, 36 deletions
@@ -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 |
16 | PREFIX = /usr/local | 16 | PREFIX = /usr/local |
17 | CFLAGS_EXTRA = -DUSE_POSIX_SETLOCALE | 17 | #CFLAGS = -g -Wall -pedantic -fno-inline |
18 | LDFLAGS_EXTRA = -shared | 18 | CFLAGS = -O3 -Wall -pedantic |
19 | CJSON_CFLAGS = -DUSE_POSIX_SETLOCALE | ||
20 | CJSON_LDFLAGS = -shared | ||
21 | LUA_INCLUDE_DIR = $(PREFIX)/include | ||
22 | LUA_MODULE_DIR = $(PREFIX)/lib/lua/$(LUA_VERSION) | ||
23 | INSTALL_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 |
28 | CFLAGS_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 | ||
43 | LUA_INCLUDE_DIR ?= $(PREFIX)/include | 48 | CJSON_CFLAGS += -fpic -I$(LUA_INCLUDE_DIR) -DVERSION=\"$(CJSON_VERSION)\" |
44 | LUA_LIB_DIR ?= $(PREFIX)/lib/lua/$(LUA_VERSION) | 49 | OBJS := lua_cjson.o strbuf.o |
45 | |||
46 | #CFLAGS ?= -g -Wall -pedantic -fno-inline | ||
47 | CFLAGS ?= -O3 -Wall -pedantic | ||
48 | override CFLAGS += $(CFLAGS_EXTRA) -fpic -I$(LUA_INCLUDE_DIR) -DVERSION=\"$(CJSON_VERSION)\" | ||
49 | override LDFLAGS += $(LDFLAGS_EXTRA) | ||
50 | |||
51 | INSTALL ?= install | ||
52 | 50 | ||
53 | .PHONY: all clean install package | 51 | .PHONY: all clean install package |
54 | 52 | ||
55 | all: cjson.so | 53 | all: cjson.so |
56 | 54 | ||
57 | cjson.so: lua_cjson.o strbuf.o | 55 | .c.o: |
58 | $(CC) $(LDFLAGS) -o $@ $^ | 56 | $(CC) -c $(CFLAGS) $(CPPFLAGS) $(CJSON_CFLAGS) -o $@ $< |
57 | |||
58 | cjson.so: $(OBJS) | ||
59 | $(CC) $(LDFLAGS) $(CJSON_LDFLAGS) -o $@ $(OBJS) | ||
59 | 60 | ||
60 | install: | 61 | install: 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 | ||
64 | clean: | 65 | clean: |
65 | rm -f *.o *.so | 66 | rm -f *.o *.so |
@@ -1,3 +1,6 @@ | |||
1 | Version 1.0.5 (?) | ||
2 | * Updated Makefile for compatibility with non-GNU make implementations | ||
3 | |||
1 | Version 1.0.4 (Nov 30 2011) | 4 | Version 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 | ||
@@ -37,19 +37,19 @@ Or: | |||
37 | - LuaJIT (http://www.luajit.org/) | 37 | - LuaJIT (http://www.luajit.org/) |
38 | 38 | ||
39 | There are 3 build methods available: | 39 | There 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 | ||
45 | Gmake | 45 | Make |
46 | ----- | 46 | ---- |
47 | 47 | ||
48 | Review and update the included Makefile to suit your platform. Next, | 48 | Review and update the included Makefile to suit your platform. Next, |
49 | build and install the module: | 49 | build 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 |
27 | make %{?_smp_mflags} CFLAGS="%{optflags}" LUA_INCLUDE_DIR="%{_includedir}" | 27 | make %{?_smp_mflags} CFLAGS="%{optflags}" CJSON_CFLAGS="-DUSE_POSIX_USELOCALE" \ |
28 | LUA_INCLUDE_DIR="%{_includedir}" | ||
28 | 29 | ||
29 | 30 | ||
30 | %install | 31 | %install |
31 | rm -rf "$RPM_BUILD_ROOT" | 32 | rm -rf "$RPM_BUILD_ROOT" |
32 | make install DESTDIR="$RPM_BUILD_ROOT" LUA_LIB_DIR="%{lualibdir}" | 33 | make 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 | ||
3 | MAKE=make | ||
4 | #MAKE=gmake | ||
5 | |||
6 | EGREP="grep -E" | 3 | EGREP="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 | ||
30 | echo "===== Cleaning old build data =====" | 27 | echo "===== Cleaning old build data =====" |
31 | $MAKE clean | 28 | make clean |
32 | rm -f tests/cjson.so | 29 | rm -f tests/cjson.so |
33 | 30 | ||
34 | echo "===== Testing LuaRocks build =====" | 31 | echo "===== Testing LuaRocks build =====" |
35 | luarocks make --local | 32 | luarocks make --local |
36 | do_tests | 33 | do_tests |
37 | luarocks remove --local lua-cjson | 34 | luarocks remove --local lua-cjson |
38 | $MAKE clean | 35 | make clean |
39 | 36 | ||
40 | echo "===== Testing Makefile build =====" | 37 | echo "===== Testing Makefile build =====" |
41 | $MAKE | 38 | make |
42 | cp cjson.so tests | 39 | cp cjson.so tests |
43 | do_tests | 40 | do_tests |
44 | $MAKE clean | 41 | make clean |
45 | rm -f tests/cjson.so | 42 | rm -f tests/cjson.so |