Makefile 4.8 KB

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