Makefile 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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_FEATURE_PACKAGES := $(shell scripts/features.sh '$(GLUON_FEATURES)')
  48. ifneq ($(.SHELLSTATUS),0)
  49. $(error Error while evaluating GLUON_FEATURES)
  50. endif
  51. GLUON_PACKAGES :=
  52. define merge_packages
  53. $(foreach pkg,$(1),
  54. GLUON_PACKAGES := $$(strip $$(filter-out -$$(patsubst -%,%,$(pkg)) $$(patsubst -%,%,$(pkg)),$$(GLUON_PACKAGES)) $(pkg))
  55. )
  56. endef
  57. $(eval $(call merge_packages,$(GLUON_DEFAULT_PACKAGES) $(GLUON_FEATURE_PACKAGES) $(GLUON_SITE_PACKAGES)))
  58. GLUON_PACKAGES_YES := $(filter-out -%,$(GLUON_PACKAGES))
  59. GLUON_PACKAGES_NO := $(patsubst -%,%,$(filter -%,$(GLUON_PACKAGES)))
  60. config: FORCE
  61. @$(CheckExternal)
  62. @$(CheckTarget)
  63. @( \
  64. echo 'CONFIG_TARGET_$(BOARD)=y' \
  65. $(if $(SUBTARGET),&& echo 'CONFIG_TARGET_$(BOARD)_$(SUBTARGET)=y') \
  66. $(foreach pkg,$(GLUON_PACKAGES_NO),&& echo '# CONFIG_PACKAGE_$(pkg) is not set') \
  67. && scripts/target_config.sh generic \
  68. && GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/target_config.sh '$(GLUON_TARGET)' \
  69. $(foreach pkg,$(GLUON_PACKAGES_YES),&& echo 'CONFIG_PACKAGE_$(pkg)=y') \
  70. $(foreach lang,$(GLUON_LANGS),&& echo 'CONFIG_GLUON_WEB_LANG_$(lang)=y') \
  71. && echo 'CONFIG_GLUON_RELEASE="$(GLUON_RELEASE)"' \
  72. && echo 'CONFIG_GLUON_SITEDIR="$(GLUON_SITEDIR)"' \
  73. && echo 'CONFIG_GLUON_BRANCH="$(GLUON_BRANCH)"' \
  74. ) > lede/.config
  75. +@$(LEDEMAKE) defconfig
  76. @GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/target_config_check.sh '$(GLUON_TARGET)' '$(GLUON_PACKAGES_YES)'
  77. LUA := lede/staging_dir/hostpkg/bin/lua
  78. $(LUA):
  79. @$(CheckExternal)
  80. +@[ -e lede/.config ] || $(LEDEMAKE) defconfig
  81. +@$(LEDEMAKE) tools/install
  82. +@$(LEDEMAKE) package/lua/host/install
  83. prepare-target: config $(LUA) ;
  84. all: prepare-target
  85. @GLUON_SITEDIR='$(GLUON_SITEDIR)' $(LUA) scripts/site_config.lua \
  86. || (echo 'Your site configuration did not pass validation.'; false)
  87. @scripts/clean_output.sh
  88. +@$(LEDEMAKE)
  89. @GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/copy_output.sh '$(GLUON_TARGET)'
  90. clean download: config
  91. +@$(LEDEMAKE) $@
  92. dirclean: FORCE
  93. +@[ -e lede/.config ] || $(LEDEMAKE) defconfig
  94. +@$(LEDEMAKE) dirclean
  95. @rm -rf $(GLUON_TMPDIR) $(GLUON_OUTPUTDIR)
  96. manifest: $(LUA) FORCE
  97. @[ '$(GLUON_BRANCH)' ] || (echo 'Please set GLUON_BRANCH to create a manifest.'; false)
  98. @echo '$(GLUON_PRIORITY)' | grep -qE '^([0-9]*\.)?[0-9]+$$' || (echo 'Please specify a numeric value for GLUON_PRIORITY to create a manifest.'; false)
  99. @$(CheckExternal)
  100. @( \
  101. echo 'BRANCH=$(GLUON_BRANCH)' && \
  102. echo "DATE=$$($(LUA) scripts/rfc3339date.lua)" && \
  103. echo 'PRIORITY=$(GLUON_PRIORITY)' && \
  104. echo && \
  105. $(foreach GLUON_TARGET,$(GLUON_TARGETS), \
  106. GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/generate_manifest.sh '$(GLUON_TARGET)' && \
  107. ) : \
  108. ) > 'tmp/$(GLUON_BRANCH).manifest.tmp'
  109. @mkdir -p '$(GLUON_IMAGEDIR)/sysupgrade'
  110. @mv 'tmp/$(GLUON_BRANCH).manifest.tmp' '$(GLUON_IMAGEDIR)/sysupgrade/$(GLUON_BRANCH).manifest'
  111. FORCE: ;
  112. .PHONY: FORCE
  113. .NOTPARALLEL: