Makefile 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. ##### Build defaults #####
  13. LUA_VERSION = 5.1
  14. TARGET = cjson.so
  15. PREFIX = /usr/local
  16. #CFLAGS = -g -Wall -pedantic -fno-inline
  17. CFLAGS = -O3 -Wall -pedantic -DNDEBUG
  18. CJSON_CFLAGS = -fpic
  19. CJSON_LDFLAGS = -shared
  20. LUA_INCLUDE_DIR = ../lua
  21. LUA_CMODULE_DIR = $(PREFIX)/lib/lua/$(LUA_VERSION)
  22. LUA_MODULE_DIR = $(PREFIX)/share/lua/$(LUA_VERSION)
  23. LUA_BIN_DIR = $(PREFIX)/bin
  24. ##### Platform overrides #####
  25. ##
  26. ## Tweak one of the platform sections below to suit your situation.
  27. ##
  28. ## See http://lua-users.org/wiki/BuildingModules for further platform
  29. ## specific details.
  30. ## Linux
  31. ## FreeBSD
  32. #LUA_INCLUDE_DIR = $(PREFIX)/include/lua51
  33. ## MacOSX (Macports)
  34. #PREFIX = /opt/local
  35. #CJSON_LDFLAGS = -bundle -undefined dynamic_lookup
  36. ## Solaris
  37. #PREFIX = /home/user/opt
  38. #CC = gcc
  39. #CJSON_CFLAGS = -fpic -DUSE_INTERNAL_ISINF
  40. ## Windows (MinGW)
  41. #TARGET = cjson.dll
  42. #PREFIX = /home/user/opt
  43. #CJSON_CFLAGS = -DDISABLE_INVALID_NUMBERS
  44. #CJSON_LDFLAGS = -shared -L$(PREFIX)/lib -llua51
  45. #LUA_BIN_SUFFIX = .lua
  46. ##### Number conversion configuration #####
  47. ## Use Libc support for number conversion (default)
  48. FPCONV_OBJS = fpconv.o
  49. ## Use built in number conversion
  50. #FPCONV_OBJS = g_fmt.o dtoa.o
  51. #CJSON_CFLAGS += -DUSE_INTERNAL_FPCONV
  52. ## Compile built in number conversion for big endian architectures
  53. #CJSON_CFLAGS += -DIEEE_BIG_ENDIAN
  54. ## Compile built in number conversion to support multi-threaded
  55. ## applications (recommended)
  56. #CJSON_CFLAGS += -pthread -DMULTIPLE_THREADS
  57. #CJSON_LDFLAGS += -pthread
  58. ##### End customisable sections #####
  59. TEST_FILES = README bench.lua genutf8.pl test.lua octets-escaped.dat \
  60. example1.json example2.json example3.json example4.json \
  61. example5.json numbers.json rfc-example1.json \
  62. rfc-example2.json types.json
  63. DATAPERM = 644
  64. EXECPERM = 755
  65. ASCIIDOC = asciidoc
  66. BUILD_CFLAGS = -I$(LUA_INCLUDE_DIR) $(CJSON_CFLAGS)
  67. OBJS = lua_cjson.o strbuf.o $(FPCONV_OBJS)
  68. .PHONY: all clean install install-extra doc
  69. .SUFFIXES: .html .txt
  70. .c.o:
  71. $(CC) -c $(CFLAGS) $(CPPFLAGS) $(BUILD_CFLAGS) -o $@ $<
  72. .txt.html:
  73. $(ASCIIDOC) -n -a toc $<
  74. all: $(TARGET)
  75. doc: manual.html performance.html
  76. $(TARGET): $(OBJS)
  77. $(CC) $(LDFLAGS) $(CJSON_LDFLAGS) -o $@ $(OBJS)
  78. install: $(TARGET)
  79. mkdir -p $(DESTDIR)/$(LUA_CMODULE_DIR)
  80. cp $(TARGET) $(DESTDIR)/$(LUA_CMODULE_DIR)
  81. chmod $(EXECPERM) $(DESTDIR)/$(LUA_CMODULE_DIR)/$(TARGET)
  82. install-extra:
  83. mkdir -p $(DESTDIR)/$(LUA_MODULE_DIR)/cjson/tests \
  84. $(DESTDIR)/$(LUA_BIN_DIR)
  85. cp lua/cjson/util.lua $(DESTDIR)/$(LUA_MODULE_DIR)/cjson
  86. chmod $(DATAPERM) $(DESTDIR)/$(LUA_MODULE_DIR)/cjson/util.lua
  87. cp lua/lua2json.lua $(DESTDIR)/$(LUA_BIN_DIR)/lua2json$(LUA_BIN_SUFFIX)
  88. chmod $(EXECPERM) $(DESTDIR)/$(LUA_BIN_DIR)/lua2json$(LUA_BIN_SUFFIX)
  89. cp lua/json2lua.lua $(DESTDIR)/$(LUA_BIN_DIR)/json2lua$(LUA_BIN_SUFFIX)
  90. chmod $(EXECPERM) $(DESTDIR)/$(LUA_BIN_DIR)/json2lua$(LUA_BIN_SUFFIX)
  91. cd tests; cp $(TEST_FILES) $(DESTDIR)/$(LUA_MODULE_DIR)/cjson/tests
  92. cd tests; chmod $(DATAPERM) $(TEST_FILES); chmod $(EXECPERM) *.lua *.pl
  93. clean:
  94. rm -f *.o $(TARGET)