Makefile 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. update: FORCE
  17. @GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/update.sh
  18. @GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/patch.sh
  19. @GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/feeds.sh
  20. update-patches: FORCE
  21. @GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/update.sh
  22. @GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/update-patches.sh
  23. @GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/patch.sh
  24. update-feeds: FORCE
  25. @GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/feeds.sh
  26. GLUON_TARGETS :=
  27. define GluonTarget
  28. gluon_target := $(1)$$(if $(2),-$(2))
  29. GLUON_TARGETS += $$(gluon_target)
  30. GLUON_TARGET_$$(gluon_target)_BOARD := $(1)
  31. GLUON_TARGET_$$(gluon_target)_SUBTARGET := $(if $(3),$(3),$(2))
  32. endef
  33. include targets/targets.mk
  34. LEDEMAKE = $(MAKE) -C lede
  35. BOARD := $(GLUON_TARGET_$(GLUON_TARGET)_BOARD)
  36. SUBTARGET := $(GLUON_TARGET_$(GLUON_TARGET)_SUBTARGET)
  37. LEDE_TARGET := $(BOARD)$(if $(SUBTARGET),-$(SUBTARGET))
  38. export LEDE_TARGET
  39. CheckTarget := [ '$(LEDE_TARGET)' ] \
  40. || (echo 'Please set GLUON_TARGET to a valid target. Gluon supports the following targets:'; $(foreach target,$(GLUON_TARGETS),echo ' * $(target)';) false)
  41. CheckExternal := test -d lede || (echo 'You don'"'"'t seem to have obtained the external repositories needed by Gluon; please call `make update` first!'; false)
  42. list-targets: FORCE
  43. @$(foreach target,$(GLUON_TARGETS),echo '$(target)';)
  44. GLUON_DEFAULT_PACKAGES := -odhcpd -ppp -ppp-mod-pppoe -wpad-mini gluon-core ip6tables hostapd-mini
  45. GLUON_PACKAGES :=
  46. define merge_packages
  47. $(foreach pkg,$(1),
  48. GLUON_PACKAGES := $$(strip $$(filter-out -$$(patsubst -%,%,$(pkg)) $$(patsubst -%,%,$(pkg)),$$(GLUON_PACKAGES)) $(pkg))
  49. )
  50. endef
  51. $(eval $(call merge_packages,$(GLUON_DEFAULT_PACKAGES) $(GLUON_SITE_PACKAGES)))
  52. GLUON_PACKAGES_YES := $(filter-out -%,$(GLUON_PACKAGES))
  53. GLUON_PACKAGES_NO := $(patsubst -%,%,$(filter -%,$(GLUON_PACKAGES)))
  54. config: FORCE
  55. @$(CheckExternal)
  56. @$(CheckTarget)
  57. @( \
  58. echo 'CONFIG_TARGET_$(BOARD)=y' \
  59. $(if $(SUBTARGET),&& echo 'CONFIG_TARGET_$(BOARD)_$(SUBTARGET)=y') \
  60. $(foreach pkg,$(GLUON_PACKAGES_NO),&& echo '# CONFIG_PACKAGE_$(pkg) is not set') \
  61. && scripts/target_config.sh generic \
  62. && GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/target_config.sh '$(GLUON_TARGET)' \
  63. $(foreach pkg,$(GLUON_PACKAGES_YES),&& echo 'CONFIG_PACKAGE_$(pkg)=y') \
  64. $(foreach lang,$(GLUON_LANGS),&& echo 'CONFIG_GLUON_WEB_LANG_$(lang)=y') \
  65. && echo 'CONFIG_GLUON_RELEASE="$(GLUON_RELEASE)"' \
  66. && echo 'CONFIG_GLUON_SITEDIR="$(GLUON_SITEDIR)"' \
  67. && echo 'CONFIG_GLUON_BRANCH="$(GLUON_BRANCH)"' \
  68. ) > lede/.config
  69. +@$(LEDEMAKE) defconfig
  70. @GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/target_config_check.sh '$(GLUON_TARGET)' '$(GLUON_PACKAGES_YES)'
  71. LUA := lede/staging_dir/hostpkg/bin/lua
  72. $(LUA):
  73. @$(CheckExternal)
  74. +@[ -e lede/.config ] || $(LEDEMAKE) defconfig
  75. +@$(LEDEMAKE) tools/install
  76. +@$(LEDEMAKE) package/lua/host/install
  77. prepare-target: config $(LUA) ;
  78. all: prepare-target
  79. @GLUON_SITEDIR='$(GLUON_SITEDIR)' $(LUA) scripts/site_config.lua \
  80. || (echo 'Your site configuration did not pass validation.'; false)
  81. @scripts/clean_output.sh
  82. +@$(LEDEMAKE)
  83. @GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/copy_output.sh '$(GLUON_TARGET)'
  84. clean download: config
  85. +@$(LEDEMAKE) $@
  86. dirclean: FORCE
  87. +@[ -e lede/.config ] || $(LEDEMAKE) defconfig
  88. +@$(LEDEMAKE) dirclean
  89. @rm -rf $(GLUON_TMPDIR) $(GLUON_OUTPUTDIR)
  90. manifest: $(LUA) FORCE
  91. @[ '$(GLUON_BRANCH)' ] || (echo 'Please set GLUON_BRANCH to create a manifest.'; false)
  92. @echo '$(GLUON_PRIORITY)' | grep -qE '^([0-9]*\.)?[0-9]+$$' || (echo 'Please specify a numeric value for GLUON_PRIORITY to create a manifest.'; false)
  93. @$(CheckExternal)
  94. @( \
  95. echo 'BRANCH=$(GLUON_BRANCH)' && \
  96. echo "DATE=$$($(LUA) scripts/rfc3339date.lua)" && \
  97. echo 'PRIORITY=$(GLUON_PRIORITY)' && \
  98. echo && \
  99. $(foreach GLUON_TARGET,$(GLUON_TARGETS), \
  100. GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/generate_manifest.sh '$(GLUON_TARGET)' && \
  101. ) : \
  102. ) > 'tmp/$(GLUON_BRANCH).manifest.tmp'
  103. @mkdir -p '$(GLUON_IMAGEDIR)/sysupgrade'
  104. @mv 'tmp/$(GLUON_BRANCH).manifest.tmp' '$(GLUON_IMAGEDIR)/sysupgrade/$(GLUON_BRANCH).manifest'
  105. FORCE: ;
  106. .PHONY: FORCE
  107. .NOTPARALLEL: