From 11b35407875cc363f7897ff1c7c34828b4efe3ce Mon Sep 17 00:00:00 2001 From: Mark Pulford Date: Tue, 29 Nov 2011 00:10:42 +1030 Subject: Improve build documentation and layout --- Makefile | 58 ++++++++++++++++++++++++++++++---------------- README | 3 --- lua-cjson-1.0.4-1.rockspec | 4 ++-- 3 files changed, 40 insertions(+), 25 deletions(-) diff --git a/Makefile b/Makefile index 10e0ba1..1cf5d53 100644 --- a/Makefile +++ b/Makefile @@ -4,31 +4,49 @@ LUA_VERSION = 5.1 # See http://lua-users.org/wiki/BuildingModules for platform specific # details. -## Linux/BSD -PREFIX ?= /usr/local -LDFLAGS += -shared +## Available Lua CJSON specific workarounds +# +# To ensure JSON encoding/decoding works correctly for locales using +# comma decimal separators, Lua CJSON must be compiled with one of +# these options: +# USE_POSIX_USELOCALE: Linux, OSX. Thread safe. Recommended option. +# USE_POSIX_SETLOCALE: Works on all ANSI C platforms. May be used when +# thread-safety isn't required. +# +# USE_INTERNAL_ISINF: Handle Solaris platforms that are missing isinf(). + +# Tweak one of these platform sections below to suit your situation. + +## Linux +PREFIX ?= /usr/local +CFLAGS_EXTRA ?= -DUSE_POSIX_USELOCALE +LDFLAGS_EXTRA ?= -shared + +## FreeBSD +#PREFIX ?= /usr/local +#CFLAGS_EXTRA ?= -DUSE_POSIX_SETLOCALE +#LUA_INCLUDE_DIR ?= $(PREFIX)/include/lua51 +#LDFLAGS_EXTRA ?= -shared ## OSX (Macports) -#PREFIX ?= /opt/local -#LDFLAGS += -bundle -undefined dynamic_lookup +#PREFIX ?= /opt/local +#CFLAGS_EXTRA ?= -DUSE_POSIX_USELOCALE +#LDFLAGS_EXTRA ?= -bundle -undefined dynamic_lookup -LUA_INCLUDE_DIR ?= $(PREFIX)/include -LUA_LIB_DIR ?= $(PREFIX)/lib/lua/$(LUA_VERSION) +## Solaris +#PREFIX ?= /usr/local +#CFLAGS_EXTRA ?= -DUSE_POSIX_SETLOCALE -DUSE_INTERNAL_ISINF +#LDFLAGS_EXTRA ?= -shared -#CFLAGS ?= -g -Wall -pedantic -fno-inline -CFLAGS ?= -g -O3 -Wall -pedantic -override CFLAGS += -fpic -I$(LUA_INCLUDE_DIR) -DVERSION=\"$(CJSON_VERSION)\" +## End platform specific section -## Optional work arounds -# Handle Solaris platforms that are missing isinf(). -#override CFLAGS += -DUSE_INTERNAL_ISINF -# Handle locales that use comma as a decimal separator on locale aware -# platforms (optional, but recommended). -# USE_POSIX_USELOCALE: Linux, OSX. Thread safe. Recommended option. -# USE_POSIX_SETLOCALE: Works on all ANSI C platforms. May be used when -# thread-safety isn't required. -override CFLAGS += -DUSE_POSIX_USELOCALE -#override CFLAGS += -DUSE_POSIX_SETLOCALE +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 diff --git a/README b/README index e2e8dbc..09caab5 100644 --- a/README +++ b/README @@ -54,9 +54,6 @@ build and install the module: OR # cp cjson.so [your_module_directory] -Note: Some Solaris platforms are missing isinf(). You can work around - this bug by adding -DUSE_INTERNAL_ISINF to CFLAGS in the Makefile. - RPM --- diff --git a/lua-cjson-1.0.4-1.rockspec b/lua-cjson-1.0.4-1.rockspec index b08032b..da19bd1 100644 --- a/lua-cjson-1.0.4-1.rockspec +++ b/lua-cjson-1.0.4-1.rockspec @@ -28,8 +28,8 @@ build = { -- USE_POSIX_USELOCALE: Linux, OSX. Thread safe. Recommended. -- USE_POSIX_SETLOCALE: Works on all ANSI C platforms. May be used when -- thread-safety isn't required. --- USE_INTERNAL_ISINF: Provide internal isinf() implementation. Required --- on some Solaris platforms. +-- USE_INTERNAL_ISINF: Provide internal isinf() implementation. Required +-- on some Solaris platforms. defines = { "VERSION=\"1.0.4\"", "USE_POSIX_SETLOCALE" } } }, -- cgit v1.2.3-55-g6feb