gluon.mk 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # Dependencies for LuaSrcDiet
  2. PKG_BUILD_DEPENDS += luci-base/host
  3. include $(INCLUDE_DIR)/package.mk
  4. # Annoyingly, make's shell function replaces all newlines with spaces, so we have to do some escaping work. Yuck.
  5. shell-escape = $(shell $(1) | sed -ne '1h; 1!H; $$ {g; s/@/@1/g; s/\n/@2/g; p}')
  6. shell-unescape = $(subst @1,@,$(subst @2,$(newline),$(1)))
  7. shell-verbatim = $(call shell-unescape,$(call shell-escape,$(1)))
  8. define GluonCheckSite
  9. [ -z "$$IPKG_INSTROOT" ] || "${TOPDIR}/staging_dir/hostpkg/bin/lua" "${TOPDIR}/../scripts/check_site.lua" <<'END__GLUON__CHECK__SITE'
  10. $(call shell-verbatim,cat '$(1)')
  11. END__GLUON__CHECK__SITE
  12. endef
  13. GLUON_SUPPORTED_LANGS := de fr
  14. GLUON_LANG_de := German
  15. GLUON_LANG_fr := French
  16. GLUON_I18N_CONFIG := $(foreach lang,$(GLUON_SUPPORTED_LANGS),CONFIG_GLUON_WEB_LANG_$(lang))
  17. GLUON_ENABLED_LANGS := en $(foreach lang,$(GLUON_SUPPORTED_LANGS),$(if $(CONFIG_GLUON_WEB_LANG_$(lang)),$(lang)))
  18. define GluonBuildI18N
  19. mkdir -p $$(PKG_BUILD_DIR)/i18n
  20. for lang in $$(GLUON_ENABLED_LANGS); do \
  21. if [ -e $(2)/$$$$lang.po ]; then \
  22. rm -f $$(PKG_BUILD_DIR)/i18n/$(1).$$$$lang.lmo; \
  23. po2lmo $(2)/$$$$lang.po $$(PKG_BUILD_DIR)/i18n/$(1).$$$$lang.lmo; \
  24. fi; \
  25. done
  26. endef
  27. define GluonInstallI18N
  28. $$(INSTALL_DIR) $(2)/lib/gluon/web/i18n
  29. for lang in $$(GLUON_ENABLED_LANGS); do \
  30. if [ -e $$(PKG_BUILD_DIR)/i18n/$(1).$$$$lang.lmo ]; then \
  31. $$(INSTALL_DATA) $$(PKG_BUILD_DIR)/i18n/$(1).$$$$lang.lmo $(2)/lib/gluon/web/i18n/$(1).$$$$lang.lmo; \
  32. fi; \
  33. done
  34. endef
  35. define GluonSrcDiet
  36. rm -rf $(2)
  37. $(CP) $(1) $(2)
  38. $(FIND) $(2) -type f | while read src; do \
  39. if LuaSrcDiet --noopt-binequiv -o "$$$$src.o" "$$$$src"; then \
  40. chmod $$$$(stat -c%a "$$$$src") "$$$$src.o"; \
  41. mv "$$$$src.o" "$$$$src"; \
  42. fi; \
  43. done
  44. endef