-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
179 lines (124 loc) · 5.1 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
all:
LC_ALL:=C
LANG:=C
export LC_ALL LANG
# initialize (possibly already user set) folder vars
GLUON_SITEDIR ?= $(CURDIR)/site
GLUON_TMPDIR ?= $(CURDIR)/tmp
GLUON_OUTPUTDIR ?= $(CURDIR)/output
GLUON_IMAGEDIR ?= $(GLUON_OUTPUTDIR)/images
GLUON_PACKAGEDIR ?= $(GLUON_OUTPUTDIR)/packages
# resolve possibly relative paths or symlinks to make vars reusable in subfolder packages
makeAbsolute = $(shell realpath -m "$(1)")
override GLUON_SITEDIR := $(call makeAbsolute,$(GLUON_SITEDIR))
override GLUON_TMPDIR := $(call makeAbsolute,$(GLUON_TMPDIR))
override GLUON_OUTPUTDIR := $(call makeAbsolute,$(GLUON_OUTPUTDIR))
override GLUON_IMAGEDIR := $(call makeAbsolute,$(GLUON_IMAGEDIR))
override GLUON_PACKAGEDIR := $(call makeAbsolute,$(GLUON_PACKAGEDIR))
ifeq ($(V),s)
$(info GLUON_SITEDIR="$(GLUON_SITEDIR)")
$(info GLUON_TMPDIR="$(GLUON_TMPDIR)")
$(info GLUON_OUTPUTDIR="$(GLUON_OUTPUTDIR)")
$(info GLUON_IMAGEDIR="$(GLUON_IMAGEDIR)")
$(info GLUON_PACKAGEDIR="$(GLUON_PACKAGEDIR)")
endif
export GLUON_TMPDIR GLUON_IMAGEDIR GLUON_PACKAGEDIR DEVICES
$(GLUON_SITEDIR)/site.mk:
$(error No site configuration was found. Please check out a site configuration to $(GLUON_SITEDIR))
include $(GLUON_SITEDIR)/site.mk
GLUON_RELEASE ?= $(error GLUON_RELEASE not set. GLUON_RELEASE can be set in site.mk or on the command line)
export GLUON_RELEASE GLUON_ATH10K_MESH GLUON_REGION GLUON_DEBUG
show-release:
@echo '$(GLUON_RELEASE)'
update: FORCE
@GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/update.sh
@GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/patch.sh
@GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/feeds.sh
update-patches: FORCE
@GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/update.sh
@GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/update-patches.sh
@GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/patch.sh
update-feeds: FORCE
@GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/feeds.sh
GLUON_TARGETS :=
define GluonTarget
gluon_target := $(1)$$(if $(2),-$(2))
GLUON_TARGETS += $$(gluon_target)
GLUON_TARGET_$$(gluon_target)_BOARD := $(1)
GLUON_TARGET_$$(gluon_target)_SUBTARGET := $(if $(3),$(3),$(2))
endef
include targets/targets.mk
LEDEMAKE = $(MAKE) -C lede
BOARD := $(GLUON_TARGET_$(GLUON_TARGET)_BOARD)
SUBTARGET := $(GLUON_TARGET_$(GLUON_TARGET)_SUBTARGET)
GLUON_CONFIG_VARS := \
GLUON_SITEDIR='$(GLUON_SITEDIR)' \
GLUON_RELEASE='$(GLUON_RELEASE)' \
GLUON_BRANCH='$(GLUON_BRANCH)' \
GLUON_LANGS='$(GLUON_LANGS)' \
BOARD='$(BOARD)' \
SUBTARGET='$(SUBTARGET)'
LEDE_TARGET := $(BOARD)$(if $(SUBTARGET),-$(SUBTARGET))
export LEDE_TARGET
CheckTarget := [ '$(LEDE_TARGET)' ] \
|| (echo 'Please set GLUON_TARGET to a valid target. Gluon supports the following targets:'; $(foreach target,$(GLUON_TARGETS),echo ' * $(target)';) false)
CheckExternal := test -d lede || (echo 'You don'"'"'t seem to have obtained the external repositories needed by Gluon; please call `make update` first!'; false)
list-targets: FORCE
@$(foreach target,$(GLUON_TARGETS),echo '$(target)';)
GLUON_FEATURE_PACKAGES := $(shell scripts/features.sh '$(GLUON_FEATURES)' || echo '__ERROR__')
ifneq ($(filter __ERROR__,$(GLUON_FEATURE_PACKAGES)),)
$(error Error while evaluating GLUON_FEATURES)
endif
GLUON_PACKAGES :=
define merge_packages
$(foreach pkg,$(1),
GLUON_PACKAGES := $$(strip $$(filter-out -$$(patsubst -%,%,$(pkg)) $$(patsubst -%,%,$(pkg)),$$(GLUON_PACKAGES)) $(pkg))
)
endef
$(eval $(call merge_packages,$(GLUON_FEATURE_PACKAGES) $(GLUON_SITE_PACKAGES)))
config: FORCE
@$(CheckExternal)
@$(CheckTarget)
@$(GLUON_CONFIG_VARS) \
scripts/target_config.sh '$(GLUON_TARGET)' '$(GLUON_PACKAGES)' \
> lede/.config
+@$(LEDEMAKE) defconfig
@$(GLUON_CONFIG_VARS) \
scripts/target_config_check.sh '$(GLUON_TARGET)' '$(GLUON_PACKAGES)'
LUA := lede/staging_dir/hostpkg/bin/lua
$(LUA):
@$(CheckExternal)
+@[ -e lede/.config ] || $(LEDEMAKE) defconfig
+@$(LEDEMAKE) tools/install
+@$(LEDEMAKE) package/lua/host/install
prepare-target: config $(LUA) ;
all: prepare-target
@GLUON_SITEDIR='$(GLUON_SITEDIR)' $(LUA) scripts/site_config.lua \
|| (echo 'Your site configuration did not pass validation.'; false)
@scripts/clean_output.sh
+@$(LEDEMAKE)
@GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/copy_output.sh '$(GLUON_TARGET)'
clean download: config
+@$(LEDEMAKE) $@
dirclean: FORCE
+@[ -e lede/.config ] || $(LEDEMAKE) defconfig
+@$(LEDEMAKE) dirclean
@rm -rf $(GLUON_TMPDIR) $(GLUON_OUTPUTDIR)
manifest: $(LUA) FORCE
@[ '$(GLUON_BRANCH)' ] || (echo 'Please set GLUON_BRANCH to create a manifest.'; false)
@echo '$(GLUON_PRIORITY)' | grep -qE '^([0-9]*\.)?[0-9]+$$' || (echo 'Please specify a numeric value for GLUON_PRIORITY to create a manifest.'; false)
@$(CheckExternal)
@( \
echo 'BRANCH=$(GLUON_BRANCH)' && \
echo "DATE=$$($(LUA) scripts/rfc3339date.lua)" && \
echo 'PRIORITY=$(GLUON_PRIORITY)' && \
echo && \
$(foreach GLUON_TARGET,$(GLUON_TARGETS), \
GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/generate_manifest.sh '$(GLUON_TARGET)' && \
) : \
) > 'tmp/$(GLUON_BRANCH).manifest.tmp'
@mkdir -p '$(GLUON_IMAGEDIR)/sysupgrade'
@mv 'tmp/$(GLUON_BRANCH).manifest.tmp' '$(GLUON_IMAGEDIR)/sysupgrade/$(GLUON_BRANCH).manifest'
FORCE: ;
.PHONY: FORCE
.NOTPARALLEL: