Makefile 4.4 KB

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