standalone.mk 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. LUAC = luac
  2. LUAC_OPTIONS = -s
  3. LUA_TARGET ?= source
  4. LUA_MODULEDIR = /usr/local/share/lua/5.1
  5. LUA_LIBRARYDIR = /usr/local/lib/lua/5.1
  6. OS ?= $(shell uname)
  7. LUA_SHLIBS = $(shell pkg-config --silence-errors --libs lua5.1 || pkg-config --silence-errors --libs lua-5.1 || pkg-config --silence-errors --libs lua)
  8. LUA_LIBS = $(if $(LUA_SHLIBS),$(LUA_SHLIBS),$(firstword $(wildcard /usr/lib/liblua.a /usr/local/lib/liblua.a /opt/local/lib/liblua.a)))
  9. LUA_CFLAGS = $(shell pkg-config --silence-errors --cflags lua5.1 || pkg-config --silence-errors --cflags lua-5.1 || pkg-config --silence-errors --cflags lua)
  10. CC = gcc
  11. AR = ar
  12. RANLIB = ranlib
  13. CFLAGS = -O2
  14. FPIC = -fPIC
  15. EXTRA_CFLAGS = --std=gnu99
  16. WFLAGS = -Wall -Werror -pedantic
  17. CPPFLAGS =
  18. COMPILE = $(CC) $(CPPFLAGS) $(CFLAGS) $(EXTRA_CFLAGS) $(WFLAGS)
  19. ifeq ($(OS),Darwin)
  20. SHLIB_FLAGS = -bundle -undefined dynamic_lookup
  21. else
  22. SHLIB_FLAGS = -shared
  23. endif
  24. LINK = $(CC) $(LDFLAGS)
  25. .PHONY: all build compile luacompile luasource clean luaclean
  26. all: build
  27. build: luabuild gccbuild
  28. luabuild: lua$(LUA_TARGET)
  29. gccbuild: compile
  30. compile:
  31. clean: luaclean
  32. luasource:
  33. mkdir -p dist$(LUA_MODULEDIR)
  34. cp -pR root/* dist 2>/dev/null || true
  35. cp -pR lua/* dist$(LUA_MODULEDIR) 2>/dev/null || true
  36. for i in $$(find dist -name .svn); do rm -rf $$i || true; done
  37. luastrip: luasource
  38. for i in $$(find dist -type f -name '*.lua'); do perl -e 'undef $$/; open( F, "< $$ARGV[0]" ) || die $$!; $$src = <F>; close F; $$src =~ s/--\[\[.*?\]\](--)?//gs; $$src =~ s/^\s*--.*?\n//gm; open( F, "> $$ARGV[0]" ) || die $$!; print F $$src; close F' $$i; done
  39. luacompile: luasource
  40. for i in $$(find dist -name *.lua -not -name debug.lua); do $(LUAC) $(LUAC_OPTIONS) -o $$i $$i; done
  41. luaclean:
  42. rm -rf dist