3 # kBuild - File included at top of makefile.
7 # Copyright (c) 2004-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net>
9 # This file is part of kBuild.
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.
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.
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
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.
35 # start-of-file-content
36 ifdef KBUILD_PROFILE_SELF
37 $(evalcall def_profile_self
, start of footer.kmk
)
38 _KBUILD_TS_FOOTER_START
:= $(_KBUILD_TS_PREV
)
43 # (Some of these need initialization before including definitions using them.)
46 # All targets of each types.
47 _ALL_BLDPROGS
:= $(BLDPROGS
) $(BLDPROGS.
$(KBUILD_HOST
)) $(BLDPROGS.
$(KBUILD_HOST
).
$(KBUILD_HOST_ARCH
)) $(BLDPROGS.
$(KBUILD_HOST_ARCH
)) $(BLDPROGS.
$(KBUILD_HOST_CPU
)) $(BLDPROGS.
$(KBUILD_TYPE
))
48 _ALL_LIBRARIES
:= $(LIBRARIES
) $(LIBRARIES.
$(KBUILD_TARGET
)) $(LIBRARIES.
$(KBUILD_TARGET
).
$(KBUILD_TARGET_ARCH
)) $(LIBRARIES.
$(KBUILD_TARGET_ARCH
)) $(LIBRARIES.
$(KBUILD_TARGET_CPU
)) $(LIBRARIES.
$(KBUILD_TYPE
))
49 _ALL_IMPORT_LIBS
:= $(IMPORT_LIBS
) $(IMPORT_LIBS.
$(KBUILD_TARGET
)) $(IMPORT_LIBS.
$(KBUILD_TARGET
).
$(KBUILD_TARGET_ARCH
)) $(IMPORT_LIBS.
$(KBUILD_TARGET_ARCH
)) $(IMPORT_LIBS.
$(KBUILD_TARGET_CPU
)) $(IMPORT_LIBS.
$(KBUILD_TYPE
))
50 _ALL_DLLS
:= $(DLLS
) $(DLLS.
$(KBUILD_TARGET
)) $(DLLS.
$(KBUILD_TARGET
).
$(KBUILD_TARGET_ARCH
)) $(DLLS.
$(KBUILD_TARGET_ARCH
)) $(DLLS.
$(KBUILD_TARGET_CPU
)) $(DLLS.
$(KBUILD_TYPE
))
51 _ALL_PROGRAMS
:= $(PROGRAMS
) $(PROGRAMS.
$(KBUILD_TARGET
)) $(PROGRAMS.
$(KBUILD_TARGET
).
$(KBUILD_TARGET_ARCH
)) $(PROGRAMS.
$(KBUILD_TARGET_ARCH
)) $(PROGRAMS.
$(KBUILD_TARGET_CPU
)) $(PROGRAMS.
$(KBUILD_TYPE
))
52 _ALL_SYSMODS
:= $(SYSMODS
) $(SYSMODS.
$(KBUILD_TARGET
)) $(SYSMODS.
$(KBUILD_TARGET
).
$(KBUILD_TARGET_ARCH
)) $(SYSMODS.
$(KBUILD_TARGET_ARCH
)) $(SYSMODS.
$(KBUILD_TARGET_CPU
)) $(SYSMODS.
$(KBUILD_TYPE
))
53 _ALL_MISCBINS
:= $(MISCBINS
) $(MISCBINS.
$(KBUILD_TARGET
)) $(MISCBINS.
$(KBUILD_TARGET
).
$(KBUILD_TARGET_ARCH
)) $(MISCBINS.
$(KBUILD_TARGET_ARCH
)) $(MISCBINS.
$(KBUILD_TARGET_CPU
)) $(MISCBINS.
$(KBUILD_TYPE
))
54 _ALL_OTHERS
:= $(OTHERS
) $(OTHERS.
$(KBUILD_TARGET
)) $(OTHERS.
$(KBUILD_TARGET
).
$(KBUILD_TARGET_ARCH
)) $(OTHERS.
$(KBUILD_TARGET_ARCH
)) $(OTHERS.
$(KBUILD_TARGET_CPU
)) $(OTHERS.
$(KBUILD_TYPE
))
55 _ALL_INSTALLS
:= $(INSTALLS
) $(INSTALLS.
$(KBUILD_TARGET
)) $(INSTALLS.
$(KBUILD_TARGET
).
$(KBUILD_TARGET_ARCH
)) $(INSTALLS.
$(KBUILD_TARGET_ARCH
)) $(INSTALLS.
$(KBUILD_TARGET_CPU
)) $(INSTALLS.
$(KBUILD_TYPE
))
56 _ALL_FETCHES
:= $(FETCHES
) $(FETCHES.
$(KBUILD_TARGET
)) $(FETCHES.
$(KBUILD_TARGET
).
$(KBUILD_TARGET_ARCH
)) $(FETCHES.
$(KBUILD_TARGET_ARCH
)) $(FETCHES.
$(KBUILD_TARGET_CPU
)) $(FETCHES.
$(KBUILD_TYPE
))
57 _ALL_PATCHES
:= $(PATCHES
) $(PATCHES.
$(KBUILD_TARGET
)) $(PATCHES.
$(KBUILD_TARGET
).
$(KBUILD_TARGET_ARCH
)) $(PATCHES.
$(KBUILD_TARGET_ARCH
)) $(PATCHES.
$(KBUILD_TARGET_CPU
)) $(PATCHES.
$(KBUILD_TYPE
))
73 # all $(KBUILD_TARGET) targets.
74 _ALL_TARGET_TARGETS
= \
86 # all $(KBUILD_HOST) targets.
90 # all targets making use of srcname.
91 _ALL_SRCNAME_TARGETS
= \
95 # Dependency files. (currently not on target level, only this global stuff)
96 _DEPFILES
:= $(DEPFILES
) $(DEPFILES.
$(KBUILD_TARGET
)) $(DEPFILES.
$(KBUILD_TARGET
).
$(KBUILD_TARGET_ARCH
)) $(DEPFILES.
$(KBUILD_TARGET_ARCH
)) $(DEPFILES.
$(KBUILD_TARGET_CPU
)) $(DEPFILES.
$(KBUILD_TYPE
))
98 # included dependency files.
102 # All kind of output files except for _OBJS and _DEPFILES.
103 # Compiling or linking definition outputting other things that $@ and any
104 # required dependency file must add those output files to this variable.
107 # Files which only requires cleaning up.
128 _DIRS
:= $(PATH_TARGET
)/ $(PATH_TARGET
) $(BLDDIRS
)
140 ## Figure out the tool for a target.
141 # @param $1 normalized target.
142 # @param $2 tooltype.
143 # @param bld_trg build target.
144 # @param bld_trg_arch build target architecture.
145 _TARGET_TOOL
= $(strip $(firstword \
146 $($(1)_
$(2)TOOL.
$(bld_trg
).
$(bld_trg_arch
)) \
147 $($(1)_
$(2)TOOL.
$(bld_trg
)) \
149 $($(1)_TOOL.
$(bld_trg
).
$(bld_trg_arch
)) \
150 $($(1)_TOOL.
$(bld_trg
)) \
152 $($(2)TOOL.
$(bld_trg
).
$(bld_trg_arch
)) \
153 $($(2)TOOL.
$(bld_trg
)) \
155 $(TOOL.
$(bld_trg
).
$(bld_trg_arch
)) \
160 ## Figure out the actual name of an installed file.
161 # @param $1 The file to install.
162 # @param $2 The target name.
163 # @param $3 The _INST value (can be empty).
164 # @param $4 The default directory to use when $3 is empty.
165 _INSTALL_FILE
= $(patsubst %/,%/$(notdir $(1)),$(if
$(3),$(PATH_INS
)/$(3),$(4)/))
169 ## Converts a variable from simple to recursive flavor.
170 # This is used by def_inherit_template_one_accumulate_l and def_inherit_template_one_accumulate_r.
171 # @param $1 The variable name.
172 define def_simple_2_recursive
173 $1_DEFERRED := $$($1)
178 ## Inherit one keyword in a non-accumulative manner.
179 # @param $(trg) Target object.
180 # @param $(prop) The property.
181 # @param $(src_key) Source keyword.
182 # @param $(trg_key) Target keyword.
183 define def_inherit_one_keyword
184 ifdef $(trg
)_
$(prop
).
$(src_key
)
185 ifndef $(trg
)_
$(prop
).
$(trg_key
)
186 $(trg
)_
$(prop
).
$(trg_key
) = $($(trg
)_
$(prop
).
$(src_key
))
192 # EXPAND_BY = overriding
194 ## Inherit one keyword in a non-accumulative manner.
195 # @param $(trg) Target object.
196 # @param $(prop) The property.
197 # @param $(src_key) Source keyword.
198 # @param $(trg_key) Target keyword.
199 define def_inherit_one_keyword_overriding_now_l
200 ifdef $(trg
)_
$(prop
).
$(src_key
)
201 ifndef $(trg
)_
$(prop
).
$(trg_key
)
202 $(trg
)_
$(prop
).
$(trg_key
) := $($(trg
)_
$(prop
).
$(src_key
))
207 ## @copydoc def_inherit_one_overriding_now_l
208 define def_inherit_one_keyword_overriding_now_r
209 ifdef $(trg
)_
$(prop
).
$(src_key
)
210 ifndef $(trg
)_
$(prop
).
$(trg_key
)
211 $(trg
)_
$(prop
).
$(trg_key
) := $($(trg
)_
$(prop
).
$(src_key
))
216 ## Inherit one keyword in a non-accumulative manner, deferred expansion.
217 # @param $(trg) Target object.
218 # @param $(prop) The property.
219 # @param $(src_key) Source keyword.
220 # @param $(trg_key) Target keyword.
221 # @remark This define relies on double evaluation
222 define def_inherit_one_keyword_overriding_deferred
223 ifdef $(trg
)_
$(prop
).
$(src_key
)
224 ifndef $(trg
)_
$(prop
).
$(trg_key
)
225 $(trg
)_
$(prop
).
$(trg_key
) = $$($(trg
)_
$(prop
).
$(src_key
))
230 ## @copydoc def_inherit_one_overriding_deferred
231 define def_inherit_one_keyword_overriding_deferred_l
232 ifdef $(trg
)_
$(prop
).
$(src_key
)
233 ifndef $(trg
)_
$(prop
).
$(trg_key
)
234 $(trg
)_
$(prop
).
$(trg_key
) = $$($(trg
)_
$(prop
).
$(src_key
))
239 ## @copydoc def_inherit_one_overriding_deferred
240 define def_inherit_one_keyword_overriding_deferred_r
241 ifdef $(trg
)_
$(prop
).
$(src_key
)
242 ifndef $(trg
)_
$(prop
).
$(trg_key
)
243 $(trg
)_
$(prop
).
$(trg_key
) = $$($(trg
)_
$(prop
).
$(src_key
))
249 # EXPAND_BY = prepending
251 ## Inherit one keyword in a prepending manner.
252 # @param $(trg) Target object.
253 # @param $(prop) The property.
254 # @param $(src_key) Source keyword.
255 # @param $(trg_key) Target keyword.
256 define def_inherit_one_keyword_prepending_now_l
257 ifdef $(trg
)_
$(prop
).
$(src_key
)
258 $(trg
)_
$(prop
).
$(trg_key
) := $($(trg
)_
$(prop
).
$(src_key
)) $($(trg
)_
$(prop
).
$(trg_key
))
262 ## @copydoc def_inherit_one_prepending_now_l
263 define def_inherit_one_keyword_prepending_now_r
264 ifdef $(trg
)_
$(prop
).
$(src_key
)
265 $(trg
)_
$(prop
).
$(trg_key
) := $($(trg
)_
$(prop
).
$(trg_key
)) $($(trg
)_
$(prop
).
$(src_key
))
269 ## Inherit one keyword in a non-accumulative manner, deferred expansion.
270 # @param $(trg) Target object.
271 # @param $(prop) The property.
272 # @param $(src_key) Source keyword.
273 # @param $(trg_key) Target keyword.
274 # @remark This define relies on double evaluation
275 define def_inherit_one_keyword_prepending_deferred
276 ifdef $(trg
)_
$(prop
).
$(src_key
)
277 ifndef $(trg
)_
$(prop
).
$(trg_key
)
278 $(trg
)_
$(prop
).
$(trg_key
) = $$($(trg
)_
$(prop
).
$(src_key
))
283 ## Inherit one keyword in a prepending manner, deferred expansion.
284 # @param $(trg) Target object.
285 # @param $(prop) The property.
286 # @param $(src_key) Source keyword.
287 # @param $(trg_key) Target keyword.
288 define def_inherit_one_keyword_prepending_deferred_l
289 ifdef $(trg
)_
$(prop
).
$(src_key
)
290 ifeq ($$(flavor
$(trg
)_
$(prop
).
$(trg_key
)),simple
)
291 $$(evalcall2 def_simple_2_recursive
,$(trg
)_
$(prop
).
$(trg_key
))
293 $(trg
)_
$(prop
).
$(trg_key
) <= $$($(trg
)_
$(prop
).
$(src_key
))
297 ## @copydoc def_inherit_one_prepending_deferred_l
298 define def_inherit_one_keyword_prepending_deferred_r
299 ifdef $(trg
)_
$(prop
).
$(src_key
)
300 ifeq ($$(flavor
$(trg
)_
$(prop
).
$(trg_key
)),simple
)
301 $$(evalcall2 def_simple_2_recursive
,$(trg
)_
$(prop
).
$(trg_key
))
303 $(trg
)_
$(prop
).
$(trg_key
) += $$($(trg
)_
$(prop
).
$(src_key
))
308 # EXPAND_BY = appending
310 ## Inherit one keyword in an appending manner.
311 # @param $(trg) Target object.
312 # @param $(prop) The property.
313 # @param $(src_key) Source keyword.
314 # @param $(trg_key) Target keyword.
315 define def_inherit_one_keyword_appending_now_l
316 ifdef $(trg
)_
$(prop
).
$(src_key
)
317 $(trg
)_
$(prop
).
$(trg_key
) := $($(trg
)_
$(prop
).
$(trg_key
)) $($(trg
)_
$(prop
).
$(src_key
))
321 ## @copydoc def_inherit_one_appending_now_l
322 define def_inherit_one_keyword_appending_now_r
323 ifdef $(trg
)_
$(prop
).
$(src_key
)
324 $(trg
)_
$(prop
).
$(trg_key
) := $($(trg
)_
$(prop
).
$(src_key
)) $($(trg
)_
$(prop
).
$(trg_key
))
328 ## Inherit one keyword in a non-accumulative manner, deferred expansion.
329 # @param $(trg) Target object.
330 # @param $(prop) The property.
331 # @param $(src_key) Source keyword.
332 # @param $(trg_key) Target keyword.
333 # @remark This define relies on double evaluation
334 define def_inherit_one_keyword_appending_deferred
335 ifdef $(trg
)_
$(prop
).
$(src_key
)
336 ifndef $(trg
)_
$(prop
).
$(trg_key
)
337 $(trg
)_
$(prop
).
$(trg_key
) = $$($(trg
)_
$(prop
).
$(src_key
))
342 ## Inherit one keyword in an appending manner, deferred expansion.
343 # @param $(trg) Target object.
344 # @param $(prop) The property.
345 # @param $(src_key) Source keyword.
346 # @param $(trg_key) Target keyword.
347 define def_inherit_one_keyword_appending_deferred_l
348 ifdef $(trg
)_
$(prop
).
$(src_key
)
349 ifeq ($$(flavor
$(trg
)_
$(prop
).
$(trg_key
)),simple
)
350 $$(evalcall2 def_simple_2_recursive
,$(trg
)_
$(prop
).
$(trg_key
))
352 $(trg
)_
$(prop
).
$(trg_key
) += $$($(trg
)_
$(prop
).
$(src_key
))
356 ## @copydoc def_inherit_one_appending_deferred_l
357 define def_inherit_one_keyword_appending_deferred_r
358 ifdef $(trg
)_
$(prop
).
$(src_key
)
359 ifeq ($$(flavor
$(trg
)_
$(prop
).
$(trg_key
)),simple
)
360 $$(evalcall2 def_simple_2_recursive
,$(trg
)_
$(prop
).
$(trg_key
))
362 $(trg
)_
$(prop
).
$(trg_key
) <= $$($(trg
)_
$(prop
).
$(src_key
))
367 ## Worker for def_inherit that deals with one keyword that makes
368 # use of inheritance.
369 # @param prefix_keyword key_prefix:keyword. The cool join/split game as usual.
370 # @param trg Object to consider for inheriting.
371 # @param properties List of the properties with straight expansion.
372 # @param properties_now_l List of the properties with immediate expansion, accumulating on the left side.
373 # @param properties_now_r List of the properties with immediate expansion, accumulating on the right side.
374 # @param properties_deferred List of the properties with deferred expansion (e.g. function), non-accumulative .
375 # @param properties_deferred_l List of the properties with deferred expansion (e.g. function), accumulating on the left side.
376 # @param properties_deferred_r List of the properties with deferred expansion (e.g. function), accumulating on the right side.
377 define def_inherit_keyword
378 local
prefix := $(word 1,$(subst :, ,$(prefix_keyword
)))
379 local trg_key
:= $(word 2,$(subst :, ,$(prefix_keyword
)))
380 local src_key
:= $($(prefix)_
$(trg_key
)_EXTENDS
)
381 local by
:= $($(prefix)_
$(trg_key
)_EXTENDS_BY
)
383 # Inherit the properties.
384 $(foreach prop
, $(properties
), $(eval
$(def_inherit_one_keyword
)))
385 $(foreach prop
, $(properties_now_l
), $(eval
$(def_inherit_one_keyword_
$(by
)_now_l
)))
386 $(foreach prop
, $(properties_now_r
), $(eval
$(def_inherit_one_keyword_
$(by
)_now_r
)))
387 $(foreach prop
, $(properties_deferred
), $(eval
$(def_inherit_one_keyword_
$(by
)_deferred
)))
388 $(foreach prop
, $(properties_deferred_l
), $(eval
$(def_inherit_one_keyword_
$(by
)_deferred_l
)))
389 $(foreach prop
, $(properties_deferred_r
), $(eval
$(def_inherit_one_keyword_
$(by
)_deferred_r
)))
391 endef # def_inherit_keyword
394 ## Inherit one template property in a non-accumulative manner.
395 # @param $(prop) Property name
396 # @param $(src) Source (parent) object.
397 # @param $(trg) Target (child) object.
398 define def_inherit_one
400 ifndef $(trg
)_
$(prop
)
401 $(trg
)_
$(prop
) = $($(src
)_
$(prop
))
407 # EXPAND_BY = overriding
409 ## Inherit one template property in a non-accumulative manner.
410 # @param $(prop) Property name
411 # @param $(src) Source (parent) object.
412 # @param $(trg) Target (child) object.
413 define def_inherit_one_overriding_now_l
415 ifndef $(trg
)_
$(prop
)
416 $(trg
)_
$(prop
) := $($(src
)_
$(prop
))
421 ## @copydoc def_inherit_one_overriding_now_l
422 define def_inherit_one_overriding_now_r
424 ifndef $(trg
)_
$(prop
)
425 $(trg
)_
$(prop
) := $($(src
)_
$(prop
))
430 ## Inherit one template property in a non-accumulative manner, deferred expansion.
431 # @param $(prop) Property name
432 # @param $(src) Source
433 # @param $(trg) Target
434 # @remark This define relies on double evaluation
435 define def_inherit_one_overriding_deferred
437 ifndef $(trg
)_
$(prop
)
438 $(trg
)_
$(prop
) = $$($(src
)_
$(prop
))
443 ## @copydoc def_inherit_one_overriding_deferred
444 define def_inherit_one_overriding_deferred_l
446 ifndef $(trg
)_
$(prop
)
447 $(trg
)_
$(prop
) = $$($(src
)_
$(prop
))
452 ## @copydoc def_inherit_one_overriding_deferred
453 define def_inherit_one_overriding_deferred_r
455 ifndef $(trg
)_
$(prop
)
456 $(trg
)_
$(prop
) = $$($(src
)_
$(prop
))
462 # EXPAND_BY = prepending
464 ## Inherit one template property in a prepending manner.
465 # @param $(prop) Property name
466 # @param $(src) Source (parent) object.
467 # @param $(trg) Target (child) object.
468 define def_inherit_one_prepending_now_l
470 $(trg
)_
$(prop
) := $($(src
)_
$(prop
)) $($(trg
)_
$(prop
))
474 ## @copydoc def_inherit_one_prepending_now_l
475 define def_inherit_one_prepending_now_r
477 $(trg
)_
$(prop
) := $($(trg
)_
$(prop
)) $($(src
)_
$(prop
))
481 ## Inherit one template property in a non-accumulative manner, deferred expansion.
482 # @param $(prop) Property name
483 # @param $(src) Source
484 # @param $(trg) Target
485 # @remark This define relies on double evaluation
486 define def_inherit_one_prepending_deferred
488 ifndef $(trg
)_
$(prop
)
489 $(trg
)_
$(prop
) = $$($(src
)_
$(prop
))
494 ## Inherit one template property in a prepending manner, deferred expansion.
495 # @param $(prop) Property name
496 # @param $(src) Source (parent) object.
497 # @param $(trg) Target (child) object.
498 define def_inherit_one_prepending_deferred_l
500 ifeq ($$(flavor
$(trg
)_
$(prop
)),simple
)
501 $$(evalcall2 def_simple_2_recursive
,$(trg
)_
$(prop
))
503 $(trg
)_
$(prop
) <= $$($(src
)_
$(prop
))
507 ## @copydoc def_inherit_one_prepending_deferred_l
508 define def_inherit_one_prepending_deferred_r
510 ifeq ($$(flavor
$(trg
)_
$(prop
)),simple
)
511 $$(evalcall2 def_simple_2_recursive
,$(trg
)_
$(prop
))
513 $(trg
)_
$(prop
) += $$($(src
)_
$(prop
))
518 # EXPAND_BY = appending
520 ## Inherit one template property in an appending manner.
521 # @param $(prop) Property name
522 # @param $(src) Source (parent) object.
523 # @param $(trg) Target (child) object.
524 define def_inherit_one_appending_now_l
526 $(trg
)_
$(prop
) := $($(trg
)_
$(prop
)) $($(src
)_
$(prop
))
530 ## @copydoc def_inherit_one_appending_now_l
531 define def_inherit_one_appending_now_r
533 $(trg
)_
$(prop
) := $($(src
)_
$(prop
)) $($(trg
)_
$(prop
))
537 ## Inherit one template property in a non-accumulative manner, deferred expansion.
538 # @param $(prop) Property name
539 # @param $(src) Source
540 # @param $(trg) Target
541 # @remark This define relies on double evaluation
542 define def_inherit_one_appending_deferred
544 ifndef $(trg
)_
$(prop
)
545 $(trg
)_
$(prop
) = $$($(src
)_
$(prop
))
550 ## Inherit one template property in an appending manner, deferred expansion.
551 # @param $(prop) Property name
552 # @param $(src) Source (parent) object.
553 # @param $(trg) Target (child) object.
554 define def_inherit_one_appending_deferred_l
556 ifeq ($$(flavor
$(trg
)_
$(prop
)),simple
)
557 $$(evalcall2 def_simple_2_recursive
,$(trg
)_
$(prop
))
559 $(trg
)_
$(prop
) += $$($(src
)_
$(prop
))
563 ## @copydoc def_inherit_one_appending_deferred_l
564 define def_inherit_one_appending_deferred_r
566 ifeq ($$(flavor
$(trg
)_
$(prop
)),simple
)
567 $$(evalcall2 def_simple_2_recursive
,$(trg
)_
$(prop
))
569 $(trg
)_
$(prop
) <= $$($(src
)_
$(prop
))
574 ## combines the specified properties $(1) with the $(_KEYWORDS) list.
575 _INHERIT_JOIN_KEYWORDS
= $(1) $(foreach keyword
,$(_KEYWORDS
), $(addsuffix .
$(keyword
), $(1)))
578 ## Generic inheritance for use with targets templates and tools.
579 # @param trg Object to consider for inheriting.
580 # @param src_prefix What to prefix the value found in EXTENDS with to get the object.
581 # @param load_function Load function for stuff that needs
582 # @param properties List of the properties with straight expansion.
583 # @param properties_now_l List of the properties with immediate expansion, accumulating on the left side.
584 # @param properties_now_r List of the properties with immediate expansion, accumulating on the right side.
585 # @param properties_deferred List of the properties with deferred expansion (e.g. function), non-accumulative .
586 # @param properties_deferred_l List of the properties with deferred expansion (e.g. function), accumulating on the left side.
587 # @param properties_deferred_r List of the properties with deferred expansion (e.g. function), accumulating on the right side.
590 # Load it - loading is a mess, fix.
591 ifneq ($(load_function
),)
592 local loading
:= $(patsubst $(src_prefix
)%,%,$(trg
))
593 $(evalvalctx
$(load_function
))
596 local src
:= $(strip $($(trg
)_EXTENDS
))
598 ifndef $(trg
)_EXTENDS_STATUS_
599 $(trg
)_EXTENDS_STATUS_
:= 0
602 ifneq ($(load_function
),)
603 local loading
:= $(src
)
604 $(evalvalctx
$(load_function
))
608 local src
:= $(src_prefix
)$(src
)
610 # Recursivly process the parent (src) if it's inherting from somebody too.
612 ifneq ($($(src
)_EXTENDS_STATUS_
),42)
613 # 'foreach' will create 'trg' in a new variable context hiding
614 # out current variable. 'src' OTOH will be overwritten.
615 $(foreach trg
, $(src
), $(evalval def_inherit
))
616 local src
:= $(src_prefix
)$(strip $($(trg
)_EXTENDS
))
620 # Get & check EXTENDS_BY.
621 local by
= $(strip $($(trg
)_EXTENDS_BY
))
623 local by
= overriding
624 else ifn1of
($(by
), overriding appending prepending
)
625 $(error kBuild
: Invalid EXTENDS_BY value
'$(by)' on
'$(trg)'!)
628 # Inherit the properties.
629 $(foreach prop
, $(call _INHERIT_JOIN_KEYWORDS
,$(properties
)), $(eval
$(def_inherit_one
)))
630 $(foreach prop
, $(call _INHERIT_JOIN_KEYWORDS
,$(properties_now_l
)), $(eval
$(def_inherit_one_
$(by
)_now_l
)))
631 $(foreach prop
, $(call _INHERIT_JOIN_KEYWORDS
,$(properties_now_r
)), $(eval
$(def_inherit_one_
$(by
)_now_r
)))
632 $(foreach prop
, $(call _INHERIT_JOIN_KEYWORDS
,$(properties_deferred
)), $(eval
$(def_inherit_one_
$(by
)_deferred
)))
633 $(foreach prop
, $(call _INHERIT_JOIN_KEYWORDS
,$(properties_deferred_l
)), $(eval
$(def_inherit_one_
$(by
)_deferred_l
)))
634 $(foreach prop
, $(call _INHERIT_JOIN_KEYWORDS
,$(properties_deferred_r
)), $(eval
$(def_inherit_one_
$(by
)_deferred_r
)))
636 # Mark the target as done.
637 $(trg
)_EXTENDS_STATUS_
:= 42
639 # Check for inheritance loops.
640 ifneq ($($(trg
)_EXTENDS_STATUS_
),42)
641 $(error kBuild
: Target inheritance loop
! target
=$(trg
) $(trg
)_EXTENDS_STATUS_
=$($(trg
)_EXTENDS_STATUS_
))
646 # Keyword inheritance.
647 $(foreach prefix_keyword
, $(join $(_KEYWORDS_PREFIX
), $(addprefix :,$(_KEYWORDS_EXTENDS
))), $(evalval def_inherit_keyword
))
653 # Load global units before doing any inheriting so they can add new properties.
655 # This only applies to the guys listed in the global USES since there is
656 # no reliable way to deal with things on a target level without first
657 # applying templates. So, to avoid having USES mess up all targets,
658 # we'll make the global and per-target USES property work differently:
659 # The global USES does not apply to targets, just globally.
662 ## Unit load function.
663 # @param loading The unit name
664 define def_unit_load_function
665 ifndef UNIT_
$(loading
)
666 UNIT_
$(loading
)_KMK_FILE
:= $(firstword $(foreach path
, $(KBUILD_UNIT_PATHS
) $(KBUILD_PATH
)/units
$(KBUILD_DEFAULT_PATHS
), $(wildcard $(path
)/$(loading
).kmk
)))
667 ifeq ($(UNIT_
$(loading
)_KMK_FILE
),)
668 $(error kBuild
: Cannot find
include file for the unit
'$(loading)'! Searched
: $(KBUILD_UNIT_PATHS
) $(KBUILD_PATH
)/units
$(KBUILD_DEFAULT_PATHS
))
670 include $(UNIT_
$(loading
)_KMK_FILE
)
671 ifndef UNIT_
$(loading
)
672 $(warning kBuild
: UNIT_
$(loading
) was not defined by
$(UNIT_
$(loading
)_KMK_FILE
)!)
675 endef # def_unit_load_function
678 $(USES.
$(KBUILD_TARGET
).
$(KBUILD_TARGET_ARCH
)) \
679 $(USES.
$(KBUILD_TARGET_CPU
)) \
680 $(USES.
$(KBUILD_TARGET_ARCH
)) \
681 $(USES.
$(KBUILD_TARGET
)) \
682 $(USES.
$(KBUILD_HOST
).
$(KBUILD_HOST_ARCH
)) \
683 $(USES.
$(KBUILD_HOST_CPU
)) \
684 $(USES.
$(KBUILD_HOST_ARCH
)) \
685 $(USES.
$(KBUILD_TARGET
)) \
686 $(USES.
$(KBUILD_TYPE
)) \
687 $(USES
),$(evalval def_unit_load_function
))
691 # Determin all the templates that is being used and make
692 # sure they are present before we try collect keywords.
694 _TEMPLATES
:= $(TEMPLATE
)
696 ifdef $(target
)_TEMPLATE
697 ifneq ("$($(target)_TEMPLATE)","$(strip $($(target)_TEMPLATE))")
698 $$(error kBuild
: The template name of target
'$(target)' contains tabs
($($(target
)_TEMPLATE
))). Please remove them
)
700 _TEMPLATES
+= $($(target
)_TEMPLATE
)
702 endef # def_templates
703 $(foreach target
, $(_ALL_TARGETS
), $(eval
$(def_templates
)))
704 _TEMPLATES
:= $(sort $(_TEMPLATES
))
706 ## Template load function.
707 # @param loading The template name. This is prefixed.
708 define def_templates_load_function
709 ifndef TEMPLATE_
$(loading
)
710 TEMPLATE_
$(loading
)_KMK_FILE
:= $(firstword $(foreach path
, $(KBUILD_TEMPLATE_PATHS
) $(KBUILD_PATH
)/templates
$(KBUILD_DEFAULT_PATHS
), $(wildcard $(path
)/$(loading
).kmk
)))
711 ifeq ($(TEMPLATE_
$(loading
)_KMK_FILE
),)
712 $(error kBuild
: Cannot find
include file for the template
'$(loading)'! Searched
: $(KBUILD_TEMPLATE_PATHS
) $(KBUILD_PATH
)/templates
$(KBUILD_DEFAULT_PATHS
))
714 include $(TEMPLATE_
$(loading
)_KMK_FILE
)
715 ifndef TEMPLATE_
$(loading
)
716 $(warning kBuild
: TEMPLATE_
$(loading
) was not defined by
$(TEMPLATE_
$(loading
)_KMK_FILE
)!)
719 endef # def_templates_load_function
720 $(foreach loading
, $(_TEMPLATES
), $(evalval def_templates_load_function
))
724 # Determin the keywords required for correct inherting and setup keyword inheritance.
726 # This means walking all the lists of immediate template and targets and
727 # pick up all the BLD_T* keywords. Since templates that are referenced
728 # indirectly in the inheritance hierarchy, the result from this exercise
729 # might not be 100% accurate... :-/
731 _BLD_TYPES
:= $(KBUILD_TYPE
)
732 _BLD_TARGETS
:= $(KBUILD_TARGET
) $(KBUILD_HOSTS
)
733 _BLD_ARCHES
:= $(KBUILD_TARGET_ARCH
) $(KBUILD_HOST_ARCH
)
734 _BLD_CPUS
:= $(KBUILD_TARGET_CPU
) $(KBUILD_HOST_CPU
)
736 define def_collect_bld_xyz
737 ifdef $(src
)_BLD_TYPE
738 ifn1of
($($(src
)_BLD_TYPE
), $(KBUILD_BLD_TYPES
))
739 $(error kBuild
: $(src
)_BLD_TYPE
=$($(src
)_BLD_TYPE
) not in KBUILD_BLD_TYPES
={$(KBUILD_BLD_TYPES
)}!)
741 _BLD_TYPES
+= $($(src
)_BLD_TYPE
)
744 ifn1of
($($(src
)_BLD_TRG
), $(KBUILD_OSES
))
745 $(error kBuild
: $(src
)_BLD_TRG
=$($(src
)_BLD_TRG
) not in KBUILD_OSES
={$(KBUILD_OSES
)}!)
747 _BLD_TARGETS
+= $($(src
)_BLD_TRG
)
749 ifdef $(src
)_BLD_TRG_ARCH
750 ifn1of
($($(src
)_BLD_TRG_ARCH
), $(KBUILD_ARCHES
))
751 $(error kBuild
: $(src
)_BLD_TRG_ARCH
=$($(src
)_BLD_TRG_ARCH
) not in KBUILD_ARCHES
={$(KBUILD_ARCHES
)}!)
753 _BLD_ARCHES
+= $($(src
)_BLD_TRG_ARCH
)
755 ifdef $(src
)_BLD_TRG_CPU
756 if1of
($($(src
)_BLD_CPU
), $(KBUILD_ARCHES
) $(KBUILD_OSES
) $(KBUILD_BLD_TYPES
))
757 $(error kBuild
: $(src
)_BLD_TRG_CPU
=$($(src
)_BLD_TRG_CPU
) found in KBUILD_ARCHES
, KBUILD_OSES or KBUILD_BLD_TYPES
!)
759 _BLD_CPUS
+= $($(src
)_BLD_TRG_CPU
)
761 endef # def_collect_bld_xyz
762 $(foreach src
, $(addprefix TEMPLATE_
, $(_TEMPLATES
)) $(_ALL_TARGETS
) \
763 ,$(evalval def_collect_bld_xyz
))
765 # Drop duplicate values.
766 # WARNING! These list might not include keywords only involved in inheritance.
767 _BLD_TYPES
:= $(sort $(_BLD_TYPES
))
768 _BLD_TARGETS
:= $(sort $(_BLD_TARGETS
))
769 _BLD_ARCHES
:= $(sort $(_BLD_ARCHES
))
770 _BLD_CPUS
:= $(sort $(_BLD_CPUS
))
772 ## Look for keywords which extends others and order them.
776 define def_keyword_ordering
777 # Check for EXTENDS, fix and validate it if found.
778 local src
:= $(strip $($(prefix)_
$(keyword
)_EXTENDS
))
780 ifndef $(prefix)_
$(keyword
)_EXTENDS_STATUS_
781 ifn1of
($(src
), $(valid
))
782 $(error kBuild
: $(keyword
) tries to extend unknown keyword
'$(src)'! (known
= $(valid
)))
785 # Recursivly process the parent (src).
786 ifneq ($($(prefix)_
$(src
)_EXTENDS_STATUS_
),42)
787 $(prefix)_
$(keyword
)_EXTENDS_STATUS_
:= 0
788 # 'foreach' will create 'keyword' in a new variable context hiding
789 # out current variable. 'src' OTOH will be overwritten.
790 $(foreach keyword
, $(src
), $(evalval def_keyword_ordering
))
791 local src
:= $(strip $($(prefix)_
$(keyword
)_EXTENDS
))
794 # Check and strip EXTENDS_BY.
795 local by
= $(strip $($(prefix)_
$(keyword
)_EXTENDS_BY
))
797 local by
= overriding
798 else ifn1of
($(by
), overriding appending prepending
)
799 $(error kBuild
: Invalid EXTENDS_BY value
'$(by)' on
'$(keyword)'!)
802 # Update the attributes with stripped
803 $(prefix)_
$(keyword
)_EXTENDS_BY
:= $(by
)
804 $(prefix)_
$(keyword
)_EXTENDS
:= $(src
)
806 # Add it to the list and mark it as done.
807 _KEYWORDS_EXTENDS
+= $(keyword
)
808 _KEYWORDS_PREFIX
+= $(prefix)
809 $(prefix)_
$(keyword
)_EXTENDS_STATUS_
:= 42
811 # Check for inheritance loops.
812 ifneq ($($(trg
)_EXTENDS_STATUS_
),42)
813 $(error kBuild
: Keyword inheritance loop
! keyword
=$(keyword
) $(prefix)_
$(keyword
)_EXTENDS_STATUS_
=$($(prefix)_
$(keyword
)_EXTENDS_STATUS_
))
817 # Add it to the ordered list and mark it as done.
818 _KEYWORDS_ORDERED
+= $(keyword
)
819 $(prefix)_
$(src
)_EXTENDS_STATUS_
:= 42
821 endef # def_keyword_ordering
822 $(eval-opt-var def_keyword_ordering
)
824 # Look for keywords which extends others and their parents, and from this
825 # construct two lists.
831 valid
:= $(KBUILD_BLD_TYPES
)
832 $(foreach keyword
, $(_BLD_TYPES
) , $(evalval def_keyword_ordering
))
835 valid
:= $(KBUILD_OSES
)
836 $(foreach keyword
, $(_BLD_TARGETS
), $(evalval def_keyword_ordering
))
839 valid
:= $(KBUILD_ARCHES
)
840 $(foreach keyword
, $(_BLD_ARCHES
) , $(evalval def_keyword_ordering
))
843 valid
:= $(KBUILD_CPUS
)
844 $(foreach keyword
, $(_BLD_CPUS
) , $(evalval def_keyword_ordering
))
846 ## @todo Inherit bld_trg.bld_arch for too?
848 # Construct all the possible keywords.
849 _KEYWORDS
:= $(_KEYWORDS_ORDERED
) $(_KEYWORDS_EXTENDS
) \
850 $(foreach bld_trg
,$(_BLD_TARGETS
),$(addprefix $(bld_trg
).
,$(_BLD_ARCHES
)))
852 ifdef KBUILD_PROFILE_SELF
853 $(evalcall def_profile_self
, done keywords
)
858 # Target inheritance.
860 # This has to be done on a per target list basis as to avoid adding
861 # incorrect properties that will wast memory, time, and may confuse
862 # later strictness checks. This also has to be done *before* templates
863 # are applied to the targets. Since we're doing that part rather
864 # early on, the target inheritance feature is a bit restricted at
865 # the moment. However, this will be addressed in a little(?) while.
870 properties_deferred_l
:=
871 properties_deferred_r
:=
874 properties
:= $(PROPS_FETCHES_SINGLE
)
875 properties_now_l
:= $(PROPS_FETCHES_ACCUMULATE_L
)
876 properties_now_r
:= $(PROPS_FETCHES_ACCUMULATE_R
)
877 properties_deferred
:= $(PROPS_FETCHES_DEFERRED
)
878 $(foreach trg
, $(_ALL_FETCHES
),$(evalval def_inherit
))
880 ## Patches. - not implemented yet.
881 #properties := $(PROPS_PATCHES_SINGLE)
882 #properties_now_l := $(PROPS_PATCHES_ACCUMULATE_L)
883 #properties_now_r := $(PROPS_PATCHES_ACCUMULATE_R)
884 #properties_deferred := $(PROPS_PATCHES_DEFERRED)
885 #$(foreach trg, $(_ALL_PATCHES),$(evalval def_inherit))
887 # Programs and build programs.
888 properties
:= $(PROPS_PROGRAMS_SINGLE
)
889 properties_now_l
:= $(PROPS_PROGRAMS_ACCUMULATE_L
)
890 properties_now_r
:= $(PROPS_PROGRAMS_ACCUMULATE_R
)
891 properties_deferred
:= $(PROPS_PROGRAMS_DEFERRED
)
892 $(foreach trg
, $(_ALL_BLDPROGS
) $(_ALL_PROGRAMS
),$(evalval def_inherit
))
894 # Libraries and import libraries.
895 properties
:= $(PROPS_LIBRARIES_SINGLE
)
896 properties_now_l
:= $(PROPS_LIBRARIES_ACCUMULATE_L
)
897 properties_now_r
:= $(PROPS_LIBRARIES_ACCUMULATE_R
)
898 properties_deferred
:= $(PROPS_LIBRARIES_DEFERRED
)
899 if1of
($(KBUILD_TARGET
), nt os2 win
)
900 $(foreach trg
, $(_ALL_LIBRARIES
) $(_ALL_IMPORT_LIBS
),$(evalval def_inherit
))
902 $(foreach trg
, $(_ALL_LIBRARIES
),$(evalval def_inherit
))
906 properties
:= $(PROPS_DLLS_SINGLE
)
907 properties_now_l
:= $(PROPS_DLLS_ACCUMULATE_L
)
908 properties_now_r
:= $(PROPS_DLLS_ACCUMULATE_R
)
909 properties_deferred
:= $(PROPS_DLLS_DEFERRED
)
910 if1of
($(KBUILD_TARGET
), nt os2 win
)
911 $(foreach trg
, $(_ALL_DLLS
),$(evalval def_inherit
))
913 $(foreach trg
, $(_ALL_DLLS
) $(_ALL_IMPORT_LIBS
),$(evalval def_inherit
))
917 properties
:= $(PROPS_SYSMODS_SINGLE
)
918 properties_now_l
:= $(PROPS_SYSMODS_ACCUMULATE_L
)
919 properties_now_r
:= $(PROPS_SYSMODS_ACCUMULATE_R
)
920 properties_deferred
:= $(PROPS_SYSMODS_DEFERRED
)
921 $(foreach trg
, $(_ALL_SYSMODS
),$(evalval def_inherit
))
924 properties
:= $(PROPS_MISCBINS_SINGLE
)
925 properties_now_l
:= $(PROPS_MISCBINS_ACCUMULATE_L
)
926 properties_now_r
:= $(PROPS_MISCBINS_ACCUMULATE_R
)
927 properties_deferred
:= $(PROPS_MISCBINS_DEFERRED
)
928 $(foreach trg
, $(_ALL_MISCBINS
),$(evalval def_inherit
))
931 properties
:= $(PROPS_INSTALLS_SINGLE
)
932 properties_now_l
:= $(PROPS_INSTALLS_ACCUMULATE_L
)
933 properties_now_r
:= $(PROPS_INSTALLS_ACCUMULATE_R
)
934 properties_deferred
:= $(PROPS_INSTALLS_DEFERRED
)
935 $(foreach trg
, $(_ALL_INSTALLS
),$(evalval def_inherit
))
937 ifdef KBUILD_PROFILE_SELF
938 $(evalcall def_profile_self
, done target inheritance
)
943 # Template Inheritance.
945 # This is much the same as with target inheritance, except we cannot
946 # restrict the properties involved since we haven't got a clue which
947 # target platforms/archs are using them. But, we can drop the instance
948 # expansion we're doing for targets since there won't be any more
949 # changes to either the source nor the target templates beyond this
953 src_prefix
:= TEMPLATE_
954 load_function
:= def_templates_load_function
958 properties_deferred
:= $(PROPS_SINGLE
) $(PROPS_DEFERRED
)
959 properties_deferred_l
:= $(PROPS_ACCUMULATE_L
)
960 properties_deferred_r
:= $(PROPS_ACCUMULATE_R
)
961 $(foreach trg
, $(addprefix TEMPLATE_
,$(_TEMPLATES
)),$(evalval def_inherit
))
969 properties_deferred
:=
970 properties_deferred_l
:=
971 properties_deferred_r
:=
973 ifdef KBUILD_PROFILE_SELF
974 $(evalcall def_profile_self
, done template inheritance
)
981 # Template/Target Expansion.
983 # Extend all targets with the values from the template. Doing this up front
984 # allows more generic code and less mess down in the pass 2 target handling.
985 # However it does eat a good deal of memory.
988 if1of
($(KMK_FEATURES
), kb-exp-tmpl
)
989 $(kb-exp-tmpl
1,$(_ALL_TARGET_TARGETS
),$(KBUILD_TARGET
),$(KBUILD_TARGET_ARCH
),$(KBUILD_TARGET_CPU
),$(KBUILD_TYPE
))
990 $(kb-exp-tmpl
1,$(_ALL_HOST_TARGETS
),$(KBUILD_HOST
),$(KBUILD_HOST_ARCH
),$(KBUILD_HOST_CPU
),$(KBUILD_TYPE
))
994 ## Inherit one template property in a non-accumulative manner.
995 # @param $(prop) Property name
996 # @param $(target) Target name
997 # @todo fix the precedence order for some properties.
998 define def_inherit_template_one
999 ifdef TEMPLATE_
$($(target
)_TEMPLATE
)_
$(prop
)
1000 ifndef $(target
)_
$(prop
)
1001 $(target
)_
$(prop
) := $(TEMPLATE_
$($(target
)_TEMPLATE
)_
$(prop
))
1004 ifdef TEMPLATE_
$($(target
)_TEMPLATE
)_
$(prop
).
$(bld_trg
)
1005 ifndef $(target
)_
$(prop
).
$(bld_trg
)
1006 $(target
)_
$(prop
).
$(bld_trg
) := $(TEMPLATE_
$($(target
)_TEMPLATE
)_
$(prop
).
$(bld_trg
))
1009 ifdef TEMPLATE_
$($(target
)_TEMPLATE
)_
$(prop
).
$(bld_trg
).
$(bld_trg_arch
)
1010 ifndef $(target
)_
$(prop
).
$(bld_trg
).
$(bld_trg_arch
)
1011 $(target
)_
$(prop
).
$(bld_trg
).
$(bld_trg_arch
) := $(TEMPLATE_
$($(target
)_TEMPLATE
)_
$(prop
).
$(bld_trg
).
$(bld_trg_arch
))
1014 ifdef TEMPLATE_
$($(target
)_TEMPLATE
)_
$(prop
).
$(bld_trg_arch
)
1015 ifndef $(target
)_
$(prop
).
$(bld_trg_arch
)
1016 $(target
)_
$(prop
).
$(bld_trg_arch
) := $(TEMPLATE_
$($(target
)_TEMPLATE
)_
$(prop
).
$(bld_trg_arch
))
1019 ifdef TEMPLATE_
$($(target
)_TEMPLATE
)_
$(prop
).
$(bld_trg_cpu
)
1020 ifndef $(target
)_
$(prop
).
$(bld_trg_cpu
)
1021 $(target
)_
$(prop
).
$(bld_trg_cpu
) := $(TEMPLATE_
$($(target
)_TEMPLATE
)_
$(prop
).
$(bld_trg_cpu
))
1026 ## Inherit one template property in a non-accumulative manner, deferred expansion.
1027 # @param 1: $(prop) Property name
1028 # @param 2: $(target) Target name
1029 # @todo fix the precedence order for some properties.
1030 # @remark this define relies on double evaluation
1031 define def_inherit_template_one_deferred
1032 ifdef TEMPLATE_
$($(target
)_TEMPLATE
)_
$(prop
)
1033 ifndef $(target
)_
$(prop
)
1034 $(target
)_
$(prop
) = $$(TEMPLATE_
$($(target
)_TEMPLATE
)_
$(prop
))
1037 ifdef TEMPLATE_
$($(target
)_TEMPLATE
)_
$(prop
).
$(bld_trg
)
1038 ifndef $(target
)_
$(prop
).
$(bld_trg
)
1039 $(target
)_
$(prop
).
$(bld_trg
) = $$(TEMPLATE_
$($(target
)_TEMPLATE
)_
$(prop
).
$(bld_trg
))
1042 ifdef TEMPLATE_
$($(target
)_TEMPLATE
)_
$(prop
).
$(bld_trg
).
$(bld_trg_arch
)
1043 ifndef $(target
)_
$(prop
).
$(bld_trg
).
$(bld_trg_arch
)
1044 $(target
)_
$(prop
).
$(bld_trg
).
$(bld_trg_arch
) = $$(TEMPLATE_
$($(target
)_TEMPLATE
)_
$(prop
).
$(bld_trg
).
$(bld_trg_arch
))
1047 ifdef TEMPLATE_
$($(target
)_TEMPLATE
)_
$(prop
).
$(bld_trg_arch
)
1048 ifndef $(target
)_
$(prop
).
$(bld_trg_arch
)
1049 $(target
)_
$(prop
).
$(bld_trg_arch
) = $$(TEMPLATE_
$($(target
)_TEMPLATE
)_
$(prop
).
$(bld_trg_arch
))
1052 ifdef TEMPLATE_
$($(target
)_TEMPLATE
)_
$(prop
).
$(bld_trg_cpu
)
1053 ifndef $(target
)_
$(prop
).
$(bld_trg_cpu
)
1054 $(target
)_
$(prop
).
$(bld_trg_cpu
) = $$(TEMPLATE_
$($(target
)_TEMPLATE
)_
$(prop
).
$(bld_trg_cpu
))
1059 ## Inherit one acculumlative template property where the 'most significant' items are at the left end.
1060 # @param $(prop) Property name
1061 # @param $(target) Target name
1062 define def_inherit_template_one_accumulate_l
1063 ifdef TEMPLATE_
$($(target
)_TEMPLATE
)_
$(prop
)
1064 ifeq ($$(flavor
$(target
)_
$(prop
)),simple
)
1065 $$(evalcall2 def_simple_2_recursive
,$(target
)_
$(prop
))
1067 $(target
)_
$(prop
) += $$(TEMPLATE_
$($(target
)_TEMPLATE
)_
$(prop
))
1069 ifdef TEMPLATE_
$($(target
)_TEMPLATE
)_
$(prop
).
$(KBUILD_TYPE
)
1070 ifeq ($$(flavor
$(target
)_
$(prop
).
$(KBUILD_TYPE
)),simple
)
1071 $$(evalcall2 def_simple_2_recursive
,$(target
)_
$(prop
).
$(KBUILD_TYPE
))
1073 $(target
)_
$(prop
).
$(KBUILD_TYPE
) += $$(TEMPLATE_
$($(target
)_TEMPLATE
)_
$(prop
).
$(KBUILD_TYPE
))
1075 ifdef TEMPLATE_
$($(target
)_TEMPLATE
)_
$(prop
).
$(bld_trg
)
1076 ifeq ($$(flavor
$(target
)_
$(prop
).
$(bld_trg
)),simple
)
1077 $$(evalcall2 def_simple_2_recursive
,$(target
)_
$(prop
).
$(bld_trg
))
1079 $(target
)_
$(prop
).
$(bld_trg
) += $$(TEMPLATE_
$($(target
)_TEMPLATE
)_
$(prop
).
$(bld_trg
))
1081 ifdef TEMPLATE_
$($(target
)_TEMPLATE
)_
$(prop
).
$(bld_trg
).
$(bld_trg_arch
)
1082 ifeq ($$(flavor
$(target
)_
$(prop
).
$(bld_trg
).
$(bld_trg_arch
)),simple
)
1083 $$(evalcall2 def_simple_2_recursive
,$(target
)_
$(prop
).
$(bld_trg
).
$(bld_trg_arch
))
1085 $(target
)_
$(prop
).
$(bld_trg
).
$(bld_trg_arch
) += $$(TEMPLATE_
$($(target
)_TEMPLATE
)_
$(prop
).
$(bld_trg
).
$(bld_trg_arch
))
1087 ifdef TEMPLATE_
$($(target
)_TEMPLATE
)_
$(prop
).
$(bld_trg_cpu
)
1088 ifeq ($$(flavor
$(target
)_
$(prop
).
$(bld_trg_cpu
)),simple
)
1089 $$(evalcall2 def_simple_2_recursive
,$(target
)_
$(prop
).
$(bld_trg_cpu
))
1091 $(target
)_
$(prop
).
$(bld_trg_cpu
) += $$(TEMPLATE_
$($(target
)_TEMPLATE
)_
$(prop
).
$(bld_trg_cpu
))
1093 ifdef TEMPLATE_
$($(target
)_TEMPLATE
)_
$(prop
).
$(bld_trg_arch
)
1094 ifeq ($$(flavor
$(target
)_
$(prop
).
$(bld_trg_arch
)),simple
)
1095 $$(evalcall2 def_simple_2_recursive
,$(target
)_
$(prop
).
$(bld_trg_arch
))
1097 $(target
)_
$(prop
).
$(bld_trg_arch
) += $$(TEMPLATE_
$($(target
)_TEMPLATE
)_
$(prop
).
$(bld_trg_arch
))
1101 ## Inherit one acculumlative template property where the 'most significant' items are at the right end.
1102 # @param $(prop) Property name
1103 # @param $(target) Target name
1104 define def_inherit_template_one_accumulate_r
1105 ifdef TEMPLATE_
$($(target
)_TEMPLATE
)_
$(prop
)
1106 ifeq ($$(flavor
$(target
)_
$(prop
)),simple
)
1107 $$(evalcall2 def_simple_2_recursive
,$(target
)_
$(prop
))
1109 $(target
)_
$(prop
) <=$$(TEMPLATE_
$($(target
)_TEMPLATE
)_
$(prop
))
1111 ifdef TEMPLATE_
$($(target
)_TEMPLATE
)_
$(prop
).
$(KBUILD_TYPE
)
1112 ifeq ($$(flavor
$(target
)_
$(prop
).
$(KBUILD_TYPE
)),simple
)
1113 $$(evalcall2 def_simple_2_recursive
,$(target
)_
$(prop
).
$(KBUILD_TYPE
))
1115 $(target
)_
$(prop
).
$(KBUILD_TYPE
) <=$$(TEMPLATE_
$($(target
)_TEMPLATE
)_
$(prop
).
$(KBUILD_TYPE
))
1117 ifdef TEMPLATE_
$($(target
)_TEMPLATE
)_
$(prop
).
$(bld_trg
)
1118 ifeq ($$(flavor
$(target
)_
$(prop
).
$(bld_trg
)),simple
)
1119 $$(evalcall2 def_simple_2_recursive
,$(target
)_
$(prop
).
$(bld_trg
))
1121 $(target
)_
$(prop
).
$(bld_trg
) <=$$(TEMPLATE_
$($(target
)_TEMPLATE
)_
$(prop
).
$(bld_trg
))
1123 ifdef TEMPLATE_
$($(target
)_TEMPLATE
)_
$(prop
).
$(bld_trg
).
$(bld_trg_arch
)
1124 ifeq ($$(flavor
$(target
)_
$(prop
).
$(bld_trg
).
$(bld_trg_arch
)),simple
)
1125 $$(evalcall2 def_simple_2_recursive
,$(target
)_
$(prop
).
$(bld_trg
).
$(bld_trg_arch
))
1127 $(target
)_
$(prop
).
$(bld_trg
).
$(bld_trg_arch
) <=$$(TEMPLATE_
$($(target
)_TEMPLATE
)_
$(prop
).
$(bld_trg
).
$(bld_trg_arch
))
1129 ifdef TEMPLATE_
$($(target
)_TEMPLATE
)_
$(prop
).
$(bld_trg_cpu
)
1130 ifeq ($$(flavor
$(target
)_
$(prop
).
$(bld_trg_cpu
)),simple
)
1131 $$(evalcall2 def_simple_2_recursive
,$(target
)_
$(prop
).
$(bld_trg_cpu
))
1133 $(target
)_
$(prop
).
$(bld_trg_cpu
) <=$$(TEMPLATE_
$($(target
)_TEMPLATE
)_
$(prop
).
$(bld_trg_cpu
))
1135 ifdef TEMPLATE_
$($(target
)_TEMPLATE
)_
$(prop
).
$(bld_trg_arch
)
1136 ifeq ($$(flavor
$(target
)_
$(prop
).
$(bld_trg_arch
)),simple
)
1137 $$(evalcall2 def_simple_2_recursive
,$(target
)_
$(prop
).
$(bld_trg_arch
))
1139 $(target
)_
$(prop
).
$(bld_trg_arch
) <=$$(TEMPLATE_
$($(target
)_TEMPLATE
)_
$(prop
).
$(bld_trg_arch
))
1144 ## Inherit template properties for on target.
1145 # @param $(target) Target name.
1146 define def_inherit_template
1148 ifdef _
$(target
)_ALREADY_PROCESSED
1149 $(error kBuild
: The target
$(target
) appears more than once in the target lists
! Please correct the makefile
(s
))
1151 _
$(target
)_ALREADY_PROCESSED
:= 1
1153 # Inherit any default template.
1155 ifeq ($($(target
)_TEMPLATE
),)
1156 $(eval
$(target
)_TEMPLATE
:=$(TEMPLATE
))
1159 # Expand the template if specified.
1160 ifneq ($($(target
)_TEMPLATE
),)
1161 $(foreach prop
,$(PROPS_SINGLE
),$(evalval def_inherit_template_one
))
1162 $(foreach prop
,$(PROPS_DEFERRED
),$(eval
$(def_inherit_template_one_deferred
))) # exploits the 2 evaluation, so no value!
1163 $(foreach prop
,$(PROPS_ACCUMULATE_L
),$(eval
$(def_inherit_template_one_accumulate_l
))) # += works fine without value
1164 $(foreach prop
,$(PROPS_ACCUMULATE_R
),$(eval
$(def_inherit_template_one_accumulate_r
))) # use <= (kmk addition)
1167 $(eval-opt-var def_inherit_template
)
1169 # Inherit template properties
1170 bld_trg
:= $(KBUILD_TARGET
)
1171 bld_trg_arch
:= $(KBUILD_TARGET_ARCH
)
1172 bld_trg_cpu
:= $(KBUILD_TARGET_CPU
)
1173 $(foreach target
, $(_ALL_TARGET_TARGETS
),$(evalval def_inherit_template
))
1175 bld_trg
:= $(KBUILD_HOST
)
1176 bld_trg_arch
:= $(KBUILD_HOST_ARCH
)
1177 bld_trg_cpu
:= $(KBUILD_HOST_CPU
)
1178 $(foreach target
, $(_ALL_HOST_TARGETS
),$(evalval def_inherit_template
))
1180 endif # !kb-exp-tmpl
1181 ifdef KBUILD_PROFILE_SELF
1182 $(evalcall def_profile_self
, done template
/target expansion
)
1187 # Include tools, sdks and units.
1189 # The first part of this exercise is to figure out which TOOLS and SDKS
1190 # that should be included.
1192 _TOOLS
:= $(TOOL.
$(KBUILD_TARGET
)) $(TOOL.
$(KBUILD_TARGET_ARCH
)) $(TOOL.
$(KBUILD_TARGET
).
$(KBUILD_TARGET_ARCH
)) \
1193 $(TOOL.
$(KBUILD_HOST
)) $(TOOL.
$(KBUILD_HOST_ARCH
)) $(TOOL.
$(KBUILD_HOST
).
$(KBUILD_HOST_ARCH
)) \
1195 _SDKS
:= $(SDKS.
$(KBUILD_TARGET
)) $(SDKS.
$(KBUILD_TARGET_ARCH
)) $(SDKS.
$(KBUILD_TARGET
).
$(KBUILD_TARGET_ARCH
)) \
1196 $(SDKS.
$(KBUILD_HOST
)) $(SDKS.
$(KBUILD_HOST_ARCH
)) $(SDKS.
$(KBUILD_HOST
).
$(KBUILD_HOST_ARCH
)) \
1197 $(SDKS.
$(KBUILD_TYPE
)) \
1199 _USES
:= $(USES.
$(KBUILD_TARGET
)) $(USES.
$(KBUILD_TARGET_ARCH
)) $(USES.
$(KBUILD_TARGET
).
$(KBUILD_TARGET_ARCH
)) \
1200 $(USES.
$(KBUILD_HOST
)) $(USES.
$(KBUILD_HOST_ARCH
)) $(USES.
$(KBUILD_HOST
).
$(KBUILD_HOST_ARCH
)) \
1201 $(USES.
$(KBUILD_TYPE
)) \
1203 define def_tools_sdks_target_source
1204 $(eval _TOOLS
+= $(foreach prop
, $(PROPS_TOOLS
), \
1205 $($(source
)_
$(prop
).
$(_bld_trg
)) \
1206 $($(target
)_
$(source
)_
$(prop
).
$(_bld_trg
)) \
1207 $($(source
)_
$(prop
).
$(_bld_trg
).
$(_bld_trg_arch
)) \
1208 $($(target
)_
$(source
)_
$(prop
).
$(_bld_trg
).
$(_bld_trg_arch
)) \
1209 $($(source
)_
$(prop
).
$(_bld_trg_arch
)) \
1210 $($(target
)_
$(source
)_
$(prop
).
$(_bld_trg_arch
)) \
1211 $($(source
)_
$(prop
)) \
1212 $($(target
)_
$(source
)_
$(prop
))))
1214 $($(source
)_SDKS.
$(_bld_trg
)) \
1215 $($(target
)_
$(source
)_SDKS.
$(_bld_trg
)) \
1216 $($(source
)_SDKS.
$(_bld_trg
).
$(_bld_trg_arch
)) \
1217 $($(target
)_
$(source
)_SDKS.
$(_bld_trg
).
$(_bld_trg_arch
)) \
1218 $($(source
)_SDKS.
$(_bld_trg_arch
)) \
1219 $($(target
)_
$(source
)_SDKS.
$(_bld_trg_arch
)) \
1220 $($(source
)_SDKS.
$(KBUILD_TYPE
)) \
1221 $($(target
)_
$(source
)_SDKS.
$(KBUILD_TYPE
)) \
1223 $($(target
)_
$(source
)_SDKS
))
1225 $($(source
)_USES.
$(_bld_trg
)) \
1226 $($(target
)_
$(source
)_USES.
$(_bld_trg
)) \
1227 $($(source
)_USES.
$(_bld_trg
).
$(_bld_trg_arch
)) \
1228 $($(target
)_
$(source
)_USES.
$(_bld_trg
).
$(_bld_trg_arch
)) \
1229 $($(source
)_USES.
$(_bld_trg_arch
)) \
1230 $($(target
)_
$(source
)_USES.
$(_bld_trg_arch
)) \
1231 $($(source
)_USES.
$(KBUILD_TYPE
)) \
1232 $($(target
)_
$(source
)_USES.
$(KBUILD_TYPE
)) \
1234 $($(target
)_
$(source
)_USES
))
1235 endef # def_tools_sdks_target_source
1236 $(eval-opt-var def_tools_sdks_target_source
)
1238 define def_tools_sdks_target
1239 local _bld_type
:= $(firstword $($(target
)_BLD_TYPE
) $(KBUILD_TYPE
))
1240 local _bld_trg
:= $(firstword $($(target
)_BLD_TRG
) $(bld_trg
))
1241 local _bld_trg_arch
:= $(firstword $($(target
)_BLD_TRG_ARCH
) $(bld_trg_arch
))
1242 local _bld_trg_cpu
:= $(firstword $($(target
)_BLD_TRG_CPU
) $(bld_trg_cpu
))
1244 $(eval _TOOLS
+= $(foreach prop
, $(PROPS_TOOLS
), \
1245 $($(target
)_
$(prop
).
$(_bld_trg
)) \
1246 $($(target
)_
$(prop
).
$(_bld_trg_arch
)) \
1247 $($(target
)_
$(prop
).
$(_bld_trg
).
$(_bld_trg_arch
)) \
1248 $($(target
)_
$(prop
))))
1250 $($(target
)_SDKS.
$(_bld_trg
)) \
1251 $($(target
)_SDKS.
$(_bld_trg_arch
)) \
1252 $($(target
)_SDKS.
$(_bld_trg
).
$(_bld_trg_arch
)) \
1255 $($(target
)_USES.
$(_bld_trg
)) \
1256 $($(target
)_USES.
$(_bld_trg_arch
)) \
1257 $($(target
)_USES.
$(_bld_trg
).
$(_bld_trg_arch
)) \
1260 $($(target
)_SOURCES.
$(_bld_trg
)) \
1261 $($(target
)_SOURCES.
$(_bld_trg_arch
)) \
1262 $($(target
)_SOURCES.
$(_bld_trg
).
$(_bld_trg_arch
)) \
1263 $($(target
)_SOURCES.
$(_bld_trg_cpu
)) \
1264 $($(target
)_SOURCES.
$(_bld_type
)) \
1265 $($(target
)_SOURCES
) \
1266 , $(evalval def_tools_sdks_target_source
))
1267 endef # def_tools_sdks_target
1268 $(eval-opt-var def_tools_sdks_target
)
1270 define def_tools_srcname_target
1271 local _bld_type
:= $(firstword $($(target
)_BLD_TYPE
) $(KBUILD_TYPE
))
1272 local _bld_trg
:= $(firstword $($(target
)_BLD_TRG
) $(bld_trg
))
1273 local _bld_trg_arch
:= $(firstword $($(target
)_BLD_TRG_ARCH
) $(bld_trg_arch
))
1274 local _bld_trg_cpu
:= $(firstword $($(target
)_BLD_TRG_CPU
) $(bld_trg_cpu
))
1276 $(foreach source
, $(notdir\
1277 $($(target
)_SOURCES.
$(_bld_trg
)) \
1278 $($(target
)_SOURCES.
$(_bld_trg_arch
)) \
1279 $($(target
)_SOURCES.
$(_bld_trg
).
$(_bld_trg_arch
)) \
1280 $($(target
)_SOURCES.
$(_bld_trg_cpu
)) \
1281 $($(target
)_SOURCES.
$(_bld_type
)) \
1282 $($(target
)_SOURCES
) \
1283 ), $(evalval def_tools_sdks_target_source
))
1284 endef # def_tools_srcname_target
1285 $(eval-opt-var def_tools_srcname_target
)
1287 bld_trg
:= $(KBUILD_TARGET
)
1288 bld_trg_arch
:= $(KBUILD_TARGET_ARCH
)
1289 bld_trg_cpu
:= $(KBUILD_TARGET_CPU
)
1290 $(foreach target
, $(_ALL_TARGET_TARGETS
), $(evalval def_tools_sdks_target
))
1291 $(foreach target
, $(_ALL_SRCNAME_TARGETS
), $(evalval def_tools_srcname_target
))
1293 bld_trg
:= $(KBUILD_HOST
)
1294 bld_trg_arch
:= $(KBUILD_HOST_ARCH
)
1295 bld_trg_cpu
:= $(KBUILD_HOST_CPU
)
1296 $(foreach target
, $(_ALL_HOST_TARGETS
), $(evalval def_tools_sdks_target
))
1298 _TOOLS
:= $(sort $(_TOOLS
))
1299 _SDKS
:= $(sort $(_SDKS
))
1301 ## Tool load function.
1302 # @param loading The tool name
1303 define def_tools_load_function
1304 ifndef TOOL_
$(loading
)
1305 TOOL_
$(loading
)_KMK_FILE
:= $(firstword $(foreach path
, $(KBUILD_TOOL_PATHS
) $(KBUILD_PATH
)/tools
$(KBUILD_DEFAULT_PATHS
), $(wildcard $(path
)/$(loading
).kmk
)))
1306 ifeq ($(TOOL_
$(loading
)_KMK_FILE
),)
1307 $(error kBuild
: Cannot find
include file for the tool
'$(loading)'! Searched
: $(KBUILD_TOOL_PATHS
) $(KBUILD_PATH
)/tools
$(KBUILD_DEFAULT_PATHS
))
1309 include $(TOOL_
$(loading
)_KMK_FILE
)
1310 ifndef TOOL_
$(loading
)
1311 $(warning kBuild
: TOOL_
$(loading
) was not defined by
$(TOOL_
$(loading
)_KMK_FILE
)!)
1314 endef # def_tools_include
1316 ## SDK load function.
1317 # @param loading The tool name
1318 define def_sdk_load_function
1319 ifndef SDK_
$(loading
)
1320 SDK_
$(loading
)_KMK_FILE
:= $(firstword $(foreach path
, $(KBUILD_SDK_PATHS
) $(KBUILD_PATH
)/sdks
$(KBUILD_DEFAULT_PATHS
), $(wildcard $(path
)/$(loading
).kmk
)))
1321 ifeq ($(SDK_
$(loading
)_KMK_FILE
),)
1322 $(error kBuild
: Cannot find
include file for the SDK
'$(loading)'! Searched
: $(KBUILD_SDK_PATHS
) $(KBUILD_PATH
)/sdks
$(KBUILD_DEFAULT_PATHS
))
1324 include $(SDK_
$(loading
)_KMK_FILE
)
1325 ifndef SDK_
$(loading
)
1326 $(warning kBuild
: SDK_
$(loading
) was not defined by
$(SDK_
$(loading
)_KMK_FILE
)!)
1329 endef # def_sdk_load_function
1335 properties_deferred
:= $(PROPS_SINGLE
) $(PROPS_DEFERRED
)
1336 properties_deferred_l
:= $(PROPS_ACCUMULATE_L
)
1337 properties_deferred_r
:= $(PROPS_ACCUMULATE_R
)
1340 load_function
:= def_sdk_load_function
1341 $(foreach trg
, $(addprefix SDK_
,$(_SDKS
)), $(evalval def_inherit
))
1343 properties_deferred
:= $(PROPS_SINGLE
) $(PROPS_DEFERRED
) $(PROPS_TOOLS_ONLY
)
1345 load_function
:= def_tools_load_function
1346 $(foreach trg
, $(addprefix TOOL_
,$(_TOOLS
)), $(evalval def_inherit
))
1354 properties_deferred
:=
1355 properties_deferred_l
:=
1356 properties_deferred_r
:=
1358 # No inheriting for the uses, they're just global 'code'.
1359 $(foreach loading
, $(_USES
), $(evalval def_unit_load_function
))
1362 ifdef KBUILD_PROFILE_SELF
1363 $(evalcall def_profile_self
, done tools
+ sdks
+ units
)
1370 # Target lists - Pass 1
1372 # This pass is for defining variables that might be referenced in
1373 # properties of other targets.
1377 # Don't do anything for fetch targets (yet).
1380 # Link prolog for Pass 1.
1382 # @param $(target) Normalized target name.
1383 # @param $(EXT) EXE,DLL,SYS,LIB.
1384 # @param $(EXTPRE) HOST or nothing.
1385 # @param $(definst) The default _INST value.
1386 # @param $(tool_prefix) LD or AR.
1387 # @param $(bld_trg_base_var) TARGET or PLATFORM.
1388 define def_pass1_link_common
1390 local bld_type
:= $(firstword $($(target
)_BLD_TYPE
) $(KBUILD_TYPE
))
1391 local bld_trg
:= $(firstword $($(target
)_BLD_TRG
) $(BUILD_
$(bld_trg_base_var
)))
1392 local bld_trg_arch
:= $(firstword $($(target
)_BLD_TRG_ARCH
) $(BUILD_
$(bld_trg_base_var
)_ARCH
))
1393 local bld_trg_cpu
:= $(firstword $($(target
)_BLD_TRG_CPU
) $(BUILD_
$(bld_trg_base_var
)_CPU
))
1395 local tool
:= $(call _TARGET_TOOL
,$(target
),$(tool_prefix
))
1396 local name
:= $(firstword\
1397 $($(target
)_NAME.
$(bld_trg
).
$(bld_trg_arch
))\
1398 $($(target
)_NAME.
$(bld_trg_arch
))\
1399 $($(target
)_NAME.
$(bld_trg
))\
1400 $($(target
)_NAME.
$(bld_type
))\
1403 local outbase
:= $(call TARGET_BASE
,$(name
),$(target
))
1404 $(target
)_0_OUTDIR
:= $(patsubst %/,%,$(dir $(outbase
)))
1405 PATH_
$(target
) := $($(target
)_0_OUTDIR
)
1406 ## @todo fix the fun at the last line (AR != LIB => mess).
1407 local suff
:= $(firstword \
1408 $($(target
)_
$(EXT
)SUFF.
$(bld_trg
).
$(bld_trg_arch
))\
1409 $($(target
)_
$(EXT
)SUFF.
$(bld_trg
))\
1410 $($(target
)_
$(EXT
)SUFF
)\
1411 $(TOOL_
$(tool
)_
$(tool_prefix
)$(EXT
)SUFF.
$(bld_trg
).
$(bld_trg_arch
))\
1412 $(TOOL_
$(tool
)_
$(tool_prefix
)$(EXT
)SUFF.
$(bld_trg
))\
1413 $(TOOL_
$(tool
)_
$(tool_prefix
)$(EXT
)SUFF
)\
1414 $(if
$(eq
$(tool_prefix
),AR
),$(SUFF_LIB
),$($(EXTPRE
)SUFF_
$(EXT
))) )
1415 local out
:= $(outbase
)$(suff
)
1418 TARGET_
$(target
) := $(out
)
1419 $(target
)_1_TARGET
:= $(out
)
1422 ifeq ($(strip $($(target
)_NOINST
) $($(target
)_NOINST.
$(bld_trg
)) $($(target
)_NOINST.
$(bld_trg
).
$(bld_trg_arch
)) $($(target
)_NOINST.
$(bld_trg
).
$(bld_trg_arch
).
$(bld_type
)) $($(target
)_NOINST.
$(bld_trg_arch
)) $($(target
)_NOINST.
$(bld_trg_cpu
)) $($(target
)_NOINST.
$(bld_trg_type
))),)
1423 ifneq ($(strip $($(target
)_INST.
$(bld_trg
).
$(bld_trg_arch
).
$(bld_type
))),)
1424 local inst
:= $(addprefix $(PATH_INS
)/,$($(target
)_INST.
$(bld_trg
).
$(bld_trg_arch
).
$(bld_type
)))
1425 else ifneq ($(strip $($(target
)_INST.
$(bld_trg
).
$(bld_trg_arch
))),)
1426 local inst
:= $(addprefix $(PATH_INS
)/,$($(target
)_INST.
$(bld_trg
).
$(bld_trg_arch
)))
1427 else ifneq ($(strip $($(target
)_INST.
$(bld_trg
).
$(bld_type
))),)
1428 local inst
:= $(addprefix $(PATH_INS
)/,$($(target
)_INST.
$(bld_trg
).
$(bld_type
)))
1429 else ifneq ($(strip $($(target
)_INST.
$(bld_trg_arch
))),)
1430 local inst
:= $(addprefix $(PATH_INS
)/,$($(target
)_INST.
$(bld_trg_arch
)))
1431 else ifneq ($(strip $($(target
)_INST.
$(bld_trg
))),)
1432 local inst
:= $(addprefix $(PATH_INS
)/,$($(target
)_INST.
$(bld_trg
)))
1433 else ifneq ($(strip $($(target
)_INST.
$(bld_type
))),)
1434 local inst
:= $(addprefix $(PATH_INS
)/,$($(target
)_INST.
$(bld_type
)))
1435 else ifneq ($(strip $($(target
)_INST
)),)
1436 local inst
:= $(addprefix $(PATH_INS
)/,$($(target
)_INST
))
1438 local inst
:= $(definst
)/
1440 INSTARGET_
$(target
) := $(patsubst %/,%/$(notdir $(out
)),$(inst
))
1443 INSTARGET_
$(target
) :=
1447 $(eval-opt-var def_pass1_link_common
)
1453 define def_pass1_bldprog
1454 # set NOINST if not forced installation before doing the usual stuff.
1455 ifndef $(target
)_INST
1456 $(target
)_NOINST
:= 1
1458 $(evalval def_pass1_link_common
)
1463 definst
:= $(PATH_BIN
)
1465 bld_trg_base_var
:= PLATFORM
1466 $(foreach target
, $(_ALL_BLDPROGS
), \
1467 $(evalval def_pass1_bldprog
))
1471 # LIBRARIES (Pass 1)
1475 definst
:= $(PATH_LIB
)
1477 bld_trg_base_var
:= TARGET
1478 $(foreach target
, $(_ALL_LIBRARIES
), \
1479 $(evalval def_pass1_link_common
))
1487 definst
:= $(PATH_DLL
)
1489 bld_trg_base_var
:= TARGET
1490 $(foreach target
, $(_ALL_DLLS
), \
1491 $(evalval def_pass1_link_common
))
1495 # IMPORT LIBRARIES (Pass 1)
1497 # - On OS/2 and windows these are libraries.
1498 # - On other platforms they are fake DLLs.
1500 if1of
($(KBUILD_TARGET
), nt os2 win win64 win32
)
1503 definst
:= $(PATH_LIB
)
1505 bld_trg_base_var
:= TARGET
1506 $(foreach target
, $(_ALL_IMPORT_LIBS
), \
1507 $(evalval def_pass1_link_common
))
1511 definst
:= $(PATH_DLL
)
1513 bld_trg_base_var
:= TARGET
1514 $(foreach target
, $(_ALL_IMPORT_LIBS
), \
1515 $(evalval def_pass1_link_common
))
1524 definst
:= $(PATH_BIN
)
1526 bld_trg_base_var
:= TARGET
1527 $(foreach target
, $(_ALL_PROGRAMS
), \
1528 $(evalval def_pass1_link_common
))
1536 definst
:= $(PATH_SYS
)
1538 bld_trg_base_var
:= TARGET
1539 $(foreach target
, $(_ALL_SYSMODS
), \
1540 $(evalval def_pass1_link_common
))
1548 definst
:= $(PATH_BIN
)
1550 bld_trg_base_var
:= TARGET
1551 $(foreach target
, $(_ALL_MISCBINS
), \
1552 $(evalval def_pass1_link_common
))
1557 # Note! INSTARGET_* for INSTALLS aren't available until later.
1559 define def_pass1_install
1560 local bld_type
:= $(firstword $($(target
)_BLD_TYPE
) $(KBUILD_TYPE
))
1561 local bld_trg
:= $(firstword $($(target
)_BLD_TRG
) $(KBUILD_TARGET
))
1562 local bld_trg_arch
:= $(firstword $($(target
)_BLD_TRG_ARCH
) $(KBUILD_TARGET_ARCH
))
1563 local bld_trg_cpu
:= $(firstword $($(target
)_BLD_TRG_CPU
) $(KBUILD_TARGET_CPU
))
1565 $(target
)_1_TARGET
:= $(PATH_TARGET
)/$(target
).ins
1566 TARGET_
$(target
) := $($(target
)_1_TARGET
)
1570 local outbase
:= $(call TARGET_BASE
,$(target
),$(target
))
1571 $(target
)_0_OUTDIR
:= $(patsubst %/,%,$(dir $(outbase
)))
1572 PATH_
$(target
) := $($(target
)_0_OUTDIR
)
1573 endef # def_pass1_install
1574 $(eval-opt-var def_pass1_install
)
1575 $(foreach target
, $(_ALL_INSTALLS
), \
1576 $(evalval def_pass1_install
))
1578 ifdef KBUILD_PROFILE_SELF
1579 $(evalcall def_profile_self
, done pass
1)
1587 # Target lists - Pass 2
1592 ## @page pg_fetches Fetching Tools, Sources and Similar.
1594 # The targets listed in the the FETCHES target list have the following attributes:
1603 # As usual the target name is an alias for 'creating' the target. Other
1613 # This is a little bit complex because we must guarantee that if a source file
1614 # changes only sligtly we must refetch it and to a proper unpacking of it. It
1615 # is also a desire that fetched archives and unpacked files can be deleted to
1618 # Thus, we must be able to cleanup what we've unpacked should any of the
1619 # sources be removed. We do this by maintaining a file listing the files
1620 # and directories that was unpacked. This operation is named 'unfetch'.
1622 # We make use of the SIZE and MD5 attributes for each of the sources to
1623 # create a digest that is stored in the primary target file. Subsequent
1624 # runswill compare their digest with it to decide if a refetch is required.
1625 # When a refetch is found necessary, an 'unfetch' is performed first to
1626 # clean out old files and directores. Note even changes in source order
1627 # will cause a refetch due to the way the digest is constructed and
1630 # By not depending directly on the archives (nor on any unpacked files)
1631 # but on a goal made up from the archive name, size and md5, we allow
1632 # the user to delete the archives. Naturally, this means we'll have to
1633 # check and fetch missing archives before attempting to unpack them.
1637 # This feature will *NOT* work correctly with vanilla GNU make becuase
1638 # it makes use of includedep to avoid too many unnecessary files.
1641 # 1. Download corruption / continuation.
1642 # 2. It's quite possible that there is one too many indirect dependency now...
1645 ## generates the fetch rule
1646 define def_fetch_src_fetch_rule
1647 # Indirect goal for downloading something.
1649 $(out
) + $($(target
)_
$(srcname
)_FETCH_2_OUTPUT
) +|
$($(target
)_
$(srcname
)_FETCH_2_OUTPUT_MAYBE
) : \
1650 |
$($(target
)_
$(srcname
)_FETCH_2_DEPORD
)
1651 %$$(call MSG_FETCH_DL
,$(target
),$(source
),$(out
))
1652 @
## @todo do fancy stuff like download continuation.
1653 $$(QUIET
)$$(RM
) -f
-- $(out
)
1655 $$(QUIET
)$(if
$(md5
),$$(MD5SUM_EXT
) -b
-C
$(md5
) $(out
))
1659 # Intermediate goal for making sure the md5 and size matches. it will (re) fetch the archive if necessary.
1660 $(out
).checked_
$(md5
)_
$(size
): $($(target
)_
$(srcname
)_FETCH_2_DEPEND
) |
$($(target
)_
$(srcname
)_FETCH_2_DEPORD
)
1661 %$$(call MSG_FETCH_CHK
,$(target
),$(source
),$(out
))
1662 $$(QUIET
)$$(RM
) -f
-- $$@
1663 @
# (re)fetch the file if it doesn't exist or if it doesn't matches the md5.
1664 @
## @todo do fancy stuff like download continuation.
1665 $$(QUIET
)( test -f
$(out
) && $(if
$(md5
),$$(MD5SUM_EXT
) -b
-C
$(md5
) $(out
), true
) ) \
1666 ||
( $$(RM_EXT
) -f
$(out
) \
1667 && $$(MAKE
) $(out
) -f
$(MAKEFILE
) --no-print-directory
)
1668 $$(QUIET2
)$$(APPEND
) $$@
1670 _TARGET_
$(target
)_FETCHED
+= $(out
) $(out
).checked_
$(md5
)_
$(size
)
1672 # Just a little precaution.
1673 .NOTPARALLEL
: $(out
) $(out
).checked_
$(md5
)_
$(size
)
1675 endef # def_fetch_src_fetch_rule
1676 $(eval-opt-var def_fetch_src_fetch_rule
)
1678 ## generates the unpack rule
1679 define def_fetch_src_unpack_rule
1680 # This is the unpack rule. it has an order-only dependency on the download check.
1681 $(out
) + $($(target
)_
$(srcname
)_UNPACK_2_OUTPUT
) +|
$($(target
)_
$(srcname
)_UNPACK_2_OUTPUT_MAYBE
) : \
1682 $($(target
)_
$(srcname
)_UNPACK_2_DEPEND
) \
1683 |
$($(target
)_
$(srcname
)_UNPACK_2_DEPORD
) \
1684 $(archive
).checked_
$(md5
)_
$(size
) \
1686 %$$(call MSG_FETCH_UP
,$(target
),$(archive
),$(inst
))
1687 $$(QUIET
)$$(RM
) -f
-- $(out
)
1688 $$(QUIET
)$$(MKDIR
) -p
-- $(dir $(out
))
1689 @
# if the source archive doesn't exist fetch it (may have been deleted to save space).
1690 $$(QUIET
)test -f
$(archive
) \
1691 ||
( $$(RM_EXT
) -f
$(archive
).checked_
$(md5
)_
$(size
) \
1692 && $$(MAKE
) $(archive
).checked_
$(md5
)_
$(size
) -f
$(MAKEFILE
) --no-print-directory
)
1694 $$(QUIET2
)$$(APPEND
) $(out
) $(notdir $(archive
).checked_
$(md5
)_
$(size
))
1695 $$(QUIET2
)$$(APPEND
) $(out
) $(notdir $(out
))
1697 $(eval _TARGET_
$(target
)_UNPACKED
+= $(out
))
1698 _TARGET_
$(target
)_DIGEST
:= $(_TARGET_
$(target
)_DIGEST
)-$(srcname
)_
$(md5
)_
$(size
)
1700 .NOTPARALLEL
: $(out
)
1702 endef # def_fetch_src_unpack_rule
1703 $(eval-opt-var def_fetch_src_unpack_rule
)
1705 ## Processes a fetch source
1707 define def_fetch_src
1708 #$ (warning dbg: def_fetch_src: source='$(source)' target='$(target)')
1711 local srcname
:= $(notdir $(source
))
1712 local inst
:= $(firstword \
1713 $($(target
)_
$(source
)_INST
)\
1714 $($(target
)_
$(srcname
)_INST
)\
1719 ifneq ($(patsubst %/,ok
,$(inst
)),ok
)
1720 $(error kBuild
: Bad or missing INST property for source
'$(source)' in target
'$(target)': $(inst
))
1722 INSTARGET_
$(target
)_
$(srcname
) := $(inst
)
1723 local fetchdir
:= $(firstword \
1724 $($(target
)_
$(source
)_FETCHDIR
)\
1725 $($(target
)_
$(srcname
)_FETCHDIR
)\
1726 $($(source
)_FETCHDIR
)\
1727 $($(srcname
)_FETCHDIR
)\
1728 $($(target
)_FETCHDIR
)\
1733 $($(target
)_
$(source
)_DEPS
)\
1734 $($(target
)_
$(srcname
)_DEPS
)\
1738 local orderdeps
:= \
1739 $($(target
)_
$(source
)_ORDERDEPS
)\
1740 $($(target
)_
$(srcname
)_ORDERDEPS
)\
1741 $($(source
)_ORDERDEPS
)\
1742 $($(srcname
)_ORDERDEPS
)\
1743 $($(target
)_ORDERDEPS
)
1744 local md5
:= $(firstword \
1745 $($(target
)_
$(source
)_MD5
)\
1746 $($(target
)_
$(srcname
)_MD5
)\
1751 local size
:= $(firstword \
1752 $($(target
)_
$(source
)_SIZE
)\
1753 $($(target
)_
$(srcname
)_SIZE
)\
1759 $($(target
)_
$(source
)_CLEAN
)\
1760 $($(target
)_
$(srcname
)_CLEAN
)\
1763 local dep
:= # not legal for fetch and unpack tools
1769 local out
:= $(fetchdir
)/$(srcname
)
1770 local archive
:= $(out
)
1771 TARGET_
$(target
)_
$(srcname
) := $(out
)
1772 $(target
)_
$(srcname
)_1_TARGET
= $(TARGET_
$(target
)_
$(srcname
))
1773 local dirdep
:= $(call DIRDEP
,$(fetchdir
))
1774 local tool
:= $(firstword \
1775 $($(target
)_
$(source
)_FETCHTOOL
)\
1776 $($(target
)_
$(srcname
)_FETCHTOOL
)\
1777 $($(target
)_
$(source
)_TOOL
)\
1778 $($(target
)_
$(srcname
)_TOOL
)\
1779 $($(source
)_FETCHTOOL
)\
1780 $($(srcname
)_FETCHTOOL
)\
1783 $($(target
)_FETCHTOOL
)\
1787 $(TOOL_
$(tool
)_FETCHFLAGS
)\
1789 $($(target
)_FETCHFLAGS
)\
1790 $($(srcname
)_FETCHFLAGS
)\
1791 $($(source
)_FETCHFLAGS
)\
1792 $($(target
)_
$(srcname
)_FETCHFLAGS
)\
1793 $($(target
)_
$(source
)_FETCHFLAGS
)
1795 #$ (warning dbg: target=$(target) source=$(source) $(srcname)=$(srcname) tool=$(tool) out=$(out) flags=$(flags) dirdep=$(dirdep) fetchdir=$(fetchdir) md5=$(md5) size=$(size))
1797 ifndef TOOL_
$(tool
)_FETCH_CMDS
1798 $(warning kBuild
: tools
: \
1799 1 $($(target
)_
$(source
)_FETCHTOOL
)\
1800 2 $($(target
)_
$(srcname
)_FETCHTOOL
)\
1801 3 $($(target
)_
$(source
)_TOOL
)\
1802 4 $($(target
)_
$(srcname
)_TOOL
)\
1803 5 $($(source
)_FETCHTOOL
)\
1804 6 $($(srcname
)_FETCHTOOL
)\
1805 7 $($(source
)_TOOL
)\
1806 8 $($(srcname
)_TOOL
)\
1807 9 $($(target
)_FETCHTOOL
)\
1808 10 $($(target
)_TOOL
) )
1809 $(error kBuild
: TOOL_
$(tool
)_FETCH_CMDS is not defined. source
=$(source
) target
=$(target
) )
1813 local cmds
:= $(TOOL_
$(tool
)_FETCH_CMDS
)
1814 $(target
)_
$(srcname
)_FETCH_2_OUTPUT
:= $(TOOL_
$(tool
)_FETCH_OUTPUT
)
1815 $(target
)_
$(srcname
)_FETCH_2_OUTPUT_MAYBE
:= $(TOOL_
$(tool
)_FETCH_OUTPUT_MAYBE
)
1816 $(target
)_
$(srcname
)_FETCH_2_DEPEND
:= $(TOOL_
$(tool
)_FETCH_DEPEND
) $(deps
)
1817 $(target
)_
$(srcname
)_FETCH_2_DEPORD
:= $(TOOL_
$(tool
)_FETCH_DEPORD
) $(dirdep
) $(orderdeps
)
1819 # generate the fetch rule.
1820 $(eval
$(def_fetch_src_fetch_rule
))
1824 # The unpacking / installing.
1826 local out
:= $(inst
)_kBuild_
$(target
)_
$(srcname
)_unpacked.lst
1827 local dirdep
:= $(call DIRDEP
,$(inst
))
1828 local tool
:= $(firstword \
1829 $($(target
)_
$(source
)_UNPACKTOOL
)\
1830 $($(target
)_
$(srcname
)_UNPACKTOOL
)\
1831 $($(target
)_
$(source
)_TOOL
)\
1832 $($(target
)_
$(srcname
)_TOOL
)\
1833 $($(source
)_UNPACKTOOL
)\
1834 $($(srcname
)_UNPACKTOOL
)\
1837 $($(target
)_UNPACKTOOL
)\
1841 local tool
:= $(toupper
$(subst .
,,$(suffix $(subst tar.
,TAR
,$(srcname
)))))
1842 $(evalval def_tools_include
)
1845 $(TOOL_
$(tool
)_UNPACKFLAGS
)\
1847 $($(target
)_UNPACKFLAGS
)\
1848 $($(srcname
)_UNPACKFLAGS
)\
1849 $($(source
)_UNPACKFLAGS
)\
1850 $($(target
)_
$(srcname
)_UNPACKFLAGS
)\
1851 $($(target
)_
$(source
)_UNPACKFLAGS
)
1853 #$ (warning dbg: target=$(target) source=$(source) $(srcname)=$(srcname) tool=$(tool) out=$(out) flags=$(flags) dirdep=$(dirdep) inst=$(inst) md5=$(md5) size=$(size))
1854 ifndef TOOL_
$(tool
)_UNPACK_CMDS
1855 $(warning kBuild
: tools
: \
1856 1 $($(target
)_
$(source
)_UNPACKTOOL
)\
1857 2 $($(target
)_
$(srcname
)_UNPACKTOOL
)\
1858 3 $($(target
)_
$(source
)_TOOL
)\
1859 4 $($(target
)_
$(srcname
)_TOOL
)\
1860 5 $($(source
)_UNPACKTOOL
)\
1861 6 $($(srcname
)_UNPACKTOOL
)\
1862 7 $($(source
)_TOOL
)\
1863 8 $($(srcname
)_TOOL
)\
1864 9 $($(target
)_UNPACKTOOL
)\
1865 10 $($(target
)_TOOL
) \
1866 11 $(toupper
$(subst tar.
,TAR
,$(ext
$(srcname
)))) \
1868 $(error kBuild
: TOOL_
$(tool
)_UNPACK_CMDS is not defined. source
=$(source
) target
=$(target
) )
1872 local cmds
:= $(TOOL_
$(tool
)_UNPACK_CMDS
)
1873 $(target
)_
$(srcname
)_UNPACK_2_OUTPUT
:= $(TOOL_
$(tool
)_UNPACK_OUTPUT
)
1874 $(target
)_
$(srcname
)_UNPACK_2_OUTPUT_MAYBE
:= $(TOOL_
$(tool
)_UNPACK_OUTPUT_MAYBE
)
1875 $(target
)_
$(srcname
)_UNPACK_2_DEPEND
:= $(TOOL_
$(tool
)_UNPACK_DEPEND
) $(deps
)
1876 $(target
)_
$(srcname
)_UNPACK_2_DEPORD
:= $(TOOL_
$(tool
)_UNPACK_DEPORD
) $(dirdep
) $(orderdeps
)
1878 # generate the fetch rule.
1879 $(eval
$(def_fetch_src_unpack_rule
))
1881 _DIRS
+= $(inst
) $(fetchdir
)
1883 endef # def_fetch_src
1884 $(eval-opt-var def_fetch_src
)
1888 # Define the target level rules for a fetch.
1892 # @param _TARGET_$(target)_UNPACKED
1893 # @param _TARGET_$(target)_DIGEST
1895 # @param bld_trg_arch
1896 define def_fetch_rules
1898 $(out
).lst
: $(_TARGET_
$(target
)_UNPACKED
) |
$(call DIRDEP
,$(inst
))
1899 %$$(call MSG_FETCH_OK
,$(target
))
1900 $$(QUIET
)$$(RM
) -f
-- $$@
$$@.tmp
1901 $$(QUIET2
)$$(APPEND
) $$@.tmp
'$(notdir $(out))'
1902 $$(QUIET
)$(if
$(_TARGET_
$(target
)_UNPACKED
),$$(CAT_EXT
) $(_TARGET_
$(target
)_UNPACKED
) >> $$@.tmp
)
1903 $$(QUIET
)$$(MV
) -f
-- $$@.tmp
$$@
1906 %$$(call MSG_UNFETCH
,$(target
))
1907 $$(QUIET
)$$(RM
) -f
-- $$(addprefix $(inst
),$$(shell $$(CAT_EXT
) $(out
).lst
2> /dev
/null |
$$(SED
) -e
'/\/$$$$/d'))
1908 $$(QUIET
)$$(RMDIR
) -p
--ignore-fail-on-non-empty
--ignore-fail-on-not-exist
-- $$(dir $$@
) \
1909 $$(addprefix $(inst
),$$(sort $$(dir $$(shell $$(CAT_EXT
) $(out
).lst
2> /dev
/null
))))
1910 $$(QUIET
)$$(RM
) -f
-- $(out
).lst
$(out
)
1911 $$(QUIET
)$$(RMDIR
) -p
--ignore-fail-on-non-empty
--ignore-fail-on-not-exist
-- $$(dir $$@
)
1913 $(out
): $(comp-vars _TARGET_
$(target
)_DIGEST_PREV
,_TARGET_
$(target
)_DIGEST
,FORCE
) |
$(call DIRDEP
,$(inst
))
1914 $$(QUIET
)$$(RM
) -f
-- $$@
1915 %$$(if
$$(_TARGET_
$(target
)_DIGEST
),$$(if
$$(eq
$$(file-size
$(out
).lst
),-1)\
1916 ,$$(call MSG_REFETCH
,$(target
)),$$(call MSG_FETCH
,$(target
))),$$(call MSG_UNFETCH
,$(target
)))
1917 $$(QUIET
)$(TEST_EXT
) -f
$(out
).lst
-- $$(MAKE
) -f
$(MAKEFILE
) --no-print-directory
$(out
)_unfetched
1918 $$(QUIET
)$$(if
$$(_TARGET_
$(target
)_DIGEST
),$$(MAKE
) -f
$(MAKEFILE
) --no-print-directory
$(out
).lst
,$$(RMDIR
) -p
--ignore-fail-on-non-empty
--ignore-fail-on-not-exist
-- $$(dir $$@
))
1919 $$(QUIET2
)$$(if
$$(_TARGET_
$(target
)_DIGEST
),$$(APPEND
) $$@
"_TARGET_$(target)_DIGEST_PREV := $(_TARGET_$(target)_DIGEST)")
1921 .NOTPARALLEL
: $(out
).lst
$(out
)_unfetched
$(out
)
1927 # Deal with one fetch target.
1930 # @param bld_trg_arch
1933 INSTARGET_
$(target
) := $($(target
)_INST
)
1934 ifneq ($(patsubst %/,ok
,$(INSTARGET_
$(target
))),ok
)
1935 $(error kBuild
: Bad or missing INST property for target
'$(target)'. \
1936 $(target
)_INST
='$($(target)_INST)' ($(origin $(target
)_INST
)))
1938 _TARGET_
$(target
)_FETCHED
:=
1939 _TARGET_
$(target
)_UNPACKED
:=
1940 _TARGET_
$(target
)_DIGEST
:=
1941 local clean_files
:= $($(target
)_CLEAN
) $($(target
)_CLEAN.
$(bld_trg
)) $($(target
)_CLEAN.
$(bld_trg
).
$(bld_trg_arch
)) $($(target
)_CLEAN.
$(bld_trg_arch
)) $($(target
)_CLEAN.
$(KBUILD_TYPE
))
1944 #$ (warning dbg fetch: target=$(target) sources=$($(target)_SOURCES) $($(target)_SOURCES.$(KBUILD_TYPE)) $($(target)_SOURCES.$(KBUILD_TARGET)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(KBUILD_TARGET).$(bld_trg_arch)))
1945 $(foreach source
,$($(target
)_SOURCES
) $($(target
)_SOURCES.
$(KBUILD_TYPE
)) $($(target
)_SOURCES.
$(bld_trg
)) $($(target
)_SOURCES.
$(bld_trg_arch
)) $($(target
)_SOURCES.
$(bld_trg
).
$(bld_trg_arch
)),\
1946 $(evalval def_fetch_src
))
1949 local inst
:= $(INSTARGET_
$(target
))
1950 local out
:= $(inst
)_kBuild_fetch_
$(target
)
1952 $(eval includedep
$(out
))
1954 $(eval
$(def_fetch_rules
))
1956 # Define the aliases here (doesn't work if defined in def_fetch_rules, just like includedep).
1958 $(target
)_unfetch
: $(out
)_unfetched
1961 _DOWNLOADS
+= $(_TARGET_
$(target
)_FETCHED
)
1962 _UNPACKS
+= $(_TARGET_
$(target
)_UNPACKED
)
1963 _UNFETCHES
+= $(out
)_unfetched
1965 _CLEAN_FILES
+= $(clean_files
)
1968 $(eval-opt-var def_fetch
)
1970 # Walk the FETCH target lists.
1971 bld_trg
:= $(KBUILD_TARGET
)
1972 bld_trg_arch
:= $(KBUILD_TARGET_ARCH
)
1973 $(foreach target
, $(_ALL_FETCHES
), \
1974 $(evalvalctx def_fetch
))
1977 download
: $(_DOWNLOADS
)
1980 unfetch
: $(_UNFETCHES
)
1982 ifdef KBUILD_PROFILE_SELF
1983 $(evalcall def_profile_self
, done fetching targets
)
1992 #define def_patch_src
1997 ## Deal with one patch target.
2000 #$(foreach source,$($(target)_SOURCES) $($(target)_SOURCES.$(KBUILD_TYPE)) $($(target)_SOURCES.$(KBUILD_TARGET)) $($(target)_SOURCES.$(KBUILD_TARGET_ARCH)) $($(target)_SOURCES.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)),\
2001 # $(evalval def_patch_src))
2006 #$(foreach target, $(_ALL_PATCHES), \
2007 # $(evalval def_patch))
2012 # Object processing.
2015 ## wrapper the compile command dependency check.
2016 ifndef NO_COMPILE_CMDS_DEPS
2017 if1of
($(KMK_FEATURES
),dot-must-make
)
2019 # for debugging: $$(warning MUST_MAKE=$$$$(comp-cmds-ex $$$$($(target)_$(subst :,_,$(source))_CMDS_PREV_), $$$$(commands $$@)) -> $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_CMDS_PREV_),$$(commands $$@),FORCE))
2021 _DEP_COMPILE_CMDS
= $$(comp-cmds-ex
$$($(target
)_
$(subst :,_
,$(source
))_CMDS_PREV_
),$$(commands
$(obj
)),FORCE
)
2028 ## Generates the rules for building a specific object, and the aliases
2029 # for building a source file.
2030 # @param $(obj) The object file.
2031 define def_target_source_rule
2032 ifndef NO_COMPILE_CMDS_DEPS
2033 $(obj
): .MUST_MAKE
= $$(comp-cmds-ex
$$($(target
)_
$(subst :,_
,$(source
))_CMDS_PREV_
),$$(commands
$$@
),FORCE
)
2035 ifdef TOOL_
$(tool
)_COMPILE_
$(type
)_USES_KOBJCACHE
2036 _OUT_FILES
+= $(outbase
).koc
2037 $(outbase
).koc
+|
$(obj
) $($(target
)_
$(source
)_OUTPUT_
) $($(target
)_
$(source
)_OUTPUT_MAYBE_
) : \
2038 $($(target
)_
$(source
)_DEPEND_
) \
2039 $(value _DEP_COMPILE_CMDS
) \
2041 $($(target
)_
$(source
)_DEPORD_
) \
2042 $$$$($(target
)_INTERMEDIATES
) \
2043 $$$$($(target
)_INTERMEDIATES.
$(bld_trg
)) \
2044 $$$$($(target
)_INTERMEDIATES.
$(bld_trg
).
$(bld_trg_arch
)) \
2045 $$$$($(target
)_INTERMEDIATES.
$(bld_trg_arch
)) \
2046 $$$$($(target
)_INTERMEDIATES.
$(bld_trg_cpu
)) \
2047 $$$$($(target
)_INTERMEDIATES.
$(bld_type
))
2048 %$$(call MSG_COMPILE
,$(target
),$(source
),$$@
,$(type
))
2050 $(obj
) + $($(target
)_
$(source
)_OUTPUT_
) +|
$($(target
)_
$(source
)_OUTPUT_MAYBE_
) : \
2051 $($(target
)_
$(source
)_DEPEND_
) \
2052 $(value _DEP_COMPILE_CMDS
) \
2054 $($(target
)_
$(source
)_DEPORD_
) \
2055 $$$$($(target
)_INTERMEDIATES
) \
2056 $$$$($(target
)_INTERMEDIATES.
$(bld_trg
)) \
2057 $$$$($(target
)_INTERMEDIATES.
$(bld_trg
).
$(bld_trg_arch
)) \
2058 $$$$($(target
)_INTERMEDIATES.
$(bld_trg_arch
)) \
2059 $$$$($(target
)_INTERMEDIATES.
$(bld_trg_cpu
)) \
2060 $$$$($(target
)_INTERMEDIATES.
$(bld_type
))
2061 %$$(call MSG_COMPILE
,$(target
),$(source
),$$@
,$(type
))
2062 ifdef TOOL_
$(tool
)_COMPILE_
$(type
)_DONT_PURGE_OUTPUT
2063 $$(QUIET
)$$(RM
) -f
-- $(dep
) $(obj
) $($(target
)_
$(source
)_OUTPUT_
) $($(target
)_OUTPUT_MAYBE_
)
2067 $($(target
)_
$(source
)_CMDS_
)
2069 ifndef NO_COMPILE_CMDS_DEPS
2070 %$$(QUIET2
)$$(APPEND
) '$(dep)'
2071 %$$(QUIET2
)$$(APPEND
) '$(dep)' 'define $(target)_$(subst :,_,$(source))_CMDS_PREV_'
2072 %$$(QUIET2
)$$(APPEND
) -c
'$(dep)' '$(obj)'
2073 %$$(QUIET2
)$$(APPEND
) '$(dep)' 'endef'
2076 $(basename $(notdir $(obj
))).o
: $(obj
)
2077 $(basename $(notdir $(obj
))).obj
: $(obj
)
2079 ## @todo make this 'local cmds,output,output_maybe,depend and depord' in 0.2.x or when a new kb-src-one is added.
2080 $(target
)_
$(source
)_CMDS_
:=
2081 $(target
)_
$(source
)_OUTPUT_
:=
2082 $(target
)_
$(source
)_OUTPUT_MAYBE_
:=
2083 $(target
)_
$(source
)_DEPEND_
:=
2084 $(target
)_
$(source
)_DEPORD_
:=
2085 endef # def_target_source_rule
2086 $(eval-opt-var def_target_source_rule
)
2089 ## wrapper the link command dependency check.
2090 ifndef NO_LINK_CMDS_DEPS
2091 if1of
($(KMK_FEATURES
),dot-must-make
)
2094 _DEP_LINK_CMDS
= $$(comp-cmds-ex
$$($(target
)_CMDS_PREV_
),$$(commands
$(out
)),FORCE
)
2100 ## Generate the link rule for a target.
2101 # @param $(target) The normalized target name.
2102 # @param $(dirdep) Directories we depend upon begin created before linking.
2103 # @param $(dep) The name of the dependency file.
2105 # @param $($(target)_2_OUTPUT) Output files from the link.
2106 # @param $($(target)_2_OUTPUT_MAYBE) Output files that the link may perhaps create.
2107 # @param $($(target)_2_DEPEND) Dependencies.
2108 # @param $($(target)_2_DEPORD) Dependencies which should only affect build order.
2109 # @param $(cmds) The link commands.
2110 # @param $($(target)_CMDS_PREV_) The link commands from the previous run.
2111 define def_link_rule
2112 ifndef NO_LINK_CMDS_DEPS
2113 $(out
): .MUST_MAKE
= $$(comp-cmds-ex
$$($(target
)_CMDS_PREV_
),$$(commands
$$@
),FORCE
)
2115 $(out
) + $($(target
)_2_OUTPUT
) +|
$($(target
)_2_OUTPUT_MAYBE
) : \
2116 $$$$($(target
)_2_DEPEND
) \
2117 $(value _DEP_LINK_CMDS
) \
2119 $$$$($(target
)_2_DEPORD
)
2120 %$$(call MSG_LINK
,$(target
),$$@
,$(tool_do
))
2121 $$(QUIET
)$$(RM
) -f
-- $(dep
) $(out
) $($(target
)_2_OUTPUT
) $($(target
)_2_OUTPUT_MAYBE
)
2125 ifndef NO_LINK_CMDS_DEPS
2126 %$$(QUIET2
)$$(APPEND
) '$(dep)' 'define $(target)_CMDS_PREV_'
2127 %$$(QUIET2
)$$(APPEND
) -c
'$(dep)' '$(out)'
2128 %$$(QUIET2
)$$(APPEND
) '$(dep)' 'endef'
2131 $(basename $(notdir $(out
))):: $(out
)
2133 endef # def_link_rule
2134 $(eval-opt-var def_link_rule
)
2137 ## Generate the link & lib install rule
2138 # @param $(target) Normalized target name.
2139 # @param $(out) The build target.
2140 # @param $(INSTARGET_$(target)) The installation targets.
2141 # @param $(mode) The file mode (optional)
2142 define def_link_install_rule
2143 $(INSTARGET_
$(target
)) : $(out
) |
$(call DIRDEP
,$(dir $(INSTARGET_
$(target
))))
2144 %$$(call MSG_INST_TRG
,$(target
),$(out
),$$@
)
2145 $$(QUIET
)$$(INSTALL
) $(if
$(mode
),-m
$(mode
)) $(if
$(uid
),-o
$(uid
)) $(if
$(gid
),-g
$(gid
)) -- $(out
) $$@
2147 ifdef KBUILD_DO_AUTO_INSTALL
2148 $(basename $(notdir $(out
))):: $(INSTARGET_
$(target
))
2150 endef # def_link_install_rule
2153 ## def_src_handler_*
2156 define def_src_handler_c
2161 define def_src_handler_cxx
2166 define def_src_handler_objc
2171 define def_src_handler_objcxx
2172 local type
:= OBJCXX
2176 define def_src_handler_asm
2181 define def_src_handler_rc
2186 define def_src_handler_obj
2188 $(target
)_2_OBJS
+= $(source
)
2190 $(target
)_2_OBJS
+= $(abspathex
$(source
), $(defpath
))
2195 ## Handle one source.
2197 define def_src_handler_one
2198 local suff
:= $(suffix $(source
))
2199 local src_handler
:= $(firstword $(filter $(suff
):%, $($(target
)_
$(source
)_SRC_HANDLERS
) $($(source
)_SRC_HANDLERS
) $(target_src_handlers
) ))
2200 local handler
:= $(patsubst $(suff
):%,%,$(src_handler
))
2202 $(evalvalctx
$(handler
))
2204 othersrc
+= $(source
)
2208 ## Generic macro for processing all target sources.
2209 # @param $(target) Normalized target name.
2211 # @param much-more...
2212 # @returns othersrc, $(target)_2_OBJS, ++
2213 define def_target_sources
2214 local target_src_handlers
:= $($(target
)_SRC_HANDLERS
) $(KBUILD_SRC_HANDLERS
)
2216 $($(target
)_SOURCES
)\
2217 $($(target
)_SOURCES.
$(bld_trg
))\
2218 $($(target
)_SOURCES.
$(bld_trg
).
$(bld_trg_arch
))\
2219 $($(target
)_SOURCES.
$(bld_trg_arch
))\
2220 $($(target
)_SOURCES.
$(bld_trg_cpu
))\
2221 $($(target
)_SOURCES.
$(bld_type
))\
2222 ,$(evalval def_src_handler_one
) )
2225 $($(target
)_GEN_SOURCES_
)\
2226 $($(target
)_GEN_SOURCES_.
$(bld_trg
))\
2227 $($(target
)_GEN_SOURCES_.
$(bld_trg
).
$(bld_trg_arch
))\
2228 $($(target
)_GEN_SOURCES_.
$(bld_trg_arch
))\
2229 $($(target
)_GEN_SOURCES_.
$(bld_trg_cpu
))\
2230 $($(target
)_GEN_SOURCES_.
$(bld_type
))\
2231 ,$(evalval def_src_handler_one
) )
2232 endef # def_target_sources
2233 $(eval-opt-var def_target_sources
)
2237 ## Generic macro for generating the install rule(s) for a target
2238 # and update the globals with default out.
2240 # @param $(target) Normalized target name.
2241 # @param $(out) The output file.
2242 # @param $(definst) The default _INST value.
2243 # @param $(typevar) The name of the variable with all the root targets of its type.
2244 # @remark Only library uses this now.
2245 define def_target_install_pluss
2246 ifeq ($(strip $($(target
)_NOINST
) $($(target
)_NOINST.
$(bld_trg
)) $($(target
)_NOINST.
$(bld_trg
).
$(bld_trg_arch
)) $($(target
)_NOINST.
$(bld_trg
).
$(bld_trg_arch
).
$(bld_type
)) $($(target
)_NOINST.
$(bld_trg_arch
)) $($(target
)_NOINST.
$(bld_trg_cpu
)) $($(target
)_NOINST.
$(bld_trg_type
))),)
2247 ifneq ($(strip $($(target
)_INST.
$(bld_trg
).
$(bld_trg_arch
).
$(bld_type
))),)
2248 local inst
:= $(addprefix $(PATH_INS
)/,$($(target
)_INST.
$(bld_trg
).
$(bld_trg_arch
).
$(bld_type
)))
2249 else ifneq ($(strip $($(target
)_INST.
$(bld_trg
).
$(bld_trg_arch
))),)
2250 local inst
:= $(addprefix $(PATH_INS
)/,$($(target
)_INST.
$(bld_trg
).
$(bld_trg_arch
)))
2251 else ifneq ($(strip $($(target
)_INST.
$(bld_trg
).
$(bld_type
))),)
2252 local inst
:= $(addprefix $(PATH_INS
)/,$($(target
)_INST.
$(bld_trg
).
$(bld_type
)))
2253 else ifneq ($(strip $($(target
)_INST.
$(bld_trg_arch
))),)
2254 local inst
:= $(addprefix $(PATH_INS
)/,$($(target
)_INST.
$(bld_trg_arch
)))
2255 else ifneq ($(strip $($(target
)_INST.
$(bld_trg
))),)
2256 local inst
:= $(addprefix $(PATH_INS
)/,$($(target
)_INST.
$(bld_trg
)))
2257 else ifneq ($(strip $($(target
)_INST.
$(bld_type
))),)
2258 local inst
:= $(addprefix $(PATH_INS
)/,$($(target
)_INST.
$(bld_type
)))
2259 else ifneq ($(strip $($(target
)_INST
)),)
2260 local inst
:= $(addprefix $(PATH_INS
)/,$($(target
)_INST
))
2262 local inst
:= $(definst
)/
2264 INSTARGET_
$(target
) := $(patsubst %/,%/$(notdir $(out
)),$(inst
))
2265 local mode
:= $(firstword \
2266 $($(target
)_MODE.
$(bld_trg
).
$(bld_trg_arch
).
$(bld_type
)) \
2267 $($(target
)_MODE.
$(bld_trg
).
$(bld_trg_arch
)) \
2268 $($(target
)_MODE.
$(bld_trg
).
$(bld_type
)) \
2269 $($(target
)_MODE.
$(bld_trg_arch
)) \
2270 $($(target
)_MODE.
$(bld_trg
)) \
2271 $($(target
)_MODE.
$(bld_type
)) \
2273 local uid
:= $(firstword \
2274 $($(target
)_UID.
$(bld_trg
).
$(bld_trg_arch
).
$(bld_type
)) \
2275 $($(target
)_UID.
$(bld_trg
).
$(bld_trg_arch
)) \
2276 $($(target
)_UID.
$(bld_trg
).
$(bld_type
)) \
2277 $($(target
)_UID.
$(bld_trg_arch
)) \
2278 $($(target
)_UID.
$(bld_trg
)) \
2279 $($(target
)_UID.
$(bld_type
)) \
2281 local gid
:= $(firstword \
2282 $($(target
)_GID.
$(bld_trg
).
$(bld_trg_arch
).
$(bld_type
)) \
2283 $($(target
)_GID.
$(bld_trg
).
$(bld_trg_arch
)) \
2284 $($(target
)_GID.
$(bld_trg
).
$(bld_type
)) \
2285 $($(target
)_GID.
$(bld_trg_arch
)) \
2286 $($(target
)_GID.
$(bld_trg
)) \
2287 $($(target
)_GID.
$(bld_type
)) \
2290 # generate the install rule
2291 $(eval
$(def_link_install_rule
))
2293 _INSTALLS_FILES
+= $(INSTARGET_
$(target
))
2295 ifdef KBUILD_DO_AUTO_INSTALL
2296 $(typevar
) += $(INSTARGET_
$(target
))
2298 $(typevar
) += $(out
)
2301 $(typevar
) += $(out
)
2304 _OUT_FILES
+= $($(target
)_2_OUTPUT
) $($(target
)_2_OUTPUT_MAYBE
) $(out
)
2305 _CLEAN_FILES
+= $($(target
)_CLEAN
) $($(target
)_CLEAN.
$(bld_trg
)) $($(target
)_CLEAN.
$(bld_trg
).
$(bld_trg_arch
)) $($(target
)_CLEAN.
$(bld_trg_arch
)) $($(target
)_CLEAN.
$(bld_trg_cpu
)) $($(target
)_CLEAN.
$(bld_type
))
2306 _DIRS
+= $($(target
)_BLDDIRS
) $($(target
)_BLDDIRS.
$(bld_trg
)) $($(target
)_BLDDIRS.
$(bld_trg
).
$(bld_trg_arch
)) $($(target
)_BLDDIRS.
$(bld_trg_arch
)) $($(target
)_BLDDIRS.
$(bld_trg_cpu
)) $($(target
)_BLDDIRS.
$(bld_type
))
2307 _OBJS
+= $($(target
)_2_OBJS
)
2309 endef # def_target_install_pluss
2318 # @param $(target) Normalized library (target) name.
2322 local bld_type
:= $(firstword $($(target
)_BLD_TYPE
) $(KBUILD_TYPE
))
2323 local bld_trg
:= $(firstword $($(target
)_BLD_TRG
) $(KBUILD_TARGET
))
2324 local bld_trg_arch
:= $(firstword $($(target
)_BLD_TRG_ARCH
) $(KBUILD_TARGET_ARCH
))
2325 local bld_trg_cpu
:= $(firstword $($(target
)_BLD_TRG_CPU
) $(KBUILD_TARGET_CPU
))
2326 local tool
:= $(call _TARGET_TOOL
,$(target
),AR
)
2328 $(error kBuild
: Library target
$(target
) does not have a tool defined
!)
2330 local name
:= $(firstword\
2331 $($(target
)_NAME.
$(bld_trg
).
$(bld_trg_arch
))\
2332 $($(target
)_NAME.
$(bld_trg_arch
))\
2333 $($(target
)_NAME.
$(bld_trg
))\
2334 $($(target
)_NAME.
$(bld_type
))\
2337 local outbase
:= $(call TARGET_BASE
,$(name
),$(target
))
2338 $(target
)_0_OUTDIR
:= $(patsubst %/,%,$(dir $(outbase
)))
2339 PATH_
$(target
) := $($(target
)_0_OUTDIR
)
2340 local suff
:= $(firstword\
2341 $($(target
)_LIBSUFF.
$(bld_trg
).
$(bld_trg_arch
))\
2342 $($(target
)_LIBSUFF.
$(bld_trg
))\
2343 $($(target
)_LIBSUFF
)\
2344 $(TOOL_
$(tool
)_ARLIBSUFF.
$(bld_trg
).
$(bld_trg_arch
))\
2345 $(TOOL_
$(tool
)_ARLIBSUFF.
$(bld_trg
))\
2346 $(TOOL_
$(tool
)_ARLIBSUFF
)\
2348 local out
:= $(outbase
)$(suff
)
2349 local defpath
:= $(firstword $($(target
)_PATH
) $($(target
)_DEFPATH
))
2350 TARGET_
$(target
) := $(out
)
2351 $(target
)_1_TARGET
:= $(out
)
2352 # no local here - must be writable across some foreachs.
2356 # Do units pre source callouts.
2358 $($(target
)_USES.
$(bld_trg
).
$(bld_trg_arch
))\
2359 $($(target
)_USES.
$(bld_trg_arch
))\
2360 $($(target
)_USES.
$(bld_trg
))\
2361 $($(target
)_USES.
$(bld_type
))\
2363 $(foreach unit
,$(units
),$(evalval def_unit_
$(unit
)_target_pre
))
2366 $(evalval def_target_sources
)
2369 local tool
:= $(call _TARGET_TOOL
,$(target
),AR
)
2370 local name
:= $(firstword\
2371 $($(target
)_NAME.
$(bld_trg
).
$(bld_trg_arch
))\
2372 $($(target
)_NAME.
$(bld_trg_arch
))\
2373 $($(target
)_NAME.
$(bld_trg
))\
2374 $($(target
)_NAME.
$(bld_type
))\
2377 local outbase
:= $(call TARGET_BASE
,$(name
),$(target
))
2379 $(TOOL_
$(tool
)_ARFLAGS
)\
2380 $(TOOL_
$(tool
)_ARFLAGS.
$(bld_type
))\
2382 $(ARFLAGS.
$(bld_type
))\
2383 $($(target
)_ARFLAGS
)\
2384 $($(target
)_ARFLAGS.
$(bld_type
)) \
2385 $($(target
)_ARFLAGS.
$(bld_trg
)) \
2386 $($(target
)_ARFLAGS.
$(bld_trg_arch
)) \
2387 $($(target
)_ARFLAGS.
$(bld_trg
).
$(bld_trg_arch
)) \
2388 $($(target
)_ARFLAGS.
$(bld_trg_cpu
))
2389 local dirdep
:= $(call DIRDEP
,$(dir $(out
)))
2391 $($(target
)_DEPS.
$(bld_trg_cpu
)) \
2392 $($(target
)_DEPS.
$(bld_trg
).
$(bld_trg_arch
).
$(bld_type
)) \
2393 $($(target
)_DEPS.
$(bld_trg
).
$(bld_trg_arch
)) \
2394 $($(target
)_DEPS.
$(bld_trg
).
$(bld_type
)) \
2395 $($(target
)_DEPS.
$(bld_trg_arch
)) \
2396 $($(target
)_DEPS.
$(bld_trg
)) \
2397 $($(target
)_DEPS.
$(bld_type
)) \
2399 $($(target
)_LNK_DEPS.
$(bld_trg_cpu
)) \
2400 $($(target
)_LNK_DEPS.
$(bld_trg
).
$(bld_trg_arch
).
$(bld_type
)) \
2401 $($(target
)_LNK_DEPS.
$(bld_trg
).
$(bld_trg_arch
)) \
2402 $($(target
)_LNK_DEPS.
$(bld_trg
).
$(bld_type
)) \
2403 $($(target
)_LNK_DEPS.
$(bld_trg_arch
)) \
2404 $($(target
)_LNK_DEPS.
$(bld_trg
)) \
2405 $($(target
)_LNK_DEPS.
$(bld_type
)) \
2406 $($(target
)_LNK_DEPS
)
2407 local orderdeps
:= \
2408 $($(target
)_ORDERDEPS.
$(bld_trg_cpu
)) \
2409 $($(target
)_ORDERDEPS.
$(bld_trg
).
$(bld_trg_arch
).
$(bld_type
)) \
2410 $($(target
)_ORDERDEPS.
$(bld_trg
).
$(bld_trg_arch
)) \
2411 $($(target
)_ORDERDEPS.
$(bld_trg
).
$(bld_type
)) \
2412 $($(target
)_ORDERDEPS.
$(bld_trg_arch
)) \
2413 $($(target
)_ORDERDEPS.
$(bld_trg
)) \
2414 $($(target
)_ORDERDEPS.
$(bld_type
)) \
2415 $($(target
)_ORDERDEPS
) \
2416 $($(target
)_LNK_ORDERDEPS.
$(bld_trg_cpu
)) \
2417 $($(target
)_LNK_ORDERDEPS.
$(bld_trg
).
$(bld_trg_arch
).
$(bld_type
)) \
2418 $($(target
)_LNK_ORDERDEPS.
$(bld_trg
).
$(bld_trg_arch
)) \
2419 $($(target
)_LNK_ORDERDEPS.
$(bld_trg
).
$(bld_type
)) \
2420 $($(target
)_LNK_ORDERDEPS.
$(bld_trg_arch
)) \
2421 $($(target
)_LNK_ORDERDEPS.
$(bld_trg
)) \
2422 $($(target
)_LNK_ORDERDEPS.
$(bld_type
)) \
2423 $($(target
)_LNK_ORDERDEPS
)
2425 # Adjust paths if we got a default path.
2427 local deps
:= $(abspathex
$(deps
),$(defpath
))
2428 local orderdeps
:= $(abspathex
$(orderdeps
),$(defpath
))
2429 othersrc
:= $(abspathex
$(othersrc
),$(defpath
))
2433 # Custom pre-link actions.
2434 ## @todo bld_trg_cpu is missing here.
2435 ifdef $(target
)_PRE_CMDS.
$(bld_trg
).
$(bld_trg_arch
).
$(bld_type
)
2436 local pre_cmds
:= $($(target
)_PRE_CMDS.
$(bld_trg
).
$(bld_trg_arch
).
$(bld_type
))
2437 else ifdef $(target
)_PRE_CMDS.
$(bld_trg
).
$(bld_trg_arch
)
2438 local pre_cmds
:= $($(target
)_PRE_CMDS.
$(bld_trg
).
$(bld_trg_arch
))
2439 else ifdef $(target
)_PRE_CMDS.
$(bld_trg
).
$(bld_type
)
2440 local pre_cmds
:= $($(target
)_PRE_CMDS.
$(bld_trg
).
$(bld_type
))
2441 else ifdef $(target
)_PRE_CMDS.
$(bld_trg_arch
)
2442 local pre_cmds
:= $($(target
)_PRE_CMDS.
$(bld_trg_arch
))
2443 else ifdef $(target
)_PRE_CMDS.
$(bld_trg
)
2444 local pre_cmds
:= $($(target
)_PRE_CMDS.
$(bld_trg
))
2445 else ifdef $(target
)_PRE_CMDS.
$(bld_type
)
2446 local pre_cmds
:= $($(target
)_PRE_CMDS.
$(bld_type
))
2447 else ifdef $(target
)_PRE_CMDS
2448 local pre_cmds
:= $($(target
)_PRE_CMDS
)
2449 else ifdef PRE_CMDS.
$(bld_trg
).
$(bld_trg_arch
).
$(bld_type
)
2450 local pre_cmds
:= $(PRE_CMDS.
$(bld_trg
).
$(bld_trg_arch
).
$(bld_type
))
2451 else ifdef PRE_CMDS.
$(bld_trg
).
$(bld_trg_arch
)
2452 local pre_cmds
:= $(PRE_CMDS.
$(bld_trg
).
$(bld_trg_arch
))
2453 else ifdef PRE_CMDS.
$(bld_trg
).
$(bld_type
)
2454 local pre_cmds
:= $(PRE_CMDS.
$(bld_trg
).
$(bld_type
))
2455 else ifdef PRE_CMDS.
$(bld_trg_arch
)
2456 local pre_cmds
:= $(PRE_CMDS.
$(bld_trg_arch
))
2457 else ifdef PRE_CMDS.
$(bld_trg
)
2458 local pre_cmds
:= $(PRE_CMDS.
$(bld_trg
))
2459 else ifdef PRE_CMDS.
$(bld_type
)
2460 local pre_cmds
:= $(PRE_CMDS.
$(bld_type
))
2462 local pre_cmds
:= $(PRE_CMDS
)
2465 # Custom post-link actions.
2466 ifdef $(target
)_POST_CMDS.
$(bld_trg
).
$(bld_trg_arch
).
$(bld_type
)
2467 local post_cmds
:= $($(target
)_POST_CMDS.
$(bld_trg
).
$(bld_trg_arch
).
$(bld_type
))
2468 else ifdef $(target
)_POST_CMDS.
$(bld_trg
).
$(bld_trg_arch
)
2469 local post_cmds
:= $($(target
)_POST_CMDS.
$(bld_trg
).
$(bld_trg_arch
))
2470 else ifdef $(target
)_POST_CMDS.
$(bld_trg
).
$(bld_type
)
2471 local post_cmds
:= $($(target
)_POST_CMDS.
$(bld_trg
).
$(bld_type
))
2472 else ifdef $(target
)_POST_CMDS.
$(bld_trg_arch
)
2473 local post_cmds
:= $($(target
)_POST_CMDS.
$(bld_trg_arch
))
2474 else ifdef $(target
)_POST_CMDS.
$(bld_trg
)
2475 local post_cmds
:= $($(target
)_POST_CMDS.
$(bld_trg
))
2476 else ifdef $(target
)_POST_CMDS.
$(bld_type
)
2477 local post_cmds
:= $($(target
)_POST_CMDS.
$(bld_type
))
2478 else ifdef $(target
)_POST_CMDS
2479 local post_cmds
:= $($(target
)_POST_CMDS
)
2480 else ifdef POST_CMDS.
$(bld_trg
).
$(bld_trg_arch
).
$(bld_type
)
2481 local post_cmds
:= $(POST_CMDS.
$(bld_trg
).
$(bld_trg_arch
).
$(bld_type
))
2482 else ifdef POST_CMDS.
$(bld_trg
).
$(bld_trg_arch
)
2483 local post_cmds
:= $(POST_CMDS.
$(bld_trg
).
$(bld_trg_arch
))
2484 else ifdef POST_CMDS.
$(bld_trg
).
$(bld_type
)
2485 local post_cmds
:= $(POST_CMDS.
$(bld_trg
).
$(bld_type
))
2486 else ifdef POST_CMDS.
$(bld_trg_arch
)
2487 local post_cmds
:= $(POST_CMDS.
$(bld_trg_arch
))
2488 else ifdef POST_CMDS.
$(bld_trg
)
2489 local post_cmds
:= $(POST_CMDS.
$(bld_trg
))
2490 else ifdef POST_CMDS.
$(bld_type
)
2491 local post_cmds
:= $(POST_CMDS.
$(bld_type
))
2493 local post_cmds
:= $(POST_CMDS
)
2496 # eliminate this guy?
2497 local objs
= $($(target
)_2_OBJS
)
2500 local dep
:= $(out
)$(SUFF_DEP
)
2501 ifndef NO_LINK_CMDS_DEPS
2502 _DEPFILES_INCLUDED
+= $(dep
)
2503 ifdef KB_HAVE_INCLUDEDEP_QUEUE
2504 includedep-queue
$(dep
)
2510 # check that the tool is defined.
2511 ifndef TOOL_
$(tool
)_LINK_LIBRARY_CMDS
2512 $(warning kBuild
: tools
: \
2513 1 $($(target
)_
$(source
)TOOL.
$(bld_trg
).
$(bld_trg_arch
)) \
2514 2 $($(target
)_
$(source
)TOOL.
$(bld_trg
)) \
2515 3 $($(target
)_
$(source
)TOOL
) \
2516 4 $($(target
)_TOOL.
$(bld_trg
).
$(bld_trg_arch
)) \
2517 5 $($(target
)_TOOL.
$(bld_trg
)) \
2518 6 $($(target
)_TOOL
) \
2519 7 $($(source
)TOOL
) \
2520 8 $($(source
)TOOL.
$(bld_trg
).
$(bld_trg_arch
)) \
2521 9 $($(source
)TOOL.
$(bld_trg
)) \
2522 10 $(TOOL.
$(bld_trg
).
$(bld_trg_arch
)) \
2523 11 $(TOOL.
$(bld_trg
)) \
2525 $(error kBuild
: TOOL_
$(tool
)_LINK_LIBRARY_CMDS isn
't defined! target=$(target) )
2529 local cmds := $(TOOL_$(tool)_LINK_LIBRARY_CMDS)
2530 ifneq ($(pre_cmds),)
2531 local cmds := $(TAB)$(pre_cmds)$(NL)$(TAB)$(cmds)
2533 ifneq ($(post_cmds),)
2534 local cmds := $(cmds)$(NL)$(TAB)$(post_cmds)
2536 $(target)_2_OUTPUT := $(TOOL_$(tool)_LINK_LIBRARY_OUTPUT)
2537 $(target)_2_OUTPUT_MAYBE := $(TOOL_$(tool)_LINK_LIBRARY_OUTPUT_MAYBE)
2538 $(target)_2_DEPEND := $(TOOL_$(tool)_LINK_LIBRARY_DEPEND) $(deps) $($(target)_2_OBJS)
2539 $(target)_2_DEPORD := $(TOOL_$(tool)_LINK_LIBRARY_DEPORD) $(dirdep) $(orderdeps)
2541 # generate the link rule.
2542 $(eval $(def_link_rule))
2544 # installing and globals
2545 $(evalval def_target_install_pluss)
2547 $(eval-opt-var def_lib)
2550 definst := $(PATH_LIB)
2552 tool_do := LINK_LIBRARY
2554 $(foreach target, $(_ALL_LIBRARIES), $(evalval def_lib))
2556 ifdef KBUILD_PROFILE_SELF
2557 $(evalcall def_profile_self, done library targets)
2568 # @param $(target) Normalized target name.
2569 # @param $(EXT) EXE,DLL,SYS.
2570 # @param $(definst) The default _INST value.
2571 # @param $(typevar) The name of the variable with all the root targets of its type.
2572 define def_link_common
2574 local bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE))
2575 local bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_$(bld_trg_base_var)))
2576 local bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_$(bld_trg_base_var)_ARCH))
2577 local bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_$(bld_trg_base_var)_CPU))
2579 local tool := $(call _TARGET_TOOL,$(target),LD)
2580 local name := $(firstword\
2581 $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\
2582 $($(target)_NAME.$(bld_trg_arch))\
2583 $($(target)_NAME.$(bld_trg))\
2584 $($(target)_NAME.$(bld_type))\
2587 local outbase := $(call TARGET_BASE,$(name),$(target))
2588 $(target)_0_OUTDIR:= $(patsubst %/,%,$(dir $(outbase)))
2589 PATH_$(target) := $($(target)_0_OUTDIR)
2590 local suff := $(firstword \
2591 $($(target)_$(EXT)SUFF.$(bld_trg).$(bld_trg_arch))\
2592 $($(target)_$(EXT)SUFF.$(bld_trg))\
2593 $($(target)_$(EXT)SUFF)\
2594 $(TOOL_$(tool)_LD$(EXT)SUFF.$(bld_trg).$(bld_trg_arch))\
2595 $(TOOL_$(tool)_LD$(EXT)SUFF.$(bld_trg))\
2596 $(TOOL_$(tool)_LD$(EXT)SUFF)\
2597 $($(EXTPRE)SUFF_$(EXT)) )
2598 local out := $(outbase)$(suff)
2599 TARGET_$(target) := $(out)
2600 $(target)_1_TARGET:= $(out)
2601 local defpath := $(firstword $($(target)_PATH) $($(target)_DEFPATH))
2602 # no local here - must be writable across some foreachs.
2606 # Do units pre source callouts.
2608 $($(target)_USES.$(bld_trg).$(bld_trg_arch))\
2609 $($(target)_USES.$(bld_trg_arch))\
2610 $($(target)_USES.$(bld_trg))\
2611 $($(target)_USES.$(bld_type))\
2613 $(foreach unit,$(units),$(evalval def_unit_$(unit)_target_pre))
2616 $(evalval def_target_sources)
2619 local tool := $(call _TARGET_TOOL,$(target),LD)
2620 local name := $(firstword\
2621 $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\
2622 $($(target)_NAME.$(bld_trg_arch))\
2623 $($(target)_NAME.$(bld_trg))\
2624 $($(target)_NAME.$(bld_type))\
2627 local outbase := $(call TARGET_BASE,$(name),$(target))
2629 $(TOOL_$(tool)_LDFLAGS)\
2630 $(TOOL_$(tool)_LDFLAGS.$(bld_type))\
2631 $(TOOL_$(tool)_LDFLAGS.$(bld_trg))\
2632 $(TOOL_$(tool)_LDFLAGS.$(bld_trg_arch))\
2633 $(TOOL_$(tool)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\
2634 $(TOOL_$(tool)_LDFLAGS.$(bld_trg_cpu))\
2635 $(foreach sdk, $(SDKS) \
2636 $(SDKS.$(bld_type)) \
2637 $(SDKS.$(bld_trg)) \
2638 $(SDKS.$(bld_trg_arch)) \
2639 $(SDKS.$(bld_trg).$(bld_trg_arch)),\
2640 $(SDK_$(sdk)_LDFLAGS)\
2641 $(SDK_$(sdk)_LDFLAGS.$(bld_type))\
2642 $(SDK_$(sdk)_LDFLAGS.$(bld_trg))\
2643 $(SDK_$(sdk)_LDFLAGS.$(bld_trg_arch))\
2644 $(SDK_$(sdk)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\
2645 $(SDK_$(sdk)_LDFLAGS.$(bld_trg_cpu)))\
2647 $(LDFLAGS.$(bld_type))\
2648 $(LDFLAGS.$(bld_trg))\
2649 $(LDFLAGS.$(bld_trg_arch))\
2650 $(LDFLAGS.$(bld_trg).$(bld_trg_arch))\
2651 $(LDFLAGS.$(bld_trg_cpu))\
2652 $(foreach sdk, $($(target)_SDKS) \
2653 $($(target)_SDKS.$(bld_type)) \
2654 $($(target)_SDKS.$(bld_trg)) \
2655 $($(target)_SDKS.$(bld_trg_arch)) \
2656 $($(target)_SDKS.$(bld_trg).$(bld_trg_arch)),\
2657 $(SDK_$(sdk)_LDFLAGS)\
2658 $(SDK_$(sdk)_LDFLAGS.$(bld_type))\
2659 $(SDK_$(sdk)_LDFLAGS.$(bld_trg))\
2660 $(SDK_$(sdk)_LDFLAGS.$(bld_trg_arch))\
2661 $(SDK_$(sdk)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\
2662 $(SDK_$(sdk)_LDFLAGS.$(bld_trg_cpu)))\
2663 $($(target)_LDFLAGS)\
2664 $($(target)_LDFLAGS.$(bld_type))\
2665 $($(target)_LDFLAGS.$(bld_trg))\
2666 $($(target)_LDFLAGS.$(bld_trg_arch))\
2667 $($(target)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\
2668 $($(target)_LDFLAGS.$(bld_trg_cpu))
2670 $($(target)_LIBS.$(bld_trg_cpu))\
2671 $($(target)_LIBS.$(bld_trg).$(bld_trg_arch))\
2672 $($(target)_LIBS.$(bld_trg_arch))\
2673 $($(target)_LIBS.$(bld_trg))\
2674 $($(target)_LIBS.$(bld_type))\
2676 $(foreach sdk, $($(target)_SDKS.$(bld_trg).$(bld_trg_arch)) \
2677 $($(target)_SDKS.$(bld_trg_arch)) \
2678 $($(target)_SDKS.$(bld_trg)) \
2679 $($(target)_SDKS.$(bld_type)) \
2681 $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
2682 $(SDK_$(sdk)_LIBS.$(bld_trg).$(bld_trg_arch))\
2683 $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
2684 $(SDK_$(sdk)_LIBS.$(bld_trg))\
2685 $(SDK_$(sdk)_LIBS.$(bld_type))\
2686 $(SDK_$(sdk)_LIBS))\
2687 $(LIBS.$(bld_trg_cpu))\
2688 $(LIBS.$(bld_trg).$(bld_trg_arch))\
2689 $(LIBS.$(bld_trg_arch))\
2691 $(LIBS.$(bld_type))\
2693 $(foreach sdk, $(SDKS.$(bld_trg).$(bld_trg_arch)) \
2694 $(SDKS.$(bld_trg_arch)) \
2695 $(SDKS.$(bld_trg)) \
2696 $(SDKS.$(bld_type)) \
2698 $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
2699 $(SDK_$(sdk)_LIBS.$(bld_trg).$(bld_trg_arch))\
2700 $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
2701 $(SDK_$(sdk)_LIBS.$(bld_trg))\
2702 $(SDK_$(sdk)_LIBS.$(bld_type))\
2703 $(SDK_$(sdk)_LIBS))\
2704 $(TOOL_$(tool)_LIBS.$(bld_trg_cpu))\
2705 $(TOOL_$(tool)_LIBS.$(bld_trg).$(bld_trg_arch))\
2706 $(TOOL_$(tool)_LIBS.$(bld_trg_arch))\
2707 $(TOOL_$(tool)_LIBS.$(bld_trg))\
2708 $(TOOL_$(tool)_LIBS.$(bld_type))\
2709 $(TOOL_$(tool)_LIBS)
2711 $($(target)_LIBPATH.$(bld_trg_cpu))\
2712 $($(target)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
2713 $($(target)_LIBPATH.$(bld_trg_arch))\
2714 $($(target)_LIBPATH.$(bld_trg))\
2715 $($(target)_LIBPATH.$(bld_type))\
2716 $($(target)_LIBPATH)\
2717 $(foreach sdk, $($(target)_SDKS.$(bld_trg).$(bld_trg_arch)) \
2718 $($(target)_SDKS.$(bld_trg_arch)) \
2719 $($(target)_SDKS.$(bld_trg)) \
2720 $($(target)_SDKS.$(bld_type)) \
2722 $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
2723 $(SDK_$(sdk)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
2724 $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
2725 $(SDK_$(sdk)_LIBPATH.$(bld_trg))\
2726 $(SDK_$(sdk)_LIBPATH.$(bld_type))\
2727 $(SDK_$(sdk)_LIBPATH))\
2728 $(LIBPATH.$(bld_trg_cpu))\
2729 $(LIBPATH.$(bld_trg).$(bld_trg_arch))\
2730 $(LIBPATH.$(bld_trg_arch))\
2731 $(LIBPATH.$(bld_trg))\
2732 $(LIBPATH.$(bld_type))\
2734 $(foreach sdk, $(SDKS.$(bld_trg).$(bld_trg_arch)) \
2735 $(SDKS.$(bld_trg_arch)) \
2736 $(SDKS.$(bld_trg)) \
2737 $(SDKS.$(bld_type)) \
2739 $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
2740 $(SDK_$(sdk)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
2741 $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
2742 $(SDK_$(sdk)_LIBPATH.$(bld_trg))\
2743 $(SDK_$(sdk)_LIBPATH.$(bld_type))\
2744 $(SDK_$(sdk)_LIBPATH))\
2745 $(TOOL_$(tool)_LIBPATH.$(bld_trg_cpu))\
2746 $(TOOL_$(tool)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
2747 $(TOOL_$(tool)_LIBPATH.$(bld_trg_arch))\
2748 $(TOOL_$(tool)_LIBPATH.$(bld_trg))\
2749 $(TOOL_$(tool)_LIBPATH.$(bld_type))\
2750 $(TOOL_$(tool)_LIBPATH)
2751 local dirdep := $(call DIRDEP,$(dir $(out)))
2753 $($(target)_DEPS.$(bld_trg_cpu)) \
2754 $($(target)_DEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
2755 $($(target)_DEPS.$(bld_trg).$(bld_trg_arch)) \
2756 $($(target)_DEPS.$(bld_trg).$(bld_type)) \
2757 $($(target)_DEPS.$(bld_trg_arch)) \
2758 $($(target)_DEPS.$(bld_trg)) \
2759 $($(target)_DEPS.$(bld_type)) \
2761 $($(target)_LNK_DEPS.$(bld_trg_cpu)) \
2762 $($(target)_LNK_DEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
2763 $($(target)_LNK_DEPS.$(bld_trg).$(bld_trg_arch)) \
2764 $($(target)_LNK_DEPS.$(bld_trg).$(bld_type)) \
2765 $($(target)_LNK_DEPS.$(bld_trg_arch)) \
2766 $($(target)_LNK_DEPS.$(bld_trg)) \
2767 $($(target)_LNK_DEPS.$(bld_type)) \
2768 $($(target)_LNK_DEPS)
2769 local orderdeps := \
2770 $($(target)_ORDERDEPS.$(bld_trg_cpu)) \
2771 $($(target)_ORDERDEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
2772 $($(target)_ORDERDEPS.$(bld_trg).$(bld_trg_arch)) \
2773 $($(target)_ORDERDEPS.$(bld_trg).$(bld_type)) \
2774 $($(target)_ORDERDEPS.$(bld_trg_arch)) \
2775 $($(target)_ORDERDEPS.$(bld_trg)) \
2776 $($(target)_ORDERDEPS.$(bld_type)) \
2777 $($(target)_ORDERDEPS) \
2778 $($(target)_LNK_ORDERDEPS.$(bld_trg_cpu)) \
2779 $($(target)_LNK_ORDERDEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
2780 $($(target)_LNK_ORDERDEPS.$(bld_trg).$(bld_trg_arch)) \
2781 $($(target)_LNK_ORDERDEPS.$(bld_trg).$(bld_type)) \
2782 $($(target)_LNK_ORDERDEPS.$(bld_trg_arch)) \
2783 $($(target)_LNK_ORDERDEPS.$(bld_trg)) \
2784 $($(target)_LNK_ORDERDEPS.$(bld_type)) \
2785 $($(target)_LNK_ORDERDEPS)
2787 # Adjust paths if we got a default path.
2789 local libpath := $(abspathex $(libpath),$(defpath))
2790 local deps := $(abspathex $(deps),$(defpath))
2791 local orderdeps := $(abspathex $(orderdeps),$(defpath))
2792 othersrc := $(abspathex $(othersrc),$(defpath))
2793 # libs are not subject to this because of the the -l<lib> stuff. Use $(<target>_DEFPATH)/lib if relative to current dir!
2796 # Custom pre-link actions.
2797 ifdef $(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)
2798 local pre_cmds := $($(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type))
2799 else ifdef $(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch)
2800 local pre_cmds := $($(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch))
2801 else ifdef $(target)_PRE_CMDS.$(bld_trg).$(bld_type)
2802 local pre_cmds := $($(target)_PRE_CMDS.$(bld_trg).$(bld_type))
2803 else ifdef $(target)_PRE_CMDS.$(bld_trg_arch)
2804 local pre_cmds := $($(target)_PRE_CMDS.$(bld_trg_arch))
2805 else ifdef $(target)_PRE_CMDS.$(bld_trg)
2806 local pre_cmds := $($(target)_PRE_CMDS.$(bld_trg))
2807 else ifdef $(target)_PRE_CMDS.$(bld_type)
2808 local pre_cmds := $($(target)_PRE_CMDS.$(bld_type))
2809 else ifdef $(target)_PRE_CMDS
2810 local pre_cmds := $($(target)_PRE_CMDS)
2811 else ifdef PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)
2812 local pre_cmds := $(PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type))
2813 else ifdef PRE_CMDS.$(bld_trg).$(bld_trg_arch)
2814 local pre_cmds := $(PRE_CMDS.$(bld_trg).$(bld_trg_arch))
2815 else ifdef PRE_CMDS.$(bld_trg).$(bld_type)
2816 local pre_cmds := $(PRE_CMDS.$(bld_trg).$(bld_type))
2817 else ifdef PRE_CMDS.$(bld_trg_arch)
2818 local pre_cmds := $(PRE_CMDS.$(bld_trg_arch))
2819 else ifdef PRE_CMDS.$(bld_trg)
2820 local pre_cmds := $(PRE_CMDS.$(bld_trg))
2821 else ifdef PRE_CMDS.$(bld_type)
2822 local pre_cmds := $(PRE_CMDS.$(bld_type))
2824 local pre_cmds := $(PRE_CMDS)
2827 # Custom post-link actions.
2828 ifdef $(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)
2829 local post_cmds := $($(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type))
2830 else ifdef $(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch)
2831 local post_cmds := $($(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch))
2832 else ifdef $(target)_POST_CMDS.$(bld_trg).$(bld_type)
2833 local post_cmds := $($(target)_POST_CMDS.$(bld_trg).$(bld_type))
2834 else ifdef $(target)_POST_CMDS.$(bld_trg_arch)
2835 local post_cmds := $($(target)_POST_CMDS.$(bld_trg_arch))
2836 else ifdef $(target)_POST_CMDS.$(bld_trg)
2837 local post_cmds := $($(target)_POST_CMDS.$(bld_trg))
2838 else ifdef $(target)_POST_CMDS.$(bld_type)
2839 local post_cmds := $($(target)_POST_CMDS.$(bld_type))
2840 else ifdef $(target)_POST_CMDS
2841 local post_cmds := $($(target)_POST_CMDS)
2842 else ifdef POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)
2843 local post_cmds := $(POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type))
2844 else ifdef POST_CMDS.$(bld_trg).$(bld_trg_arch)
2845 local post_cmds := $(POST_CMDS.$(bld_trg).$(bld_trg_arch))
2846 else ifdef POST_CMDS.$(bld_trg).$(bld_type)
2847 local post_cmds := $(POST_CMDS.$(bld_trg).$(bld_type))
2848 else ifdef POST_CMDS.$(bld_trg_arch)
2849 local post_cmds := $(POST_CMDS.$(bld_trg_arch))
2850 else ifdef POST_CMDS.$(bld_trg)
2851 local post_cmds := $(POST_CMDS.$(bld_trg))
2852 else ifdef POST_CMDS.$(bld_type)
2853 local post_cmds := $(POST_CMDS.$(bld_type))
2855 local post_cmds := $(POST_CMDS)
2858 # eliminate this guy?
2859 local objs = $($(target)_2_OBJS)
2861 # installation targets
2862 ifeq ($(strip $($(target)_NOINST) $($(target)_NOINST.$(bld_trg)) $($(target)_NOINST.$(bld_trg).$(bld_trg_arch)) $($(target)_NOINST.$(bld_trg).$(bld_trg_arch).$(bld_type)) $($(target)_NOINST.$(bld_trg_arch)) $($(target)_NOINST.$(bld_trg_cpu)) $($(target)_NOINST.$(bld_trg_type))),)
2863 ifneq ($(strip $($(target)_INST.$(bld_trg).$(bld_trg_arch).$(bld_type))),)
2864 local inst := $(addprefix $(PATH_INS)/,$($(target)_INST.$(bld_trg).$(bld_trg_arch).$(bld_type)))
2865 else ifneq ($(strip $($(target)_INST.$(bld_trg).$(bld_trg_arch))),)
2866 local inst := $(addprefix $(PATH_INS)/,$($(target)_INST.$(bld_trg).$(bld_trg_arch)))
2867 else ifneq ($(strip $($(target)_INST.$(bld_trg).$(bld_type))),)
2868 local inst := $(addprefix $(PATH_INS)/,$($(target)_INST.$(bld_trg).$(bld_type)))
2869 else ifneq ($(strip $($(target)_INST.$(bld_trg_arch))),)
2870 local inst := $(addprefix $(PATH_INS)/,$($(target)_INST.$(bld_trg_arch)))
2871 else ifneq ($(strip $($(target)_INST.$(bld_trg))),)
2872 local inst := $(addprefix $(PATH_INS)/,$($(target)_INST.$(bld_trg)))
2873 else ifneq ($(strip $($(target)_INST.$(bld_type))),)
2874 local inst := $(addprefix $(PATH_INS)/,$($(target)_INST.$(bld_type)))
2875 else ifneq ($(strip $($(target)_INST)),)
2876 local inst := $(addprefix $(PATH_INS)/,$($(target)_INST))
2878 local inst := $(definst)/
2880 INSTARGET_$(target) := $(patsubst %/,%/$(notdir $(out)),$(inst))
2881 ifdef KBUILD_DO_AUTO_INSTALL
2882 $(typevar) += $(INSTARGET_$(target))
2884 $(typevar) += $(out)
2886 local mode := $(firstword \
2887 $($(target)_MODE.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
2888 $($(target)_MODE.$(bld_trg).$(bld_trg_arch)) \
2889 $($(target)_MODE.$(bld_trg).$(bld_type)) \
2890 $($(target)_MODE.$(bld_trg_arch)) \
2891 $($(target)_MODE.$(bld_trg)) \
2892 $($(target)_MODE.$(bld_type)) \
2894 local uid := $(firstword \
2895 $($(target)_UID.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
2896 $($(target)_UID.$(bld_trg).$(bld_trg_arch)) \
2897 $($(target)_UID.$(bld_trg).$(bld_type)) \
2898 $($(target)_UID.$(bld_trg_arch)) \
2899 $($(target)_UID.$(bld_trg)) \
2900 $($(target)_UID.$(bld_type)) \
2902 local gid := $(firstword \
2903 $($(target)_GID.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
2904 $($(target)_GID.$(bld_trg).$(bld_trg_arch)) \
2905 $($(target)_GID.$(bld_trg).$(bld_type)) \
2906 $($(target)_GID.$(bld_trg_arch)) \
2907 $($(target)_GID.$(bld_trg)) \
2908 $($(target)_GID.$(bld_type)) \
2911 # generate the install rule
2912 $(eval $(def_link_install_rule))
2915 INSTARGET_$(target) :=
2916 $(typevar) += $(out)
2920 local dep := $(outbase)$(SUFF_DEP)
2921 ifndef NO_LINK_CMDS_DEPS
2922 _DEPFILES_INCLUDED += $(dep)
2923 ifdef KB_HAVE_INCLUDEDEP_QUEUE
2924 includedep-queue $(dep)
2930 # check that the tool is defined.
2931 ifndef TOOL_$(tool)_$(tool_do)_CMDS
2932 $(warning kBuild: tools: \
2933 1 $($(target)_$(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
2934 2 $($(target)_$(source)TOOL.$(bld_trg)) \
2935 3 $($(target)_$(source)TOOL) \
2936 4 $($(target)_TOOL.$(bld_trg).$(bld_trg_arch)) \
2937 5 $($(target)_TOOL.$(bld_trg)) \
2938 6 $($(target)_TOOL) \
2939 7 $($(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
2940 8 $($(source)TOOL.$(bld_trg)) \
2941 9 $($(source)TOOL) \
2942 10 $(TOOL.$(bld_trg).$(bld_trg_arch)) \
2943 11 $(TOOL.$(bld_trg)) \
2945 $(error kBuild: TOOL_$(tool)_$(tool_do)_CMDS isn't defined
! target
=$(target
) )
2949 local cmds
:= $(TOOL_
$(tool
)_
$(tool_do
)_CMDS
)
2950 ifneq ($(pre_cmds
),)
2951 local cmds
:= $(TAB
)$(pre_cmds
)$(NL
)$(TAB
)$(cmds
)
2953 ifneq ($(post_cmds
),)
2954 local cmds
:= $(cmds
)$(NL
)$(TAB
)$(post_cmds
)
2956 $(target
)_2_OUTPUT
:= $(TOOL_
$(tool
)_
$(tool_do
)_OUTPUT
)
2957 $(target
)_2_OUTPUT_MAYBE
:= $(TOOL_
$(tool
)_
$(tool_do
)_OUTPUT_MAYBE
)
2958 $(target
)_2_DEPEND
:= $(TOOL_
$(tool
)_
$(tool_do
)_DEPEND
) $(deps
) $($(target
)_2_OBJS
)
2959 $(target
)_2_DEPORD
:= $(TOOL_
$(tool
)_
$(tool_do
)_DEPORD
) $(dirdep
) $(orderdeps
)
2961 # generate the link rule.
2962 $(eval
$(def_link_rule
))
2966 _OBJS
+= $($(target
)_2_OBJS
)
2967 _OUT_FILES
+= $($(target
)_2_OUTPUT
) $($(target
)_2_OUTPUT_MAYBE
) $(out
)
2968 _CLEAN_FILES
+= $($(target
)_CLEAN
) $($(target
)_CLEAN.
$(bld_trg
)) $($(target
)_CLEAN.
$(bld_trg
).
$(bld_trg_arch
)) $($(target
)_CLEAN.
$(bld_trg_arch
)) $($(target
)_CLEAN.
$(bld_trg_cpu
)) $($(target
)_CLEAN.
$(bld_type
))
2969 _DIRS
+= $($(target
)_BLDDIRS
) $($(target
)_BLDDIRS.
$(bld_trg
)) $($(target
)_BLDDIRS.
$(bld_trg
).
$(bld_trg_arch
)) $($(target
)_BLDDIRS.
$(bld_trg_arch
)) $($(target
)_BLDDIRS.
$(bld_trg_cpu
)) $($(target
)_BLDDIRS.
$(bld_type
))
2970 _INSTALLS_FILES
+= $(INSTARGET_
$(target
))
2972 endef # def_link_common
2973 $(eval-opt-var def_link_common
)
2980 ## Build program (one).
2981 # @param $(target) Normalized target (program) name.
2984 # set NOINST if not forced installation.
2985 ifndef $(target
)_INST
2986 $(target
)_NOINST
:= 1
2989 # do the usual stuff.
2990 $(evalval def_link_common
)
2994 # Process build programs.
2997 tool_do
:= LINK_PROGRAM
2998 definst
:= $(PATH_BIN
)
2999 typevar
:= _BLDPROGS
3001 bld_trg_base_var
:= PLATFORM
3002 $(foreach target
, $(_ALL_BLDPROGS
), $(evalval def_bldprog
))
3004 ifdef KBUILD_PROFILE_SELF
3005 $(evalcall def_profile_self
, done build program targets
)
3017 definst
:= $(PATH_DLL
)
3020 bld_trg_base_var
:= TARGET
3021 $(foreach target
, $(_ALL_DLLS
), $(evalval def_link_common
))
3023 ifdef KBUILD_PROFILE_SELF
3024 $(evalcall def_profile_self
, done dll targets
)
3031 # - On OS/2 and windows these are libraries.
3032 # - On other platforms they are fake DLLs.
3035 typevar
:= _IMPORT_LIBS
3037 bld_trg_base_var
:= TARGET
3038 ifeq ($(filter-out nt os2 win win64 win32
,$(KBUILD_TARGET
)),)
3040 tool_do
:= LINK_LIBRARY
3041 definst
:= $(PATH_LIB
)
3042 $(foreach target
, $(_ALL_IMPORT_LIBS
), $(evalval def_lib
))
3046 definst
:= $(PATH_DLL
)
3047 $(foreach target
, $(_ALL_IMPORT_LIBS
), $(evalval def_link_common
))
3050 ifdef KBUILD_PROFILE_SELF
3051 $(evalcall def_profile_self
, done import library targets
)
3062 tool_do
:= LINK_PROGRAM
3063 definst
:= $(PATH_BIN
)
3064 typevar
:= _PROGRAMS
3066 bld_trg_base_var
:= TARGET
3067 $(foreach target
, $(_ALL_PROGRAMS
), $(evalval def_link_common
))
3069 ifdef KBUILD_PROFILE_SELF
3070 $(evalcall def_profile_self
, done program targets
)
3081 tool_do
:= LINK_SYSMOD
3082 definst
:= $(PATH_SYS
)
3085 bld_trg_base_var
:= TARGET
3086 $(foreach target
, $(_ALL_SYSMODS
), $(evalval def_link_common
))
3088 ifdef KBUILD_PROFILE_SELF
3089 $(evalcall def_profile_self
, done sysmod targets
)
3100 tool_do
:= LINK_MISCBIN
3101 definst
:= $(PATH_BIN
)
3102 typevar
:= _MISCBINS
3104 bld_trg_base_var
:= TARGET
3105 $(foreach target
, $(_ALL_MISCBINS
), $(evalval def_link_common
))
3107 ifdef KBUILD_PROFILE_SELF
3108 $(evalcall def_profile_self
, done misc binary targets
)
3115 _OTHERS
= $(OTHERS
) $(OTHERS.
$(KBUILD_TARGET
)) $(OTHERS.
$(KBUILD_TARGET
).
$(KBUILD_TARGET_ARCH
))
3122 ## generate the install rule
3123 define def_install_src_rule
3125 $(insdst
) : $(srcsrc
) |
$(call DIRDEP
,$(dir $(insdst
)))
3126 %$$(call MSG_INST_FILE
,$(srcsrc
),$(insdst
))
3129 $(eval-opt-var def_install_src_rule
)
3132 define def_install_src
3134 # deal with '=>' in the source file name.
3136 $(error kBuild
: Install target
'$(target)' has a bad source specifier containing
'=>' without any file names
)
3138 ifeq ($(substr
$(src
),1,2),=>)
3139 $(warning kBuild
: Install target
'$(target)' has a bad source specifier
: $(src
))
3141 ifeq ($(substr
$(src
),-2),=>)
3142 $(warning kBuild
: Install target
'$(target)' has a bad source specifier
: $(src
))
3144 local srcdst
:= $(subst =>, ,$(src
))
3145 local srcsrc
:= $(firstword $(srcdst
))
3146 local srcdstdir
:= $(dir $(word 2,$(srcdst
)))
3147 local srcdst
:= $(word $(words $(srcdst
)),$(srcdst
))
3150 ifdef $(srcsrc
)_INSTFUN
3151 local instfun
:= $(srcsrc
)_INSTFUN
3152 else ifdef $(target
)_INSTFUN
3153 local instfun
:= $(target
)_INSTFUN
3155 local instfun
:= _INSTALL_FILE
3159 ifdef $(srcsrc
)_INST
3160 local inst
:= $(patsubst %/,%,$($(srcsrc
)_INST
))/$(dir $(srcdstdir
))
3161 else ifdef $(target
)_INST
3162 local inst
:= $(patsubst %/,%,$($(target
)_INST
))/$(dir $(srcdstdir
))
3164 local inst
:= $(dir $(srcdstdir
))
3168 local insdst
:= $(call
$(instfun
),$(srcdst
),$(target
),$(inst
),$(PATH_INS
))
3169 #$(warning instfun=$(instfun) srcdst=$(srcdst) target=$(target) inst=$(inst) => insdst=$(insdst))
3172 local mode
:= $(firstword \
3173 $($(target
)_
$(srcsrc
)_MODE.
$(bld_trg
).
$(bld_trg_arch
)) \
3174 $($(target
)_
$(srcsrc
)_MODE.
$(bld_trg
)) \
3175 $($(target
)_
$(srcsrc
)_MODE
) \
3176 $($(target
)_
$(srcdst
)_MODE.
$(bld_trg
).
$(bld_trg_arch
)) \
3177 $($(target
)_
$(srcdst
)_MODE.
$(bld_trg
)) \
3178 $($(target
)_
$(srcdst
)_MODE
) \
3179 $($(srcsrc
)_MODE.
$(bld_trg
).
$(bld_trg_arch
)) \
3180 $($(srcsrc
)_MODE.
$(bld_trg
)) \
3182 $($(srcdst
)_MODE.
$(bld_trg
).
$(bld_trg_arch
)) \
3183 $($(srcdst
)_MODE.
$(bld_trg
)) \
3185 $($(target
)_MODE.
$(bld_trg
).
$(bld_trg_arch
)) \
3186 $($(target
)_MODE.
$(bld_trg
)) \
3188 local uid
:= $(firstword \
3189 $($(target
)_
$(srcsrc
)_UID.
$(bld_trg
).
$(bld_trg_arch
)) \
3190 $($(target
)_
$(srcsrc
)_UID.
$(bld_trg
)) \
3191 $($(target
)_
$(srcsrc
)_UID
) \
3192 $($(target
)_
$(srcdst
)_UID.
$(bld_trg
).
$(bld_trg_arch
)) \
3193 $($(target
)_
$(srcdst
)_UID.
$(bld_trg
)) \
3194 $($(target
)_
$(srcdst
)_UID
) \
3195 $($(srcsrc
)_UID.
$(bld_trg
).
$(bld_trg_arch
)) \
3196 $($(srcsrc
)_UID.
$(bld_trg
)) \
3198 $($(srcdst
)_UID.
$(bld_trg
).
$(bld_trg_arch
)) \
3199 $($(srcdst
)_UID.
$(bld_trg
)) \
3201 $($(target
)_UID.
$(bld_trg
).
$(bld_trg_arch
)) \
3202 $($(target
)_UID.
$(bld_trg
)) \
3204 local gid
:= $(firstword \
3205 $($(target
)_
$(srcsrc
)_GID.
$(bld_trg
).
$(bld_trg_arch
)) \
3206 $($(target
)_
$(srcsrc
)_GID.
$(bld_trg
)) \
3207 $($(target
)_
$(srcsrc
)_GID
) \
3208 $($(target
)_
$(srcdst
)_GID.
$(bld_trg
).
$(bld_trg_arch
)) \
3209 $($(target
)_
$(srcdst
)_GID.
$(bld_trg
)) \
3210 $($(target
)_
$(srcdst
)_GID
) \
3211 $($(srcsrc
)_GID.
$(bld_trg
).
$(bld_trg_arch
)) \
3212 $($(srcsrc
)_GID.
$(bld_trg
)) \
3214 $($(srcdst
)_GID.
$(bld_trg
).
$(bld_trg_arch
)) \
3215 $($(srcdst
)_GID.
$(bld_trg
)) \
3217 $($(target
)_GID.
$(bld_trg
).
$(bld_trg_arch
)) \
3218 $($(target
)_GID.
$(bld_trg
)) \
3221 $($(target
)_IFFLAGS
) \
3222 $($(target
)_IFFLAGS.
$(bld_trg
)) \
3223 $($(target
)_IFFLAGS.
$(bld_trg
).
$(bld_trg_arch
)) \
3224 $($(srcdst
)_IFFLAGS
) \
3225 $($(srcdst
)_IFFLAGS.
$(bld_trg
)) \
3226 $($(srcdst
)_IFFLAGS.
$(bld_trg
).
$(bld_trg_arch
)) \
3227 $($(srcsrc
)_IFFLAGS
) \
3228 $($(srcsrc
)_IFFLAGS.
$(bld_trg
)) \
3229 $($(srcsrc
)_IFFLAGS.
$(bld_trg
).
$(bld_trg_arch
)) \
3230 $($(target
)_
$(srcdst
)_IFFLAGS
) \
3231 $($(target
)_
$(srcdst
)_IFFLAGS.
$(bld_trg
)) \
3232 $($(target
)_
$(srcdst
)_IFFLAGS.
$(bld_trg
).
$(bld_trg_arch
)) \
3233 $($(target
)_
$(srcsrc
)_IFFLAGS
) \
3234 $($(target
)_
$(srcsrc
)_IFFLAGS.
$(bld_trg
)) \
3235 $($(target
)_
$(srcsrc
)_IFFLAGS.
$(bld_trg
).
$(bld_trg_arch
))
3237 $($(srcdst
)_CLEAN
) \
3238 $($(srcdst
)_CLEAN.
$(bld_trg
)) \
3239 $($(srcdst
)_CLEAN.
$(bld_trg
).
$(bld_trg_arch
)) \
3240 $($(srcsrc
)_CLEAN
) \
3241 $($(srcsrc
)_CLEAN.
$(bld_trg
)) \
3242 $($(srcsrc
)_CLEAN.
$(bld_trg
).
$(bld_trg_arch
)) \
3243 $($(target
)_
$(srcdst
)_CLEAN
) \
3244 $($(target
)_
$(srcdst
)_CLEAN.
$(bld_trg
)) \
3245 $($(target
)_
$(srcdst
)_CLEAN.
$(bld_trg
).
$(bld_trg_arch
)) \
3246 $($(target
)_
$(srcsrc
)_CLEAN
) \
3247 $($(target
)_
$(srcsrc
)_CLEAN.
$(bld_trg
)) \
3248 $($(target
)_
$(srcsrc
)_CLEAN.
$(bld_trg
).
$(bld_trg_arch
))
3251 # Adjust the source if we got a default PATH. (This must be done this late!)
3252 local defpath
:= $(firstword $($(target
)_PATH
) $($(target
)_DEFPATH
))
3254 local srcsrc
:= $(abspathex
$(srcsrc
),$(defpath
))
3257 # create the command
3258 ifdef $(srcsrc
)_INSTALLER
3259 local inscmd
:= $(call
$(srcsrc
)_INSTALLER
,$(srcsrc
),$(insdst
),$(target
),$(flags
))
3260 else ifdef $(target
)_INSTALLER
3261 local inscmd
:= $(call
$(target
)_INSTALLER
,$(srcsrc
),$(insdst
),$(target
),$(flags
))
3263 local inscmd
:= $$(INSTALL
)\
3264 $(if
$(uid
),-o
$(uid
))\
3265 $(if
$(gid
),-g
$(gid
))\
3266 $(if
$(mode
),-m
$(mode
))\
3271 # generate the rule (need double evaluation here)
3272 $(eval
$(def_install_src_rule
))
3274 INSTARGET_
$(target
) += $(insdst
)
3275 endef # def_install_src
3276 $(eval-opt-var def_install_src
)
3279 ## generate the symlink rule
3280 define def_install_symlink_rule
3282 $(insdst
) : |
$(call DIRDEP
,$(dir $(insdst
)))
3283 %$$(call MSG_INST_SYM
,$(insdst
),$(symdst
))
3284 $$(QUIET
)$$(RM
) -f
-- $$@
3285 $$(QUIET
)$$(LN_SYMLINK
) $(symdst
) $(insdst
)
3286 endef # def_install_symlink_rule
3287 $(eval-opt-var def_install_symlink_rule
)
3289 ## create one symlink
3290 define def_install_symlink
3292 # deal with '=>' in the source file name.
3293 local symdst
:= $(subst =>, ,$(src
))
3294 local symlnk
:= $(firstword $(symdst
))
3295 local symdst
:= $(word $(words $(symdst
)),$(symdst
))
3298 ifdef $(symlnk
)_INSTFUN
3299 local instfun
:= $(symlnk
)_INSTFUN
3300 else ifdef $(target
)_INSTFUN
3301 local instfun
:= $(target
)_INSTFUN
3303 local instfun
:= _INSTALL_FILE
3307 ifdef $(symlnk
)_INST
3308 local inst
:= $(patsubst %/,%,$($(symlnk
)_INST
))/$(dir $(symlnk
))
3309 else ifdef $(target
)_INST
3310 local inst
:= $(patsubst %/,%,$($(target
)_INST
))/$(dir $(symlnk
))
3312 local inst
:= $(dir $(symlnk
))
3316 local insdst
:= $(call
$(instfun
),$(symlnk
),$(target
),$(inst
),$(PATH_INS
))
3317 #$(warning symlnk=$(symlnk) symdst=$(symdst) insdst=$(insdst) instfun=$(instfun) inst='$(inst)')
3319 # generate the rule (need double evaluation here)
3320 $(eval
$(def_install_symlink_rule
))
3322 INSTARGET_
$(target
) += $(insdst
)
3323 endef # def_install_symlink
3324 $(optmize def_install_symlink
)
3327 ## generate the install rule
3328 define def_install_directory_rule
3331 %$$(call MSG_INST_DIR
,$(insdst
))
3332 $$(QUIET
)$$(INSTALL
) -d \
3333 $(if
$(uid
),-o
$(uid
))\
3334 $(if
$(gid
),-g
$(gid
))\
3335 $(if
$(mode
),-m
$(mode
))\
3339 .NOTPARALLEL
: $(insdst
)
3340 endef # def_install_directory_rule
3341 $(eval-opt-var def_install_directory_rule
)
3344 ## create one directory
3345 define def_install_directory
3348 ifdef $(directory
)_INST
3349 local inst
:= $(PATH_INS
)/$(patsubst %/,%,$($(directory
)_INST
))
3350 else ifdef $(target
)_INST
3351 local inst
:= $(PATH_INS
)/$(patsubst %/,%,$($(target
)_INST
))
3353 local inst
:= $(PATH_INS
)
3356 local mode
:= $(firstword \
3357 $($(target
)_
$(directory
)_MODE.
$(bld_trg
).
$(bld_trg_arch
)) \
3358 $($(target
)_
$(directory
)_MODE.
$(bld_trg
)) \
3359 $($(target
)_
$(directory
)_MODE
) \
3360 $($(directory
)_MODE.
$(bld_trg
).
$(bld_trg_arch
)) \
3361 $($(directory
)_MODE.
$(bld_trg
)) \
3362 $($(directory
)_MODE
) \
3363 $($(target
)_MODE.
$(bld_trg
).
$(bld_trg_arch
)) \
3364 $($(target
)_MODE.
$(bld_trg
)) \
3366 local uid
:= $(firstword \
3367 $($(target
)_
$(directory
)_UID.
$(bld_trg
).
$(bld_trg_arch
)) \
3368 $($(target
)_
$(directory
)_UID.
$(bld_trg
)) \
3369 $($(target
)_
$(directory
)_UID
) \
3370 $($(directory
)_UID.
$(bld_trg
).
$(bld_trg_arch
)) \
3371 $($(directory
)_UID.
$(bld_trg
)) \
3372 $($(directory
)_UID
) \
3373 $($(target
)_UID.
$(bld_trg
).
$(bld_trg_arch
)) \
3374 $($(target
)_UID.
$(bld_trg
)) \
3376 local gid
:= $(firstword \
3377 $($(target
)_
$(directory
)_GID.
$(bld_trg
).
$(bld_trg_arch
)) \
3378 $($(target
)_
$(directory
)_GID.
$(bld_trg
)) \
3379 $($(target
)_
$(directory
)_GID
) \
3380 $($(directory
)_GID.
$(bld_trg
).
$(bld_trg_arch
)) \
3381 $($(directory
)_GID.
$(bld_trg
)) \
3382 $($(directory
)_GID
) \
3383 $($(target
)_GID.
$(bld_trg
).
$(bld_trg_arch
)) \
3384 $($(target
)_GID.
$(bld_trg
)) \
3387 $($(target
)_IDFLAGS
)\
3388 $($(target
)_IDFLAGS.
$(bld_trg
)) \
3389 $($(target
)_IDFLAGS.
$(bld_trg
).
$(bld_trg_arch
)) \
3390 $($(directory
)_IDFLAGS
) \
3391 $($(directory
)_IDFLAGS.
$(bld_trg
)) \
3392 $($(directory
)_IDFLAGS.
$(bld_trg
).
$(bld_trg_arch
)) \
3393 $($(target
)_
$(directory
)_IDFLAGS
) \
3394 $($(target
)_
$(directory
)_IDFLAGS.
$(bld_trg
)) \
3395 $($(target
)_
$(directory
)_IDFLAGS.
$(bld_trg
).
$(bld_trg_arch
))
3397 local insdst
:= $(inst
)/$(directory
)/
3398 #$(warning directory=$(directory) inst=$(inst) insdst=$(insdst) mode=$(mode) gid=$(gid) uid=$(uid))
3400 # generate the rule (need double evaluation here)
3401 $(eval
$(def_install_directory_rule
))
3403 INSTARGET_DIRS_
$(target
) += $(insdst
)
3404 endef # def_install_directory
3405 $(eval-opt-var def_install_directory
)
3408 ## process one install target.
3411 local bld_type
:= $(firstword $($(target
)_BLD_TYPE
) $(KBUILD_TYPE
))
3412 local bld_trg
:= $(firstword $($(target
)_BLD_TRG
) $(KBUILD_TARGET
))
3413 local bld_trg_arch
:= $(firstword $($(target
)_BLD_TRG_ARCH
) $(KBUILD_TARGET_ARCH
))
3414 local bld_trg_cpu
:= $(firstword $($(target
)_BLD_TRG_CPU
) $(KBUILD_TARGET_CPU
))
3416 INSTARGET_
$(target
) := $($(target
)_GOALS
)
3417 INSTARGET_DIRS_
$(target
) :=
3418 local outbase
:= $(call TARGET_BASE
,$(target
),$(target
))
3419 $(target
)_0_OUTDIR
:= $(patsubst %/,%,$(dir $(outbase
)))
3420 PATH_
$(target
) := $($(target
)_0_OUTDIR
)
3422 local clean_files
:= $($(target
)_CLEAN
) $($(target
)_CLEAN.
$(bld_trg
)) $($(target
)_CLEAN.
$(bld_trg
).
$(bld_trg_arch
)) $($(target
)_CLEAN.
$(bld_trg_arch
)) $($(target
)_CLEAN.
$(bld_trg_cpu
)) $($(target
)_CLEAN.
$(bld_type
))
3424 $(foreach directory
,$($(target
)_DIRS
) $($(target
)_DIRS.
$(bld_trg
)) $($(target
)_DIRS.
$(bld_trg
).
$(bld_trg_arch
)) $($(target
)_DIRS.
$(bld_trg_arch
)) $($(target
)_DIRS.
$(bld_trg_cpu
)) $($(target
)_DIRS.
$(bld_type
)), \
3425 $(evalval def_install_directory
))
3427 $(foreach src
,$($(target
)_SOURCES
) $($(target
)_SOURCES.
$(bld_trg
)) $($(target
)_SOURCES.
$(bld_trg
).
$(bld_trg_arch
)) $($(target
)_SOURCES.
$(bld_trg_arch
)) $($(target
)_SOURCES.
$(bld_trg_cpu
)) $($(target
)_SOURCES.
$(bld_type
)), \
3428 $(evalval def_install_src
))
3430 $(foreach src
,$($(target
)_SYMLINKS
) $($(target
)_SYMLINKS.
$(bld_trg
)) $($(target
)_SYMLINKS.
$(bld_trg
).
$(bld_trg_arch
)) $($(target
)_SYMLINKS.
$(bld_trg_arch
)) $($(target
)_SYMLINKS.
$(bld_trg_cpu
)) $($(target
)_SYMLINKS.
$(bld_type
)), \
3431 $(evalval def_install_symlink
))
3433 # the collection target
3434 local clean_files
+= $(PATH_TARGET
)/$(target
).ins
3435 $(target
)_1_TARGET
:= $(PATH_TARGET
)/$(target
).ins
3436 TARGET_
$(target
) := $($(target
)_1_TARGET
)
3437 $($(target
)_1_TARGET
): $$(INSTARGET_
$(target
)) |
$$(INSTARGET_DIRS_
$(target
)) $(call DIRDEP
,$(PATH_TARGET
))
3438 @
$(QUIET2
)$(APPEND
) $@
3440 $(target
): $$($(target
)_1_TARGET
)
3442 _INSTALLS
+= $($(target
)_1_TARGET
)
3443 _INSTALLS_FILES
+= $(INSTARGET_
$(target
))
3444 _INSTALLS_DIRS
+= $(INSTARGET_DIRS_
$(target
))
3445 _CLEAN_FILES
+= $(clean_files
)
3446 _DIRS
+= $($(target
)_0_OUTDIR
) $($(target
)_BLDDIRS
) $($(target
)_BLDDIRS.
$(bld_trg
)) $($(target
)_BLDDIRS.
$(bld_trg
).
$(bld_trg_arch
)) $($(target
)_BLDDIRS.
$(bld_trg_arch
)) $($(target
)_BLDDIRS.
$(bld_trg_cpu
)) $($(target
)_BLDDIRS.
$(bld_type
))
3448 $(eval-opt-var def_install
)
3450 ## process all install targets
3451 $(foreach target
, $(_ALL_INSTALLS
), \
3452 $(evalvalctx def_install
))
3454 ifdef KBUILD_PROFILE_SELF
3455 $(evalcall def_profile_self
, done
install targets
)
3458 # Some introspection targets that can be useful for package maintainers.
3459 .PHONY
: kbuild-show-install-files kbuild-show-install-dirs
3460 kbuild-show-install-files
::
3461 $(addprefix $(NL
)$(TAB
)$(QUIET
)$(ECHO
) , $(subst $(PATH_INS
)/,,$(_INSTALLS_FILES
)))
3463 kbuild-show-install-dirs
::
3464 $(addprefix $(NL
)$(TAB
)$(QUIET
)$(ECHO
) , $(subst $(PATH_INS
)/,,$(_INSTALLS_DIRS
)))
3470 _TESTING
+= $(TESTING
) $(TESTING.
$(KBUILD_TARGET
)) $(TESTING.
$(KBUILD_TARGET
).
$(KBUILD_TARGET_ARCH
)) $(TESTING.
$(KBUILD_TARGET_ARCH
)) $(TESTING.
$(KBUILD_TARGET_CPU
))
3476 _PACKING
+= $(PACKING
) $(PACKING.
$(KBUILD_TARGET
)) $(PACKING.
$(KBUILD_TARGET
).
$(KBUILD_TARGET_ARCH
)) $(PACKING.
$(KBUILD_TARGET_ARCH
)) $(PACKING.
$(KBUILD_TARGET_CPU
))
3487 _DIR_ALL
:= $(sort $(addsuffix /,$(patsubst %/,%,$(_DIRS
))) $(dir $(_OUT_FILES
) $(_OBJS
) $(_INSTALLS_FILES
)))
3488 $(foreach directory
,$(_INSTALLS_DIRS
), $(eval _DIR_ALL
:= $(filter-out $(directory
),$(_DIR_ALL
))))
3491 define def_mkdir_rule
3493 %$$(call MSG_MKDIR
,$$@
)
3494 $$(QUIET
)$$(MKDIR
) -p
-- $$@
3497 $(foreach directory
,$(_DIR_ALL
),$(eval
$(def_mkdir_rule
)))
3499 ifdef KBUILD_PROFILE_SELF
3500 $(evalcall def_profile_self
, done directories
)
3508 %$(call MSG_NOTHING
)
3509 ifdef KBUILD_PROFILE_SELF
3510 @
$(ECHO
) 'prof: $(call _KBUILD_FMT_ELAPSED_EX, $(nanots ), $(_KBUILD_TS_HEADER_START)) - $(call _KBUILD_FMT_ELAPSED_EX, $(nanots ), $(_KBUILD_TS_PREV)) - executing $@'
3511 ifeq ($(KBUILD_PROFILE_SELF
),2)
3512 @
$(ECHO
) 'stat: $(make-stats )'
3522 $(QUIET
)$(RM
) -f
-- $(_OUT_FILES
) $(_OBJS
) $(_DEPFILES
) $(_DEPFILES_INCLUDED
) $(_CLEAN_FILES
) $(OTHER_CLEAN
)
3523 $(QUIET
)$(RMDIR
) -p
--ignore-fail-on-non-empty
--ignore-fail-on-not-exist
-- $(rsort
$(dir $(_OUT_FILES
) $(_OBJS
) $(_DEPFILES
) $(_DEPFILES_INCLUDED
) $(_CLEAN_FILES
) $(OTHER_CLEAN
)))
3528 # PASSES (including directory and makefile walking)
3532 # First, check whether we need to order the passes explicitly or not.
3533 # This depends on whether we're a leaf makefile or not. A leaf will
3534 # know all its dependencies, while a recursive one relies on the
3535 # order sub-directories and other makefiles are executed it.
3538 ## Setup a pass and check for optimizations.
3539 # @param $(PASS) Uppercase pass name.
3540 define def_pass_setup_and_optimize
3542 # The setup. ## @todo This is looks a bit weird...
3543 ifndef SUBDIRS_
$(PASS
)
3544 SUBDIRS_
$(PASS
) := $(SUBDIRS
) $(SUBDIRS.
$(KBUILD_TARGET
)) $(SUBDIRS.
$(KBUILD_TARGET.
$(KBUILD_TARGET_ARCH
)))
3546 ifndef SUBDIRS_AFTER_
$(PASS
)
3547 SUBDIRS_AFTER_
$(PASS
) := $(SUBDIRS_AFTER
) $(SUBDIRS_AFTER.
$(KBUILD_TARGET
)) $(SUBDIRS_AFTER.
$(KBUILD_TARGET
).
$(KBUILD_TARGET_ARCH
))
3549 ifndef MAKEFILES_BEFORE_
$(PASS
)
3550 MAKEFILES_BEFORE_
$(PASS
) := $(MAKEFILES_BEFORE
) $(MAKEFILES_BEFORE.
$(KBUILD_TARGET
)) $(MAKEFILES_BEFORE.
$(KBUILD_TARGET
).
$(KBUILD_TARGET_ARCH
))
3552 ifndef MAKEFILES_AFTER_
$(PASS
)
3553 MAKEFILES_AFTER_
$(PASS
) := $(MAKEFILES_AFTER
) $(MAKEFILES_AFTER.
$(KBUILD_TARGET
)) $(MAKEFILES_AFTER.
$(KBUILD_TARGET
).
$(KBUILD_TARGET_ARCH
))
3557 ifeq ($(_KBUILD_STRICT_PASS_ORDER
),nonstrict
)
3559 $(SUBDIRS_
$(PASS
)) $(SUBDIRS_
$(PASS
).
$(KBUILD_TARGET
)) $(SUBDIRS_
$(PASS
).
$(KBUILD_TARGET
).
$(KBUILD_TARGET_ARCH
)) \
3560 $(MAKEFILES_BEFORE_
$(PASS
)) $(MAKEFILES_BEFORE_
$(PASS
).
$(KBUILD_TARGET
)) $(MAKEFILES_BEFORE_
$(PASS
).
$(KBUILD_TARGET
).
$(KBUILD_TARGET_ARCH
)) \
3561 $(SUBDIRS_AFTER_
$(PASS
)) $(SUBDIRS_AFTER_
$(PASS
).
$(KBUILD_TARGET
)) $(SUBDIRS_AFTER_
$(PASS
).
$(KBUILD_TARGET
).
$(KBUILD_TARGET_ARCH
)) \
3562 $(MAKEFILES_AFTER_
$(PASS
)) $(MAKEFILES_AFTER_
$(PASS
).
$(KBUILD_TARGET
)) $(MAKEFILES_AFTER_
$(PASS
).
$(KBUILD_TARGET
).
$(KBUILD_TARGET_ARCH
)) \
3564 _KBUILD_STRICT_PASS_ORDER
:= strict
3566 endif # _KBUILD_STRICT_PASS_ORDER == nonstrict
3567 endef # def_pass_setup_and_optimize
3568 $(eval-opt-var def_pass_setup_and_optimize
)
3570 ## PASS: Setup & optimization.
3571 # Check if we can apply the non-strict pass order optimzation (no SUBDIRS_* and MAKEFILES_*),
3572 # and set up the pass specific variables as we go along.
3573 _KBUILD_STRICT_PASS_ORDER
:= nonstrict
3574 $(foreach PASS
, $(PASSES
), $(evalval def_pass_setup_and_optimize
))
3575 #$ (error _KBUILD_STRICT_PASS_ORDER=$(_KBUILD_STRICT_PASS_ORDER))
3577 ifeq ($(_KBUILD_STRICT_PASS_ORDER
),strict
)
3578 if
!defined
(KBUILD_SAFE_PARALLEL
) ||
"$(KMK_OPT_JOBS)" == "1"
3579 _KBUILD_STRICT_PASS_ORDER
:= strict_unsafe
3585 # @param $(pass) Lowercase pass name.
3586 # @param $(PASS) Uppercase pass name.
3587 # @param $(subdir) Subdirectory
3588 # @param $(tag) tag to attach to the rule name.
3589 define def_pass_subdir
3590 pass_
$(pass
)$(tag
):: $(dep
)
3591 + $$(QUIET
)$$(MAKE
) -C
$(subdir
) -f
$$(notdir $$(firstword $$(wildcard $$(addprefix $(subdir
)/,$$(DEFAULT_MAKEFILE
))))) pass_
$(pass
)
3595 # @param $(pass) Lowercase pass name.
3596 # @param $(PASS) Uppercase pass name.
3597 # @param $(makefile) Makefile.
3598 # @param $(tag) tag to attach to the rule name.
3599 define def_pass_makefile
3600 pass_
$(pass
)$(tag
):: $(dep
)
3601 + $$(QUIET
)$$(MAKE
) -C
$(patsubst %/,%,$(dir $(makefile
))) -f
$(notdir $(makefile
)) pass_
$(pass
)
3604 ## Execute a pass, strict order.
3605 # @param $(pass) Lowercase pass name.
3606 # @param $(PASS) Uppercase pass name.
3607 define def_pass_strict
3608 $(eval tag
:=_before
)
3610 $(foreach subdir
, $(SUBDIRS_
$(PASS
)) $(SUBDIRS_
$(PASS
).
$(KBUILD_TARGET
)) $(SUBDIRS_
$(PASS
).
$(KBUILD_TARGET
).
$(KBUILD_TARGET_ARCH
)) ,$(eval
$(def_pass_subdir
)))
3611 $(foreach makefile
,$(MAKEFILES_BEFORE_
$(PASS
)) $(MAKEFILES_BEFORE_
$(PASS
).
$(KBUILD_TARGET
)) $(MAKEFILES_BEFORE_
$(PASS
).
$(KBUILD_TARGET
).
$(KBUILD_TARGET_ARCH
)),$(eval
$(def_pass_makefile
)))
3614 $(eval dep
:=pass_
$(pass
)_doit
)
3615 $(foreach subdir
, $(SUBDIRS_AFTER_
$(PASS
)) $(SUBDIRS_AFTER_
$(PASS
).
$(KBUILD_TARGET
)) $(SUBDIRS_AFTER_
$(PASS
).
$(KBUILD_TARGET
).
$(KBUILD_TARGET_ARCH
)) ,$(eval
$(def_pass_subdir
)))
3616 $(foreach makefile
,$(MAKEFILES_AFTER_
$(PASS
)) $(MAKEFILES_AFTER_
$(PASS
).
$(KBUILD_TARGET
)) $(MAKEFILES_AFTER_
$(PASS
).
$(KBUILD_TARGET
).
$(KBUILD_TARGET_ARCH
)) ,$(eval
$(def_pass_makefile
)))
3618 .NOTPARALLEL
: pass_
$(pass
) pass_
$(pass
)_before pass_
$(pass
)_after pass_
$(pass
)_this
3619 .PHONY
: pass_
$(pass
) pass_
$(pass
)_before pass_
$(pass
)_after pass_
$(pass
)_this pass_
$(pass
)_doit
3620 pass_
$(pass
)_doit
: $(PASS_
$(PASS
)_trgs
) $(foreach var
,$(PASS_
$(PASS
)_vars
),$($(var
)))
3621 pass_
$(pass
)_this
: pass_
$(pass
)_before
3622 + $$(QUIET
)$$(MAKE
) -f
$$(MAKEFILE
) pass_
$(pass
)_doit
3623 pass_
$(pass
)_after
:: pass_
$(pass
)_this
3624 pass_
$(pass
): pass_
$(pass
)_after
3625 #$ (warning pass=$(pass) PASS=$(PASS): $(PASS_$(PASS)_trgs) $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var))))
3626 endef # def_pass_strict
3627 $(eval-opt-var def_pass_strict
)
3629 ## Execute a pass, strict order.
3630 # @param $(pass) Lowercase pass name.
3631 # @param $(PASS) Uppercase pass name.
3632 define def_pass_strict_unsafe
3633 $(eval tag
:=_before
)
3635 $(foreach subdir
, $(SUBDIRS_
$(PASS
)) $(SUBDIRS_
$(PASS
).
$(KBUILD_TARGET
)) $(SUBDIRS_
$(PASS
).
$(KBUILD_TARGET
).
$(KBUILD_TARGET_ARCH
)) ,$(eval
$(def_pass_subdir
)))
3636 $(foreach makefile
,$(MAKEFILES_BEFORE_
$(PASS
)) $(MAKEFILES_BEFORE_
$(PASS
).
$(KBUILD_TARGET
)) $(MAKEFILES_BEFORE_
$(PASS
).
$(KBUILD_TARGET
).
$(KBUILD_TARGET_ARCH
)),$(eval
$(def_pass_makefile
)))
3639 $(eval dep
:=pass_
$(pass
)_doit
)
3640 $(foreach subdir
, $(SUBDIRS_AFTER_
$(PASS
)) $(SUBDIRS_AFTER_
$(PASS
).
$(KBUILD_TARGET
)) $(SUBDIRS_AFTER_
$(PASS
).
$(KBUILD_TARGET
).
$(KBUILD_TARGET_ARCH
)) ,$(eval
$(def_pass_subdir
)))
3641 $(foreach makefile
,$(MAKEFILES_AFTER_
$(PASS
)) $(MAKEFILES_AFTER_
$(PASS
).
$(KBUILD_TARGET
)) $(MAKEFILES_AFTER_
$(PASS
).
$(KBUILD_TARGET
).
$(KBUILD_TARGET_ARCH
)) ,$(eval
$(def_pass_makefile
)))
3643 .PHONY
: pass_
$(pass
) pass_
$(pass
)_before pass_
$(pass
)_after pass_
$(pass
)_doit
3644 .NOTPARALLEL
: pass_
$(pass
) pass_
$(pass
)_before pass_
$(pass
)_after pass_
$(pass
)_doit
3645 pass_
$(pass
)_doit
: pass_
$(pass
)_before \
3646 $(PASS_
$(PASS
)_trgs
) $(foreach var
,$(PASS_
$(PASS
)_vars
),$($(var
)))
3648 pass_
$(pass
)_before \
3651 #$ (warning pass=$(pass) PASS=$(PASS): $(PASS_$(PASS)_trgs) $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var))))
3652 endef # def_pass_strict_unsafe
3653 $(eval-opt-var def_pass_strict_unsafe
)
3655 ## Execute a pass, non-strict pass ordering.
3656 # @param $(pass) Lowercase pass name.
3657 # @param $(PASS) Uppercase pass name.
3658 define def_pass_nonstrict
3659 .PHONY
: pass_
$(pass
) pass_
$(pass
)_before pass_
$(pass
)_after pass_
$(pass
)_doit
3660 pass_
$(pass
)_doit
: $(PASS_
$(PASS
)_trgs
) $(foreach var
,$(PASS_
$(PASS
)_vars
),$$$$($(var
)))
3661 pass_
$(pass
): pass_
$(pass
)_doit
3662 endef # def_pass_nonstrict
3665 # Generate the rules for the defined passes.
3666 $(foreach PASS
, $(PASSES
), \
3667 $(eval pass
:= $(PASS_
$(PASS
)_pass
)) \
3668 $(eval
$(def_pass_
$(_KBUILD_STRICT_PASS_ORDER
))))
3671 ## Pass order, strict.
3672 # @param $(pass) Current pass name.
3673 # @param $(prev_pass) The previous pass name.
3674 define def_pass_order_strict
3675 .PHONY
: pass_
$(pass
)_order
3676 .NOTPARALLEL
: pass_
$(pass
)_order
3677 pass_
$(pass
)_order
: $(pass_prev
)
3678 %$$(call MSG_PASS
,$$(if
$$(PASS_
$(PASS
)),$$(PASS_
$(PASS
)),$(pass
)))
3679 + $$(QUIET
)$$(MAKE
) -f
$$(MAKEFILE
) pass_
$(pass
)
3680 $(eval pass_prev
:= pass_
$(pass
)_order
)
3681 endef # def_pass_order_strict
3682 $(eval-opt-var def_pass_order_strict
)
3684 ## Pass order, strict unsafe.
3685 # @param $(pass) Current pass name.
3686 # @param $(prev_pass) The previous pass name.
3687 define def_pass_order_strict_unsafe
3688 .NOTPARALLEL
: pass_
$(pass
)_order pass_
$(pass
)_banner
3689 .PHONY
: pass_
$(pass
)_order pass_
$(pass
)_banner
3690 pass_
$(pass
)_banner
: $(pass_prev
)
3691 %$$(call MSG_PASS
,$$(if
$$(PASS_
$(PASS
)),$$(PASS_
$(PASS
)),$(pass
)))
3692 pass_
$(pass
)_order
: $(pass_prev
) \
3693 pass_
$(pass
)_banner \
3695 $(eval pass_prev
:= pass_
$(pass
)_order
)
3696 endef # def_pass_order_strict_unsafe
3697 $(eval-opt-var def_pass_order_strict_unsafe
)
3699 ## Pass order, non-strict.
3700 # @param $(pass) Current pass name.
3701 # @param $(prev_pass) The previous pass name.
3702 define def_pass_order_nonstrict
3703 .PHONY
: pass_
$(pass
)_order pass_
$(pass
)_banner
3704 pass_
$(pass
)_banner
:
3705 %$$(call MSG_PASS
,$$(if
$$(PASS_
$(PASS
)),$$(PASS_
$(PASS
)),$(pass
)))
3706 pass_
$(pass
)_order
: \
3708 pass_
$(pass
)_banner \
3710 $(eval pass_prev
:= pass_
$(pass
)_order
)
3711 endef # def_pass_order_nonstrict
3712 $(eval-opt-var def_pass_order_nonstrict
)
3715 # Use dependencies to ensure correct pass order.
3717 $(foreach PASS
,$(DEFAULT_PASSES
),\
3718 $(eval pass
:= $(PASS_
$(PASS
)_pass
)) \
3719 $(eval
$(def_pass_order_
$(_KBUILD_STRICT_PASS_ORDER
))))
3721 ifdef KBUILD_PROFILE_SELF
3722 $(evalcall def_profile_self
, done passes
)
3725 # Some common pass aliases
3726 ifndef KBUILD_NO_PASS_ALIASES
3731 nothing
: pass_nothing
3734 packing
: pass_packing
3736 ifndef KBUILD_NO_TESTING_PASS_ALIASES
3738 check:: pass_testing
3742 endif # KBUILD_NO_TESTING_PASS_ALIASES
3743 endif # KBUILD_NO_PASS_ALIASES
3749 all_recursive
: $(pass_prev
)
3752 + $(MAKE
) -f
$(firstword $(MAKEFILE_LIST
)) all_recursive
3754 # @todo make this a non-default pass!
3756 $(RM
) -f
-- $(_INSTALLS_FILES
)
3758 install:: pass_installs
3760 # misc shortcuts (use secondary expansion here to save strcache[file] space).
3761 targets
: bldprogs libraries dlls programs sysmods miscbins others installs
3763 bldprogs
: $$(_BLDPROGS
)
3764 libraries
: $$(_LIBS
) $$(_IMPORT_LIBS
) $$(_OTHER_LIBRARIES
)
3766 programs
: $$(_PROGRAMS
)
3767 sysmods
: $$(_SYSMODS
)
3768 miscbins
: $$(_MISCBINS
)
3770 installs
: $$(_INSTALLS
) $$(_INSTALLS_DIRS
) $$(_INSTALLS_FILES
)
3775 # kBuild debugging stuff.
3777 ## @todo this doesn't work. Move to a debug unit and expand it.
3779 @
$(foreach target
, $(_ALL_TARGETS
),\
3780 @
$(ECHO
) "target: $(target)" $(NLTAB
)\
3781 @
$(ECHO
) " $(target)_0_OUTDIR=$($(target)_0_OUTDIR)" $(NLTAB
)\
3782 @
$(ECHO
) " $(target)_1_TARGET=$($(target)_1_TARGET)" $(NLTAB
)\
3783 @
$(ECHO
) " INSTARGET_$(target)=$(INSTARGET_$(target))" $(NLTAB
)\
3784 $(foreach prop
,$(PROPS_SINGLE
) $(PROPS_ACCUMULATE_L
) $(PROPS_ACCUMULATE_R
) 2_OBJS CLEAN
, \
3785 $(eval _tmp
:=$(firstword $($(target
)_BLD_TRG
) $(KBUILD_TARGET
))) \
3786 $(if
$($(target
)_
$(prop
).
$(_tmp
)),\
3787 @
$(ECHO
) " $(target)_$(prop).$(_tmp)=$($(target)_$(prop).$(_tmp))" $(NLTAB
)) \
3788 $(if
$($(target
)_
$(prop
)), $(NLTAB
)@
$(ECHO
) " $(target)_$(prop)=$($(target)_$(prop))" $(NLTAB
)) \
3790 $(foreach prop
,$(PROPS_DEFERRED
), \
3791 $(eval _tmp
:=$(firstword $($(target
)_BLD_TRG
) $(KBUILD_TARGET
))) \
3792 $(if
$(value
$(target
)_
$(prop
).
$(_tmp
)),\
3793 @
$(ECHO
) ' $(target)_$(prop).$(_tmp)=$(value $(TARGET)_$(prop).$(_tmp))' $(NLTAB
)) \
3794 $(if
$(value
$(target
)_
$(prop
)), $(NLTAB
)@
$(ECHO
) ' $(target)_$(prop)=$(value $(target)_$(prop))' $(NLTAB
)) \
3800 # Include dependency files.
3803 # TODO: first works the second doesn't, provided _KB_INCLUDE_DEPS is undefined:
3804 # if "$(_KB_INCLUDE_DEPS)" == "1"
3805 # if $(_KB_INCLUDE_DEPS) == "1"
3807 ifdef KB_HAVE_INCLUDEDEP_QUEUE
3808 includedep-queue
$(_DEPFILES
)
3810 $(foreach dep
, $(_DEPFILES
), $(eval includedep
$(dep
)))
3815 ifdef KBUILD_PROFILE_SELF
3816 $(evalcall def_profile_self
, end of footer.kmk
)
3817 _KBUILD_TS_FOOTER_END
:= $(_KBUILD_TS_PREV
)
3819 ifneq ($(KBUILD_PROFILE_SELF
),0)
3820 $(info prof
: ALL
=$(words $(_ALL_TARGETS
)) BLDPROGS
=$(words $(_ALL_BLDPROGS
)) LIBRARIES
=$(words $(_ALL_LIBRARIES
)) IMPORT_LIBS
=$(words $(IMPORT_LIBS
)) DLLS
=$(words $(DLLS
)) PROGRAMS
=$(words $(_ALL_PROGRAMS
)) )
3821 $(info prof
: SYSMODS
=$(words $(_ALL_SYSMODS
)) MISCBINS
=$(words $(_ALL_MISCBINS
)) OTHERS
=$(words $(_ALL_OTHERS
)) INSTALLS
=$(words $(_ALL_INSTALLS
)) FETCHES
=$(words $(_ALL_FETCHES
)) PACKING
=$(words $(_PACKING
)) TESTING
=$(words $(TESTING
)) )
3822 $(info prof
: DIRS
=$(words $(_DIR_ALL
)) TOOLS
=$(words $(_TOOLS
)) SDKS
=$(words $(_SDKS
)) USES
=$(words $(_USES
)) OUT_FILES
=$(words $(_OUT_FILES
)) OBJS
=$(words $(_OBJS
)) CLEAN_FILES
=$(words $(CLEAN_FILES
) $(OTHER_CLEAN
)) )
3823 $(info prof
: DEPFILES_INCLUDED
=$(words $(_DEPFILES_INCLUDED
)) DEPFILES
=$(words $(_DEPFILES
)) MAKEFILES
=$(words $(MAKEFILE_LIST
)) )
3828 # end-of-file-content
3829 __footer_kmk__
:= target
3830 endif # __footer_kmk__