1 | # $Id: footer-inherit-uses-tools.kmk 2726 2014-02-26 23:23:54Z bird $
|
---|
2 | ## @file
|
---|
3 | # kBuild - Footer - Target lists - Pass 2 - Template & Target Inheritance, Uses and Tools.
|
---|
4 | #
|
---|
5 |
|
---|
6 | #
|
---|
7 | # Copyright (c) 2004-2014 knut st. osmundsen <bird-kBuild-spam-xiv@anduin.net>
|
---|
8 | #
|
---|
9 | # This file is part of kBuild.
|
---|
10 | #
|
---|
11 | # kBuild is free software; you can redistribute it and/or modify
|
---|
12 | # it under the terms of the GNU General Public License as published by
|
---|
13 | # the Free Software Foundation; either version source of the License, or
|
---|
14 | # (at your option) any later version.
|
---|
15 | #
|
---|
16 | # kBuild is distributed in the hope that it will be useful,
|
---|
17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
19 | # GNU General Public License for more details.
|
---|
20 | #
|
---|
21 | # You should have received a copy of the GNU General Public License
|
---|
22 | # along with kBuild; if not, write to the Free Software
|
---|
23 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
24 | #
|
---|
25 | #
|
---|
26 | # As a special exception you are granted permission to include this file, via
|
---|
27 | # the kmk include directive, as you wish without this in itself causing the
|
---|
28 | # resulting makefile, program or whatever to be covered by the GPL license.
|
---|
29 | # This exception does not however invalidate any other reasons why the makefile,
|
---|
30 | # program, whatever should not be covered the GPL.
|
---|
31 | #
|
---|
32 | #
|
---|
33 |
|
---|
34 | ## Converts a variable from simple to recursive flavor.
|
---|
35 | # This is used by def_inherit_template_one_accumulate_l and def_inherit_template_one_accumulate_r.
|
---|
36 | # @param $1 The variable name.
|
---|
37 | define def_simple_2_recursive
|
---|
38 | $1_DEFERRED := $$($1)
|
---|
39 | $1 = $$($1_DEFERRED)
|
---|
40 | endef
|
---|
41 |
|
---|
42 |
|
---|
43 | ## Inherit one keyword in a non-accumulative manner.
|
---|
44 | # @param $(trg) Target object.
|
---|
45 | # @param $(prop) The property.
|
---|
46 | # @param $(src_key) Source keyword.
|
---|
47 | # @param $(trg_key) Target keyword.
|
---|
48 | define def_inherit_one_keyword
|
---|
49 | ifdef $(trg)_$(prop).$(src_key)
|
---|
50 | ifndef $(trg)_$(prop).$(trg_key)
|
---|
51 | $(trg)_$(prop).$(trg_key) = $($(trg)_$(prop).$(src_key))
|
---|
52 | endif
|
---|
53 | endif
|
---|
54 | endef
|
---|
55 |
|
---|
56 |
|
---|
57 | # EXPAND_BY = overriding
|
---|
58 |
|
---|
59 | ## Inherit one keyword in a non-accumulative manner.
|
---|
60 | # @param $(trg) Target object.
|
---|
61 | # @param $(prop) The property.
|
---|
62 | # @param $(src_key) Source keyword.
|
---|
63 | # @param $(trg_key) Target keyword.
|
---|
64 | define def_inherit_one_keyword_overriding_now_l
|
---|
65 | ifdef $(trg)_$(prop).$(src_key)
|
---|
66 | ifndef $(trg)_$(prop).$(trg_key)
|
---|
67 | $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(src_key))
|
---|
68 | endif
|
---|
69 | endif
|
---|
70 | endef
|
---|
71 |
|
---|
72 | ## @copydoc def_inherit_one_overriding_now_l
|
---|
73 | define def_inherit_one_keyword_overriding_now_r
|
---|
74 | ifdef $(trg)_$(prop).$(src_key)
|
---|
75 | ifndef $(trg)_$(prop).$(trg_key)
|
---|
76 | $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(src_key))
|
---|
77 | endif
|
---|
78 | endif
|
---|
79 | endef
|
---|
80 |
|
---|
81 | ## Inherit one keyword in a non-accumulative manner, deferred expansion.
|
---|
82 | # @param $(trg) Target object.
|
---|
83 | # @param $(prop) The property.
|
---|
84 | # @param $(src_key) Source keyword.
|
---|
85 | # @param $(trg_key) Target keyword.
|
---|
86 | # @remark This define relies on double evaluation
|
---|
87 | define def_inherit_one_keyword_overriding_deferred
|
---|
88 | ifdef $(trg)_$(prop).$(src_key)
|
---|
89 | ifndef $(trg)_$(prop).$(trg_key)
|
---|
90 | $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key))
|
---|
91 | endif
|
---|
92 | endif
|
---|
93 | endef
|
---|
94 |
|
---|
95 | ## @copydoc def_inherit_one_overriding_deferred
|
---|
96 | define def_inherit_one_keyword_overriding_deferred_l
|
---|
97 | ifdef $(trg)_$(prop).$(src_key)
|
---|
98 | ifndef $(trg)_$(prop).$(trg_key)
|
---|
99 | $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key))
|
---|
100 | endif
|
---|
101 | endif
|
---|
102 | endef
|
---|
103 |
|
---|
104 | ## @copydoc def_inherit_one_overriding_deferred
|
---|
105 | define def_inherit_one_keyword_overriding_deferred_r
|
---|
106 | ifdef $(trg)_$(prop).$(src_key)
|
---|
107 | ifndef $(trg)_$(prop).$(trg_key)
|
---|
108 | $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key))
|
---|
109 | endif
|
---|
110 | endif
|
---|
111 | endef
|
---|
112 |
|
---|
113 |
|
---|
114 | # EXPAND_BY = prepending
|
---|
115 |
|
---|
116 | ## Inherit one keyword in a prepending manner.
|
---|
117 | # @param $(trg) Target object.
|
---|
118 | # @param $(prop) The property.
|
---|
119 | # @param $(src_key) Source keyword.
|
---|
120 | # @param $(trg_key) Target keyword.
|
---|
121 | define def_inherit_one_keyword_prepending_now_l
|
---|
122 | ifdef $(trg)_$(prop).$(src_key)
|
---|
123 | $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(src_key)) $($(trg)_$(prop).$(trg_key))
|
---|
124 | endif
|
---|
125 | endef
|
---|
126 |
|
---|
127 | ## @copydoc def_inherit_one_prepending_now_l
|
---|
128 | define def_inherit_one_keyword_prepending_now_r
|
---|
129 | ifdef $(trg)_$(prop).$(src_key)
|
---|
130 | $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(trg_key)) $($(trg)_$(prop).$(src_key))
|
---|
131 | endif
|
---|
132 | endef
|
---|
133 |
|
---|
134 | ## Inherit one keyword in a non-accumulative manner, deferred expansion.
|
---|
135 | # @param $(trg) Target object.
|
---|
136 | # @param $(prop) The property.
|
---|
137 | # @param $(src_key) Source keyword.
|
---|
138 | # @param $(trg_key) Target keyword.
|
---|
139 | # @remark This define relies on double evaluation
|
---|
140 | define def_inherit_one_keyword_prepending_deferred
|
---|
141 | ifdef $(trg)_$(prop).$(src_key)
|
---|
142 | ifndef $(trg)_$(prop).$(trg_key)
|
---|
143 | $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key))
|
---|
144 | endif
|
---|
145 | endif
|
---|
146 | endef
|
---|
147 |
|
---|
148 | ## Inherit one keyword in a prepending manner, deferred expansion.
|
---|
149 | # @param $(trg) Target object.
|
---|
150 | # @param $(prop) The property.
|
---|
151 | # @param $(src_key) Source keyword.
|
---|
152 | # @param $(trg_key) Target keyword.
|
---|
153 | define def_inherit_one_keyword_prepending_deferred_l
|
---|
154 | ifdef $(trg)_$(prop).$(src_key)
|
---|
155 | ifeq ($$(flavor $(trg)_$(prop).$(trg_key)),simple)
|
---|
156 | $$(evalcall2 def_simple_2_recursive,$(trg)_$(prop).$(trg_key))
|
---|
157 | endif
|
---|
158 | $(trg)_$(prop).$(trg_key) <= $$($(trg)_$(prop).$(src_key))
|
---|
159 | endif
|
---|
160 | endef
|
---|
161 |
|
---|
162 | ## @copydoc def_inherit_one_prepending_deferred_l
|
---|
163 | define def_inherit_one_keyword_prepending_deferred_r
|
---|
164 | ifdef $(trg)_$(prop).$(src_key)
|
---|
165 | ifeq ($$(flavor $(trg)_$(prop).$(trg_key)),simple)
|
---|
166 | $$(evalcall2 def_simple_2_recursive,$(trg)_$(prop).$(trg_key))
|
---|
167 | endif
|
---|
168 | $(trg)_$(prop).$(trg_key) += $$($(trg)_$(prop).$(src_key))
|
---|
169 | endif
|
---|
170 | endef
|
---|
171 |
|
---|
172 |
|
---|
173 | # EXPAND_BY = appending
|
---|
174 |
|
---|
175 | ## Inherit one keyword in an appending manner.
|
---|
176 | # @param $(trg) Target object.
|
---|
177 | # @param $(prop) The property.
|
---|
178 | # @param $(src_key) Source keyword.
|
---|
179 | # @param $(trg_key) Target keyword.
|
---|
180 | define def_inherit_one_keyword_appending_now_l
|
---|
181 | ifdef $(trg)_$(prop).$(src_key)
|
---|
182 | $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(trg_key)) $($(trg)_$(prop).$(src_key))
|
---|
183 | endif
|
---|
184 | endef
|
---|
185 |
|
---|
186 | ## @copydoc def_inherit_one_appending_now_l
|
---|
187 | define def_inherit_one_keyword_appending_now_r
|
---|
188 | ifdef $(trg)_$(prop).$(src_key)
|
---|
189 | $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(src_key)) $($(trg)_$(prop).$(trg_key))
|
---|
190 | endif
|
---|
191 | endef
|
---|
192 |
|
---|
193 | ## Inherit one keyword in a non-accumulative manner, deferred expansion.
|
---|
194 | # @param $(trg) Target object.
|
---|
195 | # @param $(prop) The property.
|
---|
196 | # @param $(src_key) Source keyword.
|
---|
197 | # @param $(trg_key) Target keyword.
|
---|
198 | # @remark This define relies on double evaluation
|
---|
199 | define def_inherit_one_keyword_appending_deferred
|
---|
200 | ifdef $(trg)_$(prop).$(src_key)
|
---|
201 | ifndef $(trg)_$(prop).$(trg_key)
|
---|
202 | $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key))
|
---|
203 | endif
|
---|
204 | endif
|
---|
205 | endef
|
---|
206 |
|
---|
207 | ## Inherit one keyword in an appending manner, deferred expansion.
|
---|
208 | # @param $(trg) Target object.
|
---|
209 | # @param $(prop) The property.
|
---|
210 | # @param $(src_key) Source keyword.
|
---|
211 | # @param $(trg_key) Target keyword.
|
---|
212 | define def_inherit_one_keyword_appending_deferred_l
|
---|
213 | ifdef $(trg)_$(prop).$(src_key)
|
---|
214 | ifeq ($$(flavor $(trg)_$(prop).$(trg_key)),simple)
|
---|
215 | $$(evalcall2 def_simple_2_recursive,$(trg)_$(prop).$(trg_key))
|
---|
216 | endif
|
---|
217 | $(trg)_$(prop).$(trg_key) += $$($(trg)_$(prop).$(src_key))
|
---|
218 | endif
|
---|
219 | endef
|
---|
220 |
|
---|
221 | ## @copydoc def_inherit_one_appending_deferred_l
|
---|
222 | define def_inherit_one_keyword_appending_deferred_r
|
---|
223 | ifdef $(trg)_$(prop).$(src_key)
|
---|
224 | ifeq ($$(flavor $(trg)_$(prop).$(trg_key)),simple)
|
---|
225 | $$(evalcall2 def_simple_2_recursive,$(trg)_$(prop).$(trg_key))
|
---|
226 | endif
|
---|
227 | $(trg)_$(prop).$(trg_key) <= $$($(trg)_$(prop).$(src_key))
|
---|
228 | endif
|
---|
229 | endef
|
---|
230 |
|
---|
231 |
|
---|
232 | ## Worker for def_inherit that deals with one keyword that makes
|
---|
233 | # use of inheritance.
|
---|
234 | # @param prefix_keyword key_prefix:keyword. The cool join/split game as usual.
|
---|
235 | # @param trg Object to consider for inheriting.
|
---|
236 | # @param properties List of the properties with straight expansion.
|
---|
237 | # @param properties_now_l List of the properties with immediate expansion, accumulating on the left side.
|
---|
238 | # @param properties_now_r List of the properties with immediate expansion, accumulating on the right side.
|
---|
239 | # @param properties_deferred List of the properties with deferred expansion (e.g. function), non-accumulative .
|
---|
240 | # @param properties_deferred_l List of the properties with deferred expansion (e.g. function), accumulating on the left side.
|
---|
241 | # @param properties_deferred_r List of the properties with deferred expansion (e.g. function), accumulating on the right side.
|
---|
242 | define def_inherit_keyword
|
---|
243 | local prefix := $(word 1,$(subst :, ,$(prefix_keyword)))
|
---|
244 | local trg_key := $(word 2,$(subst :, ,$(prefix_keyword)))
|
---|
245 | local src_key := $($(prefix)_$(trg_key)_EXTENDS)
|
---|
246 | local by := $($(prefix)_$(trg_key)_EXTENDS_BY)
|
---|
247 |
|
---|
248 | # Inherit the properties.
|
---|
249 | $(foreach prop, $(properties), $(eval $(def_inherit_one_keyword)))
|
---|
250 | $(foreach prop, $(properties_now_l), $(eval $(def_inherit_one_keyword_$(by)_now_l)))
|
---|
251 | $(foreach prop, $(properties_now_r), $(eval $(def_inherit_one_keyword_$(by)_now_r)))
|
---|
252 | $(foreach prop, $(properties_deferred), $(eval $(def_inherit_one_keyword_$(by)_deferred)))
|
---|
253 | $(foreach prop, $(properties_deferred_l), $(eval $(def_inherit_one_keyword_$(by)_deferred_l)))
|
---|
254 | $(foreach prop, $(properties_deferred_r), $(eval $(def_inherit_one_keyword_$(by)_deferred_r)))
|
---|
255 |
|
---|
256 | endef # def_inherit_keyword
|
---|
257 |
|
---|
258 |
|
---|
259 | ## Inherit one template property in a non-accumulative manner.
|
---|
260 | # @param $(prop) Property name
|
---|
261 | # @param $(src) Source (parent) object.
|
---|
262 | # @param $(trg) Target (child) object.
|
---|
263 | define def_inherit_one
|
---|
264 | ifdef $(src)_$(prop)
|
---|
265 | ifndef $(trg)_$(prop)
|
---|
266 | $(trg)_$(prop) = $($(src)_$(prop))
|
---|
267 | endif
|
---|
268 | endif
|
---|
269 | endef
|
---|
270 |
|
---|
271 |
|
---|
272 | # EXPAND_BY = overriding
|
---|
273 |
|
---|
274 | ## Inherit one template property in a non-accumulative manner.
|
---|
275 | # @param $(prop) Property name
|
---|
276 | # @param $(src) Source (parent) object.
|
---|
277 | # @param $(trg) Target (child) object.
|
---|
278 | define def_inherit_one_overriding_now_l
|
---|
279 | ifdef $(src)_$(prop)
|
---|
280 | ifndef $(trg)_$(prop)
|
---|
281 | $(trg)_$(prop) := $($(src)_$(prop))
|
---|
282 | endif
|
---|
283 | endif
|
---|
284 | endef
|
---|
285 |
|
---|
286 | ## @copydoc def_inherit_one_overriding_now_l
|
---|
287 | define def_inherit_one_overriding_now_r
|
---|
288 | ifdef $(src)_$(prop)
|
---|
289 | ifndef $(trg)_$(prop)
|
---|
290 | $(trg)_$(prop) := $($(src)_$(prop))
|
---|
291 | endif
|
---|
292 | endif
|
---|
293 | endef
|
---|
294 |
|
---|
295 | ## Inherit one template property in a non-accumulative manner, deferred expansion.
|
---|
296 | # @param $(prop) Property name
|
---|
297 | # @param $(src) Source
|
---|
298 | # @param $(trg) Target
|
---|
299 | # @remark This define relies on double evaluation
|
---|
300 | define def_inherit_one_overriding_deferred
|
---|
301 | ifdef $(src)_$(prop)
|
---|
302 | ifndef $(trg)_$(prop)
|
---|
303 | $(trg)_$(prop) = $$($(src)_$(prop))
|
---|
304 | endif
|
---|
305 | endif
|
---|
306 | endef
|
---|
307 |
|
---|
308 | ## @copydoc def_inherit_one_overriding_deferred
|
---|
309 | define def_inherit_one_overriding_deferred_l
|
---|
310 | ifdef $(src)_$(prop)
|
---|
311 | ifndef $(trg)_$(prop)
|
---|
312 | $(trg)_$(prop) = $$($(src)_$(prop))
|
---|
313 | endif
|
---|
314 | endif
|
---|
315 | endef
|
---|
316 |
|
---|
317 | ## @copydoc def_inherit_one_overriding_deferred
|
---|
318 | define def_inherit_one_overriding_deferred_r
|
---|
319 | ifdef $(src)_$(prop)
|
---|
320 | ifndef $(trg)_$(prop)
|
---|
321 | $(trg)_$(prop) = $$($(src)_$(prop))
|
---|
322 | endif
|
---|
323 | endif
|
---|
324 | endef
|
---|
325 |
|
---|
326 |
|
---|
327 | # EXPAND_BY = prepending
|
---|
328 |
|
---|
329 | ## Inherit one template property in a prepending manner.
|
---|
330 | # @param $(prop) Property name
|
---|
331 | # @param $(src) Source (parent) object.
|
---|
332 | # @param $(trg) Target (child) object.
|
---|
333 | define def_inherit_one_prepending_now_l
|
---|
334 | ifdef $(src)_$(prop)
|
---|
335 | $(trg)_$(prop) := $($(src)_$(prop)) $($(trg)_$(prop))
|
---|
336 | endif
|
---|
337 | endef
|
---|
338 |
|
---|
339 | ## @copydoc def_inherit_one_prepending_now_l
|
---|
340 | define def_inherit_one_prepending_now_r
|
---|
341 | ifdef $(src)_$(prop)
|
---|
342 | $(trg)_$(prop) := $($(trg)_$(prop)) $($(src)_$(prop))
|
---|
343 | endif
|
---|
344 | endef
|
---|
345 |
|
---|
346 | ## Inherit one template property in a non-accumulative manner, deferred expansion.
|
---|
347 | # @param $(prop) Property name
|
---|
348 | # @param $(src) Source
|
---|
349 | # @param $(trg) Target
|
---|
350 | # @remark This define relies on double evaluation
|
---|
351 | define def_inherit_one_prepending_deferred
|
---|
352 | ifdef $(src)_$(prop)
|
---|
353 | ifndef $(trg)_$(prop)
|
---|
354 | $(trg)_$(prop) = $$($(src)_$(prop))
|
---|
355 | endif
|
---|
356 | endif
|
---|
357 | endef
|
---|
358 |
|
---|
359 | ## Inherit one template property in a prepending manner, deferred expansion.
|
---|
360 | # @param $(prop) Property name
|
---|
361 | # @param $(src) Source (parent) object.
|
---|
362 | # @param $(trg) Target (child) object.
|
---|
363 | define def_inherit_one_prepending_deferred_l
|
---|
364 | ifdef $(src)_$(prop)
|
---|
365 | ifeq ($$(flavor $(trg)_$(prop)),simple)
|
---|
366 | $$(evalcall2 def_simple_2_recursive,$(trg)_$(prop))
|
---|
367 | endif
|
---|
368 | $(trg)_$(prop) <= $$($(src)_$(prop))
|
---|
369 | endif
|
---|
370 | endef
|
---|
371 |
|
---|
372 | ## @copydoc def_inherit_one_prepending_deferred_l
|
---|
373 | define def_inherit_one_prepending_deferred_r
|
---|
374 | ifdef $(src)_$(prop)
|
---|
375 | ifeq ($$(flavor $(trg)_$(prop)),simple)
|
---|
376 | $$(evalcall2 def_simple_2_recursive,$(trg)_$(prop))
|
---|
377 | endif
|
---|
378 | $(trg)_$(prop) += $$($(src)_$(prop))
|
---|
379 | endif
|
---|
380 | endef
|
---|
381 |
|
---|
382 |
|
---|
383 | # EXPAND_BY = appending
|
---|
384 |
|
---|
385 | ## Inherit one template property in an appending manner.
|
---|
386 | # @param $(prop) Property name
|
---|
387 | # @param $(src) Source (parent) object.
|
---|
388 | # @param $(trg) Target (child) object.
|
---|
389 | define def_inherit_one_appending_now_l
|
---|
390 | ifdef $(src)_$(prop)
|
---|
391 | $(trg)_$(prop) := $($(trg)_$(prop)) $($(src)_$(prop))
|
---|
392 | endif
|
---|
393 | endef
|
---|
394 |
|
---|
395 | ## @copydoc def_inherit_one_appending_now_l
|
---|
396 | define def_inherit_one_appending_now_r
|
---|
397 | ifdef $(src)_$(prop)
|
---|
398 | $(trg)_$(prop) := $($(src)_$(prop)) $($(trg)_$(prop))
|
---|
399 | endif
|
---|
400 | endef
|
---|
401 |
|
---|
402 | ## Inherit one template property in a non-accumulative manner, deferred expansion.
|
---|
403 | # @param $(prop) Property name
|
---|
404 | # @param $(src) Source
|
---|
405 | # @param $(trg) Target
|
---|
406 | # @remark This define relies on double evaluation
|
---|
407 | define def_inherit_one_appending_deferred
|
---|
408 | ifdef $(src)_$(prop)
|
---|
409 | ifndef $(trg)_$(prop)
|
---|
410 | $(trg)_$(prop) = $$($(src)_$(prop))
|
---|
411 | endif
|
---|
412 | endif
|
---|
413 | endef
|
---|
414 |
|
---|
415 | ## Inherit one template property in an appending manner, deferred expansion.
|
---|
416 | # @param $(prop) Property name
|
---|
417 | # @param $(src) Source (parent) object.
|
---|
418 | # @param $(trg) Target (child) object.
|
---|
419 | define def_inherit_one_appending_deferred_l
|
---|
420 | ifdef $(src)_$(prop)
|
---|
421 | ifeq ($$(flavor $(trg)_$(prop)),simple)
|
---|
422 | $$(evalcall2 def_simple_2_recursive,$(trg)_$(prop))
|
---|
423 | endif
|
---|
424 | $(trg)_$(prop) += $$($(src)_$(prop))
|
---|
425 | endif
|
---|
426 | endef
|
---|
427 |
|
---|
428 | ## @copydoc def_inherit_one_appending_deferred_l
|
---|
429 | define def_inherit_one_appending_deferred_r
|
---|
430 | ifdef $(src)_$(prop)
|
---|
431 | ifeq ($$(flavor $(trg)_$(prop)),simple)
|
---|
432 | $$(evalcall2 def_simple_2_recursive,$(trg)_$(prop))
|
---|
433 | endif
|
---|
434 | $(trg)_$(prop) <= $$($(src)_$(prop))
|
---|
435 | endif
|
---|
436 | endef
|
---|
437 |
|
---|
438 |
|
---|
439 | ## combines the specified properties $(1) with the $(_KEYWORDS) list.
|
---|
440 | _INHERIT_JOIN_KEYWORDS = $(1) $(foreach keyword,$(_KEYWORDS), $(addsuffix .$(keyword), $(1)))
|
---|
441 |
|
---|
442 |
|
---|
443 | ## Generic inheritance for use with targets templates and tools.
|
---|
444 | # @param trg Object to consider for inheriting.
|
---|
445 | # @param src_prefix What to prefix the value found in EXTENDS with to get the object.
|
---|
446 | # @param load_function Load function for stuff that needs
|
---|
447 | # @param properties List of the properties with straight expansion.
|
---|
448 | # @param properties_now_l List of the properties with immediate expansion, accumulating on the left side.
|
---|
449 | # @param properties_now_r List of the properties with immediate expansion, accumulating on the right side.
|
---|
450 | # @param properties_deferred List of the properties with deferred expansion (e.g. function), non-accumulative .
|
---|
451 | # @param properties_deferred_l List of the properties with deferred expansion (e.g. function), accumulating on the left side.
|
---|
452 | # @param properties_deferred_r List of the properties with deferred expansion (e.g. function), accumulating on the right side.
|
---|
453 | define def_inherit
|
---|
454 |
|
---|
455 | # Load it - loading is a mess, fix.
|
---|
456 | ifneq ($(load_function),)
|
---|
457 | local loading := $(patsubst $(src_prefix)%,%,$(trg))
|
---|
458 | $(evalvalctx $(load_function))
|
---|
459 | endif
|
---|
460 |
|
---|
461 | local src := $(strip $($(trg)_EXTENDS))
|
---|
462 | ifneq ($(src),)
|
---|
463 | ifndef $(trg)_EXTENDS_STATUS_
|
---|
464 | $(trg)_EXTENDS_STATUS_ := 0
|
---|
465 |
|
---|
466 | # Load the source.
|
---|
467 | ifneq ($(load_function),)
|
---|
468 | local loading := $(src)
|
---|
469 | $(evalvalctx $(load_function))
|
---|
470 | endif
|
---|
471 |
|
---|
472 | # less typing.
|
---|
473 | local src := $(src_prefix)$(src)
|
---|
474 |
|
---|
475 | # Recursivly process the parent (src) if it's inherting from somebody too.
|
---|
476 | ifdef $(src)_EXTENDS
|
---|
477 | ifneq ($($(src)_EXTENDS_STATUS_),42)
|
---|
478 | # 'foreach' will create 'trg' in a new variable context hiding
|
---|
479 | # out current variable. 'src' OTOH will be overwritten.
|
---|
480 | $(foreach trg, $(src), $(evalval def_inherit))
|
---|
481 | local src := $(src_prefix)$(strip $($(trg)_EXTENDS))
|
---|
482 | endif
|
---|
483 | endif
|
---|
484 |
|
---|
485 | # Get & check EXTENDS_BY.
|
---|
486 | local by = $(strip $($(trg)_EXTENDS_BY))
|
---|
487 | ifeq ($(by),)
|
---|
488 | local by = overriding
|
---|
489 | else ifn1of ($(by), overriding appending prepending)
|
---|
490 | $(error kBuild: Invalid EXTENDS_BY value '$(by)' on '$(trg)'!)
|
---|
491 | endif
|
---|
492 |
|
---|
493 | # Inherit the properties.
|
---|
494 | $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties)), $(eval $(def_inherit_one)))
|
---|
495 | $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties_now_l)), $(eval $(def_inherit_one_$(by)_now_l)))
|
---|
496 | $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties_now_r)), $(eval $(def_inherit_one_$(by)_now_r)))
|
---|
497 | $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties_deferred)), $(eval $(def_inherit_one_$(by)_deferred)))
|
---|
498 | $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties_deferred_l)), $(eval $(def_inherit_one_$(by)_deferred_l)))
|
---|
499 | $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties_deferred_r)), $(eval $(def_inherit_one_$(by)_deferred_r)))
|
---|
500 |
|
---|
501 | # Mark the target as done.
|
---|
502 | $(trg)_EXTENDS_STATUS_ := 42
|
---|
503 | else
|
---|
504 | # Check for inheritance loops.
|
---|
505 | ifneq ($($(trg)_EXTENDS_STATUS_),42)
|
---|
506 | $(error kBuild: Target inheritance loop! target=$(trg) $(trg)_EXTENDS_STATUS_=$($(trg)_EXTENDS_STATUS_))
|
---|
507 | endif
|
---|
508 | endif
|
---|
509 | endif
|
---|
510 |
|
---|
511 | # Keyword inheritance.
|
---|
512 | $(foreach prefix_keyword, $(join $(_KEYWORDS_PREFIX), $(addprefix :,$(_KEYWORDS_EXTENDS))), $(evalval def_inherit_keyword))
|
---|
513 |
|
---|
514 | endef # def_inherit
|
---|
515 |
|
---|
516 |
|
---|
517 | #
|
---|
518 | # Load global units before doing any inheriting so they can add new properties.
|
---|
519 | #
|
---|
520 | # This only applies to the guys listed in the global USES since there is
|
---|
521 | # no reliable way to deal with things on a target level without first
|
---|
522 | # applying templates. So, to avoid having USES mess up all targets,
|
---|
523 | # we'll make the global and per-target USES property work differently:
|
---|
524 | # The global USES does not apply to targets, just globally.
|
---|
525 | #
|
---|
526 |
|
---|
527 | ## Unit load function.
|
---|
528 | # @param loading The unit name
|
---|
529 | define def_unit_load_function
|
---|
530 | ifndef UNIT_$(loading)
|
---|
531 | UNIT_$(loading)_KMK_FILE := $(firstword $(foreach path, $(KBUILD_UNIT_PATHS) $(KBUILD_PATH)/units $(KBUILD_DEFAULT_PATHS), $(wildcard $(path)/$(loading).kmk)))
|
---|
532 | ifeq ($(UNIT_$(loading)_KMK_FILE),)
|
---|
533 | $(error kBuild: Cannot find include file for the unit '$(loading)'! Searched: $(KBUILD_UNIT_PATHS) $(KBUILD_PATH)/units $(KBUILD_DEFAULT_PATHS))
|
---|
534 | endif
|
---|
535 | include $(UNIT_$(loading)_KMK_FILE)
|
---|
536 | ifndef UNIT_$(loading)
|
---|
537 | $(warning kBuild: UNIT_$(loading) was not defined by $(UNIT_$(loading)_KMK_FILE)!)
|
---|
538 | endif
|
---|
539 | endif
|
---|
540 | endef # def_unit_load_function
|
---|
541 |
|
---|
542 | $(foreach loading, \
|
---|
543 | $(USES.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \
|
---|
544 | $(USES.$(KBUILD_TARGET_CPU)) \
|
---|
545 | $(USES.$(KBUILD_TARGET_ARCH)) \
|
---|
546 | $(USES.$(KBUILD_TARGET)) \
|
---|
547 | $(USES.$(KBUILD_HOST).$(KBUILD_HOST_ARCH)) \
|
---|
548 | $(USES.$(KBUILD_HOST_CPU)) \
|
---|
549 | $(USES.$(KBUILD_HOST_ARCH)) \
|
---|
550 | $(USES.$(KBUILD_TARGET)) \
|
---|
551 | $(USES.$(KBUILD_TYPE)) \
|
---|
552 | $(USES),$(evalval def_unit_load_function))
|
---|
553 |
|
---|
554 |
|
---|
555 | #
|
---|
556 | # Determin all the templates that is being used and make
|
---|
557 | # sure they are present before we try collect keywords.
|
---|
558 | #
|
---|
559 | _TEMPLATES := $(TEMPLATE)
|
---|
560 | define def_templates
|
---|
561 | ifdef $(target)_TEMPLATE
|
---|
562 | ifneq ("$($(target)_TEMPLATE)","$(strip $($(target)_TEMPLATE))")
|
---|
563 | $$(error kBuild: The template name of target '$(target)' contains tabs ($($(target)_TEMPLATE))). Please remove them)
|
---|
564 | endif
|
---|
565 | _TEMPLATES += $($(target)_TEMPLATE)
|
---|
566 | endif
|
---|
567 | endef # def_templates
|
---|
568 | $(foreach target, $(_ALL_TARGETS), $(eval $(def_templates)))
|
---|
569 | _TEMPLATES := $(sort $(_TEMPLATES))
|
---|
570 |
|
---|
571 | ## Template load function.
|
---|
572 | # @param loading The template name. This is prefixed.
|
---|
573 | define def_templates_load_function
|
---|
574 | ifndef TEMPLATE_$(loading)
|
---|
575 | TEMPLATE_$(loading)_KMK_FILE := $(firstword $(foreach path, $(KBUILD_TEMPLATE_PATHS) $(KBUILD_PATH)/templates $(KBUILD_DEFAULT_PATHS), $(wildcard $(path)/$(loading).kmk)))
|
---|
576 | ifeq ($(TEMPLATE_$(loading)_KMK_FILE),)
|
---|
577 | $(error kBuild: Cannot find include file for the template '$(loading)'! Searched: $(KBUILD_TEMPLATE_PATHS) $(KBUILD_PATH)/templates $(KBUILD_DEFAULT_PATHS))
|
---|
578 | endif
|
---|
579 | include $(TEMPLATE_$(loading)_KMK_FILE)
|
---|
580 | ifndef TEMPLATE_$(loading)
|
---|
581 | $(warning kBuild: TEMPLATE_$(loading) was not defined by $(TEMPLATE_$(loading)_KMK_FILE)!)
|
---|
582 | endif
|
---|
583 | endif
|
---|
584 | endef # def_templates_load_function
|
---|
585 | $(foreach loading, $(_TEMPLATES), $(evalval def_templates_load_function))
|
---|
586 |
|
---|
587 |
|
---|
588 | #
|
---|
589 | # Determin the keywords required for correct inherting and setup keyword inheritance.
|
---|
590 | #
|
---|
591 | # This means walking all the lists of immediate template and targets and
|
---|
592 | # pick up all the BLD_T* keywords. Since templates that are referenced
|
---|
593 | # indirectly in the inheritance hierarchy, the result from this exercise
|
---|
594 | # might not be 100% accurate... :-/
|
---|
595 | #
|
---|
596 | _BLD_TYPES := $(KBUILD_TYPE)
|
---|
597 | _BLD_TARGETS := $(KBUILD_TARGET) $(KBUILD_HOSTS)
|
---|
598 | _BLD_ARCHES := $(KBUILD_TARGET_ARCH) $(KBUILD_HOST_ARCH)
|
---|
599 | _BLD_CPUS := $(KBUILD_TARGET_CPU) $(KBUILD_HOST_CPU)
|
---|
600 |
|
---|
601 | define def_collect_bld_xyz
|
---|
602 | ifdef $(src)_BLD_TYPE
|
---|
603 | ifn1of ($($(src)_BLD_TYPE), $(KBUILD_BLD_TYPES))
|
---|
604 | $(error kBuild: $(src)_BLD_TYPE=$($(src)_BLD_TYPE) not in KBUILD_BLD_TYPES={$(KBUILD_BLD_TYPES)}!)
|
---|
605 | endif
|
---|
606 | _BLD_TYPES += $($(src)_BLD_TYPE)
|
---|
607 | endif
|
---|
608 | ifdef $(src)_BLD_TRG
|
---|
609 | ifn1of ($($(src)_BLD_TRG), $(KBUILD_OSES))
|
---|
610 | $(error kBuild: $(src)_BLD_TRG=$($(src)_BLD_TRG) not in KBUILD_OSES={$(KBUILD_OSES)}!)
|
---|
611 | endif
|
---|
612 | _BLD_TARGETS += $($(src)_BLD_TRG)
|
---|
613 | endif
|
---|
614 | ifdef $(src)_BLD_TRG_ARCH
|
---|
615 | ifn1of ($($(src)_BLD_TRG_ARCH), $(KBUILD_ARCHES))
|
---|
616 | $(error kBuild: $(src)_BLD_TRG_ARCH=$($(src)_BLD_TRG_ARCH) not in KBUILD_ARCHES={$(KBUILD_ARCHES)}!)
|
---|
617 | endif
|
---|
618 | _BLD_ARCHES += $($(src)_BLD_TRG_ARCH)
|
---|
619 | endif
|
---|
620 | ifdef $(src)_BLD_TRG_CPU
|
---|
621 | if1of ($($(src)_BLD_CPU), $(KBUILD_ARCHES) $(KBUILD_OSES) $(KBUILD_BLD_TYPES))
|
---|
622 | $(error kBuild: $(src)_BLD_TRG_CPU=$($(src)_BLD_TRG_CPU) found in KBUILD_ARCHES, KBUILD_OSES or KBUILD_BLD_TYPES!)
|
---|
623 | endif
|
---|
624 | _BLD_CPUS += $($(src)_BLD_TRG_CPU)
|
---|
625 | endif
|
---|
626 | endef # def_collect_bld_xyz
|
---|
627 | $(foreach src, $(addprefix TEMPLATE_, $(_TEMPLATES)) $(_ALL_TARGETS) \
|
---|
628 | ,$(evalval def_collect_bld_xyz))
|
---|
629 |
|
---|
630 | # Drop duplicate values.
|
---|
631 | # WARNING! These list might not include keywords only involved in inheritance.
|
---|
632 | _BLD_TYPES := $(sort $(_BLD_TYPES))
|
---|
633 | _BLD_TARGETS := $(sort $(_BLD_TARGETS))
|
---|
634 | _BLD_ARCHES := $(sort $(_BLD_ARCHES))
|
---|
635 | _BLD_CPUS := $(sort $(_BLD_CPUS))
|
---|
636 |
|
---|
637 | ## Look for keywords which extends others and order them.
|
---|
638 | # @param keyword
|
---|
639 | # @param prefix
|
---|
640 | # @param valid
|
---|
641 | define def_keyword_ordering
|
---|
642 | # Check for EXTENDS, fix and validate it if found.
|
---|
643 | local src := $(strip $($(prefix)_$(keyword)_EXTENDS))
|
---|
644 | ifneq ($(src),)
|
---|
645 | ifndef $(prefix)_$(keyword)_EXTENDS_STATUS_
|
---|
646 | ifn1of ($(src), $(valid))
|
---|
647 | $(error kBuild: $(keyword) tries to extend unknown keyword '$(src)'! (known = $(valid)))
|
---|
648 | endif
|
---|
649 |
|
---|
650 | # Recursivly process the parent (src).
|
---|
651 | ifneq ($($(prefix)_$(src)_EXTENDS_STATUS_),42)
|
---|
652 | $(prefix)_$(keyword)_EXTENDS_STATUS_ := 0
|
---|
653 | # 'foreach' will create 'keyword' in a new variable context hiding
|
---|
654 | # out current variable. 'src' OTOH will be overwritten.
|
---|
655 | $(foreach keyword, $(src), $(evalval def_keyword_ordering))
|
---|
656 | local src := $(strip $($(prefix)_$(keyword)_EXTENDS))
|
---|
657 | endif
|
---|
658 |
|
---|
659 | # Check and strip EXTENDS_BY.
|
---|
660 | local by = $(strip $($(prefix)_$(keyword)_EXTENDS_BY))
|
---|
661 | ifeq ($(by),)
|
---|
662 | local by = overriding
|
---|
663 | else ifn1of ($(by), overriding appending prepending)
|
---|
664 | $(error kBuild: Invalid EXTENDS_BY value '$(by)' on '$(keyword)'!)
|
---|
665 | endif
|
---|
666 |
|
---|
667 | # Update the attributes with stripped
|
---|
668 | $(prefix)_$(keyword)_EXTENDS_BY := $(by)
|
---|
669 | $(prefix)_$(keyword)_EXTENDS := $(src)
|
---|
670 |
|
---|
671 | # Add it to the list and mark it as done.
|
---|
672 | _KEYWORDS_EXTENDS += $(keyword)
|
---|
673 | _KEYWORDS_PREFIX += $(prefix)
|
---|
674 | $(prefix)_$(keyword)_EXTENDS_STATUS_ := 42
|
---|
675 | else
|
---|
676 | # Check for inheritance loops.
|
---|
677 | ifneq ($($(trg)_EXTENDS_STATUS_),42)
|
---|
678 | $(error kBuild: Keyword inheritance loop! keyword=$(keyword) $(prefix)_$(keyword)_EXTENDS_STATUS_=$($(prefix)_$(keyword)_EXTENDS_STATUS_))
|
---|
679 | endif
|
---|
680 | endif
|
---|
681 | else
|
---|
682 | # Add it to the ordered list and mark it as done.
|
---|
683 | _KEYWORDS_ORDERED += $(keyword)
|
---|
684 | $(prefix)_$(src)_EXTENDS_STATUS_ := 42
|
---|
685 | endif
|
---|
686 | endef # def_keyword_ordering
|
---|
687 | $(eval-opt-var def_keyword_ordering)
|
---|
688 |
|
---|
689 | # Look for keywords which extends others and their parents, and from this
|
---|
690 | # construct two lists.
|
---|
691 | _KEYWORDS_ORDERED :=
|
---|
692 | _KEYWORDS_EXTENDS :=
|
---|
693 | _KEYWORDS_PREFIX :=
|
---|
694 |
|
---|
695 | prefix := BLD_TYPE
|
---|
696 | valid := $(KBUILD_BLD_TYPES)
|
---|
697 | $(foreach keyword, $(_BLD_TYPES) , $(evalval def_keyword_ordering))
|
---|
698 |
|
---|
699 | prefix := BLD_TRG
|
---|
700 | valid := $(KBUILD_OSES)
|
---|
701 | $(foreach keyword, $(_BLD_TARGETS), $(evalval def_keyword_ordering))
|
---|
702 |
|
---|
703 | prefix := BLD_ARCH
|
---|
704 | valid := $(KBUILD_ARCHES)
|
---|
705 | $(foreach keyword, $(_BLD_ARCHES) , $(evalval def_keyword_ordering))
|
---|
706 |
|
---|
707 | prefix := BLD_CPU
|
---|
708 | valid := $(KBUILD_CPUS)
|
---|
709 | $(foreach keyword, $(_BLD_CPUS) , $(evalval def_keyword_ordering))
|
---|
710 |
|
---|
711 | ## @todo Inherit bld_trg.bld_arch for too?
|
---|
712 |
|
---|
713 | # Construct all the possible keywords.
|
---|
714 | _KEYWORDS := $(_KEYWORDS_ORDERED) $(_KEYWORDS_EXTENDS) \
|
---|
715 | $(foreach bld_trg,$(_BLD_TARGETS),$(addprefix $(bld_trg).,$(_BLD_ARCHES)))
|
---|
716 |
|
---|
717 | ifdef KBUILD_PROFILE_SELF
|
---|
718 | $(evalcall def_profile_self, done keywords)
|
---|
719 | endif
|
---|
720 |
|
---|
721 |
|
---|
722 | #
|
---|
723 | # Target inheritance.
|
---|
724 | #
|
---|
725 | # This has to be done on a per target list basis as to avoid adding
|
---|
726 | # incorrect properties that will wast memory, time, and may confuse
|
---|
727 | # later strictness checks. This also has to be done *before* templates
|
---|
728 | # are applied to the targets. Since we're doing that part rather
|
---|
729 | # early on, the target inheritance feature is a bit restricted at
|
---|
730 | # the moment. However, this will be addressed in a little(?) while.
|
---|
731 | #
|
---|
732 |
|
---|
733 | src_prefix :=
|
---|
734 | load_function :=
|
---|
735 | properties_deferred_l :=
|
---|
736 | properties_deferred_r :=
|
---|
737 |
|
---|
738 | # Fetches.
|
---|
739 | properties := $(PROPS_FETCHES_SINGLE)
|
---|
740 | properties_now_l := $(PROPS_FETCHES_ACCUMULATE_L)
|
---|
741 | properties_now_r := $(PROPS_FETCHES_ACCUMULATE_R)
|
---|
742 | properties_deferred := $(PROPS_FETCHES_DEFERRED)
|
---|
743 | $(foreach trg, $(_ALL_FETCHES),$(evalval def_inherit))
|
---|
744 |
|
---|
745 | ## Patches. - not implemented yet.
|
---|
746 | #properties := $(PROPS_PATCHES_SINGLE)
|
---|
747 | #properties_now_l := $(PROPS_PATCHES_ACCUMULATE_L)
|
---|
748 | #properties_now_r := $(PROPS_PATCHES_ACCUMULATE_R)
|
---|
749 | #properties_deferred := $(PROPS_PATCHES_DEFERRED)
|
---|
750 | #$(foreach trg, $(_ALL_PATCHES),$(evalval def_inherit))
|
---|
751 |
|
---|
752 | # Programs and build programs.
|
---|
753 | properties := $(PROPS_PROGRAMS_SINGLE)
|
---|
754 | properties_now_l := $(PROPS_PROGRAMS_ACCUMULATE_L)
|
---|
755 | properties_now_r := $(PROPS_PROGRAMS_ACCUMULATE_R)
|
---|
756 | properties_deferred := $(PROPS_PROGRAMS_DEFERRED)
|
---|
757 | $(foreach trg, $(_ALL_BLDPROGS) $(_ALL_PROGRAMS),$(evalval def_inherit))
|
---|
758 |
|
---|
759 | # Libraries and import libraries.
|
---|
760 | properties := $(PROPS_LIBRARIES_SINGLE)
|
---|
761 | properties_now_l := $(PROPS_LIBRARIES_ACCUMULATE_L)
|
---|
762 | properties_now_r := $(PROPS_LIBRARIES_ACCUMULATE_R)
|
---|
763 | properties_deferred := $(PROPS_LIBRARIES_DEFERRED)
|
---|
764 | if1of ($(KBUILD_TARGET), nt os2 win)
|
---|
765 | $(foreach trg, $(_ALL_LIBRARIES) $(_ALL_IMPORT_LIBS),$(evalval def_inherit))
|
---|
766 | else
|
---|
767 | $(foreach trg, $(_ALL_LIBRARIES),$(evalval def_inherit))
|
---|
768 | endif
|
---|
769 |
|
---|
770 | # DLLs.
|
---|
771 | properties := $(PROPS_DLLS_SINGLE)
|
---|
772 | properties_now_l := $(PROPS_DLLS_ACCUMULATE_L)
|
---|
773 | properties_now_r := $(PROPS_DLLS_ACCUMULATE_R)
|
---|
774 | properties_deferred := $(PROPS_DLLS_DEFERRED)
|
---|
775 | if1of ($(KBUILD_TARGET), nt os2 win)
|
---|
776 | $(foreach trg, $(_ALL_DLLS),$(evalval def_inherit))
|
---|
777 | else
|
---|
778 | $(foreach trg, $(_ALL_DLLS) $(_ALL_IMPORT_LIBS),$(evalval def_inherit))
|
---|
779 | endif
|
---|
780 |
|
---|
781 | # System modules.
|
---|
782 | properties := $(PROPS_SYSMODS_SINGLE)
|
---|
783 | properties_now_l := $(PROPS_SYSMODS_ACCUMULATE_L)
|
---|
784 | properties_now_r := $(PROPS_SYSMODS_ACCUMULATE_R)
|
---|
785 | properties_deferred := $(PROPS_SYSMODS_DEFERRED)
|
---|
786 | $(foreach trg, $(_ALL_SYSMODS),$(evalval def_inherit))
|
---|
787 |
|
---|
788 | # Misc binaries.
|
---|
789 | properties := $(PROPS_MISCBINS_SINGLE)
|
---|
790 | properties_now_l := $(PROPS_MISCBINS_ACCUMULATE_L)
|
---|
791 | properties_now_r := $(PROPS_MISCBINS_ACCUMULATE_R)
|
---|
792 | properties_deferred := $(PROPS_MISCBINS_DEFERRED)
|
---|
793 | $(foreach trg, $(_ALL_MISCBINS),$(evalval def_inherit))
|
---|
794 |
|
---|
795 | # Installs.
|
---|
796 | properties := $(PROPS_INSTALLS_SINGLE)
|
---|
797 | properties_now_l := $(PROPS_INSTALLS_ACCUMULATE_L)
|
---|
798 | properties_now_r := $(PROPS_INSTALLS_ACCUMULATE_R)
|
---|
799 | properties_deferred := $(PROPS_INSTALLS_DEFERRED)
|
---|
800 | $(foreach trg, $(_ALL_INSTALLS),$(evalval def_inherit))
|
---|
801 |
|
---|
802 | ifdef KBUILD_PROFILE_SELF
|
---|
803 | $(evalcall def_profile_self, done target inheritance)
|
---|
804 | endif
|
---|
805 |
|
---|
806 |
|
---|
807 | #
|
---|
808 | # Template Inheritance.
|
---|
809 | #
|
---|
810 | # This is much the same as with target inheritance, except we cannot
|
---|
811 | # restrict the properties involved since we haven't got a clue which
|
---|
812 | # target platforms/archs are using them. But, we can drop the instance
|
---|
813 | # expansion we're doing for targets since there won't be any more
|
---|
814 | # changes to either the source nor the target templates beyond this
|
---|
815 | # exercise.
|
---|
816 | #
|
---|
817 |
|
---|
818 | src_prefix := TEMPLATE_
|
---|
819 | load_function := def_templates_load_function
|
---|
820 | properties :=
|
---|
821 | properties_now_l :=
|
---|
822 | properties_now_r :=
|
---|
823 | properties_deferred := $(PROPS_SINGLE) $(PROPS_DEFERRED)
|
---|
824 | properties_deferred_l := $(PROPS_ACCUMULATE_L)
|
---|
825 | properties_deferred_r := $(PROPS_ACCUMULATE_R)
|
---|
826 | $(foreach trg, $(addprefix TEMPLATE_,$(_TEMPLATES)),$(evalval def_inherit))
|
---|
827 |
|
---|
828 | # done inheriting.
|
---|
829 | src_prefix :=
|
---|
830 | load_function :=
|
---|
831 | properties :=
|
---|
832 | properties_now_l :=
|
---|
833 | properties_now_r :=
|
---|
834 | properties_deferred :=
|
---|
835 | properties_deferred_l :=
|
---|
836 | properties_deferred_r :=
|
---|
837 |
|
---|
838 | ifdef KBUILD_PROFILE_SELF
|
---|
839 | $(evalcall def_profile_self, done template inheritance)
|
---|
840 | endif
|
---|
841 |
|
---|
842 |
|
---|
843 |
|
---|
844 |
|
---|
845 | #
|
---|
846 | # Template/Target Expansion.
|
---|
847 | #
|
---|
848 | # Extend all targets with the values from the template. Doing this up front
|
---|
849 | # allows more generic code and less mess down in the pass 2 target handling.
|
---|
850 | # However it does eat a good deal of memory.
|
---|
851 | #
|
---|
852 |
|
---|
853 | define def_inherit_template_workaround_target
|
---|
854 | local _tmpl := $(firstword $($(target)_TEMPLATE) $(TEMPLATE))
|
---|
855 | local _bld_type := $(firstword $($(target)_BLD_TYPE) $(TEMPLATE_$(_tmpl)_BLD_TYPE) $(KBUILD_TYPE))
|
---|
856 | local _bld_trg := $(firstword $($(target)_BLD_TRG) $(TEMPLATE_$(_tmpl)_BLD_TRG) $(KBUILD_TARGET))
|
---|
857 | local _bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(TEMPLATE_$(_tmpl)_BLD_TRG_ARCH) $(KBUILD_TARGET_ARCH))
|
---|
858 | local _bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(TEMPLATE_$(_tmpl)_BLD_TRG_CPU) $(KBUILD_TARGET_CPU))
|
---|
859 | $(kb-exp-tmpl 1,$(target),$(_bld_trg),$(_bld_trg_arch),$(_bld_trg_cpu),$(_bld_type))
|
---|
860 | endef # def_inherit_template_workaround_target
|
---|
861 | #$(kb-exp-tmpl 1,$(_ALL_TARGET_TARGETS),$(KBUILD_TARGET),$(KBUILD_TARGET_ARCH),$(KBUILD_TARGET_CPU),$(KBUILD_TYPE))
|
---|
862 | $(foreach target,$(_ALL_TARGET_TARGETS),$(evalval def_inherit_template_workaround_target))
|
---|
863 |
|
---|
864 | define def_inherit_template_workaround_host
|
---|
865 | local _tmpl := $(firstword $($(target)_TEMPLATE) $(TEMPLATE))
|
---|
866 | local _bld_type := $(firstword $($(target)_BLD_TYPE) $(TEMPLATE_$(_tmpl)_BLD_TYPE) $(KBUILD_TYPE))
|
---|
867 | local _bld_trg := $(firstword $($(target)_BLD_TRG) $(TEMPLATE_$(_tmpl)_BLD_TRG) $(KBUILD_HOST))
|
---|
868 | local _bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(TEMPLATE_$(_tmpl)_BLD_TRG_ARCH) $(KBUILD_HOST_ARCH))
|
---|
869 | local _bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(TEMPLATE_$(_tmpl)_BLD_TRG_CPU) $(KBUILD_HOST_CPU))
|
---|
870 | $(kb-exp-tmpl 1,$(target),$(_bld_trg),$(_bld_trg_arch),$(_bld_trg_cpu),$(_bld_type))
|
---|
871 | endef # def_inherit_template_workaround_target
|
---|
872 | #$(kb-exp-tmpl 1,$(_ALL_HOST_TARGETS),$(KBUILD_HOST),$(KBUILD_HOST_ARCH),$(KBUILD_HOST_CPU),$(KBUILD_TYPE))
|
---|
873 | $(foreach target,$(_ALL_HOST_TARGETS),$(evalval def_inherit_template_workaround_host))
|
---|
874 |
|
---|
875 | ifdef KBUILD_PROFILE_SELF
|
---|
876 | $(evalcall def_profile_self, done template/target expansion)
|
---|
877 | endif
|
---|
878 |
|
---|
879 |
|
---|
880 | #
|
---|
881 | # Include tools, sdks and units.
|
---|
882 | #
|
---|
883 | # The first part of this exercise is to figure out which TOOLS and SDKS
|
---|
884 | # that should be included.
|
---|
885 | #
|
---|
886 | _TOOLS := $(TOOL.$(KBUILD_TARGET)) $(TOOL.$(KBUILD_TARGET_ARCH)) $(TOOL.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \
|
---|
887 | $(TOOL.$(KBUILD_HOST)) $(TOOL.$(KBUILD_HOST_ARCH)) $(TOOL.$(KBUILD_HOST).$(KBUILD_HOST_ARCH)) \
|
---|
888 | $(TOOL)
|
---|
889 | _SDKS := $(SDKS.$(KBUILD_TARGET)) $(SDKS.$(KBUILD_TARGET_ARCH)) $(SDKS.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \
|
---|
890 | $(SDKS.$(KBUILD_HOST)) $(SDKS.$(KBUILD_HOST_ARCH)) $(SDKS.$(KBUILD_HOST).$(KBUILD_HOST_ARCH)) \
|
---|
891 | $(SDKS.$(KBUILD_TYPE)) \
|
---|
892 | $(SDKS)
|
---|
893 | _USES := $(USES.$(KBUILD_TARGET)) $(USES.$(KBUILD_TARGET_ARCH)) $(USES.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \
|
---|
894 | $(USES.$(KBUILD_HOST)) $(USES.$(KBUILD_HOST_ARCH)) $(USES.$(KBUILD_HOST).$(KBUILD_HOST_ARCH)) \
|
---|
895 | $(USES.$(KBUILD_TYPE)) \
|
---|
896 | $(USES)
|
---|
897 | define def_tools_sdks_target_source
|
---|
898 | $(eval _TOOLS += $(foreach prop, $(PROPS_TOOLS), \
|
---|
899 | $($(source)_$(prop).$(_bld_trg)) \
|
---|
900 | $($(target)_$(source)_$(prop).$(_bld_trg)) \
|
---|
901 | $($(source)_$(prop).$(_bld_trg).$(_bld_trg_arch)) \
|
---|
902 | $($(target)_$(source)_$(prop).$(_bld_trg).$(_bld_trg_arch)) \
|
---|
903 | $($(source)_$(prop).$(_bld_trg_arch)) \
|
---|
904 | $($(target)_$(source)_$(prop).$(_bld_trg_arch)) \
|
---|
905 | $($(source)_$(prop)) \
|
---|
906 | $($(target)_$(source)_$(prop))))
|
---|
907 | $(eval _SDKS += \
|
---|
908 | $($(source)_SDKS.$(_bld_trg)) \
|
---|
909 | $($(target)_$(source)_SDKS.$(_bld_trg)) \
|
---|
910 | $($(source)_SDKS.$(_bld_trg).$(_bld_trg_arch)) \
|
---|
911 | $($(target)_$(source)_SDKS.$(_bld_trg).$(_bld_trg_arch)) \
|
---|
912 | $($(source)_SDKS.$(_bld_trg_arch)) \
|
---|
913 | $($(target)_$(source)_SDKS.$(_bld_trg_arch)) \
|
---|
914 | $($(source)_SDKS.$(KBUILD_TYPE)) \
|
---|
915 | $($(target)_$(source)_SDKS.$(KBUILD_TYPE)) \
|
---|
916 | $($(source)_SDKS) \
|
---|
917 | $($(target)_$(source)_SDKS))
|
---|
918 | $(eval _USES += \
|
---|
919 | $($(source)_USES.$(_bld_trg)) \
|
---|
920 | $($(target)_$(source)_USES.$(_bld_trg)) \
|
---|
921 | $($(source)_USES.$(_bld_trg).$(_bld_trg_arch)) \
|
---|
922 | $($(target)_$(source)_USES.$(_bld_trg).$(_bld_trg_arch)) \
|
---|
923 | $($(source)_USES.$(_bld_trg_arch)) \
|
---|
924 | $($(target)_$(source)_USES.$(_bld_trg_arch)) \
|
---|
925 | $($(source)_USES.$(KBUILD_TYPE)) \
|
---|
926 | $($(target)_$(source)_USES.$(KBUILD_TYPE)) \
|
---|
927 | $($(source)_USES) \
|
---|
928 | $($(target)_$(source)_USES))
|
---|
929 | endef # def_tools_sdks_target_source
|
---|
930 | $(eval-opt-var def_tools_sdks_target_source)
|
---|
931 |
|
---|
932 | define def_tools_sdks_target
|
---|
933 | local _bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE))
|
---|
934 | local _bld_trg := $(firstword $($(target)_BLD_TRG) $(bld_trg))
|
---|
935 | local _bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(bld_trg_arch))
|
---|
936 | local _bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(bld_trg_cpu))
|
---|
937 |
|
---|
938 | $(eval _TOOLS += $(foreach prop, $(PROPS_TOOLS), \
|
---|
939 | $($(target)_$(prop).$(_bld_trg)) \
|
---|
940 | $($(target)_$(prop).$(_bld_trg_arch)) \
|
---|
941 | $($(target)_$(prop).$(_bld_trg).$(_bld_trg_arch)) \
|
---|
942 | $($(target)_$(prop))))
|
---|
943 | $(eval _SDKS += \
|
---|
944 | $($(target)_SDKS.$(_bld_trg)) \
|
---|
945 | $($(target)_SDKS.$(_bld_trg_arch)) \
|
---|
946 | $($(target)_SDKS.$(_bld_trg).$(_bld_trg_arch)) \
|
---|
947 | $($(target)_SDKS))
|
---|
948 | $(eval _USES += \
|
---|
949 | $($(target)_USES.$(_bld_trg)) \
|
---|
950 | $($(target)_USES.$(_bld_trg_arch)) \
|
---|
951 | $($(target)_USES.$(_bld_trg).$(_bld_trg_arch)) \
|
---|
952 | $($(target)_USES))
|
---|
953 | $(foreach source, \
|
---|
954 | $($(target)_SOURCES.$(_bld_trg)) \
|
---|
955 | $($(target)_SOURCES.$(_bld_trg_arch)) \
|
---|
956 | $($(target)_SOURCES.$(_bld_trg).$(_bld_trg_arch)) \
|
---|
957 | $($(target)_SOURCES.$(_bld_trg_cpu)) \
|
---|
958 | $($(target)_SOURCES.$(_bld_type)) \
|
---|
959 | $($(target)_SOURCES) \
|
---|
960 | , $(evalval def_tools_sdks_target_source))
|
---|
961 | endef # def_tools_sdks_target
|
---|
962 | $(eval-opt-var def_tools_sdks_target)
|
---|
963 |
|
---|
964 | define def_tools_srcname_target
|
---|
965 | local _bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE))
|
---|
966 | local _bld_trg := $(firstword $($(target)_BLD_TRG) $(bld_trg))
|
---|
967 | local _bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(bld_trg_arch))
|
---|
968 | local _bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(bld_trg_cpu))
|
---|
969 |
|
---|
970 | $(foreach source, $(notdir\
|
---|
971 | $($(target)_SOURCES.$(_bld_trg)) \
|
---|
972 | $($(target)_SOURCES.$(_bld_trg_arch)) \
|
---|
973 | $($(target)_SOURCES.$(_bld_trg).$(_bld_trg_arch)) \
|
---|
974 | $($(target)_SOURCES.$(_bld_trg_cpu)) \
|
---|
975 | $($(target)_SOURCES.$(_bld_type)) \
|
---|
976 | $($(target)_SOURCES) \
|
---|
977 | ), $(evalval def_tools_sdks_target_source))
|
---|
978 | endef # def_tools_srcname_target
|
---|
979 | $(eval-opt-var def_tools_srcname_target)
|
---|
980 |
|
---|
981 | bld_trg := $(KBUILD_TARGET)
|
---|
982 | bld_trg_arch := $(KBUILD_TARGET_ARCH)
|
---|
983 | bld_trg_cpu := $(KBUILD_TARGET_CPU)
|
---|
984 | $(foreach target, $(_ALL_TARGET_TARGETS), $(evalval def_tools_sdks_target))
|
---|
985 | $(foreach target, $(_ALL_SRCNAME_TARGETS), $(evalval def_tools_srcname_target))
|
---|
986 |
|
---|
987 | bld_trg := $(KBUILD_HOST)
|
---|
988 | bld_trg_arch := $(KBUILD_HOST_ARCH)
|
---|
989 | bld_trg_cpu := $(KBUILD_HOST_CPU)
|
---|
990 | $(foreach target, $(_ALL_HOST_TARGETS), $(evalval def_tools_sdks_target))
|
---|
991 |
|
---|
992 | _TOOLS := $(sort $(_TOOLS))
|
---|
993 | _SDKS := $(sort $(_SDKS))
|
---|
994 |
|
---|
995 | ## Tool load function.
|
---|
996 | # @param loading The tool name
|
---|
997 | define def_tools_load_function
|
---|
998 | ifndef TOOL_$(loading)
|
---|
999 | TOOL_$(loading)_KMK_FILE := $(firstword $(foreach path, $(KBUILD_TOOL_PATHS) $(KBUILD_PATH)/tools $(KBUILD_DEFAULT_PATHS), $(wildcard $(path)/$(loading).kmk)))
|
---|
1000 | ifeq ($(TOOL_$(loading)_KMK_FILE),)
|
---|
1001 | $(error kBuild: Cannot find include file for the tool '$(loading)'! Searched: $(KBUILD_TOOL_PATHS) $(KBUILD_PATH)/tools $(KBUILD_DEFAULT_PATHS))
|
---|
1002 | endif
|
---|
1003 | include $(TOOL_$(loading)_KMK_FILE)
|
---|
1004 | ifndef TOOL_$(loading)
|
---|
1005 | $(warning kBuild: TOOL_$(loading) was not defined by $(TOOL_$(loading)_KMK_FILE)!)
|
---|
1006 | endif
|
---|
1007 | endif
|
---|
1008 | endef # def_tools_include
|
---|
1009 |
|
---|
1010 | ## SDK load function.
|
---|
1011 | # @param loading The tool name
|
---|
1012 | define def_sdk_load_function
|
---|
1013 | ifndef SDK_$(loading)
|
---|
1014 | SDK_$(loading)_KMK_FILE := $(firstword $(foreach path, $(KBUILD_SDK_PATHS) $(KBUILD_PATH)/sdks $(KBUILD_DEFAULT_PATHS), $(wildcard $(path)/$(loading).kmk)))
|
---|
1015 | ifeq ($(SDK_$(loading)_KMK_FILE),)
|
---|
1016 | $(error kBuild: Cannot find include file for the SDK '$(loading)'! Searched: $(KBUILD_SDK_PATHS) $(KBUILD_PATH)/sdks $(KBUILD_DEFAULT_PATHS))
|
---|
1017 | endif
|
---|
1018 | include $(SDK_$(loading)_KMK_FILE)
|
---|
1019 | ifndef SDK_$(loading)
|
---|
1020 | $(warning kBuild: SDK_$(loading) was not defined by $(SDK_$(loading)_KMK_FILE)!)
|
---|
1021 | endif
|
---|
1022 | endif
|
---|
1023 | endef # def_sdk_load_function
|
---|
1024 |
|
---|
1025 |
|
---|
1026 | properties :=
|
---|
1027 | properties_now_l :=
|
---|
1028 | properties_now_r :=
|
---|
1029 | properties_deferred := $(PROPS_SINGLE) $(PROPS_DEFERRED)
|
---|
1030 | properties_deferred_l := $(PROPS_ACCUMULATE_L)
|
---|
1031 | properties_deferred_r := $(PROPS_ACCUMULATE_R)
|
---|
1032 |
|
---|
1033 | src_prefix := SDK_
|
---|
1034 | load_function := def_sdk_load_function
|
---|
1035 | $(foreach trg, $(addprefix SDK_,$(_SDKS)), $(evalval def_inherit))
|
---|
1036 |
|
---|
1037 | properties_deferred := $(PROPS_SINGLE) $(PROPS_DEFERRED) $(PROPS_TOOLS_ONLY)
|
---|
1038 | src_prefix := TOOL_
|
---|
1039 | load_function := def_tools_load_function
|
---|
1040 | $(foreach trg, $(addprefix TOOL_,$(_TOOLS)), $(evalval def_inherit))
|
---|
1041 |
|
---|
1042 | # done inheriting.
|
---|
1043 | src_prefix :=
|
---|
1044 | load_function :=
|
---|
1045 | properties :=
|
---|
1046 | properties_now_l :=
|
---|
1047 | properties_now_r :=
|
---|
1048 | properties_deferred :=
|
---|
1049 | properties_deferred_l :=
|
---|
1050 | properties_deferred_r :=
|
---|
1051 |
|
---|
1052 | # No inheriting for the uses, they're just global 'code'.
|
---|
1053 | $(foreach loading, $(_USES), $(evalval def_unit_load_function))
|
---|
1054 |
|
---|
1055 |
|
---|
1056 | ifdef KBUILD_PROFILE_SELF
|
---|
1057 | $(evalcall def_profile_self, done tools + sdks + units)
|
---|
1058 | endif
|
---|
1059 |
|
---|