source: trunk/kBuild/footer-inherit-uses-tools.kmk@ 3594

Last change on this file since 3594 was 3594, checked in by bird, 2 years ago

kBuild/footer-inherit-uses-tools.kmk: List users of undefined templates to simplify fixing the issue.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 37.6 KB
Line 
1# $Id: footer-inherit-uses-tools.kmk 3594 2023-06-01 21:07:11Z bird $
2## @file
3# kBuild - Footer - Target lists - Pass 2 - Template & Target Inheritance, Uses and Tools.
4#
5
6#
7# Copyright (c) 2004-2017 knut st. osmundsen <bird-kBuild-spam-xviiv@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.
37define def_simple_2_recursive
38$1_DEFERRED := $$($1)
39$1 = $$($1_DEFERRED)
40endef
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.
48define def_inherit_one_keyword
49ifdef $(trg)_$(prop).$(src_key)
50 ifndef $(trg)_$(prop).$(trg_key)
51 $(trg)_$(prop).$(trg_key) = $($(trg)_$(prop).$(src_key))
52 endif
53endif
54endef
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.
64define def_inherit_one_keyword_overriding_now_l
65ifdef $(trg)_$(prop).$(src_key)
66 ifndef $(trg)_$(prop).$(trg_key)
67 $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(src_key))
68 endif
69endif
70endef
71
72## @copydoc def_inherit_one_overriding_now_l
73define def_inherit_one_keyword_overriding_now_r
74ifdef $(trg)_$(prop).$(src_key)
75 ifndef $(trg)_$(prop).$(trg_key)
76 $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(src_key))
77 endif
78endif
79endef
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
87define def_inherit_one_keyword_overriding_deferred
88ifdef $(trg)_$(prop).$(src_key)
89 ifndef $(trg)_$(prop).$(trg_key)
90 $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key))
91 endif
92endif
93endef
94
95## @copydoc def_inherit_one_overriding_deferred
96define def_inherit_one_keyword_overriding_deferred_l
97ifdef $(trg)_$(prop).$(src_key)
98 ifndef $(trg)_$(prop).$(trg_key)
99 $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key))
100 endif
101endif
102endef
103
104## @copydoc def_inherit_one_overriding_deferred
105define def_inherit_one_keyword_overriding_deferred_r
106ifdef $(trg)_$(prop).$(src_key)
107 ifndef $(trg)_$(prop).$(trg_key)
108 $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key))
109 endif
110endif
111endef
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.
121define def_inherit_one_keyword_prepending_now_l
122ifdef $(trg)_$(prop).$(src_key)
123 $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(src_key)) $($(trg)_$(prop).$(trg_key))
124endif
125endef
126
127## @copydoc def_inherit_one_prepending_now_l
128define def_inherit_one_keyword_prepending_now_r
129ifdef $(trg)_$(prop).$(src_key)
130 $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(trg_key)) $($(trg)_$(prop).$(src_key))
131endif
132endef
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
140define def_inherit_one_keyword_prepending_deferred
141ifdef $(trg)_$(prop).$(src_key)
142 ifndef $(trg)_$(prop).$(trg_key)
143 $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key))
144 endif
145endif
146endef
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.
153define def_inherit_one_keyword_prepending_deferred_l
154ifdef $(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))
159endif
160endef
161
162## @copydoc def_inherit_one_prepending_deferred_l
163define def_inherit_one_keyword_prepending_deferred_r
164ifdef $(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))
169endif
170endef
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.
180define def_inherit_one_keyword_appending_now_l
181ifdef $(trg)_$(prop).$(src_key)
182 $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(trg_key)) $($(trg)_$(prop).$(src_key))
183endif
184endef
185
186## @copydoc def_inherit_one_appending_now_l
187define def_inherit_one_keyword_appending_now_r
188ifdef $(trg)_$(prop).$(src_key)
189 $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(src_key)) $($(trg)_$(prop).$(trg_key))
190endif
191endef
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
199define def_inherit_one_keyword_appending_deferred
200ifdef $(trg)_$(prop).$(src_key)
201 ifndef $(trg)_$(prop).$(trg_key)
202 $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key))
203 endif
204endif
205endef
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.
212define def_inherit_one_keyword_appending_deferred_l
213ifdef $(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))
218endif
219endef
220
221## @copydoc def_inherit_one_appending_deferred_l
222define def_inherit_one_keyword_appending_deferred_r
223ifdef $(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))
228endif
229endef
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.
242define def_inherit_keyword
243local prefix := $(word 1,$(subst :, ,$(prefix_keyword)))
244local trg_key := $(word 2,$(subst :, ,$(prefix_keyword)))
245local src_key := $($(prefix)_$(trg_key)_EXTENDS)
246local 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
256endef # 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.
263define def_inherit_one
264ifdef $(src)_$(prop)
265 ifndef $(trg)_$(prop)
266 $(trg)_$(prop) = $($(src)_$(prop))
267 endif
268endif
269endef
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.
278define def_inherit_one_overriding_now_l
279ifdef $(src)_$(prop)
280 ifndef $(trg)_$(prop)
281 $(trg)_$(prop) := $($(src)_$(prop))
282 endif
283endif
284endef
285
286## @copydoc def_inherit_one_overriding_now_l
287define def_inherit_one_overriding_now_r
288ifdef $(src)_$(prop)
289 ifndef $(trg)_$(prop)
290 $(trg)_$(prop) := $($(src)_$(prop))
291 endif
292endif
293endef
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
300define def_inherit_one_overriding_deferred
301ifdef $(src)_$(prop)
302 ifndef $(trg)_$(prop)
303 $(trg)_$(prop) = $$($(src)_$(prop))
304 endif
305endif
306endef
307
308## @copydoc def_inherit_one_overriding_deferred
309define def_inherit_one_overriding_deferred_l
310ifdef $(src)_$(prop)
311 ifndef $(trg)_$(prop)
312 $(trg)_$(prop) = $$($(src)_$(prop))
313 endif
314endif
315endef
316
317## @copydoc def_inherit_one_overriding_deferred
318define def_inherit_one_overriding_deferred_r
319ifdef $(src)_$(prop)
320 ifndef $(trg)_$(prop)
321 $(trg)_$(prop) = $$($(src)_$(prop))
322 endif
323endif
324endef
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.
333define def_inherit_one_prepending_now_l
334ifdef $(src)_$(prop)
335 $(trg)_$(prop) := $($(src)_$(prop)) $($(trg)_$(prop))
336endif
337endef
338
339## @copydoc def_inherit_one_prepending_now_l
340define def_inherit_one_prepending_now_r
341ifdef $(src)_$(prop)
342 $(trg)_$(prop) := $($(trg)_$(prop)) $($(src)_$(prop))
343endif
344endef
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
351define def_inherit_one_prepending_deferred
352ifdef $(src)_$(prop)
353 ifndef $(trg)_$(prop)
354 $(trg)_$(prop) = $$($(src)_$(prop))
355 endif
356endif
357endef
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.
363define def_inherit_one_prepending_deferred_l
364ifdef $(src)_$(prop)
365 ifeq ($$(flavor $(trg)_$(prop)),simple)
366 $$(evalcall2 def_simple_2_recursive,$(trg)_$(prop))
367 endif
368 $(trg)_$(prop) <= $$($(src)_$(prop))
369endif
370endef
371
372## @copydoc def_inherit_one_prepending_deferred_l
373define def_inherit_one_prepending_deferred_r
374ifdef $(src)_$(prop)
375 ifeq ($$(flavor $(trg)_$(prop)),simple)
376 $$(evalcall2 def_simple_2_recursive,$(trg)_$(prop))
377 endif
378 $(trg)_$(prop) += $$($(src)_$(prop))
379endif
380endef
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.
389define def_inherit_one_appending_now_l
390ifdef $(src)_$(prop)
391 $(trg)_$(prop) := $($(trg)_$(prop)) $($(src)_$(prop))
392endif
393endef
394
395## @copydoc def_inherit_one_appending_now_l
396define def_inherit_one_appending_now_r
397ifdef $(src)_$(prop)
398 $(trg)_$(prop) := $($(src)_$(prop)) $($(trg)_$(prop))
399endif
400endef
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
407define def_inherit_one_appending_deferred
408ifdef $(src)_$(prop)
409 ifndef $(trg)_$(prop)
410 $(trg)_$(prop) = $$($(src)_$(prop))
411 endif
412endif
413endef
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.
419define def_inherit_one_appending_deferred_l
420ifdef $(src)_$(prop)
421 ifeq ($$(flavor $(trg)_$(prop)),simple)
422 $$(evalcall2 def_simple_2_recursive,$(trg)_$(prop))
423 endif
424 $(trg)_$(prop) += $$($(src)_$(prop))
425endif
426endef
427
428## @copydoc def_inherit_one_appending_deferred_l
429define def_inherit_one_appending_deferred_r
430ifdef $(src)_$(prop)
431 ifeq ($$(flavor $(trg)_$(prop)),simple)
432 $$(evalcall2 def_simple_2_recursive,$(trg)_$(prop))
433 endif
434 $(trg)_$(prop) <= $$($(src)_$(prop))
435endif
436endef
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.
453define def_inherit
454
455# Load it - loading is a mess, fix.
456ifneq ($(load_function),)
457 local loading := $(patsubst $(src_prefix)%,%,$(trg))
458 $(evalvalctx $(load_function))
459endif
460
461local src := $(strip $($(trg)_EXTENDS))
462ifneq ($(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
509endif
510
511# Keyword inheritance.
512$(foreach prefix_keyword, $(join $(_KEYWORDS_PREFIX), $(addprefix :,$(_KEYWORDS_EXTENDS))), $(evalval def_inherit_keyword))
513
514endef # 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
529define def_unit_load_function
530ifndef 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
539endif
540endef # 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)
560define def_templates
561ifdef $(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)
566endif
567endef # 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.
573define def_templates_load_function
574ifndef 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) Used by target(s): $(strip $(foreach target, $(_ALL_TARGETS),$(if-expr "$($(target)_TEMPLATE)" == "$(loading)",$(target) (in $(where $(target)_TEMPLATE)),))))
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
583endif
584endef # 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
601define def_collect_bld_xyz
602ifdef $(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)
607endif
608ifdef $(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)
613endif
614ifdef $(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)
619endif
620ifdef $(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)
625endif
626endef # 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
641define def_keyword_ordering
642# Check for EXTENDS, fix and validate it if found.
643local src := $(strip $($(prefix)_$(keyword)_EXTENDS))
644ifneq ($(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
681else
682 # Add it to the ordered list and mark it as done.
683 _KEYWORDS_ORDERED += $(keyword)
684 $(prefix)_$(src)_EXTENDS_STATUS_ := 42
685endif
686endef # 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
695prefix := BLD_TYPE
696valid := $(KBUILD_BLD_TYPES)
697$(foreach keyword, $(_BLD_TYPES) , $(evalval def_keyword_ordering))
698
699prefix := BLD_TRG
700valid := $(KBUILD_OSES)
701$(foreach keyword, $(_BLD_TARGETS), $(evalval def_keyword_ordering))
702
703prefix := BLD_ARCH
704valid := $(KBUILD_ARCHES)
705$(foreach keyword, $(_BLD_ARCHES) , $(evalval def_keyword_ordering))
706
707prefix := BLD_CPU
708valid := $(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
717ifdef KBUILD_PROFILE_SELF
718 $(evalcall def_profile_self, done keywords)
719endif
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
733src_prefix :=
734load_function :=
735properties_deferred_l :=
736properties_deferred_r :=
737
738# Fetches.
739properties := $(PROPS_FETCHES_SINGLE)
740properties_now_l := $(PROPS_FETCHES_ACCUMULATE_L)
741properties_now_r := $(PROPS_FETCHES_ACCUMULATE_R)
742properties_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.
753properties := $(PROPS_PROGRAMS_SINGLE)
754properties_now_l := $(PROPS_PROGRAMS_ACCUMULATE_L)
755properties_now_r := $(PROPS_PROGRAMS_ACCUMULATE_R)
756properties_deferred := $(PROPS_PROGRAMS_DEFERRED)
757$(foreach trg, $(_ALL_BLDPROGS) $(_ALL_PROGRAMS),$(evalval def_inherit))
758
759# Libraries and import libraries.
760properties := $(PROPS_LIBRARIES_SINGLE)
761properties_now_l := $(PROPS_LIBRARIES_ACCUMULATE_L)
762properties_now_r := $(PROPS_LIBRARIES_ACCUMULATE_R)
763properties_deferred := $(PROPS_LIBRARIES_DEFERRED)
764if1of ($(KBUILD_TARGET), nt os2 win)
765 $(foreach trg, $(_ALL_LIBRARIES) $(_ALL_IMPORT_LIBS),$(evalval def_inherit))
766else
767 $(foreach trg, $(_ALL_LIBRARIES),$(evalval def_inherit))
768endif
769
770# DLLs.
771properties := $(PROPS_DLLS_SINGLE)
772properties_now_l := $(PROPS_DLLS_ACCUMULATE_L)
773properties_now_r := $(PROPS_DLLS_ACCUMULATE_R)
774properties_deferred := $(PROPS_DLLS_DEFERRED)
775if1of ($(KBUILD_TARGET), nt os2 win)
776 $(foreach trg, $(_ALL_DLLS),$(evalval def_inherit))
777else
778 $(foreach trg, $(_ALL_DLLS) $(_ALL_IMPORT_LIBS),$(evalval def_inherit))
779endif
780
781# System modules.
782properties := $(PROPS_SYSMODS_SINGLE)
783properties_now_l := $(PROPS_SYSMODS_ACCUMULATE_L)
784properties_now_r := $(PROPS_SYSMODS_ACCUMULATE_R)
785properties_deferred := $(PROPS_SYSMODS_DEFERRED)
786$(foreach trg, $(_ALL_SYSMODS),$(evalval def_inherit))
787
788# Misc binaries.
789properties := $(PROPS_MISCBINS_SINGLE)
790properties_now_l := $(PROPS_MISCBINS_ACCUMULATE_L)
791properties_now_r := $(PROPS_MISCBINS_ACCUMULATE_R)
792properties_deferred := $(PROPS_MISCBINS_DEFERRED)
793$(foreach trg, $(_ALL_MISCBINS),$(evalval def_inherit))
794
795# Installs.
796properties := $(PROPS_INSTALLS_SINGLE)
797properties_now_l := $(PROPS_INSTALLS_ACCUMULATE_L)
798properties_now_r := $(PROPS_INSTALLS_ACCUMULATE_R)
799properties_deferred := $(PROPS_INSTALLS_DEFERRED)
800$(foreach trg, $(_ALL_INSTALLS),$(evalval def_inherit))
801
802ifdef KBUILD_PROFILE_SELF
803 $(evalcall def_profile_self, done target inheritance)
804endif
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
818src_prefix := TEMPLATE_
819load_function := def_templates_load_function
820properties :=
821properties_now_l :=
822properties_now_r :=
823properties_deferred := $(PROPS_SINGLE) $(PROPS_DEFERRED)
824properties_deferred_l := $(PROPS_ACCUMULATE_L)
825properties_deferred_r := $(PROPS_ACCUMULATE_R)
826$(foreach trg, $(addprefix TEMPLATE_,$(_TEMPLATES)),$(evalval def_inherit))
827
828# done inheriting.
829src_prefix :=
830load_function :=
831properties :=
832properties_now_l :=
833properties_now_r :=
834properties_deferred :=
835properties_deferred_l :=
836properties_deferred_r :=
837
838ifdef KBUILD_PROFILE_SELF
839 $(evalcall def_profile_self, done template inheritance)
840endif
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
853define def_inherit_template_workaround_target
854local _tmpl := $(firstword $($(target)_TEMPLATE) $(TEMPLATE))
855local _bld_type := $(firstword $($(target)_BLD_TYPE) $(TEMPLATE_$(_tmpl)_BLD_TYPE) $(KBUILD_TYPE))
856local _bld_trg := $(firstword $($(target)_BLD_TRG) $(TEMPLATE_$(_tmpl)_BLD_TRG) $(KBUILD_TARGET))
857local _bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(TEMPLATE_$(_tmpl)_BLD_TRG_ARCH) $(KBUILD_TARGET_ARCH))
858local _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))
860endef # 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
864define def_inherit_template_workaround_host
865local _tmpl := $(firstword $($(target)_TEMPLATE) $(TEMPLATE))
866local _bld_type := $(firstword $($(target)_BLD_TYPE) $(TEMPLATE_$(_tmpl)_BLD_TYPE) $(KBUILD_TYPE))
867local _bld_trg := $(firstword $($(target)_BLD_TRG) $(TEMPLATE_$(_tmpl)_BLD_TRG) $(KBUILD_HOST))
868local _bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(TEMPLATE_$(_tmpl)_BLD_TRG_ARCH) $(KBUILD_HOST_ARCH))
869local _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))
871endef # 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
875ifdef KBUILD_PROFILE_SELF
876 $(evalcall def_profile_self, done template/target expansion)
877endif
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)
897define 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))
929endef # def_tools_sdks_target_source
930$(eval-opt-var def_tools_sdks_target_source)
931
932define def_tools_sdks_target
933local _bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE))
934local _bld_trg := $(firstword $($(target)_BLD_TRG) $(bld_trg))
935local _bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(bld_trg_arch))
936local _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))
961endef # def_tools_sdks_target
962$(eval-opt-var def_tools_sdks_target)
963
964define def_tools_srcname_target
965local _bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE))
966local _bld_trg := $(firstword $($(target)_BLD_TRG) $(bld_trg))
967local _bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(bld_trg_arch))
968local _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))
978endef # def_tools_srcname_target
979$(eval-opt-var def_tools_srcname_target)
980
981bld_trg := $(KBUILD_TARGET)
982bld_trg_arch := $(KBUILD_TARGET_ARCH)
983bld_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
987bld_trg := $(KBUILD_HOST)
988bld_trg_arch := $(KBUILD_HOST_ARCH)
989bld_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
997define def_tools_load_function
998ifndef 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
1007endif
1008endef # def_tools_include
1009
1010## SDK load function.
1011# @param loading The tool name
1012define def_sdk_load_function
1013ifndef 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
1022endif
1023endef # def_sdk_load_function
1024
1025
1026properties :=
1027properties_now_l :=
1028properties_now_r :=
1029properties_deferred := $(PROPS_SINGLE) $(PROPS_DEFERRED)
1030properties_deferred_l := $(PROPS_ACCUMULATE_L)
1031properties_deferred_r := $(PROPS_ACCUMULATE_R)
1032
1033src_prefix := SDK_
1034load_function := def_sdk_load_function
1035$(foreach trg, $(addprefix SDK_,$(_SDKS)), $(evalval def_inherit))
1036
1037properties_deferred := $(PROPS_SINGLE) $(PROPS_DEFERRED) $(PROPS_TOOLS_ONLY)
1038src_prefix := TOOL_
1039load_function := def_tools_load_function
1040$(foreach trg, $(addprefix TOOL_,$(_TOOLS)), $(evalval def_inherit))
1041
1042# done inheriting.
1043src_prefix :=
1044load_function :=
1045properties :=
1046properties_now_l :=
1047properties_now_r :=
1048properties_deferred :=
1049properties_deferred_l :=
1050properties_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
1056ifdef KBUILD_PROFILE_SELF
1057 $(evalcall def_profile_self, done tools + sdks + units)
1058endif
1059
Note: See TracBrowser for help on using the repository browser.