gluon.mk 1.8 KB

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