module.mk 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. MAKEPATH:=$(dir $(lastword $(MAKEFILE_LIST)))
  2. -include $(MAKEPATH)config.mk
  3. -include $(MAKEPATH)gccconfig.mk
  4. .PHONY: all build compile luacompile luasource clean luaclean
  5. all: build
  6. build: luabuild gccbuild
  7. luabuild: lua$(LUA_TARGET)
  8. gccbuild: compile
  9. compile:
  10. clean: luaclean
  11. luasource:
  12. mkdir -p dist$(LUA_MODULEDIR)
  13. mkdir -p dist$(LUCI_MODULEDIR)
  14. mkdir -p dist$(HTDOCS)
  15. cp -pR root/* dist 2>/dev/null || true
  16. cp -pR luasrc/* dist$(LUCI_MODULEDIR) 2>/dev/null || true
  17. cp -pR lua/* dist$(LUA_MODULEDIR) 2>/dev/null || true
  18. cp -pR htdocs/* dist$(HTDOCS) 2>/dev/null || true
  19. for i in $$(find dist -name .svn -o -name .gitignore); do rm -rf $$i || true; done
  20. ifneq ($(PO),)
  21. mkdir -p dist$(LUCI_I18NDIR)
  22. for file in $(PO); do \
  23. cp $(HOST)/lua-po/$$file.$(if $(PO_LANG),$(PO_LANG),*).* dist$(LUCI_I18NDIR)/ 2>/dev/null || true; \
  24. done
  25. endif
  26. luadiet: luasource
  27. for i in $$(find dist -type f -name '*.lua'); do LUA_PATH="../../contrib/luasrcdiet/lua/?.lua" $(LUA) ../../contrib/luasrcdiet/lua/LuaSrcDiet.lua --maximum $$i -o $$i.diet && mv $$i.diet $$i; done
  28. luastrip: luasource
  29. 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
  30. luacompile: luasource
  31. for i in $$(find dist -name *.lua -not -name debug.lua| sort); do if ! $(LUAC) $(LUAC_OPTIONS) -o $$i $$i; then echo "Error compiling $$i"; exit 1; fi; done
  32. luaclean:
  33. rm -rf dist