aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 5b2b3e1ade9d6e9155983321d6d59ca0cd4d4da4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
LUA_VERSION =   5.1

## Available defines for CJSON_CFLAGS
#
# USE_INTERNAL_ISINF:   Workaround for Solaris platforms missing isinf().
# DISABLE_CJSON_GLOBAL: Do not store module is "cjson" global

## Build defaults
PREFIX =            /usr/local
#CFLAGS =            -g -Wall -pedantic -fno-inline
CFLAGS =            -O3 -Wall -pedantic -DNDEBUG
CJSON_LDFLAGS =     -shared
LUA_INCLUDE_DIR =   $(PREFIX)/include
LUA_MODULE_DIR =    $(PREFIX)/lib/lua/$(LUA_VERSION)
INSTALL_CMD =       install

## Platform overrides
#
# Tweak one of the platform sections below to suit your situation.
#
# See http://lua-users.org/wiki/BuildingModules for further platform
# specific details.

## Linux

## FreeBSD
#LUA_INCLUDE_DIR =   $(PREFIX)/include/lua51

## MacOSX (Macports)
#PREFIX =            /opt/local
#CJSON_LDFLAGS =     -bundle -undefined dynamic_lookup

## Solaris
#CJSON_CFLAGS =      -DUSE_INTERNAL_ISINF

## End platform specific section

BUILD_CFLAGS =      -fpic -I$(LUA_INCLUDE_DIR) $(CJSON_CFLAGS)
OBJS :=             lua_cjson.o strbuf.o fpconv.o

.PHONY: all clean install package doc

all: cjson.so

doc: manual.html

.c.o:
	$(CC) -c $(CFLAGS) $(CPPFLAGS) $(BUILD_CFLAGS) -o $@ $<

cjson.so: $(OBJS)
	$(CC) $(LDFLAGS) $(CJSON_LDFLAGS) -o $@ $(OBJS)

install: cjson.so
	mkdir -p $(DESTDIR)/$(LUA_MODULE_DIR)
	$(INSTALL_CMD) cjson.so $(DESTDIR)/$(LUA_MODULE_DIR)

manual.html: manual.txt
	asciidoc -n -a toc manual.txt

clean:
	rm -f *.o *.so