Makefile 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. CJSON_VERSION = 1.0.4
  2. LUA_VERSION = 5.1
  3. ## Available Lua CJSON specific workarounds
  4. #
  5. # To ensure JSON encoding/decoding works correctly for locales using
  6. # comma decimal separators, Lua CJSON must be compiled with one of
  7. # these options:
  8. # USE_POSIX_USELOCALE: Linux, OSX. Thread safe. Recommended option.
  9. # USE_POSIX_SETLOCALE: Works on all ANSI C platforms. May be used when
  10. # thread-safety isn't required.
  11. #
  12. # USE_INTERNAL_ISINF: Workaround for Solaris platforms missing isinf().
  13. ## Common build defaults
  14. PREFIX = /usr/local
  15. CFLAGS_EXTRA = -DUSE_POSIX_SETLOCALE
  16. LDFLAGS_EXTRA = -shared
  17. ## Platform overrides
  18. #
  19. # Tweaking one of the platform sections below to suit your situation.
  20. #
  21. # See http://lua-users.org/wiki/BuildingModules for further platform
  22. # specific details.
  23. ## Linux
  24. CFLAGS_EXTRA = -DUSE_POSIX_USELOCALE
  25. ## FreeBSD
  26. #LUA_INCLUDE_DIR = $(PREFIX)/include/lua51
  27. ## MacOSX (Macports)
  28. #PREFIX = /opt/local
  29. #CFLAGS_EXTRA = -DUSE_POSIX_USELOCALE
  30. #LDFLAGS_EXTRA = -bundle -undefined dynamic_lookup
  31. ## Solaris
  32. #CFLAGS_EXTRA = -DUSE_POSIX_SETLOCALE -DUSE_INTERNAL_ISINF
  33. ## End platform specific section
  34. LUA_INCLUDE_DIR ?= $(PREFIX)/include
  35. LUA_LIB_DIR ?= $(PREFIX)/lib/lua/$(LUA_VERSION)
  36. #CFLAGS ?= -g -Wall -pedantic -fno-inline
  37. CFLAGS ?= -O3 -Wall -pedantic
  38. override CFLAGS += $(CFLAGS_EXTRA) -fpic -I$(LUA_INCLUDE_DIR) -DVERSION=\"$(CJSON_VERSION)\"
  39. override LDFLAGS += $(LDFLAGS_EXTRA)
  40. INSTALL ?= install
  41. .PHONY: all clean install package
  42. all: cjson.so
  43. cjson.so: lua_cjson.o strbuf.o
  44. $(CC) $(LDFLAGS) -o $@ $^
  45. install:
  46. $(INSTALL) -d $(DESTDIR)/$(LUA_LIB_DIR)
  47. $(INSTALL) cjson.so $(DESTDIR)/$(LUA_LIB_DIR)
  48. clean:
  49. rm -f *.o *.so
  50. package:
  51. git archive --prefix="lua-cjson-$(CJSON_VERSION)/" master | \
  52. gzip -9 > "lua-cjson-$(CJSON_VERSION).tar.gz"
  53. git archive --prefix="lua-cjson-$(CJSON_VERSION)/" \
  54. -o "lua-cjson-$(CJSON_VERSION).zip" master