diff options
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 45 |
1 files changed, 23 insertions, 22 deletions
@@ -12,54 +12,55 @@ LUA_VERSION = 5.1 | |||
12 | # | 12 | # |
13 | # USE_INTERNAL_ISINF: Workaround for Solaris platforms missing isinf(). | 13 | # USE_INTERNAL_ISINF: Workaround for Solaris platforms missing isinf(). |
14 | 14 | ||
15 | ## Common build defaults | 15 | ## Build defaults |
16 | PREFIX = /usr/local | 16 | PREFIX = /usr/local |
17 | CFLAGS_EXTRA = -DUSE_POSIX_SETLOCALE | 17 | #CFLAGS = -g -Wall -pedantic -fno-inline |
18 | LDFLAGS_EXTRA = -shared | 18 | CFLAGS = -O3 -Wall -pedantic |
19 | CJSON_CFLAGS = -DUSE_POSIX_SETLOCALE | ||
20 | CJSON_LDFLAGS = -shared | ||
21 | LUA_INCLUDE_DIR = $(PREFIX)/include | ||
22 | LUA_MODULE_DIR = $(PREFIX)/lib/lua/$(LUA_VERSION) | ||
23 | INSTALL_CMD = install | ||
19 | 24 | ||
20 | ## Platform overrides | 25 | ## Platform overrides |
21 | # | 26 | # |
22 | # Tweaking one of the platform sections below to suit your situation. | 27 | # Tweak one of the platform sections below to suit your situation. |
23 | # | 28 | # |
24 | # See http://lua-users.org/wiki/BuildingModules for further platform | 29 | # See http://lua-users.org/wiki/BuildingModules for further platform |
25 | # specific details. | 30 | # specific details. |
26 | 31 | ||
27 | ## Linux | 32 | ## Linux |
28 | CFLAGS_EXTRA = -DUSE_POSIX_USELOCALE | 33 | #CJSON_CFLAGS = -DUSE_POSIX_USELOCALE |
29 | 34 | ||
30 | ## FreeBSD | 35 | ## FreeBSD |
31 | #LUA_INCLUDE_DIR = $(PREFIX)/include/lua51 | 36 | #LUA_INCLUDE_DIR = $(PREFIX)/include/lua51 |
32 | 37 | ||
33 | ## MacOSX (Macports) | 38 | ## MacOSX (Macports) |
34 | #PREFIX = /opt/local | 39 | #PREFIX = /opt/local |
35 | #CFLAGS_EXTRA = -DUSE_POSIX_USELOCALE | 40 | #CJSON_CFLAGS = -DUSE_POSIX_USELOCALE |
36 | #LDFLAGS_EXTRA = -bundle -undefined dynamic_lookup | 41 | #CJSON_LDFLAGS = -bundle -undefined dynamic_lookup |
37 | 42 | ||
38 | ## Solaris | 43 | ## Solaris |
39 | #CFLAGS_EXTRA = -DUSE_POSIX_SETLOCALE -DUSE_INTERNAL_ISINF | 44 | #CJSON_CFLAGS = -DUSE_POSIX_SETLOCALE -DUSE_INTERNAL_ISINF |
40 | 45 | ||
41 | ## End platform specific section | 46 | ## End platform specific section |
42 | 47 | ||
43 | LUA_INCLUDE_DIR ?= $(PREFIX)/include | 48 | CJSON_CFLAGS += -fpic -I$(LUA_INCLUDE_DIR) -DVERSION=\"$(CJSON_VERSION)\" |
44 | LUA_LIB_DIR ?= $(PREFIX)/lib/lua/$(LUA_VERSION) | 49 | OBJS := lua_cjson.o strbuf.o |
45 | |||
46 | #CFLAGS ?= -g -Wall -pedantic -fno-inline | ||
47 | CFLAGS ?= -O3 -Wall -pedantic | ||
48 | override CFLAGS += $(CFLAGS_EXTRA) -fpic -I$(LUA_INCLUDE_DIR) -DVERSION=\"$(CJSON_VERSION)\" | ||
49 | override LDFLAGS += $(LDFLAGS_EXTRA) | ||
50 | |||
51 | INSTALL ?= install | ||
52 | 50 | ||
53 | .PHONY: all clean install package | 51 | .PHONY: all clean install package |
54 | 52 | ||
55 | all: cjson.so | 53 | all: cjson.so |
56 | 54 | ||
57 | cjson.so: lua_cjson.o strbuf.o | 55 | .c.o: |
58 | $(CC) $(LDFLAGS) -o $@ $^ | 56 | $(CC) -c $(CFLAGS) $(CPPFLAGS) $(CJSON_CFLAGS) -o $@ $< |
57 | |||
58 | cjson.so: $(OBJS) | ||
59 | $(CC) $(LDFLAGS) $(CJSON_LDFLAGS) -o $@ $(OBJS) | ||
59 | 60 | ||
60 | install: | 61 | install: cjson.so |
61 | $(INSTALL) -d $(DESTDIR)/$(LUA_LIB_DIR) | 62 | mkdir -p $(DESTDIR)/$(LUA_MODULE_DIR) |
62 | $(INSTALL) cjson.so $(DESTDIR)/$(LUA_LIB_DIR) | 63 | $(INSTALL_CMD) cjson.so $(DESTDIR)/$(LUA_MODULE_DIR) |
63 | 64 | ||
64 | clean: | 65 | clean: |
65 | rm -f *.o *.so | 66 | rm -f *.o *.so |