gluon.mk 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # Dependencies for LuaSrcDiet
  2. PKG_BUILD_DEPENDS += luci-base/host lua/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. define GluonCheckSite
  6. [ -z "$$GLUONDIR" ] || sed -e 's/-@/\n/g' -e 's/+@/@/g' <<'END__GLUON__CHECK__SITE' | "$$GLUONDIR"/scripts/check_site.sh
  7. $(shell cat $(1) | sed -ne '1h; 1!H; $$ {g; s/@/+@/g; s/\n/-@/g; p}')
  8. END__GLUON__CHECK__SITE
  9. endef
  10. # Languages supported by LuCi
  11. GLUON_SUPPORTED_LANGS := ca zh_cn en fr de el he hu it ja ms no pl pt_br pt ro ru es sv uk vi
  12. GLUON_I18N_PACKAGES := $(foreach lang,$(GLUON_SUPPORTED_LANGS),+LUCI_LANG_$(lang):luci-i18n-base-$(lang))
  13. GLUON_I18N_CONFIG := $(foreach lang,$(GLUON_SUPPORTED_LANGS),CONFIG_LUCI_LANG_$(lang))
  14. GLUON_ENABLED_LANGS := $(foreach lang,$(GLUON_SUPPORTED_LANGS),$(if $(CONFIG_LUCI_LANG_$(lang)),$(lang)))
  15. define GluonBuildI18N
  16. mkdir -p $$(PKG_BUILD_DIR)/i18n
  17. for lang in $$(GLUON_ENABLED_LANGS); do \
  18. if [ -e $(2)/$$$$lang.po ]; then \
  19. rm -f $$(PKG_BUILD_DIR)/i18n/$(1).$$$$lang.lmo; \
  20. po2lmo $(2)/$$$$lang.po $$(PKG_BUILD_DIR)/i18n/$(1).$$$$lang.lmo; \
  21. fi; \
  22. done
  23. endef
  24. define GluonInstallI18N
  25. $$(INSTALL_DIR) $(2)/usr/lib/lua/luci/i18n
  26. for lang in $$(GLUON_ENABLED_LANGS); do \
  27. if [ -e $$(PKG_BUILD_DIR)/i18n/$(1).$$$$lang.lmo ]; then \
  28. $$(INSTALL_DATA) $$(PKG_BUILD_DIR)/i18n/$(1).$$$$lang.lmo $(2)/usr/lib/lua/luci/i18n/$(1).$$$$lang.lmo; \
  29. fi; \
  30. done
  31. endef
  32. define GluonSrcDiet
  33. rm -rf $(2)
  34. $(CP) $(1) $(2)
  35. $(FIND) $(2) -type f | while read src; do \
  36. if $(STAGING_DIR_HOST)/bin/lua $(STAGING_DIR_HOST)/bin/LuaSrcDiet \
  37. --noopt-binequiv -o "$$$$src.o" "$$$$src"; \
  38. then \
  39. chmod $$$$(stat -c%a "$$$$src") "$$$$src.o"; \
  40. mv "$$$$src.o" "$$$$src"; \
  41. fi; \
  42. done
  43. endef