Makefile 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. LEDE_TARGET := $(BOARD)$(if $(SUBTARGET),-$(SUBTARGET))
  40. export LEDE_TARGET
  41. CheckTarget := [ '$(LEDE_TARGET)' ] \
  42. || (echo 'Please set GLUON_TARGET to a valid target. Gluon supports the following targets:'; $(foreach target,$(GLUON_TARGETS),echo ' * $(target)';) false)
  43. CheckExternal := test -d lede || (echo 'You don'"'"'t seem to have obtained the external repositories needed by Gluon; please call `make update` first!'; false)
  44. list-targets: FORCE
  45. @$(foreach target,$(GLUON_TARGETS),echo '$(target)';)
  46. GLUON_DEFAULT_PACKAGES := -odhcpd -ppp -ppp-mod-pppoe -wpad-mini gluon-core ip6tables hostapd-mini
  47. GLUON_PACKAGES :=
  48. define merge_packages
  49. $(foreach pkg,$(1),
  50. GLUON_PACKAGES := $$(strip $$(filter-out -$$(patsubst -%,%,$(pkg)) $$(patsubst -%,%,$(pkg)),$$(GLUON_PACKAGES)) $(pkg))
  51. )
  52. endef
  53. $(eval $(call merge_packages,$(GLUON_DEFAULT_PACKAGES) $(GLUON_SITE_PACKAGES)))
  54. GLUON_PACKAGES_YES := $(filter-out -%,$(GLUON_PACKAGES))
  55. GLUON_PACKAGES_NO := $(patsubst -%,%,$(filter -%,$(GLUON_PACKAGES)))
  56. config: FORCE
  57. @$(CheckExternal)
  58. @$(CheckTarget)
  59. @( \
  60. echo 'CONFIG_TARGET_$(BOARD)=y' \
  61. $(if $(SUBTARGET),&& echo 'CONFIG_TARGET_$(BOARD)_$(SUBTARGET)=y') \
  62. $(foreach pkg,$(GLUON_PACKAGES_NO),&& echo '# CONFIG_PACKAGE_$(pkg) is not set') \
  63. && scripts/target_config.sh generic \
  64. && GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/target_config.sh '$(GLUON_TARGET)' \
  65. $(foreach pkg,$(GLUON_PACKAGES_YES),&& echo 'CONFIG_PACKAGE_$(pkg)=y') \
  66. $(foreach lang,$(GLUON_LANGS),&& echo 'CONFIG_GLUON_WEB_LANG_$(lang)=y') \
  67. && echo 'CONFIG_GLUON_RELEASE="$(GLUON_RELEASE)"' \
  68. && echo 'CONFIG_GLUON_SITEDIR="$(GLUON_SITEDIR)"' \
  69. && echo 'CONFIG_GLUON_BRANCH="$(GLUON_BRANCH)"' \
  70. ) > lede/.config
  71. +@$(LEDEMAKE) defconfig
  72. @GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/target_config_check.sh '$(GLUON_TARGET)' '$(GLUON_PACKAGES_YES)'
  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: