Makefile 5.0 KB

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