Makefile 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. all:
  2. LC_ALL:=C
  3. LANG:=C
  4. export LC_ALL LANG
  5. # initialize (possibly already user set) directory variables
  6. GLUON_SITEDIR ?= site
  7. GLUON_TMPDIR ?= tmp
  8. GLUON_OUTPUTDIR ?= output
  9. GLUON_IMAGEDIR ?= $(GLUON_OUTPUTDIR)/images
  10. GLUON_PACKAGEDIR ?= $(GLUON_OUTPUTDIR)/packages
  11. # check for spaces & resolve possibly relative paths
  12. define mkabspath
  13. ifneq (1,$(words [$($(1))]))
  14. $$(error $(1) must not contain spaces)
  15. endif
  16. override $(1) := $(abspath $($(1)))
  17. endef
  18. $(eval $(call mkabspath,GLUON_SITEDIR))
  19. $(eval $(call mkabspath,GLUON_TMPDIR))
  20. $(eval $(call mkabspath,GLUON_OUTPUTDIR))
  21. $(eval $(call mkabspath,GLUON_IMAGEDIR))
  22. $(eval $(call mkabspath,GLUON_PACKAGEDIR))
  23. export GLUON_TMPDIR GLUON_IMAGEDIR GLUON_PACKAGEDIR DEVICES
  24. $(GLUON_SITEDIR)/site.mk:
  25. $(error No site configuration was found. Please check out a site configuration to $(GLUON_SITEDIR))
  26. include $(GLUON_SITEDIR)/site.mk
  27. GLUON_RELEASE ?= $(error GLUON_RELEASE not set. GLUON_RELEASE can be set in site.mk or on the command line)
  28. GLUON_MULTIDOMAIN ?= 0
  29. GLUON_WLAN_MESH ?= 11s
  30. GLUON_DEBUG ?= 0
  31. export GLUON_RELEASE GLUON_REGION GLUON_MULTIDOMAIN GLUON_WLAN_MESH GLUON_DEBUG
  32. show-release:
  33. @echo '$(GLUON_RELEASE)'
  34. update: FORCE
  35. @GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/update.sh
  36. @GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/patch.sh
  37. @GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/feeds.sh
  38. update-patches: FORCE
  39. @GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/update.sh
  40. @GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/update-patches.sh
  41. @GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/patch.sh
  42. update-feeds: FORCE
  43. @GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/feeds.sh
  44. GLUON_TARGETS :=
  45. define GluonTarget
  46. gluon_target := $(1)$$(if $(2),-$(2))
  47. GLUON_TARGETS += $$(gluon_target)
  48. GLUON_TARGET_$$(gluon_target)_BOARD := $(1)
  49. GLUON_TARGET_$$(gluon_target)_SUBTARGET := $(if $(3),$(3),$(2))
  50. endef
  51. include targets/targets.mk
  52. LEDEMAKE = $(MAKE) -C lede
  53. BOARD := $(GLUON_TARGET_$(GLUON_TARGET)_BOARD)
  54. SUBTARGET := $(GLUON_TARGET_$(GLUON_TARGET)_SUBTARGET)
  55. GLUON_CONFIG_VARS := \
  56. GLUON_SITEDIR='$(GLUON_SITEDIR)' \
  57. GLUON_RELEASE='$(GLUON_RELEASE)' \
  58. GLUON_BRANCH='$(GLUON_BRANCH)' \
  59. GLUON_LANGS='$(GLUON_LANGS)' \
  60. BOARD='$(BOARD)' \
  61. SUBTARGET='$(SUBTARGET)'
  62. LEDE_TARGET := $(BOARD)$(if $(SUBTARGET),-$(SUBTARGET))
  63. export LEDE_TARGET
  64. CheckTarget := [ '$(LEDE_TARGET)' ] \
  65. || (echo 'Please set GLUON_TARGET to a valid target. Gluon supports the following targets:'; $(foreach target,$(GLUON_TARGETS),echo ' * $(target)';) false)
  66. CheckExternal := test -d lede || (echo 'You don'"'"'t seem to have obtained the external repositories needed by Gluon; please call `make update` first!'; false)
  67. define CheckSite
  68. @GLUON_SITEDIR='$(GLUON_SITEDIR)' GLUON_SITE_CONFIG='$(1).conf' $(LUA) scripts/site_config.lua \
  69. || (echo 'Your site configuration ($(1).conf) did not pass validation.'; false)
  70. endef
  71. list-targets: FORCE
  72. @$(foreach target,$(GLUON_TARGETS),echo '$(target)';)
  73. GLUON_FEATURE_PACKAGES := $(shell scripts/features.sh '$(GLUON_FEATURES)' || echo '__ERROR__')
  74. ifneq ($(filter __ERROR__,$(GLUON_FEATURE_PACKAGES)),)
  75. $(error Error while evaluating GLUON_FEATURES)
  76. endif
  77. GLUON_PACKAGES :=
  78. define merge_packages
  79. $(foreach pkg,$(1),
  80. GLUON_PACKAGES := $$(strip $$(filter-out -$$(patsubst -%,%,$(pkg)) $$(patsubst -%,%,$(pkg)),$$(GLUON_PACKAGES)) $(pkg))
  81. )
  82. endef
  83. $(eval $(call merge_packages,$(GLUON_FEATURE_PACKAGES) $(GLUON_SITE_PACKAGES)))
  84. config: FORCE
  85. @$(CheckExternal)
  86. @$(CheckTarget)
  87. @$(GLUON_CONFIG_VARS) \
  88. scripts/target_config.sh '$(GLUON_TARGET)' '$(GLUON_PACKAGES)' \
  89. > lede/.config
  90. +@$(LEDEMAKE) defconfig
  91. @$(GLUON_CONFIG_VARS) \
  92. scripts/target_config_check.sh '$(GLUON_TARGET)' '$(GLUON_PACKAGES)'
  93. LUA := lede/staging_dir/hostpkg/bin/lua
  94. $(LUA):
  95. @$(CheckExternal)
  96. +@[ -e lede/.config ] || $(LEDEMAKE) defconfig
  97. +@$(LEDEMAKE) tools/install
  98. +@$(LEDEMAKE) package/lua/host/install
  99. prepare-target: config $(LUA) ;
  100. all: prepare-target
  101. $(foreach conf,site $(patsubst $(GLUON_SITEDIR)/%.conf,%,$(wildcard $(GLUON_SITEDIR)/domains/*.conf)),$(call CheckSite,$(conf)))
  102. @scripts/clean_output.sh
  103. +@$(LEDEMAKE)
  104. @GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/copy_output.sh '$(GLUON_TARGET)'
  105. clean download: config
  106. +@$(LEDEMAKE) $@
  107. dirclean: FORCE
  108. +@[ -e lede/.config ] || $(LEDEMAKE) defconfig
  109. +@$(LEDEMAKE) dirclean
  110. @rm -rf $(GLUON_TMPDIR) $(GLUON_OUTPUTDIR)
  111. manifest: $(LUA) FORCE
  112. @[ '$(GLUON_BRANCH)' ] || (echo 'Please set GLUON_BRANCH to create a manifest.'; false)
  113. @echo '$(GLUON_PRIORITY)' | grep -qE '^([0-9]*\.)?[0-9]+$$' || (echo 'Please specify a numeric value for GLUON_PRIORITY to create a manifest.'; false)
  114. @$(CheckExternal)
  115. @( \
  116. echo 'BRANCH=$(GLUON_BRANCH)' && \
  117. echo "DATE=$$($(LUA) scripts/rfc3339date.lua)" && \
  118. echo 'PRIORITY=$(GLUON_PRIORITY)' && \
  119. echo && \
  120. $(foreach GLUON_TARGET,$(GLUON_TARGETS), \
  121. GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/generate_manifest.sh '$(GLUON_TARGET)' && \
  122. ) : \
  123. ) > 'tmp/$(GLUON_BRANCH).manifest.tmp'
  124. @mkdir -p '$(GLUON_IMAGEDIR)/sysupgrade'
  125. @mv 'tmp/$(GLUON_BRANCH).manifest.tmp' '$(GLUON_IMAGEDIR)/sysupgrade/$(GLUON_BRANCH).manifest'
  126. FORCE: ;
  127. .PHONY: FORCE
  128. .NOTPARALLEL: