Makefile 4.7 KB

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