Makefile 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. include $(TOPDIR)/rules.mk
  2. PKG_NAME:=gluon-site
  3. GLUON_SITEDIR = $(call qstrip,$(CONFIG_GLUON_SITEDIR))
  4. GLUON_SITE_VERSION = $(shell ( cd '$(GLUON_SITEDIR)' && git --git-dir=.git describe --always --dirty=+ ) 2>/dev/null || echo unknown)
  5. PKG_VERSION:=$(if $(DUMP),x,$(GLUON_SITE_VERSION))
  6. PKG_CONFIG_DEPENDS := CONFIG_GLUON_RELEASE CONFIG_GLUON_SITEDIR CONFIG_GLUON_MULTIDOMAIN
  7. PKG_FILE_DEPENDS := $(GLUON_SITEDIR)/site.conf $(GLUON_SITEDIR)/domains/ $(GLUON_SITEDIR)/i18n/
  8. PKG_BUILD_DEPENDS := lua-cjson/host
  9. PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
  10. include ../gluon.mk
  11. PKG_CONFIG_DEPENDS += $(GLUON_I18N_CONFIG)
  12. define Package/gluon-site
  13. SECTION:=gluon
  14. CATEGORY:=Gluon
  15. TITLE:=Site-specific files of Gluon
  16. endef
  17. define Package/gluon-site/config
  18. config GLUON_RELEASE
  19. string "Gluon release number"
  20. depends on PACKAGE_gluon-site
  21. default ""
  22. config GLUON_SITEDIR
  23. string "Gluon site configuration directory"
  24. depends on PACKAGE_gluon-site
  25. default ""
  26. config GLUON_MULTIDOMAIN
  27. bool "Gluon multi-domain support"
  28. endef
  29. define Build/Prepare
  30. mkdir -p $(PKG_BUILD_DIR)
  31. endef
  32. define GenerateJSON
  33. GLUON_SITEDIR='$$(GLUON_SITEDIR)' GLUON_SITE_CONFIG='$(1).conf' lua -e 'print(require("cjson").encode(assert(dofile("../../scripts/site_config.lua"))))' > '$$(PKG_BUILD_DIR)/$(1).json'
  34. endef
  35. define Build/Compile
  36. $(call GenerateJSON,site)
  37. ifdef CONFIG_GLUON_MULTIDOMAIN
  38. rm -rf $(PKG_BUILD_DIR)/domains
  39. mkdir -p $(PKG_BUILD_DIR)/domains
  40. $(foreach domain,$(patsubst $(GLUON_SITEDIR)/domains/%.conf,%,$(wildcard $(GLUON_SITEDIR)/domains/*.conf)),
  41. [ ! -e '$(PKG_BUILD_DIR)/domains/$(domain).json' ]
  42. $(call GenerateJSON,domains/$(domain))
  43. lua ../../scripts/domain_aliases.lua '$(PKG_BUILD_DIR)/domains/$(domain).json' | while read alias; do \
  44. [ "$$$${alias}" != '$(domain)' ] || continue; \
  45. ln -s '$(domain).json' $(PKG_BUILD_DIR)/domains/$$$${alias}.json || exit 1; \
  46. done
  47. )
  48. endif
  49. $(call GluonBuildI18N,gluon-site,$(GLUON_SITEDIR)/i18n)
  50. endef
  51. define Package/gluon-site/install
  52. $(INSTALL_DIR) $(1)/lib/gluon
  53. $(INSTALL_DATA) $(PKG_BUILD_DIR)/site.json $(1)/lib/gluon/
  54. ifdef CONFIG_GLUON_MULTIDOMAIN
  55. $(CP) $(PKG_BUILD_DIR)/domains $(1)/lib/gluon/
  56. endif
  57. echo '$(GLUON_SITE_VERSION)' > $(1)/lib/gluon/site-version
  58. echo '$(call qstrip,$(CONFIG_GLUON_RELEASE))' > $(1)/lib/gluon/release
  59. $(call GluonInstallI18N,gluon-site,$(1))
  60. endef
  61. $(eval $(call BuildPackage,gluon-site))