Makefile 4.6 KB

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