| 1 |
##### Available defines for CJSON_CFLAGS ##### |
| 2 |
## |
| 3 |
## USE_INTERNAL_ISINF: Workaround for Solaris platforms missing isinf(). |
| 4 |
## DISABLE_INVALID_NUMBERS: Permanently disable invalid JSON numbers: |
| 5 |
## NaN, Infinity, hex. |
| 6 |
## |
| 7 |
## Optional built-in number conversion uses the following defines: |
| 8 |
## USE_INTERNAL_FPCONV: Use builtin strtod/dtoa for numeric conversions. |
| 9 |
## IEEE_BIG_ENDIAN: Required on big endian architectures. |
| 10 |
## MULTIPLE_THREADS: Must be set when Lua CJSON may be used in a |
| 11 |
## multi-threaded application. Requries _pthreads_. |
| 12 |
|
| 13 |
##### Build defaults ##### |
| 14 |
LUA_VERSION = 5.1 |
| 15 |
TARGET = cjson.so |
| 16 |
PREFIX = /usr/local |
| 17 |
#CFLAGS = -g -Wall -pedantic -fno-inline |
| 18 |
CFLAGS = -O3 -Wall -pedantic -DNDEBUG |
| 19 |
CJSON_CFLAGS = -fpic |
| 20 |
CJSON_LDFLAGS = -shared |
| 21 |
LUA_INCLUDE_DIR = $(PREFIX)/include |
| 22 |
LUA_CMODULE_DIR = $(PREFIX)/lib/lua/$(LUA_VERSION) |
| 23 |
LUA_MODULE_DIR = $(PREFIX)/share/lua/$(LUA_VERSION) |
| 24 |
LUA_BIN_DIR = $(PREFIX)/bin |
| 25 |
|
| 26 |
##### Platform overrides ##### |
| 27 |
## |
| 28 |
## Tweak one of the platform sections below to suit your situation. |
| 29 |
## |
| 30 |
## See http://lua-users.org/wiki/BuildingModules for further platform |
| 31 |
## specific details. |
| 32 |
|
| 33 |
## Linux |
| 34 |
|
| 35 |
## FreeBSD |
| 36 |
#LUA_INCLUDE_DIR = $(PREFIX)/include/lua51 |
| 37 |
|
| 38 |
## MacOSX (Macports) |
| 39 |
#PREFIX = /opt/local |
| 40 |
#CJSON_LDFLAGS = -bundle -undefined dynamic_lookup |
| 41 |
|
| 42 |
## Solaris |
| 43 |
#CC = gcc |
| 44 |
#CJSON_CFLAGS = -fpic -DUSE_INTERNAL_ISINF |
| 45 |
|
| 46 |
## Windows (MinGW) |
| 47 |
#TARGET = cjson.dll |
| 48 |
#PREFIX = /home/user/opt |
| 49 |
#CJSON_CFLAGS = -DDISABLE_INVALID_NUMBERS |
| 50 |
#CJSON_LDFLAGS = -shared -L$(PREFIX)/lib -llua51 |
| 51 |
#LUA_BIN_SUFFIX = .lua |
| 52 |
|
| 53 |
##### Number conversion configuration ##### |
| 54 |
|
| 55 |
## Use Libc support for number conversion (default) |
| 56 |
FPCONV_OBJS = fpconv.o |
| 57 |
|
| 58 |
## Use built in number conversion |
| 59 |
#FPCONV_OBJS = g_fmt.o dtoa.o |
| 60 |
#CJSON_CFLAGS += -DUSE_INTERNAL_FPCONV |
| 61 |
|
| 62 |
## Compile built in number conversion for big endian architectures |
| 63 |
#CJSON_CFLAGS += -DIEEE_BIG_ENDIAN |
| 64 |
|
| 65 |
## Compile built in number conversion to support multi-threaded |
| 66 |
## applications (recommended) |
| 67 |
#CJSON_CFLAGS += -pthread -DMULTIPLE_THREADS |
| 68 |
#CJSON_LDFLAGS += -pthread |
| 69 |
|
| 70 |
##### End customisable sections ##### |
| 71 |
|
| 72 |
TEST_FILES = README bench.lua genutf8.pl test.lua octets-escaped.dat \ |
| 73 |
example1.json example2.json example3.json example4.json \ |
| 74 |
example5.json numbers.json rfc-example1.json \ |
| 75 |
rfc-example2.json types.json |
| 76 |
DATAPERM = 644 |
| 77 |
EXECPERM = 755 |
| 78 |
|
| 79 |
ASCIIDOC = asciidoc |
| 80 |
|
| 81 |
BUILD_CFLAGS = -I$(LUA_INCLUDE_DIR) $(CJSON_CFLAGS) |
| 82 |
OBJS = lua_cjson.o strbuf.o $(FPCONV_OBJS) |
| 83 |
|
| 84 |
.PHONY: all clean install install-extra doc |
| 85 |
|
| 86 |
.SUFFIXES: .html .txt |
| 87 |
|
| 88 |
.c.o: |
| 89 |
$(CC) -c $(CFLAGS) $(CPPFLAGS) $(BUILD_CFLAGS) -o $@ $< |
| 90 |
|
| 91 |
.txt.html: |
| 92 |
$(ASCIIDOC) -n -a toc $< |
| 93 |
|
| 94 |
all: $(TARGET) |
| 95 |
|
| 96 |
doc: manual.html performance.html |
| 97 |
|
| 98 |
$(TARGET): $(OBJS) |
| 99 |
$(CC) $(LDFLAGS) $(CJSON_LDFLAGS) -o $@ $(OBJS) |
| 100 |
|
| 101 |
install: $(TARGET) |
| 102 |
mkdir -p $(DESTDIR)/$(LUA_CMODULE_DIR) |
| 103 |
cp $(TARGET) $(DESTDIR)/$(LUA_CMODULE_DIR) |
| 104 |
chmod $(EXECPERM) $(DESTDIR)/$(LUA_CMODULE_DIR)/$(TARGET) |
| 105 |
|
| 106 |
install-extra: |
| 107 |
mkdir -p $(DESTDIR)/$(LUA_MODULE_DIR)/cjson/tests \ |
| 108 |
$(DESTDIR)/$(LUA_BIN_DIR) |
| 109 |
cp lua/cjson/util.lua $(DESTDIR)/$(LUA_MODULE_DIR)/cjson |
| 110 |
chmod $(DATAPERM) $(DESTDIR)/$(LUA_MODULE_DIR)/cjson/util.lua |
| 111 |
cp lua/lua2json.lua $(DESTDIR)/$(LUA_BIN_DIR)/lua2json$(LUA_BIN_SUFFIX) |
| 112 |
chmod $(EXECPERM) $(DESTDIR)/$(LUA_BIN_DIR)/lua2json$(LUA_BIN_SUFFIX) |
| 113 |
cp lua/json2lua.lua $(DESTDIR)/$(LUA_BIN_DIR)/json2lua$(LUA_BIN_SUFFIX) |
| 114 |
chmod $(EXECPERM) $(DESTDIR)/$(LUA_BIN_DIR)/json2lua$(LUA_BIN_SUFFIX) |
| 115 |
cd tests; cp $(TEST_FILES) $(DESTDIR)/$(LUA_MODULE_DIR)/cjson/tests |
| 116 |
cd tests; chmod $(DATAPERM) $(TEST_FILES); chmod $(EXECPERM) *.lua *.pl |
| 117 |
|
| 118 |
clean: |
| 119 |
rm -f *.o $(TARGET) |