Commit 001f3142c30c35493c57268bd49a4f87f8da9f0d
Committed by
Tom Rini
1 parent
1fbf97dc45
Exists in
smarc_8mq_lf_v2020.04
and in
17 other branches
Makefile: Provide an option to select SPL or TPL
At present we have SPL_ which can be used in Makefiles to select between normal and SPL CONFIGs like this: obj-$(CONFIG_$(SPL_)DM) += core/ When TPL is being built, SPL_ has the value 'SPL' which is generally a good idea since they tend to follow each other. But in extreme situations we may want to distinugish between SPL and TPL. For example we may not want to enable CONFIG_DM with TPL. Add a new SPL_TPL_ variable which is set to either empty (for U-Boot proper), 'SPL' or 'TPL'. This may prove useful with TPL-specific options. Signed-off-by: Simon Glass <sjg@chromium.org>
Showing 2 changed files with 12 additions and 0 deletions Inline Diff
scripts/Kbuild.include
1 | #### | 1 | #### |
2 | # kbuild: Generic definitions | 2 | # kbuild: Generic definitions |
3 | 3 | ||
4 | # Convenient variables | 4 | # Convenient variables |
5 | comma := , | 5 | comma := , |
6 | quote := " | 6 | quote := " |
7 | squote := ' | 7 | squote := ' |
8 | empty := | 8 | empty := |
9 | space := $(empty) $(empty) | 9 | space := $(empty) $(empty) |
10 | 10 | ||
11 | ### | 11 | ### |
12 | # Name of target with a '.' as filename prefix. foo/bar.o => foo/.bar.o | 12 | # Name of target with a '.' as filename prefix. foo/bar.o => foo/.bar.o |
13 | dot-target = $(dir $@).$(notdir $@) | 13 | dot-target = $(dir $@).$(notdir $@) |
14 | 14 | ||
15 | ### | 15 | ### |
16 | # The temporary file to save gcc -MD generated dependencies must not | 16 | # The temporary file to save gcc -MD generated dependencies must not |
17 | # contain a comma | 17 | # contain a comma |
18 | depfile = $(subst $(comma),_,$(dot-target).d) | 18 | depfile = $(subst $(comma),_,$(dot-target).d) |
19 | 19 | ||
20 | ### | 20 | ### |
21 | # filename of target with directory and extension stripped | 21 | # filename of target with directory and extension stripped |
22 | basetarget = $(basename $(notdir $@)) | 22 | basetarget = $(basename $(notdir $@)) |
23 | 23 | ||
24 | ### | 24 | ### |
25 | # filename of first prerequisite with directory and extension stripped | 25 | # filename of first prerequisite with directory and extension stripped |
26 | baseprereq = $(basename $(notdir $<)) | 26 | baseprereq = $(basename $(notdir $<)) |
27 | 27 | ||
28 | ### | 28 | ### |
29 | # Escape single quote for use in echo statements | 29 | # Escape single quote for use in echo statements |
30 | escsq = $(subst $(squote),'\$(squote)',$1) | 30 | escsq = $(subst $(squote),'\$(squote)',$1) |
31 | 31 | ||
32 | ### | 32 | ### |
33 | # Easy method for doing a status message | 33 | # Easy method for doing a status message |
34 | kecho := : | 34 | kecho := : |
35 | quiet_kecho := echo | 35 | quiet_kecho := echo |
36 | silent_kecho := : | 36 | silent_kecho := : |
37 | kecho := $($(quiet)kecho) | 37 | kecho := $($(quiet)kecho) |
38 | 38 | ||
39 | ### | 39 | ### |
40 | # filechk is used to check if the content of a generated file is updated. | 40 | # filechk is used to check if the content of a generated file is updated. |
41 | # Sample usage: | 41 | # Sample usage: |
42 | # define filechk_sample | 42 | # define filechk_sample |
43 | # echo $KERNELRELEASE | 43 | # echo $KERNELRELEASE |
44 | # endef | 44 | # endef |
45 | # version.h : Makefile | 45 | # version.h : Makefile |
46 | # $(call filechk,sample) | 46 | # $(call filechk,sample) |
47 | # The rule defined shall write to stdout the content of the new file. | 47 | # The rule defined shall write to stdout the content of the new file. |
48 | # The existing file will be compared with the new one. | 48 | # The existing file will be compared with the new one. |
49 | # - If no file exist it is created | 49 | # - If no file exist it is created |
50 | # - If the content differ the new file is used | 50 | # - If the content differ the new file is used |
51 | # - If they are equal no change, and no timestamp update | 51 | # - If they are equal no change, and no timestamp update |
52 | # - stdin is piped in from the first prerequisite ($<) so one has | 52 | # - stdin is piped in from the first prerequisite ($<) so one has |
53 | # to specify a valid file as first prerequisite (often the kbuild file) | 53 | # to specify a valid file as first prerequisite (often the kbuild file) |
54 | define filechk | 54 | define filechk |
55 | $(Q)set -e; \ | 55 | $(Q)set -e; \ |
56 | $(kecho) ' CHK $@'; \ | 56 | $(kecho) ' CHK $@'; \ |
57 | mkdir -p $(dir $@); \ | 57 | mkdir -p $(dir $@); \ |
58 | $(filechk_$(1)) < $< > $@.tmp; \ | 58 | $(filechk_$(1)) < $< > $@.tmp; \ |
59 | if [ -r $@ ] && cmp -s $@ $@.tmp; then \ | 59 | if [ -r $@ ] && cmp -s $@ $@.tmp; then \ |
60 | rm -f $@.tmp; \ | 60 | rm -f $@.tmp; \ |
61 | else \ | 61 | else \ |
62 | $(kecho) ' UPD $@'; \ | 62 | $(kecho) ' UPD $@'; \ |
63 | mv -f $@.tmp $@; \ | 63 | mv -f $@.tmp $@; \ |
64 | fi | 64 | fi |
65 | endef | 65 | endef |
66 | 66 | ||
67 | ###### | 67 | ###### |
68 | # gcc support functions | 68 | # gcc support functions |
69 | # See documentation in Documentation/kbuild/makefiles.txt | 69 | # See documentation in Documentation/kbuild/makefiles.txt |
70 | 70 | ||
71 | # cc-cross-prefix | 71 | # cc-cross-prefix |
72 | # Usage: CROSS_COMPILE := $(call cc-cross-prefix, m68k-linux-gnu- m68k-linux-) | 72 | # Usage: CROSS_COMPILE := $(call cc-cross-prefix, m68k-linux-gnu- m68k-linux-) |
73 | # Return first prefix where a prefix$(CC) is found in PATH. | 73 | # Return first prefix where a prefix$(CC) is found in PATH. |
74 | # If no $(CC) found in PATH with listed prefixes return nothing | 74 | # If no $(CC) found in PATH with listed prefixes return nothing |
75 | cc-cross-prefix = \ | 75 | cc-cross-prefix = \ |
76 | $(word 1, $(foreach c,$(1), \ | 76 | $(word 1, $(foreach c,$(1), \ |
77 | $(shell set -e; \ | 77 | $(shell set -e; \ |
78 | if (which $(strip $(c))$(CC)) > /dev/null 2>&1 ; then \ | 78 | if (which $(strip $(c))$(CC)) > /dev/null 2>&1 ; then \ |
79 | echo $(c); \ | 79 | echo $(c); \ |
80 | fi))) | 80 | fi))) |
81 | 81 | ||
82 | # output directory for tests below | 82 | # output directory for tests below |
83 | TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/) | 83 | TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/) |
84 | 84 | ||
85 | # try-run | 85 | # try-run |
86 | # Usage: option = $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise) | 86 | # Usage: option = $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise) |
87 | # Exit code chooses option. "$$TMP" is can be used as temporary file and | 87 | # Exit code chooses option. "$$TMP" is can be used as temporary file and |
88 | # is automatically cleaned up. | 88 | # is automatically cleaned up. |
89 | # modifed for U-Boot: prevent cc-option from leaving .*.su files | 89 | # modifed for U-Boot: prevent cc-option from leaving .*.su files |
90 | try-run = $(shell set -e; \ | 90 | try-run = $(shell set -e; \ |
91 | TMP="$(TMPOUT).$$$$.tmp"; \ | 91 | TMP="$(TMPOUT).$$$$.tmp"; \ |
92 | TMPO="$(TMPOUT).$$$$.o"; \ | 92 | TMPO="$(TMPOUT).$$$$.o"; \ |
93 | TMPSU="$(TMPOUT).$$$$.su"; \ | 93 | TMPSU="$(TMPOUT).$$$$.su"; \ |
94 | if ($(1)) >/dev/null 2>&1; \ | 94 | if ($(1)) >/dev/null 2>&1; \ |
95 | then echo "$(2)"; \ | 95 | then echo "$(2)"; \ |
96 | else echo "$(3)"; \ | 96 | else echo "$(3)"; \ |
97 | fi; \ | 97 | fi; \ |
98 | rm -f "$$TMP" "$$TMPO" "$$TMPSU") | 98 | rm -f "$$TMP" "$$TMPO" "$$TMPSU") |
99 | 99 | ||
100 | # as-option | 100 | # as-option |
101 | # Usage: cflags-y += $(call as-option,-Wa$(comma)-isa=foo,) | 101 | # Usage: cflags-y += $(call as-option,-Wa$(comma)-isa=foo,) |
102 | 102 | ||
103 | as-option = $(call try-run,\ | 103 | as-option = $(call try-run,\ |
104 | $(CC) $(KBUILD_CFLAGS) $(1) -c -x assembler /dev/null -o "$$TMP",$(1),$(2)) | 104 | $(CC) $(KBUILD_CFLAGS) $(1) -c -x assembler /dev/null -o "$$TMP",$(1),$(2)) |
105 | 105 | ||
106 | # as-instr | 106 | # as-instr |
107 | # Usage: cflags-y += $(call as-instr,instr,option1,option2) | 107 | # Usage: cflags-y += $(call as-instr,instr,option1,option2) |
108 | 108 | ||
109 | as-instr = $(call try-run,\ | 109 | as-instr = $(call try-run,\ |
110 | printf "%b\n" "$(1)" | $(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3)) | 110 | printf "%b\n" "$(1)" | $(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3)) |
111 | 111 | ||
112 | # cc-option | 112 | # cc-option |
113 | # Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586) | 113 | # Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586) |
114 | 114 | ||
115 | cc-option = $(call try-run,\ | 115 | cc-option = $(call try-run,\ |
116 | $(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2)) | 116 | $(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2)) |
117 | 117 | ||
118 | # cc-option-yn | 118 | # cc-option-yn |
119 | # Usage: flag := $(call cc-option-yn,-march=winchip-c6) | 119 | # Usage: flag := $(call cc-option-yn,-march=winchip-c6) |
120 | cc-option-yn = $(call try-run,\ | 120 | cc-option-yn = $(call try-run,\ |
121 | $(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n) | 121 | $(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n) |
122 | 122 | ||
123 | # cc-option-align | 123 | # cc-option-align |
124 | # Prefix align with either -falign or -malign | 124 | # Prefix align with either -falign or -malign |
125 | cc-option-align = $(subst -functions=0,,\ | 125 | cc-option-align = $(subst -functions=0,,\ |
126 | $(call cc-option,-falign-functions=0,-malign-functions=0)) | 126 | $(call cc-option,-falign-functions=0,-malign-functions=0)) |
127 | 127 | ||
128 | # cc-disable-warning | 128 | # cc-disable-warning |
129 | # Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable) | 129 | # Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable) |
130 | cc-disable-warning = $(call try-run,\ | 130 | cc-disable-warning = $(call try-run,\ |
131 | $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1))) | 131 | $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1))) |
132 | 132 | ||
133 | # cc-name | 133 | # cc-name |
134 | # Expands to either gcc or clang | 134 | # Expands to either gcc or clang |
135 | cc-name = $(shell $(CC) -v 2>&1 | grep -q "clang version" && echo clang || echo gcc) | 135 | cc-name = $(shell $(CC) -v 2>&1 | grep -q "clang version" && echo clang || echo gcc) |
136 | 136 | ||
137 | # cc-version | 137 | # cc-version |
138 | cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC)) | 138 | cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC)) |
139 | 139 | ||
140 | # cc-fullversion | 140 | # cc-fullversion |
141 | cc-fullversion = $(shell $(CONFIG_SHELL) \ | 141 | cc-fullversion = $(shell $(CONFIG_SHELL) \ |
142 | $(srctree)/scripts/gcc-version.sh -p $(CC)) | 142 | $(srctree)/scripts/gcc-version.sh -p $(CC)) |
143 | 143 | ||
144 | # cc-ifversion | 144 | # cc-ifversion |
145 | # Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1) | 145 | # Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1) |
146 | cc-ifversion = $(shell [ $(cc-version) $(1) $(2) ] && echo $(3) || echo $(4)) | 146 | cc-ifversion = $(shell [ $(cc-version) $(1) $(2) ] && echo $(3) || echo $(4)) |
147 | 147 | ||
148 | # added for U-Boot | 148 | # added for U-Boot |
149 | binutils-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/binutils-version.sh $(AS)) | 149 | binutils-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/binutils-version.sh $(AS)) |
150 | dtc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/dtc-version.sh $(DTC)) | 150 | dtc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/dtc-version.sh $(DTC)) |
151 | 151 | ||
152 | # cc-ldoption | 152 | # cc-ldoption |
153 | # Usage: ldflags += $(call cc-ldoption, -Wl$(comma)--hash-style=both) | 153 | # Usage: ldflags += $(call cc-ldoption, -Wl$(comma)--hash-style=both) |
154 | cc-ldoption = $(call try-run,\ | 154 | cc-ldoption = $(call try-run,\ |
155 | $(CC) $(1) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2)) | 155 | $(CC) $(1) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2)) |
156 | 156 | ||
157 | # ld-option | 157 | # ld-option |
158 | # Usage: LDFLAGS += $(call ld-option, -X) | 158 | # Usage: LDFLAGS += $(call ld-option, -X) |
159 | ld-option = $(call try-run,\ | 159 | ld-option = $(call try-run,\ |
160 | $(CC) -x c /dev/null -c -o "$$TMPO" ; $(LD) $(1) "$$TMPO" -o "$$TMP",$(1),$(2)) | 160 | $(CC) -x c /dev/null -c -o "$$TMPO" ; $(LD) $(1) "$$TMPO" -o "$$TMP",$(1),$(2)) |
161 | 161 | ||
162 | # ar-option | 162 | # ar-option |
163 | # Usage: KBUILD_ARFLAGS := $(call ar-option,D) | 163 | # Usage: KBUILD_ARFLAGS := $(call ar-option,D) |
164 | # Important: no spaces around options | 164 | # Important: no spaces around options |
165 | ar-option = $(call try-run, $(AR) rc$(1) "$$TMP",$(1),$(2)) | 165 | ar-option = $(call try-run, $(AR) rc$(1) "$$TMP",$(1),$(2)) |
166 | 166 | ||
167 | # ld-version | 167 | # ld-version |
168 | # Note this is mainly for HJ Lu's 3 number binutil versions | 168 | # Note this is mainly for HJ Lu's 3 number binutil versions |
169 | ld-version = $(shell $(LD) --version | $(srctree)/scripts/ld-version.sh) | 169 | ld-version = $(shell $(LD) --version | $(srctree)/scripts/ld-version.sh) |
170 | 170 | ||
171 | # ld-ifversion | 171 | # ld-ifversion |
172 | # Usage: $(call ld-ifversion, -ge, 22252, y) | 172 | # Usage: $(call ld-ifversion, -ge, 22252, y) |
173 | ld-ifversion = $(shell [ $(ld-version) $(1) $(2) ] && echo $(3) || echo $(4)) | 173 | ld-ifversion = $(shell [ $(ld-version) $(1) $(2) ] && echo $(3) || echo $(4)) |
174 | 174 | ||
175 | # dtc-option | 175 | # dtc-option |
176 | # Usage: DTC_FLAGS += $(call dtc-option,-Wno-unit_address_vs_reg) | 176 | # Usage: DTC_FLAGS += $(call dtc-option,-Wno-unit_address_vs_reg) |
177 | dtc-option = $(call try-run,\ | 177 | dtc-option = $(call try-run,\ |
178 | echo '/dts-v1/; / {};' | $(DTC) $(1),$(1),$(2)) | 178 | echo '/dts-v1/; / {};' | $(DTC) $(1),$(1),$(2)) |
179 | 179 | ||
180 | ###### | 180 | ###### |
181 | 181 | ||
182 | ### | 182 | ### |
183 | # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj= | 183 | # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj= |
184 | # Usage: | 184 | # Usage: |
185 | # $(Q)$(MAKE) $(build)=dir | 185 | # $(Q)$(MAKE) $(build)=dir |
186 | build := -f $(srctree)/scripts/Makefile.build obj | 186 | build := -f $(srctree)/scripts/Makefile.build obj |
187 | 187 | ||
188 | ### | 188 | ### |
189 | # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.modbuiltin obj= | 189 | # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.modbuiltin obj= |
190 | # Usage: | 190 | # Usage: |
191 | # $(Q)$(MAKE) $(modbuiltin)=dir | 191 | # $(Q)$(MAKE) $(modbuiltin)=dir |
192 | modbuiltin := -f $(srctree)/scripts/Makefile.modbuiltin obj | 192 | modbuiltin := -f $(srctree)/scripts/Makefile.modbuiltin obj |
193 | 193 | ||
194 | ### | 194 | ### |
195 | # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.dtbinst obj= | 195 | # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.dtbinst obj= |
196 | # Usage: | 196 | # Usage: |
197 | # $(Q)$(MAKE) $(dtbinst)=dir | 197 | # $(Q)$(MAKE) $(dtbinst)=dir |
198 | dtbinst := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.dtbinst obj | 198 | dtbinst := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.dtbinst obj |
199 | 199 | ||
200 | ### | 200 | ### |
201 | # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj= | 201 | # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj= |
202 | # Usage: | 202 | # Usage: |
203 | # $(Q)$(MAKE) $(clean)=dir | 203 | # $(Q)$(MAKE) $(clean)=dir |
204 | clean := -f $(srctree)/scripts/Makefile.clean obj | 204 | clean := -f $(srctree)/scripts/Makefile.clean obj |
205 | 205 | ||
206 | ### | 206 | ### |
207 | # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.headersinst obj= | 207 | # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.headersinst obj= |
208 | # Usage: | 208 | # Usage: |
209 | # $(Q)$(MAKE) $(hdr-inst)=dir | 209 | # $(Q)$(MAKE) $(hdr-inst)=dir |
210 | hdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj | 210 | hdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj |
211 | 211 | ||
212 | # Prefix -I with $(srctree) if it is not an absolute path. | 212 | # Prefix -I with $(srctree) if it is not an absolute path. |
213 | # skip if -I has no parameter | 213 | # skip if -I has no parameter |
214 | addtree = $(if $(patsubst -I%,%,$(1)), \ | 214 | addtree = $(if $(patsubst -I%,%,$(1)), \ |
215 | $(if $(filter-out -I/%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1))) $(1)) | 215 | $(if $(filter-out -I/%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1))) $(1)) |
216 | 216 | ||
217 | # Find all -I options and call addtree | 217 | # Find all -I options and call addtree |
218 | flags = $(foreach o,$($(1)),$(if $(filter -I%,$(o)),$(call addtree,$(o)),$(o))) | 218 | flags = $(foreach o,$($(1)),$(if $(filter -I%,$(o)),$(call addtree,$(o)),$(o))) |
219 | 219 | ||
220 | # echo command. | 220 | # echo command. |
221 | # Short version is used, if $(quiet) equals `quiet_', otherwise full one. | 221 | # Short version is used, if $(quiet) equals `quiet_', otherwise full one. |
222 | echo-cmd = $(if $($(quiet)cmd_$(1)),\ | 222 | echo-cmd = $(if $($(quiet)cmd_$(1)),\ |
223 | echo ' $(call escsq,$($(quiet)cmd_$(1)))$(echo-why)';) | 223 | echo ' $(call escsq,$($(quiet)cmd_$(1)))$(echo-why)';) |
224 | 224 | ||
225 | # printing commands | 225 | # printing commands |
226 | cmd = @$(echo-cmd) $(cmd_$(1)) | 226 | cmd = @$(echo-cmd) $(cmd_$(1)) |
227 | 227 | ||
228 | # Add $(obj)/ for paths that are not absolute | 228 | # Add $(obj)/ for paths that are not absolute |
229 | objectify = $(foreach o,$(1),$(if $(filter /%,$(o)),$(o),$(obj)/$(o))) | 229 | objectify = $(foreach o,$(1),$(if $(filter /%,$(o)),$(o),$(obj)/$(o))) |
230 | 230 | ||
231 | ### | 231 | ### |
232 | # if_changed - execute command if any prerequisite is newer than | 232 | # if_changed - execute command if any prerequisite is newer than |
233 | # target, or command line has changed | 233 | # target, or command line has changed |
234 | # if_changed_dep - as if_changed, but uses fixdep to reveal dependencies | 234 | # if_changed_dep - as if_changed, but uses fixdep to reveal dependencies |
235 | # including used config symbols | 235 | # including used config symbols |
236 | # if_changed_rule - as if_changed but execute rule instead | 236 | # if_changed_rule - as if_changed but execute rule instead |
237 | # See Documentation/kbuild/makefiles.txt for more info | 237 | # See Documentation/kbuild/makefiles.txt for more info |
238 | 238 | ||
239 | ifneq ($(KBUILD_NOCMDDEP),1) | 239 | ifneq ($(KBUILD_NOCMDDEP),1) |
240 | # Check if both arguments has same arguments. Result is empty string if equal. | 240 | # Check if both arguments has same arguments. Result is empty string if equal. |
241 | # User may override this check using make KBUILD_NOCMDDEP=1 | 241 | # User may override this check using make KBUILD_NOCMDDEP=1 |
242 | arg-check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \ | 242 | arg-check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \ |
243 | $(filter-out $(cmd_$@), $(cmd_$(1))) ) | 243 | $(filter-out $(cmd_$@), $(cmd_$(1))) ) |
244 | else | 244 | else |
245 | arg-check = $(if $(strip $(cmd_$@)),,1) | 245 | arg-check = $(if $(strip $(cmd_$@)),,1) |
246 | endif | 246 | endif |
247 | 247 | ||
248 | # Replace >$< with >$$< to preserve $ when reloading the .cmd file | 248 | # Replace >$< with >$$< to preserve $ when reloading the .cmd file |
249 | # (needed for make) | 249 | # (needed for make) |
250 | # Replace >#< with >\#< to avoid starting a comment in the .cmd file | 250 | # Replace >#< with >\#< to avoid starting a comment in the .cmd file |
251 | # (needed for make) | 251 | # (needed for make) |
252 | # Replace >'< with >'\''< to be able to enclose the whole string in '...' | 252 | # Replace >'< with >'\''< to be able to enclose the whole string in '...' |
253 | # (needed for the shell) | 253 | # (needed for the shell) |
254 | make-cmd = $(call escsq,$(subst \#,\\\#,$(subst $$,$$$$,$(cmd_$(1))))) | 254 | make-cmd = $(call escsq,$(subst \#,\\\#,$(subst $$,$$$$,$(cmd_$(1))))) |
255 | 255 | ||
256 | # Find any prerequisites that is newer than target or that does not exist. | 256 | # Find any prerequisites that is newer than target or that does not exist. |
257 | # PHONY targets skipped in both cases. | 257 | # PHONY targets skipped in both cases. |
258 | any-prereq = $(filter-out $(PHONY),$?) $(filter-out $(PHONY) $(wildcard $^),$^) | 258 | any-prereq = $(filter-out $(PHONY),$?) $(filter-out $(PHONY) $(wildcard $^),$^) |
259 | 259 | ||
260 | # Execute command if command has changed or prerequisite(s) are updated. | 260 | # Execute command if command has changed or prerequisite(s) are updated. |
261 | # | 261 | # |
262 | if_changed = $(if $(strip $(any-prereq) $(arg-check)), \ | 262 | if_changed = $(if $(strip $(any-prereq) $(arg-check)), \ |
263 | @set -e; \ | 263 | @set -e; \ |
264 | $(echo-cmd) $(cmd_$(1)); \ | 264 | $(echo-cmd) $(cmd_$(1)); \ |
265 | printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd) | 265 | printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd) |
266 | 266 | ||
267 | # Execute the command and also postprocess generated .d dependencies file. | 267 | # Execute the command and also postprocess generated .d dependencies file. |
268 | if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ), \ | 268 | if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ), \ |
269 | @set -e; \ | 269 | @set -e; \ |
270 | $(echo-cmd) $(cmd_$(1)); \ | 270 | $(echo-cmd) $(cmd_$(1)); \ |
271 | scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).tmp;\ | 271 | scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).tmp;\ |
272 | rm -f $(depfile); \ | 272 | rm -f $(depfile); \ |
273 | mv -f $(dot-target).tmp $(dot-target).cmd) | 273 | mv -f $(dot-target).tmp $(dot-target).cmd) |
274 | 274 | ||
275 | # Usage: $(call if_changed_rule,foo) | 275 | # Usage: $(call if_changed_rule,foo) |
276 | # Will check if $(cmd_foo) or any of the prerequisites changed, | 276 | # Will check if $(cmd_foo) or any of the prerequisites changed, |
277 | # and if so will execute $(rule_foo). | 277 | # and if so will execute $(rule_foo). |
278 | if_changed_rule = $(if $(strip $(any-prereq) $(arg-check) ), \ | 278 | if_changed_rule = $(if $(strip $(any-prereq) $(arg-check) ), \ |
279 | @set -e; \ | 279 | @set -e; \ |
280 | $(rule_$(1))) | 280 | $(rule_$(1))) |
281 | 281 | ||
282 | ### | 282 | ### |
283 | # why - tell why a a target got build | 283 | # why - tell why a a target got build |
284 | # enabled by make V=2 | 284 | # enabled by make V=2 |
285 | # Output (listed in the order they are checked): | 285 | # Output (listed in the order they are checked): |
286 | # (1) - due to target is PHONY | 286 | # (1) - due to target is PHONY |
287 | # (2) - due to target missing | 287 | # (2) - due to target missing |
288 | # (3) - due to: file1.h file2.h | 288 | # (3) - due to: file1.h file2.h |
289 | # (4) - due to command line change | 289 | # (4) - due to command line change |
290 | # (5) - due to missing .cmd file | 290 | # (5) - due to missing .cmd file |
291 | # (6) - due to target not in $(targets) | 291 | # (6) - due to target not in $(targets) |
292 | # (1) PHONY targets are always build | 292 | # (1) PHONY targets are always build |
293 | # (2) No target, so we better build it | 293 | # (2) No target, so we better build it |
294 | # (3) Prerequisite is newer than target | 294 | # (3) Prerequisite is newer than target |
295 | # (4) The command line stored in the file named dir/.target.cmd | 295 | # (4) The command line stored in the file named dir/.target.cmd |
296 | # differed from actual command line. This happens when compiler | 296 | # differed from actual command line. This happens when compiler |
297 | # options changes | 297 | # options changes |
298 | # (5) No dir/.target.cmd file (used to store command line) | 298 | # (5) No dir/.target.cmd file (used to store command line) |
299 | # (6) No dir/.target.cmd file and target not listed in $(targets) | 299 | # (6) No dir/.target.cmd file and target not listed in $(targets) |
300 | # This is a good hint that there is a bug in the kbuild file | 300 | # This is a good hint that there is a bug in the kbuild file |
301 | ifeq ($(KBUILD_VERBOSE),2) | 301 | ifeq ($(KBUILD_VERBOSE),2) |
302 | why = \ | 302 | why = \ |
303 | $(if $(filter $@, $(PHONY)),- due to target is PHONY, \ | 303 | $(if $(filter $@, $(PHONY)),- due to target is PHONY, \ |
304 | $(if $(wildcard $@), \ | 304 | $(if $(wildcard $@), \ |
305 | $(if $(strip $(any-prereq)),- due to: $(any-prereq), \ | 305 | $(if $(strip $(any-prereq)),- due to: $(any-prereq), \ |
306 | $(if $(arg-check), \ | 306 | $(if $(arg-check), \ |
307 | $(if $(cmd_$@),- due to command line change, \ | 307 | $(if $(cmd_$@),- due to command line change, \ |
308 | $(if $(filter $@, $(targets)), \ | 308 | $(if $(filter $@, $(targets)), \ |
309 | - due to missing .cmd file, \ | 309 | - due to missing .cmd file, \ |
310 | - due to $(notdir $@) not in $$(targets) \ | 310 | - due to $(notdir $@) not in $$(targets) \ |
311 | ) \ | 311 | ) \ |
312 | ) \ | 312 | ) \ |
313 | ) \ | 313 | ) \ |
314 | ), \ | 314 | ), \ |
315 | - due to target missing \ | 315 | - due to target missing \ |
316 | ) \ | 316 | ) \ |
317 | ) | 317 | ) |
318 | 318 | ||
319 | echo-why = $(call escsq, $(strip $(why))) | 319 | echo-why = $(call escsq, $(strip $(why))) |
320 | endif | 320 | endif |
321 | 321 | ||
322 | ifdef CONFIG_SPL_BUILD | 322 | ifdef CONFIG_SPL_BUILD |
323 | SPL_ := SPL_ | 323 | SPL_ := SPL_ |
324 | ifeq ($(CONFIG_TPL_BUILD),y) | ||
325 | SPL_TPL_ := TPL_ | ||
324 | else | 326 | else |
327 | SPL_TPL_ := SPL_ | ||
328 | endif | ||
329 | else | ||
325 | SPL_ := | 330 | SPL_ := |
331 | SPL_TPL_ := | ||
326 | endif | 332 | endif |
327 | 333 |
scripts/Makefile.spl
1 | # | 1 | # |
2 | # (C) Copyright 2000-2011 | 2 | # (C) Copyright 2000-2011 |
3 | # Wolfgang Denk, DENX Software Engineering, wd@denx.de. | 3 | # Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
4 | # | 4 | # |
5 | # (C) Copyright 2011 | 5 | # (C) Copyright 2011 |
6 | # Daniel Schwierzeck, daniel.schwierzeck@googlemail.com. | 6 | # Daniel Schwierzeck, daniel.schwierzeck@googlemail.com. |
7 | # | 7 | # |
8 | # (C) Copyright 2011 | 8 | # (C) Copyright 2011 |
9 | # Texas Instruments Incorporated - http://www.ti.com/ | 9 | # Texas Instruments Incorporated - http://www.ti.com/ |
10 | # Aneesh V <aneesh@ti.com> | 10 | # Aneesh V <aneesh@ti.com> |
11 | # | 11 | # |
12 | # SPDX-License-Identifier: GPL-2.0+ | 12 | # SPDX-License-Identifier: GPL-2.0+ |
13 | # | 13 | # |
14 | # Based on top-level Makefile. | 14 | # Based on top-level Makefile. |
15 | # | 15 | # |
16 | 16 | ||
17 | src := $(obj) | 17 | src := $(obj) |
18 | 18 | ||
19 | # Create output directory if not already present | 19 | # Create output directory if not already present |
20 | _dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj)) | 20 | _dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj)) |
21 | 21 | ||
22 | include $(srctree)/scripts/Kbuild.include | 22 | include $(srctree)/scripts/Kbuild.include |
23 | 23 | ||
24 | -include include/config/auto.conf | 24 | -include include/config/auto.conf |
25 | -include $(obj)/include/autoconf.mk | 25 | -include $(obj)/include/autoconf.mk |
26 | 26 | ||
27 | KBUILD_CPPFLAGS += -DCONFIG_SPL_BUILD | 27 | KBUILD_CPPFLAGS += -DCONFIG_SPL_BUILD |
28 | ifeq ($(CONFIG_TPL_BUILD),y) | 28 | ifeq ($(CONFIG_TPL_BUILD),y) |
29 | KBUILD_CPPFLAGS += -DCONFIG_TPL_BUILD | 29 | KBUILD_CPPFLAGS += -DCONFIG_TPL_BUILD |
30 | endif | 30 | endif |
31 | 31 | ||
32 | ifeq ($(CONFIG_TPL_BUILD),y) | 32 | ifeq ($(CONFIG_TPL_BUILD),y) |
33 | SPL_BIN := u-boot-tpl | 33 | SPL_BIN := u-boot-tpl |
34 | else | 34 | else |
35 | SPL_BIN := u-boot-spl | 35 | SPL_BIN := u-boot-spl |
36 | endif | 36 | endif |
37 | 37 | ||
38 | ifdef CONFIG_SPL_BUILD | 38 | ifdef CONFIG_SPL_BUILD |
39 | SPL_ := SPL_ | 39 | SPL_ := SPL_ |
40 | ifeq ($(CONFIG_TPL_BUILD),y) | ||
41 | SPL_TPL_ := TPL_ | ||
40 | else | 42 | else |
43 | SPL_TPL_ := SPL_ | ||
44 | endif | ||
45 | else | ||
41 | SPL_ := | 46 | SPL_ := |
47 | SPL_TPL_ := | ||
42 | endif | 48 | endif |
43 | 49 | ||
44 | include $(srctree)/config.mk | 50 | include $(srctree)/config.mk |
45 | include $(srctree)/arch/$(ARCH)/Makefile | 51 | include $(srctree)/arch/$(ARCH)/Makefile |
46 | 52 | ||
47 | # Enable garbage collection of un-used sections for SPL | 53 | # Enable garbage collection of un-used sections for SPL |
48 | KBUILD_CFLAGS += -ffunction-sections -fdata-sections | 54 | KBUILD_CFLAGS += -ffunction-sections -fdata-sections |
49 | LDFLAGS_FINAL += --gc-sections | 55 | LDFLAGS_FINAL += --gc-sections |
50 | 56 | ||
51 | # FIX ME | 57 | # FIX ME |
52 | cpp_flags := $(KBUILD_CPPFLAGS) $(PLATFORM_CPPFLAGS) $(UBOOTINCLUDE) \ | 58 | cpp_flags := $(KBUILD_CPPFLAGS) $(PLATFORM_CPPFLAGS) $(UBOOTINCLUDE) \ |
53 | $(NOSTDINC_FLAGS) | 59 | $(NOSTDINC_FLAGS) |
54 | c_flags := $(KBUILD_CFLAGS) $(cpp_flags) | 60 | c_flags := $(KBUILD_CFLAGS) $(cpp_flags) |
55 | 61 | ||
56 | HAVE_VENDOR_COMMON_LIB = $(if $(wildcard $(srctree)/board/$(VENDOR)/common/Makefile),y,n) | 62 | HAVE_VENDOR_COMMON_LIB = $(if $(wildcard $(srctree)/board/$(VENDOR)/common/Makefile),y,n) |
57 | 63 | ||
58 | libs-y += $(if $(BOARDDIR),board/$(BOARDDIR)/) | 64 | libs-y += $(if $(BOARDDIR),board/$(BOARDDIR)/) |
59 | libs-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/ | 65 | libs-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/ |
60 | 66 | ||
61 | libs-$(CONFIG_SPL_FRAMEWORK) += common/spl/ | 67 | libs-$(CONFIG_SPL_FRAMEWORK) += common/spl/ |
62 | libs-y += common/init/ | 68 | libs-y += common/init/ |
63 | 69 | ||
64 | # Special handling for a few options which support SPL/TPL | 70 | # Special handling for a few options which support SPL/TPL |
65 | ifeq ($(CONFIG_TPL_BUILD),y) | 71 | ifeq ($(CONFIG_TPL_BUILD),y) |
66 | libs-$(CONFIG_TPL_LIBCOMMON_SUPPORT) += common/ cmd/ | 72 | libs-$(CONFIG_TPL_LIBCOMMON_SUPPORT) += common/ cmd/ |
67 | libs-$(CONFIG_TPL_LIBGENERIC_SUPPORT) += lib/ | 73 | libs-$(CONFIG_TPL_LIBGENERIC_SUPPORT) += lib/ |
68 | else | 74 | else |
69 | libs-$(CONFIG_SPL_LIBCOMMON_SUPPORT) += common/ cmd/ | 75 | libs-$(CONFIG_SPL_LIBCOMMON_SUPPORT) += common/ cmd/ |
70 | libs-$(CONFIG_SPL_LIBGENERIC_SUPPORT) += lib/ | 76 | libs-$(CONFIG_SPL_LIBGENERIC_SUPPORT) += lib/ |
71 | endif | 77 | endif |
72 | 78 | ||
73 | libs-$(CONFIG_SPL_LIBDISK_SUPPORT) += disk/ | 79 | libs-$(CONFIG_SPL_LIBDISK_SUPPORT) += disk/ |
74 | libs-y += drivers/ | 80 | libs-y += drivers/ |
75 | libs-$(CONFIG_SPL_USB_GADGET_SUPPORT) += drivers/usb/dwc3/ | 81 | libs-$(CONFIG_SPL_USB_GADGET_SUPPORT) += drivers/usb/dwc3/ |
76 | libs-y += dts/ | 82 | libs-y += dts/ |
77 | libs-y += fs/ | 83 | libs-y += fs/ |
78 | libs-$(CONFIG_SPL_POST_MEM_SUPPORT) += post/drivers/ | 84 | libs-$(CONFIG_SPL_POST_MEM_SUPPORT) += post/drivers/ |
79 | libs-$(CONFIG_SPL_NET_SUPPORT) += net/ | 85 | libs-$(CONFIG_SPL_NET_SUPPORT) += net/ |
80 | 86 | ||
81 | head-y := $(addprefix $(obj)/,$(head-y)) | 87 | head-y := $(addprefix $(obj)/,$(head-y)) |
82 | libs-y := $(addprefix $(obj)/,$(libs-y)) | 88 | libs-y := $(addprefix $(obj)/,$(libs-y)) |
83 | u-boot-spl-dirs := $(patsubst %/,%,$(filter %/, $(libs-y))) | 89 | u-boot-spl-dirs := $(patsubst %/,%,$(filter %/, $(libs-y))) |
84 | 90 | ||
85 | libs-y := $(patsubst %/, %/built-in.o, $(libs-y)) | 91 | libs-y := $(patsubst %/, %/built-in.o, $(libs-y)) |
86 | 92 | ||
87 | # Add GCC lib | 93 | # Add GCC lib |
88 | ifeq ($(CONFIG_USE_PRIVATE_LIBGCC),y) | 94 | ifeq ($(CONFIG_USE_PRIVATE_LIBGCC),y) |
89 | PLATFORM_LIBGCC = arch/$(ARCH)/lib/lib.a | 95 | PLATFORM_LIBGCC = arch/$(ARCH)/lib/lib.a |
90 | PLATFORM_LIBS := $(filter-out %/lib.a, $(filter-out -lgcc, $(PLATFORM_LIBS))) $(PLATFORM_LIBGCC) | 96 | PLATFORM_LIBS := $(filter-out %/lib.a, $(filter-out -lgcc, $(PLATFORM_LIBS))) $(PLATFORM_LIBGCC) |
91 | endif | 97 | endif |
92 | 98 | ||
93 | u-boot-spl-init := $(head-y) | 99 | u-boot-spl-init := $(head-y) |
94 | u-boot-spl-main := $(libs-y) | 100 | u-boot-spl-main := $(libs-y) |
95 | ifdef CONFIG_SPL_OF_PLATDATA | 101 | ifdef CONFIG_SPL_OF_PLATDATA |
96 | u-boot-spl-platdata := $(obj)/dts/dt-platdata.o | 102 | u-boot-spl-platdata := $(obj)/dts/dt-platdata.o |
97 | endif | 103 | endif |
98 | 104 | ||
99 | # Linker Script | 105 | # Linker Script |
100 | ifdef CONFIG_SPL_LDSCRIPT | 106 | ifdef CONFIG_SPL_LDSCRIPT |
101 | # need to strip off double quotes | 107 | # need to strip off double quotes |
102 | LDSCRIPT := $(addprefix $(srctree)/,$(CONFIG_SPL_LDSCRIPT:"%"=%)) | 108 | LDSCRIPT := $(addprefix $(srctree)/,$(CONFIG_SPL_LDSCRIPT:"%"=%)) |
103 | endif | 109 | endif |
104 | 110 | ||
105 | ifeq ($(wildcard $(LDSCRIPT)),) | 111 | ifeq ($(wildcard $(LDSCRIPT)),) |
106 | LDSCRIPT := $(srctree)/board/$(BOARDDIR)/u-boot-spl.lds | 112 | LDSCRIPT := $(srctree)/board/$(BOARDDIR)/u-boot-spl.lds |
107 | endif | 113 | endif |
108 | ifeq ($(wildcard $(LDSCRIPT)),) | 114 | ifeq ($(wildcard $(LDSCRIPT)),) |
109 | LDSCRIPT := $(srctree)/$(CPUDIR)/u-boot-spl.lds | 115 | LDSCRIPT := $(srctree)/$(CPUDIR)/u-boot-spl.lds |
110 | endif | 116 | endif |
111 | ifeq ($(wildcard $(LDSCRIPT)),) | 117 | ifeq ($(wildcard $(LDSCRIPT)),) |
112 | LDSCRIPT := $(srctree)/arch/$(ARCH)/cpu/u-boot-spl.lds | 118 | LDSCRIPT := $(srctree)/arch/$(ARCH)/cpu/u-boot-spl.lds |
113 | endif | 119 | endif |
114 | ifeq ($(wildcard $(LDSCRIPT)),) | 120 | ifeq ($(wildcard $(LDSCRIPT)),) |
115 | $(error could not find linker script) | 121 | $(error could not find linker script) |
116 | endif | 122 | endif |
117 | 123 | ||
118 | # Special flags for CPP when processing the linker script. | 124 | # Special flags for CPP when processing the linker script. |
119 | # Pass the version down so we can handle backwards compatibility | 125 | # Pass the version down so we can handle backwards compatibility |
120 | # on the fly. | 126 | # on the fly. |
121 | LDPPFLAGS += \ | 127 | LDPPFLAGS += \ |
122 | -include $(srctree)/include/u-boot/u-boot.lds.h \ | 128 | -include $(srctree)/include/u-boot/u-boot.lds.h \ |
123 | -include $(objtree)/include/config.h \ | 129 | -include $(objtree)/include/config.h \ |
124 | -DCPUDIR=$(CPUDIR) \ | 130 | -DCPUDIR=$(CPUDIR) \ |
125 | $(shell $(LD) --version | \ | 131 | $(shell $(LD) --version | \ |
126 | sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\).*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p') | 132 | sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\).*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p') |
127 | 133 | ||
128 | MKIMAGEOUTPUT ?= /dev/null | 134 | MKIMAGEOUTPUT ?= /dev/null |
129 | 135 | ||
130 | quiet_cmd_mkimage = MKIMAGE $@ | 136 | quiet_cmd_mkimage = MKIMAGE $@ |
131 | cmd_mkimage = $(objtree)/tools/mkimage $(MKIMAGEFLAGS_$(@F)) -d $< $@ \ | 137 | cmd_mkimage = $(objtree)/tools/mkimage $(MKIMAGEFLAGS_$(@F)) -d $< $@ \ |
132 | $(if $(KBUILD_VERBOSE:1=), >$(MKIMAGEOUTPUT)) | 138 | $(if $(KBUILD_VERBOSE:1=), >$(MKIMAGEOUTPUT)) |
133 | 139 | ||
134 | MKIMAGEFLAGS_MLO = -T omapimage -a $(CONFIG_SPL_TEXT_BASE) | 140 | MKIMAGEFLAGS_MLO = -T omapimage -a $(CONFIG_SPL_TEXT_BASE) |
135 | 141 | ||
136 | MKIMAGEFLAGS_MLO.byteswap = -T omapimage -n byteswap -a $(CONFIG_SPL_TEXT_BASE) | 142 | MKIMAGEFLAGS_MLO.byteswap = -T omapimage -n byteswap -a $(CONFIG_SPL_TEXT_BASE) |
137 | 143 | ||
138 | MLO MLO.byteswap: $(obj)/u-boot-spl.bin FORCE | 144 | MLO MLO.byteswap: $(obj)/u-boot-spl.bin FORCE |
139 | $(call if_changed,mkimage) | 145 | $(call if_changed,mkimage) |
140 | 146 | ||
141 | ifeq ($(CONFIG_SYS_SOC),"at91") | 147 | ifeq ($(CONFIG_SYS_SOC),"at91") |
142 | MKIMAGEFLAGS_boot.bin = -T atmelimage | 148 | MKIMAGEFLAGS_boot.bin = -T atmelimage |
143 | 149 | ||
144 | ifeq ($(CONFIG_SPL_GENERATE_ATMEL_PMECC_HEADER),y) | 150 | ifeq ($(CONFIG_SPL_GENERATE_ATMEL_PMECC_HEADER),y) |
145 | MKIMAGEFLAGS_boot.bin += -n $(shell $(obj)/../tools/atmel_pmecc_params) | 151 | MKIMAGEFLAGS_boot.bin += -n $(shell $(obj)/../tools/atmel_pmecc_params) |
146 | 152 | ||
147 | boot.bin: $(obj)/../tools/atmel_pmecc_params | 153 | boot.bin: $(obj)/../tools/atmel_pmecc_params |
148 | endif | 154 | endif |
149 | 155 | ||
150 | boot.bin: $(obj)/u-boot-spl.bin FORCE | 156 | boot.bin: $(obj)/u-boot-spl.bin FORCE |
151 | $(call if_changed,mkimage) | 157 | $(call if_changed,mkimage) |
152 | else | 158 | else |
153 | ifdef CONFIG_ARCH_ZYNQ | 159 | ifdef CONFIG_ARCH_ZYNQ |
154 | MKIMAGEFLAGS_boot.bin = -T zynqimage -R $(srctree)/$(CONFIG_BOOT_INIT_FILE) | 160 | MKIMAGEFLAGS_boot.bin = -T zynqimage -R $(srctree)/$(CONFIG_BOOT_INIT_FILE) |
155 | endif | 161 | endif |
156 | ifdef CONFIG_ARCH_ZYNQMP | 162 | ifdef CONFIG_ARCH_ZYNQMP |
157 | MKIMAGEFLAGS_boot.bin = -T zynqmpimage -R $(srctree)/$(CONFIG_BOOT_INIT_FILE) | 163 | MKIMAGEFLAGS_boot.bin = -T zynqmpimage -R $(srctree)/$(CONFIG_BOOT_INIT_FILE) |
158 | endif | 164 | endif |
159 | 165 | ||
160 | spl/boot.bin: $(obj)/u-boot-spl.bin FORCE | 166 | spl/boot.bin: $(obj)/u-boot-spl.bin FORCE |
161 | $(call if_changed,mkimage) | 167 | $(call if_changed,mkimage) |
162 | endif | 168 | endif |
163 | 169 | ||
164 | ALL-y += $(obj)/$(SPL_BIN).bin | 170 | ALL-y += $(obj)/$(SPL_BIN).bin |
165 | 171 | ||
166 | ifdef CONFIG_SAMSUNG | 172 | ifdef CONFIG_SAMSUNG |
167 | ALL-y += $(obj)/$(BOARD)-spl.bin | 173 | ALL-y += $(obj)/$(BOARD)-spl.bin |
168 | endif | 174 | endif |
169 | 175 | ||
170 | ifdef CONFIG_ARCH_SOCFPGA | 176 | ifdef CONFIG_ARCH_SOCFPGA |
171 | ALL-y += $(obj)/$(SPL_BIN).sfp | 177 | ALL-y += $(obj)/$(SPL_BIN).sfp |
172 | endif | 178 | endif |
173 | 179 | ||
174 | ifdef CONFIG_ARCH_SUNXI | 180 | ifdef CONFIG_ARCH_SUNXI |
175 | ALL-y += $(obj)/sunxi-spl.bin | 181 | ALL-y += $(obj)/sunxi-spl.bin |
176 | endif | 182 | endif |
177 | 183 | ||
178 | ifeq ($(CONFIG_SYS_SOC),"at91") | 184 | ifeq ($(CONFIG_SYS_SOC),"at91") |
179 | ALL-y += boot.bin | 185 | ALL-y += boot.bin |
180 | endif | 186 | endif |
181 | 187 | ||
182 | ALL-$(CONFIG_SPL_X86_16BIT_INIT) += $(obj)/u-boot-x86-16bit-spl.bin | 188 | ALL-$(CONFIG_SPL_X86_16BIT_INIT) += $(obj)/u-boot-x86-16bit-spl.bin |
183 | 189 | ||
184 | ALL-$(CONFIG_ARCH_ZYNQ) += $(obj)/boot.bin | 190 | ALL-$(CONFIG_ARCH_ZYNQ) += $(obj)/boot.bin |
185 | ALL-$(CONFIG_ARCH_ZYNQMP) += $(obj)/boot.bin | 191 | ALL-$(CONFIG_ARCH_ZYNQMP) += $(obj)/boot.bin |
186 | 192 | ||
187 | all: $(ALL-y) | 193 | all: $(ALL-y) |
188 | 194 | ||
189 | quiet_cmd_cat = CAT $@ | 195 | quiet_cmd_cat = CAT $@ |
190 | cmd_cat = cat $(filter-out $(PHONY), $^) > $@ | 196 | cmd_cat = cat $(filter-out $(PHONY), $^) > $@ |
191 | 197 | ||
192 | quiet_cmd_copy = COPY $@ | 198 | quiet_cmd_copy = COPY $@ |
193 | cmd_copy = cp $< $@ | 199 | cmd_copy = cp $< $@ |
194 | 200 | ||
195 | ifeq ($(CONFIG_SPL_OF_CONTROL)$(CONFIG_OF_SEPARATE)$(CONFIG_SPL_OF_PLATDATA),yy) | 201 | ifeq ($(CONFIG_SPL_OF_CONTROL)$(CONFIG_OF_SEPARATE)$(CONFIG_SPL_OF_PLATDATA),yy) |
196 | $(obj)/$(SPL_BIN)-dtb.bin: $(obj)/$(SPL_BIN)-nodtb.bin \ | 202 | $(obj)/$(SPL_BIN)-dtb.bin: $(obj)/$(SPL_BIN)-nodtb.bin \ |
197 | $(if $(CONFIG_SPL_SEPARATE_BSS),,$(obj)/$(SPL_BIN)-pad.bin) \ | 203 | $(if $(CONFIG_SPL_SEPARATE_BSS),,$(obj)/$(SPL_BIN)-pad.bin) \ |
198 | $(obj)/$(SPL_BIN).dtb FORCE | 204 | $(obj)/$(SPL_BIN).dtb FORCE |
199 | $(call if_changed,cat) | 205 | $(call if_changed,cat) |
200 | 206 | ||
201 | $(obj)/$(SPL_BIN).bin: $(obj)/$(SPL_BIN)-dtb.bin FORCE | 207 | $(obj)/$(SPL_BIN).bin: $(obj)/$(SPL_BIN)-dtb.bin FORCE |
202 | $(call if_changed,copy) | 208 | $(call if_changed,copy) |
203 | else | 209 | else |
204 | $(obj)/$(SPL_BIN).bin: $(obj)/$(SPL_BIN)-nodtb.bin FORCE | 210 | $(obj)/$(SPL_BIN).bin: $(obj)/$(SPL_BIN)-nodtb.bin FORCE |
205 | $(call if_changed,copy) | 211 | $(call if_changed,copy) |
206 | endif | 212 | endif |
207 | 213 | ||
208 | # Create a file that pads from the end of u-boot-spl-nodtb.bin to bss_end | 214 | # Create a file that pads from the end of u-boot-spl-nodtb.bin to bss_end |
209 | $(obj)/$(SPL_BIN)-pad.bin: $(obj)/$(SPL_BIN) | 215 | $(obj)/$(SPL_BIN)-pad.bin: $(obj)/$(SPL_BIN) |
210 | @bss_size_str=$(shell $(NM) $< | awk 'BEGIN {size = 0} /__bss_size/ {size = $$1} END {print "ibase=16; " toupper(size)}' | bc); \ | 216 | @bss_size_str=$(shell $(NM) $< | awk 'BEGIN {size = 0} /__bss_size/ {size = $$1} END {print "ibase=16; " toupper(size)}' | bc); \ |
211 | dd if=/dev/zero of=$@ bs=1 count=$${bss_size_str} 2>/dev/null; | 217 | dd if=/dev/zero of=$@ bs=1 count=$${bss_size_str} 2>/dev/null; |
212 | 218 | ||
213 | # Pass the original device tree file through fdtgrep twice. The first pass | 219 | # Pass the original device tree file through fdtgrep twice. The first pass |
214 | # removes any unwanted nodes (i.e. those which don't have the | 220 | # removes any unwanted nodes (i.e. those which don't have the |
215 | # 'u-boot,dm-pre-reloc' property and thus are not needed by SPL. The second | 221 | # 'u-boot,dm-pre-reloc' property and thus are not needed by SPL. The second |
216 | # pass removes various unused properties from the remaining nodes. | 222 | # pass removes various unused properties from the remaining nodes. |
217 | # The output is typically a much smaller device tree file. | 223 | # The output is typically a much smaller device tree file. |
218 | ifeq ($(CONFIG_TPL_BUILD),y) | 224 | ifeq ($(CONFIG_TPL_BUILD),y) |
219 | fdtgrep_props := -b u-boot,dm-pre-reloc -b u-boot,dm-tpl | 225 | fdtgrep_props := -b u-boot,dm-pre-reloc -b u-boot,dm-tpl |
220 | else | 226 | else |
221 | fdtgrep_props := -b u-boot,dm-pre-reloc -b u-boot,dm-spl | 227 | fdtgrep_props := -b u-boot,dm-pre-reloc -b u-boot,dm-spl |
222 | endif | 228 | endif |
223 | quiet_cmd_fdtgrep = FDTGREP $@ | 229 | quiet_cmd_fdtgrep = FDTGREP $@ |
224 | cmd_fdtgrep = $(objtree)/tools/fdtgrep $(fdtgrep_props) -RT $< \ | 230 | cmd_fdtgrep = $(objtree)/tools/fdtgrep $(fdtgrep_props) -RT $< \ |
225 | -n /chosen -O dtb | \ | 231 | -n /chosen -O dtb | \ |
226 | $(objtree)/tools/fdtgrep -r -O dtb - -o $@ \ | 232 | $(objtree)/tools/fdtgrep -r -O dtb - -o $@ \ |
227 | $(addprefix -P ,$(subst $\",,$(CONFIG_OF_SPL_REMOVE_PROPS))) | 233 | $(addprefix -P ,$(subst $\",,$(CONFIG_OF_SPL_REMOVE_PROPS))) |
228 | 234 | ||
229 | $(obj)/$(SPL_BIN).dtb: dts/dt.dtb $(objtree)/tools/fdtgrep FORCE | 235 | $(obj)/$(SPL_BIN).dtb: dts/dt.dtb $(objtree)/tools/fdtgrep FORCE |
230 | $(call if_changed,fdtgrep) | 236 | $(call if_changed,fdtgrep) |
231 | 237 | ||
232 | pythonpath = PYTHONPATH=tools | 238 | pythonpath = PYTHONPATH=tools |
233 | 239 | ||
234 | quiet_cmd_dtocc = DTOC C $@ | 240 | quiet_cmd_dtocc = DTOC C $@ |
235 | cmd_dtocc = $(pythonpath) $(srctree)/tools/dtoc/dtoc -d $(obj)/$(SPL_BIN).dtb -o $@ platdata | 241 | cmd_dtocc = $(pythonpath) $(srctree)/tools/dtoc/dtoc -d $(obj)/$(SPL_BIN).dtb -o $@ platdata |
236 | 242 | ||
237 | quiet_cmd_dtoch = DTOC H $@ | 243 | quiet_cmd_dtoch = DTOC H $@ |
238 | cmd_dtoch = $(pythonpath) $(srctree)/tools/dtoc/dtoc -d $(obj)/$(SPL_BIN).dtb -o $@ struct | 244 | cmd_dtoch = $(pythonpath) $(srctree)/tools/dtoc/dtoc -d $(obj)/$(SPL_BIN).dtb -o $@ struct |
239 | 245 | ||
240 | quiet_cmd_plat = PLAT $@ | 246 | quiet_cmd_plat = PLAT $@ |
241 | cmd_plat = $(CC) $(c_flags) -c $< -o $@ | 247 | cmd_plat = $(CC) $(c_flags) -c $< -o $@ |
242 | 248 | ||
243 | $(obj)/dts/dt-platdata.o: $(obj)/dts/dt-platdata.c include/generated/dt-structs.h | 249 | $(obj)/dts/dt-platdata.o: $(obj)/dts/dt-platdata.c include/generated/dt-structs.h |
244 | $(call if_changed,plat) | 250 | $(call if_changed,plat) |
245 | 251 | ||
246 | PHONY += dts_dir | 252 | PHONY += dts_dir |
247 | dts_dir: | 253 | dts_dir: |
248 | $(shell [ -d $(obj)/dts ] || mkdir -p $(obj)/dts) | 254 | $(shell [ -d $(obj)/dts ] || mkdir -p $(obj)/dts) |
249 | 255 | ||
250 | include/generated/dt-structs.h: $(obj)/$(SPL_BIN).dtb dts_dir dtoc | 256 | include/generated/dt-structs.h: $(obj)/$(SPL_BIN).dtb dts_dir dtoc |
251 | $(call if_changed,dtoch) | 257 | $(call if_changed,dtoch) |
252 | 258 | ||
253 | $(obj)/dts/dt-platdata.c: $(obj)/$(SPL_BIN).dtb dts_dir dtoc | 259 | $(obj)/dts/dt-platdata.c: $(obj)/$(SPL_BIN).dtb dts_dir dtoc |
254 | $(call if_changed,dtocc) | 260 | $(call if_changed,dtocc) |
255 | 261 | ||
256 | dtoc: #$(objtree)/tools/_libfdt.so | 262 | dtoc: #$(objtree)/tools/_libfdt.so |
257 | 263 | ||
258 | ifdef CONFIG_SAMSUNG | 264 | ifdef CONFIG_SAMSUNG |
259 | ifdef CONFIG_VAR_SIZE_SPL | 265 | ifdef CONFIG_VAR_SIZE_SPL |
260 | VAR_SIZE_PARAM = --vs | 266 | VAR_SIZE_PARAM = --vs |
261 | else | 267 | else |
262 | VAR_SIZE_PARAM = | 268 | VAR_SIZE_PARAM = |
263 | endif | 269 | endif |
264 | $(obj)/$(BOARD)-spl.bin: $(obj)/u-boot-spl.bin | 270 | $(obj)/$(BOARD)-spl.bin: $(obj)/u-boot-spl.bin |
265 | $(if $(wildcard $(objtree)/spl/board/samsung/$(BOARD)/tools/mk$(BOARD)spl),\ | 271 | $(if $(wildcard $(objtree)/spl/board/samsung/$(BOARD)/tools/mk$(BOARD)spl),\ |
266 | $(objtree)/spl/board/samsung/$(BOARD)/tools/mk$(BOARD)spl,\ | 272 | $(objtree)/spl/board/samsung/$(BOARD)/tools/mk$(BOARD)spl,\ |
267 | $(objtree)/tools/mkexynosspl) $(VAR_SIZE_PARAM) $< $@ | 273 | $(objtree)/tools/mkexynosspl) $(VAR_SIZE_PARAM) $< $@ |
268 | endif | 274 | endif |
269 | 275 | ||
270 | quiet_cmd_objcopy = OBJCOPY $@ | 276 | quiet_cmd_objcopy = OBJCOPY $@ |
271 | cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@ | 277 | cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@ |
272 | 278 | ||
273 | OBJCOPYFLAGS_$(SPL_BIN)-nodtb.bin = $(SPL_OBJCFLAGS) -O binary \ | 279 | OBJCOPYFLAGS_$(SPL_BIN)-nodtb.bin = $(SPL_OBJCFLAGS) -O binary \ |
274 | $(if $(CONFIG_SPL_X86_16BIT_INIT),-R .start16 -R .resetvec) | 280 | $(if $(CONFIG_SPL_X86_16BIT_INIT),-R .start16 -R .resetvec) |
275 | 281 | ||
276 | $(obj)/$(SPL_BIN)-nodtb.bin: $(obj)/$(SPL_BIN) FORCE | 282 | $(obj)/$(SPL_BIN)-nodtb.bin: $(obj)/$(SPL_BIN) FORCE |
277 | $(call if_changed,objcopy) | 283 | $(call if_changed,objcopy) |
278 | 284 | ||
279 | OBJCOPYFLAGS_u-boot-x86-16bit-spl.bin := -O binary -j .start16 -j .resetvec | 285 | OBJCOPYFLAGS_u-boot-x86-16bit-spl.bin := -O binary -j .start16 -j .resetvec |
280 | $(obj)/u-boot-x86-16bit-spl.bin: $(obj)/u-boot-spl FORCE | 286 | $(obj)/u-boot-x86-16bit-spl.bin: $(obj)/u-boot-spl FORCE |
281 | $(call if_changed,objcopy) | 287 | $(call if_changed,objcopy) |
282 | 288 | ||
283 | LDFLAGS_$(SPL_BIN) += -T u-boot-spl.lds $(LDFLAGS_FINAL) | 289 | LDFLAGS_$(SPL_BIN) += -T u-boot-spl.lds $(LDFLAGS_FINAL) |
284 | ifneq ($(CONFIG_SPL_TEXT_BASE),) | 290 | ifneq ($(CONFIG_SPL_TEXT_BASE),) |
285 | LDFLAGS_$(SPL_BIN) += -Ttext $(CONFIG_SPL_TEXT_BASE) | 291 | LDFLAGS_$(SPL_BIN) += -Ttext $(CONFIG_SPL_TEXT_BASE) |
286 | endif | 292 | endif |
287 | 293 | ||
288 | MKIMAGEFLAGS_$(SPL_BIN).sfp = -T socfpgaimage | 294 | MKIMAGEFLAGS_$(SPL_BIN).sfp = -T socfpgaimage |
289 | $(obj)/$(SPL_BIN).sfp: $(obj)/$(SPL_BIN).bin FORCE | 295 | $(obj)/$(SPL_BIN).sfp: $(obj)/$(SPL_BIN).bin FORCE |
290 | $(call if_changed,mkimage) | 296 | $(call if_changed,mkimage) |
291 | 297 | ||
292 | quiet_cmd_mksunxiboot = MKSUNXI $@ | 298 | quiet_cmd_mksunxiboot = MKSUNXI $@ |
293 | cmd_mksunxiboot = $(objtree)/tools/mksunxiboot $< $@ | 299 | cmd_mksunxiboot = $(objtree)/tools/mksunxiboot $< $@ |
294 | $(obj)/sunxi-spl.bin: $(obj)/$(SPL_BIN).bin FORCE | 300 | $(obj)/sunxi-spl.bin: $(obj)/$(SPL_BIN).bin FORCE |
295 | $(call if_changed,mksunxiboot) | 301 | $(call if_changed,mksunxiboot) |
296 | 302 | ||
297 | # Rule to link u-boot-spl | 303 | # Rule to link u-boot-spl |
298 | # May be overridden by arch/$(ARCH)/config.mk | 304 | # May be overridden by arch/$(ARCH)/config.mk |
299 | quiet_cmd_u-boot-spl ?= LD $@ | 305 | quiet_cmd_u-boot-spl ?= LD $@ |
300 | cmd_u-boot-spl ?= (cd $(obj) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) \ | 306 | cmd_u-boot-spl ?= (cd $(obj) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) \ |
301 | $(patsubst $(obj)/%,%,$(u-boot-spl-init)) --start-group \ | 307 | $(patsubst $(obj)/%,%,$(u-boot-spl-init)) --start-group \ |
302 | $(patsubst $(obj)/%,%,$(u-boot-spl-main)) \ | 308 | $(patsubst $(obj)/%,%,$(u-boot-spl-main)) \ |
303 | $(patsubst $(obj)/%,%,$(u-boot-spl-platdata)) \ | 309 | $(patsubst $(obj)/%,%,$(u-boot-spl-platdata)) \ |
304 | --end-group \ | 310 | --end-group \ |
305 | $(PLATFORM_LIBS) -Map $(SPL_BIN).map -o $(SPL_BIN)) | 311 | $(PLATFORM_LIBS) -Map $(SPL_BIN).map -o $(SPL_BIN)) |
306 | 312 | ||
307 | $(obj)/$(SPL_BIN): $(u-boot-spl-platdata) $(u-boot-spl-init) \ | 313 | $(obj)/$(SPL_BIN): $(u-boot-spl-platdata) $(u-boot-spl-init) \ |
308 | $(u-boot-spl-main) $(obj)/u-boot-spl.lds FORCE | 314 | $(u-boot-spl-main) $(obj)/u-boot-spl.lds FORCE |
309 | $(call if_changed,u-boot-spl) | 315 | $(call if_changed,u-boot-spl) |
310 | 316 | ||
311 | $(sort $(u-boot-spl-init) $(u-boot-spl-main)): $(u-boot-spl-dirs) ; | 317 | $(sort $(u-boot-spl-init) $(u-boot-spl-main)): $(u-boot-spl-dirs) ; |
312 | 318 | ||
313 | PHONY += $(u-boot-spl-dirs) | 319 | PHONY += $(u-boot-spl-dirs) |
314 | $(u-boot-spl-dirs): $(u-boot-spl-platdata) | 320 | $(u-boot-spl-dirs): $(u-boot-spl-platdata) |
315 | $(Q)$(MAKE) $(build)=$@ | 321 | $(Q)$(MAKE) $(build)=$@ |
316 | 322 | ||
317 | quiet_cmd_cpp_lds = LDS $@ | 323 | quiet_cmd_cpp_lds = LDS $@ |
318 | cmd_cpp_lds = $(CPP) -Wp,-MD,$(depfile) $(cpp_flags) $(LDPPFLAGS) -ansi \ | 324 | cmd_cpp_lds = $(CPP) -Wp,-MD,$(depfile) $(cpp_flags) $(LDPPFLAGS) -ansi \ |
319 | -D__ASSEMBLY__ -x assembler-with-cpp -P -o $@ $< | 325 | -D__ASSEMBLY__ -x assembler-with-cpp -P -o $@ $< |
320 | 326 | ||
321 | $(obj)/u-boot-spl.lds: $(LDSCRIPT) FORCE | 327 | $(obj)/u-boot-spl.lds: $(LDSCRIPT) FORCE |
322 | $(call if_changed_dep,cpp_lds) | 328 | $(call if_changed_dep,cpp_lds) |
323 | 329 | ||
324 | # read all saved command lines | 330 | # read all saved command lines |
325 | 331 | ||
326 | targets := $(wildcard $(sort $(targets))) | 332 | targets := $(wildcard $(sort $(targets))) |
327 | cmd_files := $(wildcard $(obj)/.*.cmd $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) | 333 | cmd_files := $(wildcard $(obj)/.*.cmd $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) |
328 | 334 | ||
329 | ifneq ($(cmd_files),) | 335 | ifneq ($(cmd_files),) |
330 | $(cmd_files): ; # Do not try to update included dependency files | 336 | $(cmd_files): ; # Do not try to update included dependency files |
331 | include $(cmd_files) | 337 | include $(cmd_files) |
332 | endif | 338 | endif |
333 | 339 | ||
334 | PHONY += FORCE | 340 | PHONY += FORCE |
335 | FORCE: | 341 | FORCE: |
336 | 342 | ||
337 | # Declare the contents of the .PHONY variable as phony. We keep that | 343 | # Declare the contents of the .PHONY variable as phony. We keep that |
338 | # information in a variable so we can use it in if_changed and friends. | 344 | # information in a variable so we can use it in if_changed and friends. |
339 | .PHONY: $(PHONY) | 345 | .PHONY: $(PHONY) |
340 | 346 |