Start 0.11.x branch
[project/luci.git] / build / module.mk
1 MAKEPATH:=$(dir $(lastword $(MAKEFILE_LIST)))
2 -include $(MAKEPATH)config.mk
3 -include $(MAKEPATH)gccconfig.mk
4
5 .PHONY: all build compile luacompile luasource clean luaclean
6
7 all: build
8
9 build: luabuild gccbuild
10
11 luabuild: lua$(LUA_TARGET)
12
13 gccbuild: compile
14 compile:
15
16 clean: luaclean
17
18 luasource:
19 mkdir -p dist$(LUA_MODULEDIR)
20 mkdir -p dist$(LUCI_MODULEDIR)
21 mkdir -p dist$(HTDOCS)
22 cp -pR root/* dist 2>/dev/null || true
23 cp -pR luasrc/* dist$(LUCI_MODULEDIR) 2>/dev/null || true
24 cp -pR lua/* dist$(LUA_MODULEDIR) 2>/dev/null || true
25 cp -pR htdocs/* dist$(HTDOCS) 2>/dev/null || true
26 for i in $$(find dist -name .svn -o -name .gitignore); do rm -rf $$i || true; done
27 ifneq ($(PO),)
28 mkdir -p dist$(LUCI_I18NDIR)
29 for file in $(PO); do \
30 cp $(HOST)/lua-po/$$file.$(if $(PO_LANG),$(PO_LANG),*).* dist$(LUCI_I18NDIR)/ 2>/dev/null || true; \
31 done
32 endif
33
34
35 luadiet: luasource
36 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
37
38 luastrip: luasource
39 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
40
41 luacompile: luasource
42 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
43
44 luaclean:
45 rm -rf dist
46