REPORTED_PLATFORM=$(shell (uname -o || uname -s) 2> /dev/null)
ifeq ($(REPORTED_PLATFORM), Darwin)
PLATFORM=macosx
else ifeq ($(REPORTED_PLATFORM), GNU/Linux)
PLATFORM=linux
else
PLATFORM=none
endif
PLATFORMS = linux macosx windows
USE_INTERNAL_FPCONV=true
FPCONV_OBJS=g_fmt.o dtoa.o
PREFIX=../lua
CJSON_CFLAGS=-std=gnu99 -fPIC -fvisibility=hidden -DUSE_INTERNAL_FPCONV
ifeq ($(PLATFORM),macosx)
CC=cc
CJSON_LDFLAGS=-dynamiclib -undefined dynamic_lookup
endif
ifeq ($(PLATFORM),linux)
CC=gcc
CJSON_LDFLAGS=-shared -lpthread
endif
TARGET = cjson.so
CFLAGS = -O3 -Wall -pedantic -DNDEBUG -pthread -DMULTIPLE_THREADS
LUA_INCLUDE_DIR = $(PREFIX)/src
TEST_FILES = README bench.lua genutf8.pl test.lua octets-escaped.dat \
example1.json example2.json example3.json example4.json \
example5.json numbers.json rfc-example1.json \
rfc-example2.json types.json
DATAPERM = 644
EXECPERM = 755
ASCIIDOC = asciidoc
BUILD_CFLAGS = -I$(LUA_INCLUDE_DIR) $(CJSON_CFLAGS)
OBJS = lua_cjson.o strbuf.o $(FPCONV_OBJS)
.PHONY: all clean install install-extra doc
.SUFFIXES: .html .txt
.c.o:
$(CC) -c $(CFLAGS) $(CPPFLAGS) $(BUILD_CFLAGS) -o $@ $<
.txt.html:
$(ASCIIDOC) -n -a toc $<
all: $(TARGET)
doc: manual.html performance.html
$(TARGET): $(OBJS)
$(CC) $(LDFLAGS) $(CJSON_LDFLAGS) -o $@ $(OBJS)
clean:
rm -f *.o $(TARGET)