+# some generic macros that can be used by all packages
+ifeq ($(LUCI_MINIFY_JS),1)
+ define SrcDiet
+ $(FIND) $(1) -type f -name '*.lua' | while read src; do \
+ if LUA_PATH="$(STAGING_DIR_HOSTPKG)/lib/lua/5.1/?.lua" luasrcdiet --noopt-binequiv -o "$$$$src.o" "$$$$src"; \
+ then mv "$$$$src.o" "$$$$src"; fi; \
+ done
+ endef
+else
+ define SrcDiet
+ $$(call MESSAGE,$$(LUCI_NAME) does not support Lua source minification)
+ endef
+endif
+
+ifeq ($(LUCI_MINIFY_JS),1)
+ define JsMin
+ $(FIND) $(1) -type f -name '*.js' | while read src; do \
+ if jsmin < "$$$$src" > "$$$$src.o"; \
+ then mv "$$$$src.o" "$$$$src"; fi; \
+ done
+ endef
+else
+ define JsMin
+ $$(call MESSAGE,$$(LUCI_NAME) does not support JavaScript source minification)
+ endef
+endif
+
+ifeq ($(LUCI_MINIFY_CSS),1)
+ define CssTidy
+ $(FIND) $(1) -type f -name '*.css' | while read src; do \
+ if csstidy "$$$$src" --template=highest --remove_last_semicolon=true "$$$$src.o"; \
+ then mv "$$$$src.o" "$$$$src"; fi; \
+ done
+ endef
+else
+ define CssTidy
+ $$(call MESSAGE,$$(LUCI_NAME) does not support CSS source minification)
+ endef
+endif
+
+define SubstituteVersion
+ $(FIND) $(1) -type f -name '*.htm' | while read src; do \
+ $(SED) 's/<%# *\([^ ]*\)PKG_VERSION *%>/\1$(if $(PKG_VERSION),$(PKG_VERSION),$(PKG_SRC_VERSION))/g' \
+ -e 's/"\(<%= *\(media\|resource\) *%>[^"]*\.\(js\|css\)\)"/"\1?v=$(if $(PKG_VERSION),$(PKG_VERSION),$(PKG_SRC_VERSION))"/g' \
+ "$$$$src"; \
+ done
+endef
+
+# additional setting luci-base package
+ifeq ($(PKG_NAME),luci-base)
+ define Package/luci-base/config
+ config LUCI_SRCDIET
+ bool "Minify Lua sources"
+ default n
+
+ config LUCI_JSMIN
+ bool "Minify JavaScript sources"
+ default y
+
+ config LUCI_CSSTIDY
+ bool "Minify CSS files"
+ default y
+
+ menu "Translations"$(foreach lang,$(LUCI_LANGUAGES),
+
+ config LUCI_LANG_$(lang)
+ tristate "$(shell echo '$(LUCI_LANG.$(lang))' | sed -e 's/^.* (\(.*\))$$/\1/') ($(lang))")
+
+ endmenu
+ endef
+endif
+