From bd994cd7976ac93c530792e3c0d6f45a33c757b4 Mon Sep 17 00:00:00 2001 From: Mark Pulford Date: Thu, 8 Dec 2011 20:57:12 +1030 Subject: 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). --- Makefile | 45 +++++++++++++++++++++++---------------------- NEWS | 3 +++ README | 10 +++++----- lua-cjson.spec | 5 +++-- runtests.sh | 11 ++++------- 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 # # USE_INTERNAL_ISINF: Workaround for Solaris platforms missing isinf(). -## Common build defaults +## Build defaults PREFIX = /usr/local -CFLAGS_EXTRA = -DUSE_POSIX_SETLOCALE -LDFLAGS_EXTRA = -shared +#CFLAGS = -g -Wall -pedantic -fno-inline +CFLAGS = -O3 -Wall -pedantic +CJSON_CFLAGS = -DUSE_POSIX_SETLOCALE +CJSON_LDFLAGS = -shared +LUA_INCLUDE_DIR = $(PREFIX)/include +LUA_MODULE_DIR = $(PREFIX)/lib/lua/$(LUA_VERSION) +INSTALL_CMD = install ## Platform overrides # -# Tweaking one of the platform sections below to suit your situation. +# Tweak one of the platform sections below to suit your situation. # # See http://lua-users.org/wiki/BuildingModules for further platform # specific details. ## Linux -CFLAGS_EXTRA = -DUSE_POSIX_USELOCALE +#CJSON_CFLAGS = -DUSE_POSIX_USELOCALE ## FreeBSD #LUA_INCLUDE_DIR = $(PREFIX)/include/lua51 ## MacOSX (Macports) #PREFIX = /opt/local -#CFLAGS_EXTRA = -DUSE_POSIX_USELOCALE -#LDFLAGS_EXTRA = -bundle -undefined dynamic_lookup +#CJSON_CFLAGS = -DUSE_POSIX_USELOCALE +#CJSON_LDFLAGS = -bundle -undefined dynamic_lookup ## Solaris -#CFLAGS_EXTRA = -DUSE_POSIX_SETLOCALE -DUSE_INTERNAL_ISINF +#CJSON_CFLAGS = -DUSE_POSIX_SETLOCALE -DUSE_INTERNAL_ISINF ## End platform specific section -LUA_INCLUDE_DIR ?= $(PREFIX)/include -LUA_LIB_DIR ?= $(PREFIX)/lib/lua/$(LUA_VERSION) - -#CFLAGS ?= -g -Wall -pedantic -fno-inline -CFLAGS ?= -O3 -Wall -pedantic -override CFLAGS += $(CFLAGS_EXTRA) -fpic -I$(LUA_INCLUDE_DIR) -DVERSION=\"$(CJSON_VERSION)\" -override LDFLAGS += $(LDFLAGS_EXTRA) - -INSTALL ?= install +CJSON_CFLAGS += -fpic -I$(LUA_INCLUDE_DIR) -DVERSION=\"$(CJSON_VERSION)\" +OBJS := lua_cjson.o strbuf.o .PHONY: all clean install package all: cjson.so -cjson.so: lua_cjson.o strbuf.o - $(CC) $(LDFLAGS) -o $@ $^ +.c.o: + $(CC) -c $(CFLAGS) $(CPPFLAGS) $(CJSON_CFLAGS) -o $@ $< + +cjson.so: $(OBJS) + $(CC) $(LDFLAGS) $(CJSON_LDFLAGS) -o $@ $(OBJS) -install: - $(INSTALL) -d $(DESTDIR)/$(LUA_LIB_DIR) - $(INSTALL) cjson.so $(DESTDIR)/$(LUA_LIB_DIR) +install: cjson.so + mkdir -p $(DESTDIR)/$(LUA_MODULE_DIR) + $(INSTALL_CMD) cjson.so $(DESTDIR)/$(LUA_MODULE_DIR) clean: rm -f *.o *.so diff --git a/NEWS b/NEWS index 3b34ff0..26ab879 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +Version 1.0.5 (?) +* Updated Makefile for compatibility with non-GNU make implementations + Version 1.0.4 (Nov 30 2011) * Fixed numeric conversion under locales with a comma decimal separator diff --git a/README b/README index 4907359..36c9a64 100644 --- a/README +++ b/README @@ -37,19 +37,19 @@ Or: - LuaJIT (http://www.luajit.org/) There are 3 build methods available: -- Gmake: POSIX, OSX +- Make: POSIX, OSX - RPM: Various Linux distributions - LuaRocks (http://www.luarocks.org/): POSIX, OSX, Windows -Gmake ------ +Make +---- Review and update the included Makefile to suit your platform. Next, build and install the module: - # gmake - # gmake install + # make + # make install OR # cp cjson.so [your_module_directory] 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. %build -make %{?_smp_mflags} CFLAGS="%{optflags}" LUA_INCLUDE_DIR="%{_includedir}" +make %{?_smp_mflags} CFLAGS="%{optflags}" CJSON_CFLAGS="-DUSE_POSIX_USELOCALE" \ + LUA_INCLUDE_DIR="%{_includedir}" %install rm -rf "$RPM_BUILD_ROOT" -make install DESTDIR="$RPM_BUILD_ROOT" LUA_LIB_DIR="%{lualibdir}" +make install DESTDIR="$RPM_BUILD_ROOT" LUA_MODULE_DIR="%{lualibdir}" %clean diff --git a/runtests.sh b/runtests.sh index 1e0a5cd..ed78cc5 100755 --- a/runtests.sh +++ b/runtests.sh @@ -1,8 +1,5 @@ #!/bin/sh -MAKE=make -#MAKE=gmake - EGREP="grep -E" #EGREP="egrep" @@ -28,18 +25,18 @@ echo "===== Building UTF-8 test data =====" ( cd tests && ./genutf8.pl; ) echo "===== Cleaning old build data =====" -$MAKE clean +make clean rm -f tests/cjson.so echo "===== Testing LuaRocks build =====" luarocks make --local do_tests luarocks remove --local lua-cjson -$MAKE clean +make clean echo "===== Testing Makefile build =====" -$MAKE +make cp cjson.so tests do_tests -$MAKE clean +make clean rm -f tests/cjson.so -- cgit v1.2.3-55-g6feb