Makefile 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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. list-targets: FORCE
  66. @$(foreach target,$(GLUON_TARGETS),echo '$(target)';)
  67. GLUON_FEATURE_PACKAGES := $(shell scripts/features.sh '$(GLUON_FEATURES)' || echo '__ERROR__')
  68. ifneq ($(filter __ERROR__,$(GLUON_FEATURE_PACKAGES)),)
  69. $(error Error while evaluating GLUON_FEATURES)
  70. endif
  71. GLUON_PACKAGES :=
  72. define merge_packages
  73. $(foreach pkg,$(1),
  74. GLUON_PACKAGES := $$(strip $$(filter-out -$$(patsubst -%,%,$(pkg)) $$(patsubst -%,%,$(pkg)),$$(GLUON_PACKAGES)) $(pkg))
  75. )
  76. endef
  77. $(eval $(call merge_packages,$(GLUON_FEATURE_PACKAGES) $(GLUON_SITE_PACKAGES)))
  78. config: FORCE
  79. @$(CheckExternal)
  80. @$(CheckTarget)
  81. @$(GLUON_CONFIG_VARS) \
  82. scripts/target_config.sh '$(GLUON_TARGET)' '$(GLUON_PACKAGES)' \
  83. > lede/.config
  84. +@$(LEDEMAKE) defconfig
  85. @$(GLUON_CONFIG_VARS) \
  86. scripts/target_config_check.sh '$(GLUON_TARGET)' '$(GLUON_PACKAGES)'
  87. LUA := lede/staging_dir/hostpkg/bin/lua
  88. $(LUA):
  89. @$(CheckExternal)
  90. +@[ -e lede/.config ] || $(LEDEMAKE) defconfig
  91. +@$(LEDEMAKE) tools/install
  92. +@$(LEDEMAKE) package/lua/host/install
  93. prepare-target: config $(LUA) ;
  94. all: prepare-target
  95. @GLUON_SITEDIR='$(GLUON_SITEDIR)' $(LUA) scripts/site_config.lua \
  96. || (echo 'Your site configuration did not pass validation.'; false)
  97. @scripts/clean_output.sh
  98. +@$(LEDEMAKE)
  99. @GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/copy_output.sh '$(GLUON_TARGET)'
  100. clean download: config
  101. +@$(LEDEMAKE) $@
  102. dirclean: FORCE
  103. +@[ -e lede/.config ] || $(LEDEMAKE) defconfig
  104. +@$(LEDEMAKE) dirclean
  105. @rm -rf $(GLUON_TMPDIR) $(GLUON_OUTPUTDIR)
  106. manifest: $(LUA) FORCE
  107. @[ '$(GLUON_BRANCH)' ] || (echo 'Please set GLUON_BRANCH to create a manifest.'; false)
  108. @echo '$(GLUON_PRIORITY)' | grep -qE '^([0-9]*\.)?[0-9]+$$' || (echo 'Please specify a numeric value for GLUON_PRIORITY to create a manifest.'; false)
  109. @$(CheckExternal)
  110. @( \
  111. echo 'BRANCH=$(GLUON_BRANCH)' && \
  112. echo "DATE=$$($(LUA) scripts/rfc3339date.lua)" && \
  113. echo 'PRIORITY=$(GLUON_PRIORITY)' && \
  114. echo && \
  115. $(foreach GLUON_TARGET,$(GLUON_TARGETS), \
  116. GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/generate_manifest.sh '$(GLUON_TARGET)' && \
  117. ) : \
  118. ) > 'tmp/$(GLUON_BRANCH).manifest.tmp'
  119. @mkdir -p '$(GLUON_IMAGEDIR)/sysupgrade'
  120. @mv 'tmp/$(GLUON_BRANCH).manifest.tmp' '$(GLUON_IMAGEDIR)/sysupgrade/$(GLUON_BRANCH).manifest'
  121. FORCE: ;
  122. .PHONY: FORCE
  123. .NOTPARALLEL: