footer.kmk: check for invalid install source specifiers and display some understandab...
[kbuild-mirror.git] / kBuild / footer.kmk
blob9795ab9db57dac1d330d03bb71df3a856b8e1727
1 # $Id$
2 ## @file
3 # kBuild - File included at top of makefile.
7 # Copyright (c) 2004-2008 knut st. osmundsen <bird-kBuild-spam@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.
34 ifndef __footer_kmk__
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)
39 endif
42 # Variables.
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))
59 # all targets.
60 _ALL_TARGETS = \
61 $(_ALL_FETCHES) \
62 $(_ALL_PATCHES) \
63 $(_ALL_BLDPROGS) \
64 $(_ALL_LIBRARIES) \
65 $(_ALL_IMPORT_LIBS) \
66 $(_ALL_DLLS) \
67 $(_ALL_PROGRAMS) \
68 $(_ALL_SYSMODS) \
69 $(_ALL_MISCBINS) \
70 $(_ALL_INSTALLS) \
71 $(_ALL_OTHERS)
73 # all $(KBUILD_TARGET) targets.
74 _ALL_TARGET_TARGETS = \
75 $(_ALL_FETCHES) \
76 $(_ALL_PATCHES) \
77 $(_ALL_LIBRARIES) \
78 $(_ALL_IMPORT_LIBS) \
79 $(_ALL_DLLS) \
80 $(_ALL_PROGRAMS) \
81 $(_ALL_SYSMODS) \
82 $(_ALL_MISCBINS) \
83 $(_ALL_INSTALLS) \
84 $(_ALL_OTHERS)
86 # all $(KBUILD_HOST) targets.
87 _ALL_HOST_TARGETS = \
88 $(_ALL_BLDPROGS)
90 # all targets making use of srcname.
91 _ALL_SRCNAME_TARGETS = \
92 $(_ALL_FETCHES) \
93 $(_ALL_PATCHES)
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.
99 _DEPFILES_INCLUDED :=
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.
105 _OUT_FILES :=
107 # Files which only requires cleaning up.
108 _CLEAN_FILES :=
110 # all of a type
111 _OBJS :=
112 _FETCHES :=
113 _DOWNLOADS:=
114 _UNPACKS :=
115 _PATCHES :=
116 _UNFETCHES:=
117 _BLDPROGS :=
118 _LIBS :=
119 _DLLS :=
120 _PROGRAMS :=
121 _SYSMODS :=
122 _MISCBINS :=
123 _INSTALLS :=
124 _INSTALLS_FILES :=
125 _INSTALLS_DIRS :=
126 _OTHERS :=
127 _PACKING :=
128 _DIRS := $(PATH_TARGET)/ $(PATH_TARGET) $(BLDDIRS)
129 _IMPORT_LIBS :=
131 # misc
132 pass_prev :=
137 # Footer macros
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)) \
148 $($(1)_$(2)TOOL) \
149 $($(1)_TOOL.$(bld_trg).$(bld_trg_arch)) \
150 $($(1)_TOOL.$(bld_trg)) \
151 $($(1)_TOOL) \
152 $($(2)TOOL.$(bld_trg).$(bld_trg_arch)) \
153 $($(2)TOOL.$(bld_trg)) \
154 $($(2)TOOL) \
155 $(TOOL.$(bld_trg).$(bld_trg_arch)) \
156 $(TOOL.$(bld_trg)) \
157 $(TOOL) \
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)
174 $1 = $$($1_DEFERRED)
175 endef
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))
187 endif
188 endif
189 endef
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))
203 endif
204 endif
205 endef
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))
212 endif
213 endif
214 endef
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))
226 endif
227 endif
228 endef
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))
235 endif
236 endif
237 endef
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))
244 endif
245 endif
246 endef
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))
259 endif
260 endef
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))
266 endif
267 endef
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))
279 endif
280 endif
281 endef
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))
292 endif
293 $(trg)_$(prop).$(trg_key) <= $$($(trg)_$(prop).$(src_key))
294 endif
295 endef
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))
302 endif
303 $(trg)_$(prop).$(trg_key) += $$($(trg)_$(prop).$(src_key))
304 endif
305 endef
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))
318 endif
319 endef
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))
325 endif
326 endef
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))
338 endif
339 endif
340 endef
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))
351 endif
352 $(trg)_$(prop).$(trg_key) += $$($(trg)_$(prop).$(src_key))
353 endif
354 endef
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))
361 endif
362 $(trg)_$(prop).$(trg_key) <= $$($(trg)_$(prop).$(src_key))
363 endif
364 endef
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
399 ifdef $(src)_$(prop)
400 ifndef $(trg)_$(prop)
401 $(trg)_$(prop) = $($(src)_$(prop))
402 endif
403 endif
404 endef
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
414 ifdef $(src)_$(prop)
415 ifndef $(trg)_$(prop)
416 $(trg)_$(prop) := $($(src)_$(prop))
417 endif
418 endif
419 endef
421 ## @copydoc def_inherit_one_overriding_now_l
422 define def_inherit_one_overriding_now_r
423 ifdef $(src)_$(prop)
424 ifndef $(trg)_$(prop)
425 $(trg)_$(prop) := $($(src)_$(prop))
426 endif
427 endif
428 endef
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
436 ifdef $(src)_$(prop)
437 ifndef $(trg)_$(prop)
438 $(trg)_$(prop) = $$($(src)_$(prop))
439 endif
440 endif
441 endef
443 ## @copydoc def_inherit_one_overriding_deferred
444 define def_inherit_one_overriding_deferred_l
445 ifdef $(src)_$(prop)
446 ifndef $(trg)_$(prop)
447 $(trg)_$(prop) = $$($(src)_$(prop))
448 endif
449 endif
450 endef
452 ## @copydoc def_inherit_one_overriding_deferred
453 define def_inherit_one_overriding_deferred_r
454 ifdef $(src)_$(prop)
455 ifndef $(trg)_$(prop)
456 $(trg)_$(prop) = $$($(src)_$(prop))
457 endif
458 endif
459 endef
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
469 ifdef $(src)_$(prop)
470 $(trg)_$(prop) := $($(src)_$(prop)) $($(trg)_$(prop))
471 endif
472 endef
474 ## @copydoc def_inherit_one_prepending_now_l
475 define def_inherit_one_prepending_now_r
476 ifdef $(src)_$(prop)
477 $(trg)_$(prop) := $($(trg)_$(prop)) $($(src)_$(prop))
478 endif
479 endef
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
487 ifdef $(src)_$(prop)
488 ifndef $(trg)_$(prop)
489 $(trg)_$(prop) = $$($(src)_$(prop))
490 endif
491 endif
492 endef
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
499 ifdef $(src)_$(prop)
500 ifeq ($$(flavor $(trg)_$(prop)),simple)
501 $$(evalcall2 def_simple_2_recursive,$(trg)_$(prop))
502 endif
503 $(trg)_$(prop) <= $$($(src)_$(prop))
504 endif
505 endef
507 ## @copydoc def_inherit_one_prepending_deferred_l
508 define def_inherit_one_prepending_deferred_r
509 ifdef $(src)_$(prop)
510 ifeq ($$(flavor $(trg)_$(prop)),simple)
511 $$(evalcall2 def_simple_2_recursive,$(trg)_$(prop))
512 endif
513 $(trg)_$(prop) += $$($(src)_$(prop))
514 endif
515 endef
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
525 ifdef $(src)_$(prop)
526 $(trg)_$(prop) := $($(trg)_$(prop)) $($(src)_$(prop))
527 endif
528 endef
530 ## @copydoc def_inherit_one_appending_now_l
531 define def_inherit_one_appending_now_r
532 ifdef $(src)_$(prop)
533 $(trg)_$(prop) := $($(src)_$(prop)) $($(trg)_$(prop))
534 endif
535 endef
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
543 ifdef $(src)_$(prop)
544 ifndef $(trg)_$(prop)
545 $(trg)_$(prop) = $$($(src)_$(prop))
546 endif
547 endif
548 endef
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
555 ifdef $(src)_$(prop)
556 ifeq ($$(flavor $(trg)_$(prop)),simple)
557 $$(evalcall2 def_simple_2_recursive,$(trg)_$(prop))
558 endif
559 $(trg)_$(prop) += $$($(src)_$(prop))
560 endif
561 endef
563 ## @copydoc def_inherit_one_appending_deferred_l
564 define def_inherit_one_appending_deferred_r
565 ifdef $(src)_$(prop)
566 ifeq ($$(flavor $(trg)_$(prop)),simple)
567 $$(evalcall2 def_simple_2_recursive,$(trg)_$(prop))
568 endif
569 $(trg)_$(prop) <= $$($(src)_$(prop))
570 endif
571 endef
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.
588 define def_inherit
590 # Load it - loading is a mess, fix.
591 ifneq ($(load_function),)
592 local loading := $(patsubst $(src_prefix)%,%,$(trg))
593 $(evalvalctx $(load_function))
594 endif
596 local src := $(strip $($(trg)_EXTENDS))
597 ifneq ($(src),)
598 ifndef $(trg)_EXTENDS_STATUS_
599 $(trg)_EXTENDS_STATUS_ := 0
601 # Load the source.
602 ifneq ($(load_function),)
603 local loading := $(src)
604 $(evalvalctx $(load_function))
605 endif
607 # less typing.
608 local src := $(src_prefix)$(src)
610 # Recursivly process the parent (src) if it's inherting from somebody too.
611 ifdef $(src)_EXTENDS
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))
617 endif
618 endif
620 # Get & check EXTENDS_BY.
621 local by = $(strip $($(trg)_EXTENDS_BY))
622 ifeq ($(by),)
623 local by = overriding
624 else ifn1of ($(by), overriding appending prepending)
625 $(error kBuild: Invalid EXTENDS_BY value '$(by)' on '$(trg)'!)
626 endif
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
638 else
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_))
642 endif
643 endif
644 endif
646 # Keyword inheritance.
647 $(foreach prefix_keyword, $(join $(_KEYWORDS_PREFIX), $(addprefix :,$(_KEYWORDS_EXTENDS))), $(evalval def_inherit_keyword))
649 endef # def_inherit
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))
669 endif
670 include $(UNIT_$(loading)_KMK_FILE)
671 ifndef UNIT_$(loading)
672 $(warning kBuild: UNIT_$(loading) was not defined by $(UNIT_$(loading)_KMK_FILE)!)
673 endif
674 endif
675 endef # def_unit_load_function
677 $(foreach loading, \
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)
695 define def_templates
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)
699 endif
700 _TEMPLATES += $($(target)_TEMPLATE)
701 endif
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))
713 endif
714 include $(TEMPLATE_$(loading)_KMK_FILE)
715 ifndef TEMPLATE_$(loading)
716 $(warning kBuild: TEMPLATE_$(loading) was not defined by $(TEMPLATE_$(loading)_KMK_FILE)!)
717 endif
718 endif
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)}!)
740 endif
741 _BLD_TYPES += $($(src)_BLD_TYPE)
742 endif
743 ifdef $(src)_BLD_TRG
744 ifn1of ($($(src)_BLD_TRG), $(KBUILD_OSES))
745 $(error kBuild: $(src)_BLD_TRG=$($(src)_BLD_TRG) not in KBUILD_OSES={$(KBUILD_OSES)}!)
746 endif
747 _BLD_TARGETS += $($(src)_BLD_TRG)
748 endif
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)}!)
752 endif
753 _BLD_ARCHES += $($(src)_BLD_TRG_ARCH)
754 endif
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!)
758 endif
759 _BLD_CPUS += $($(src)_BLD_TRG_CPU)
760 endif
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.
773 # @param keyword
774 # @param prefix
775 # @param valid
776 define def_keyword_ordering
777 # Check for EXTENDS, fix and validate it if found.
778 local src := $(strip $($(prefix)_$(keyword)_EXTENDS))
779 ifneq ($(src),)
780 ifndef $(prefix)_$(keyword)_EXTENDS_STATUS_
781 ifn1of ($(src), $(valid))
782 $(error kBuild: $(keyword) tries to extend unknown keyword '$(src)'! (known = $(valid)))
783 endif
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))
792 endif
794 # Check and strip EXTENDS_BY.
795 local by = $(strip $($(prefix)_$(keyword)_EXTENDS_BY))
796 ifeq ($(by),)
797 local by = overriding
798 else ifn1of ($(by), overriding appending prepending)
799 $(error kBuild: Invalid EXTENDS_BY value '$(by)' on '$(keyword)'!)
800 endif
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
810 else
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_))
814 endif
815 endif
816 else
817 # Add it to the ordered list and mark it as done.
818 _KEYWORDS_ORDERED += $(keyword)
819 $(prefix)_$(src)_EXTENDS_STATUS_ := 42
820 endif
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.
826 _KEYWORDS_ORDERED :=
827 _KEYWORDS_EXTENDS :=
828 _KEYWORDS_PREFIX :=
830 prefix := BLD_TYPE
831 valid := $(KBUILD_BLD_TYPES)
832 $(foreach keyword, $(_BLD_TYPES) , $(evalval def_keyword_ordering))
834 prefix := BLD_TRG
835 valid := $(KBUILD_OSES)
836 $(foreach keyword, $(_BLD_TARGETS), $(evalval def_keyword_ordering))
838 prefix := BLD_ARCH
839 valid := $(KBUILD_ARCHES)
840 $(foreach keyword, $(_BLD_ARCHES) , $(evalval def_keyword_ordering))
842 prefix := BLD_CPU
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)
854 endif
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.
868 src_prefix :=
869 load_function :=
870 properties_deferred_l :=
871 properties_deferred_r :=
873 # Fetches.
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))
901 else
902 $(foreach trg, $(_ALL_LIBRARIES),$(evalval def_inherit))
903 endif
905 # DLLs.
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))
912 else
913 $(foreach trg, $(_ALL_DLLS) $(_ALL_IMPORT_LIBS),$(evalval def_inherit))
914 endif
916 # System modules.
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))
923 # Misc binaries.
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))
930 # Installs.
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)
939 endif
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
950 # exercise.
953 src_prefix := TEMPLATE_
954 load_function := def_templates_load_function
955 properties :=
956 properties_now_l :=
957 properties_now_r :=
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))
963 # done inheriting.
964 src_prefix :=
965 load_function :=
966 properties :=
967 properties_now_l :=
968 properties_now_r :=
969 properties_deferred :=
970 properties_deferred_l :=
971 properties_deferred_r :=
973 ifdef KBUILD_PROFILE_SELF
974 $(evalcall def_profile_self, done template inheritance)
975 endif
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))
992 else # !kb-exp-tmpl
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))
1002 endif
1003 endif
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))
1007 endif
1008 endif
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))
1012 endif
1013 endif
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))
1017 endif
1018 endif
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))
1022 endif
1023 endif
1024 endef
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))
1035 endif
1036 endif
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))
1040 endif
1041 endif
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))
1045 endif
1046 endif
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))
1050 endif
1051 endif
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))
1055 endif
1056 endif
1057 endef
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))
1066 endif
1067 $(target)_$(prop) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop))
1068 endif
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))
1072 endif
1073 $(target)_$(prop).$(KBUILD_TYPE) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(KBUILD_TYPE))
1074 endif
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))
1078 endif
1079 $(target)_$(prop).$(bld_trg) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
1080 endif
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))
1084 endif
1085 $(target)_$(prop).$(bld_trg).$(bld_trg_arch) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch))
1086 endif
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))
1090 endif
1091 $(target)_$(prop).$(bld_trg_cpu) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
1092 endif
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))
1096 endif
1097 $(target)_$(prop).$(bld_trg_arch) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
1098 endif
1099 endef
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))
1108 endif
1109 $(target)_$(prop) <=$$(TEMPLATE_$($(target)_TEMPLATE)_$(prop))
1110 endif
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))
1114 endif
1115 $(target)_$(prop).$(KBUILD_TYPE) <=$$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(KBUILD_TYPE))
1116 endif
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))
1120 endif
1121 $(target)_$(prop).$(bld_trg) <=$$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
1122 endif
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))
1126 endif
1127 $(target)_$(prop).$(bld_trg).$(bld_trg_arch) <=$$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch))
1128 endif
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))
1132 endif
1133 $(target)_$(prop).$(bld_trg_cpu) <=$$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
1134 endif
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))
1138 endif
1139 $(target)_$(prop).$(bld_trg_arch) <=$$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
1140 endif
1141 endef
1144 ## Inherit template properties for on target.
1145 # @param $(target) Target name.
1146 define def_inherit_template
1147 # sanity check.
1148 ifdef _$(target)_ALREADY_PROCESSED
1149 $(error kBuild: The target $(target) appears more than once in the target lists! Please correct the makefile(s))
1150 endif
1151 _$(target)_ALREADY_PROCESSED := 1
1153 # Inherit any default template.
1154 ifdef TEMPLATE
1155 ifeq ($($(target)_TEMPLATE),)
1156 $(eval $(target)_TEMPLATE:=$(TEMPLATE))
1157 endif
1158 endif
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)
1165 endif
1166 endef
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)
1183 endif
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)) \
1194 $(TOOL)
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)) \
1198 $(SDKS)
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)) \
1202 $(USES)
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))))
1213 $(eval _SDKS += \
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)) \
1222 $($(source)_SDKS) \
1223 $($(target)_$(source)_SDKS))
1224 $(eval _USES += \
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)) \
1233 $($(source)_USES) \
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))))
1249 $(eval _SDKS += \
1250 $($(target)_SDKS.$(_bld_trg)) \
1251 $($(target)_SDKS.$(_bld_trg_arch)) \
1252 $($(target)_SDKS.$(_bld_trg).$(_bld_trg_arch)) \
1253 $($(target)_SDKS))
1254 $(eval _USES += \
1255 $($(target)_USES.$(_bld_trg)) \
1256 $($(target)_USES.$(_bld_trg_arch)) \
1257 $($(target)_USES.$(_bld_trg).$(_bld_trg_arch)) \
1258 $($(target)_USES))
1259 $(foreach source, \
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))
1308 endif
1309 include $(TOOL_$(loading)_KMK_FILE)
1310 ifndef TOOL_$(loading)
1311 $(warning kBuild: TOOL_$(loading) was not defined by $(TOOL_$(loading)_KMK_FILE)!)
1312 endif
1313 endif
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))
1323 endif
1324 include $(SDK_$(loading)_KMK_FILE)
1325 ifndef SDK_$(loading)
1326 $(warning kBuild: SDK_$(loading) was not defined by $(SDK_$(loading)_KMK_FILE)!)
1327 endif
1328 endif
1329 endef # def_sdk_load_function
1332 properties :=
1333 properties_now_l :=
1334 properties_now_r :=
1335 properties_deferred := $(PROPS_SINGLE) $(PROPS_DEFERRED)
1336 properties_deferred_l := $(PROPS_ACCUMULATE_L)
1337 properties_deferred_r := $(PROPS_ACCUMULATE_R)
1339 src_prefix := TOOL_
1340 load_function := def_tools_load_function
1341 $(foreach trg, $(addprefix TOOL_,$(_TOOLS)), $(evalval def_inherit))
1343 src_prefix := SDK_
1344 load_function := def_sdk_load_function
1345 $(foreach trg, $(addprefix SDK_,$(_SDKS)), $(evalval def_inherit))
1347 # done inheriting.
1348 src_prefix :=
1349 load_function :=
1350 properties :=
1351 properties_now_l :=
1352 properties_now_r :=
1353 properties_deferred :=
1354 properties_deferred_l :=
1355 properties_deferred_r :=
1357 # No inheriting for the uses, they're just global 'code'.
1358 $(foreach loading, $(_USES), $(evalval def_unit_load_function))
1361 ifdef KBUILD_PROFILE_SELF
1362 $(evalcall def_profile_self, done tools + sdks + units)
1363 endif
1369 # Target lists - Pass 1
1371 # This pass is for defining variables that might be referenced in
1372 # properties of other targets.
1376 # Don't do anything for fetch targets (yet).
1379 # Link prolog for Pass 1.
1381 # @param $(target) Normalized target name.
1382 # @param $(EXT) EXE,DLL,SYS,LIB.
1383 # @param $(EXTPRE) HOST or nothing.
1384 # @param $(definst) The default _INST value.
1385 # @param $(tool_prefix) LD or AR.
1386 # @param $(bld_trg_base_var) TARGET or PLATFORM.
1387 define def_pass1_link_common
1389 local bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE))
1390 local bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_$(bld_trg_base_var)))
1391 local bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_$(bld_trg_base_var)_ARCH))
1392 local bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_$(bld_trg_base_var)_CPU))
1394 local tool := $(call _TARGET_TOOL,$(target),$(tool_prefix))
1395 local name := $(firstword\
1396 $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\
1397 $($(target)_NAME.$(bld_trg_arch))\
1398 $($(target)_NAME.$(bld_trg))\
1399 $($(target)_NAME.$(bld_type))\
1400 $($(target)_NAME)\
1401 $(target))
1402 local outbase := $(call TARGET_BASE,$(name),$(target))
1403 ifndef PATH_$(target)
1404 PATH_$(target) := $(patsubst %/,%,$(dir $(outbase)))
1405 else ifneq ($(PATH_$(target)),$(patsubst %/,%,$(dir $(outbase))))
1406 $(error kBuild internal error: PATH_$(target)=$(PATH_$(target)) expected $(patsubst %/,%,$(dir $(outbase))))
1407 endif
1408 ## @todo fix the fun at the last line (AR != LIB => mess).
1409 local suff := $(firstword \
1410 $($(target)_$(EXT)SUFF.$(bld_trg).$(bld_trg_arch))\
1411 $($(target)_$(EXT)SUFF.$(bld_trg))\
1412 $($(target)_$(EXT)SUFF)\
1413 $(TOOL_$(tool)_$(tool_prefix)$(EXT)SUFF.$(bld_trg).$(bld_trg_arch))\
1414 $(TOOL_$(tool)_$(tool_prefix)$(EXT)SUFF.$(bld_trg))\
1415 $(TOOL_$(tool)_$(tool_prefix)$(EXT)SUFF)\
1416 $(if $(eq $(tool_prefix),AR),$(SUFF_LIB),$($(EXTPRE)SUFF_$(EXT))) )
1417 local out := $(outbase)$(suff)
1419 # TARGET_*
1420 TARGET_$(target) := $(out)
1422 # INSTARGET_*
1423 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))),)
1424 ifneq ($(strip $($(target)_INST.$(bld_trg).$(bld_trg_arch).$(bld_type))),)
1425 local inst := $(addprefix $(PATH_INS)/,$($(target)_INST.$(bld_trg).$(bld_trg_arch).$(bld_type)))
1426 else ifneq ($(strip $($(target)_INST.$(bld_trg).$(bld_trg_arch))),)
1427 local inst := $(addprefix $(PATH_INS)/,$($(target)_INST.$(bld_trg).$(bld_trg_arch)))
1428 else ifneq ($(strip $($(target)_INST.$(bld_trg).$(bld_type))),)
1429 local inst := $(addprefix $(PATH_INS)/,$($(target)_INST.$(bld_trg).$(bld_type)))
1430 else ifneq ($(strip $($(target)_INST.$(bld_trg_arch))),)
1431 local inst := $(addprefix $(PATH_INS)/,$($(target)_INST.$(bld_trg_arch)))
1432 else ifneq ($(strip $($(target)_INST.$(bld_trg))),)
1433 local inst := $(addprefix $(PATH_INS)/,$($(target)_INST.$(bld_trg)))
1434 else ifneq ($(strip $($(target)_INST.$(bld_type))),)
1435 local inst := $(addprefix $(PATH_INS)/,$($(target)_INST.$(bld_type)))
1436 else ifneq ($(strip $($(target)_INST)),)
1437 local inst := $(addprefix $(PATH_INS)/,$($(target)_INST))
1438 else
1439 local inst := $(definst)/
1440 endif
1441 INSTARGET_$(target) := $(patsubst %/,%/$(notdir $(out)),$(inst))
1443 else # NOINST
1444 INSTARGET_$(target) :=
1445 endif # NOINST
1447 endef
1448 $(eval-opt-var def_pass1_link_common)
1452 # BLDPROGS (Pass 1)
1454 define def_pass1_bldprog
1455 # set NOINST if not forced installation before doing the usual stuff.
1456 ifndef $(target)_INST
1457 $(target)_NOINST := 1
1458 endif
1459 $(evalval def_pass1_link_common)
1460 endef
1462 EXT := EXE
1463 EXTPRE := HOST
1464 definst := $(PATH_BIN)
1465 tool_prefix := LD
1466 bld_trg_base_var := PLATFORM
1467 $(foreach target, $(_ALL_BLDPROGS), \
1468 $(evalval def_pass1_bldprog))
1472 # LIBRARIES (Pass 1)
1474 EXT := LIB
1475 EXTPRE :=
1476 definst := $(PATH_LIB)
1477 tool_prefix := AR
1478 bld_trg_base_var := TARGET
1479 $(foreach target, $(_ALL_LIBRARIES), \
1480 $(evalval def_pass1_link_common))
1484 # DLLS (Pass 1)
1486 EXT := DLL
1487 EXTPRE :=
1488 definst := $(PATH_DLL)
1489 tool_prefix := LD
1490 bld_trg_base_var := TARGET
1491 $(foreach target, $(_ALL_DLLS), \
1492 $(evalval def_pass1_link_common))
1496 # IMPORT LIBRARIES (Pass 1)
1498 # - On OS/2 and windows these are libraries.
1499 # - On other platforms they are fake DLLs.
1501 if1of ($(KBUILD_TARGET), nt os2 win win64 win32)
1502 EXT := LIB
1503 EXTPRE :=
1504 definst := $(PATH_LIB)
1505 tool_prefix := AR
1506 bld_trg_base_var := TARGET
1507 $(foreach target, $(_ALL_IMPORT_LIBS), \
1508 $(evalval def_pass1_link_common))
1509 else
1510 EXT := DLL
1511 EXTPRE :=
1512 definst := $(PATH_DLL)
1513 tool_prefix := LD
1514 bld_trg_base_var := TARGET
1515 $(foreach target, $(_ALL_IMPORT_LIBS), \
1516 $(evalval def_pass1_link_common))
1517 endif
1521 # PROGRAMS (Pass 1)
1523 EXT := EXE
1524 EXTPRE :=
1525 definst := $(PATH_BIN)
1526 tool_prefix := LD
1527 bld_trg_base_var := TARGET
1528 $(foreach target, $(_ALL_PROGRAMS), \
1529 $(evalval def_pass1_link_common))
1533 # SYSMODS (Pass 1)
1535 EXT := SYS
1536 EXTPRE :=
1537 definst := $(PATH_SYS)
1538 tool_prefix := LD
1539 bld_trg_base_var := TARGET
1540 $(foreach target, $(_ALL_SYSMODS), \
1541 $(evalval def_pass1_link_common))
1545 # MISCBINS (Pass 1)
1547 EXT := BIN
1548 EXTPRE :=
1549 definst := $(PATH_BIN)
1550 tool_prefix := LD
1551 bld_trg_base_var := TARGET
1552 $(foreach target, $(_ALL_MISCBINS), \
1553 $(evalval def_pass1_link_common))
1557 # INSTALLS (Pass 1)
1558 # Note! INSTARGET_* for INSTALLS aren't available until later.
1560 define def_pass1_install
1561 local bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE))
1562 local bld_trg := $(firstword $($(target)_BLD_TRG) $(KBUILD_TARGET))
1563 local bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(KBUILD_TARGET_ARCH))
1564 local bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(KBUILD_TARGET_CPU))
1565 # TARGET_*
1566 TARGET_$(target) := $(PATH_TARGET)/$(target).ins
1567 # INSTARGET_ later.
1568 # PATH_*
1569 local outbase := $(call TARGET_BASE,$(target),$(target))
1570 PATH_$(target) := $(patsubst %/,%,$(dir $(outbase)))
1571 endef # def_pass1_install
1572 $(eval-opt-var def_pass1_install)
1573 $(foreach target, $(_ALL_INSTALLS), \
1574 $(evalval def_pass1_install))
1576 ifdef KBUILD_PROFILE_SELF
1577 $(evalcall def_profile_self, done pass 1)
1578 endif
1585 # Target lists - Pass 2
1590 ## @page pg_fetches Fetching Tools, Sources and Similar.
1592 # The targets listed in the the FETCHES target list have the following attributes:
1593 # SOURCES
1594 # INST
1595 # FETCHTOOL
1596 # FETCHFLAGS
1597 # FETCHDIR
1598 # UNPACKTOOL
1599 # UNPACKFLAGS
1601 # As usual the target name is an alias for 'creating' the target. Other
1602 # aliases are:
1603 # pass_fetches
1604 # fetch
1605 # unfetch
1606 # download
1607 # unpack
1609 # @remark
1611 # This is a little bit complex because we must guarantee that if a source file
1612 # changes only sligtly we must refetch it and to a proper unpacking of it. It
1613 # is also a desire that fetched archives and unpacked files can be deleted to
1614 # save space.
1616 # Thus, we must be able to cleanup what we've unpacked should any of the
1617 # sources be removed. We do this by maintaining a file listing the files
1618 # and directories that was unpacked. This operation is named 'unfetch'.
1620 # We make use of the SIZE and MD5 attributes for each of the sources to
1621 # create a digest that is stored in the primary target file. Subsequent
1622 # runswill compare their digest with it to decide if a refetch is required.
1623 # When a refetch is found necessary, an 'unfetch' is performed first to
1624 # clean out old files and directores. Note even changes in source order
1625 # will cause a refetch due to the way the digest is constructed and
1626 # evaluated.
1628 # By not depending directly on the archives (nor on any unpacked files)
1629 # but on a goal made up from the archive name, size and md5, we allow
1630 # the user to delete the archives. Naturally, this means we'll have to
1631 # check and fetch missing archives before attempting to unpack them.
1633 # @remark
1635 # This feature will *NOT* work correctly with vanilla GNU make becuase
1636 # it makes use of includedep to avoid too many unnecessary files.
1638 # @todo
1639 # 1. Download corruption / continuation.
1640 # 2. It's quite possible that there is one too many indirect dependency now...
1643 ## generates the fetch rule
1644 define def_fetch_src_fetch_rule
1645 # Indirect goal for downloading something.
1646 .PRECIOUS: $(out)
1647 $(out) + $($(target)_$(srcname)_FETCH_OUTPUT_) +| $($(target)_$(srcname)_FETCH_OUTPUT_MAYBE_) : \
1648 | $($(target)_$(srcname)_FETCH_DEPORD_)
1649 %$$(call MSG_FETCH_DL,$(target),$(source),$(out))
1650 @## @todo do fancy stuff like download continuation.
1651 $$(QUIET)$$(RM) -f -- $(out)
1652 $($(target)_$(srcname)_FETCH_CMDS_)
1653 $$(QUIET)$(if $(md5),$$(MD5SUM_EXT) -b -C $(md5) $(out))
1657 # Intermediate goal for making sure the md5 and size matches. it will (re) fetch the archive if necessary.
1658 $(out).checked_$(md5)_$(size): $($(target)_$(srcname)_FETCH_DEPEND_) | $($(target)_$(srcname)_FETCH_DEPORD_)
1659 %$$(call MSG_FETCH_CHK,$(target),$(source),$(out))
1660 $$(QUIET)$$(RM) -f -- $$@
1661 @# (re)fetch the file if it doesn't exist or if it doesn't matches the md5.
1662 @## @todo do fancy stuff like download continuation.
1663 $$(QUIET)( test -f $(out) && $(if $(md5),$$(MD5SUM_EXT) -b -C $(md5) $(out), true) ) \
1664 || ( $$(RM_EXT) -f $(out) \
1665 && $$(MAKE) $(out) -f $(MAKEFILE) --no-print-directory )
1666 $$(QUIET2)$$(APPEND) $$@
1668 _TARGET_$(target)_FETCHED += $(out) $(out).checked_$(md5)_$(size)
1670 # Just a little precaution.
1671 .NOTPARALLEL: $(out) $(out).checked_$(md5)_$(size)
1673 endef # def_fetch_src_fetch_rule
1674 $(eval-opt-var def_fetch_src_fetch_rule)
1676 ## generates the unpack rule
1677 define def_fetch_src_unpack_rule
1678 # This is the unpack rule. it has an order-only dependency on the download check.
1679 $(out) + $($(target)_$(srcname)_UNPACK_OUTPUT_) +| $($(target)_$(srcname)_UNPACK_OUTPUT_MAYBE_) : \
1680 $($(target)_$(srcname)_UNPACK_DEPEND_) \
1681 | $($(target)_$(srcname)_UNPACK_DEPORD_) \
1682 $(archive).checked_$(md5)_$(size) \
1683 $(dir $(out))
1684 %$$(call MSG_FETCH_UP,$(target),$(archive),$(inst))
1685 $$(QUIET)$$(RM) -f -- $(out)
1686 $$(QUIET)$$(MKDIR) -p -- $(dir $(out))
1687 @# if the source archive doesn't exist fetch it (may have been deleted to save space).
1688 $$(QUIET)test -f $(archive) \
1689 || ( $$(RM_EXT) -f $(archive).checked_$(md5)_$(size) \
1690 && $$(MAKE) $(archive).checked_$(md5)_$(size) -f $(MAKEFILE) --no-print-directory )
1691 $($(target)_$(srcname)_UNPACK_CMDS_)
1692 $$(QUIET2)$$(APPEND) $(out) $(notdir $(archive).checked_$(md5)_$(size))
1693 $$(QUIET2)$$(APPEND) $(out) $(notdir $(out))
1695 $(eval _TARGET_$(target)_UNPACKED += $(out))
1696 _TARGET_$(target)_DIGEST := $(_TARGET_$(target)_DIGEST)-$(srcname)_$(md5)_$(size)
1698 .NOTPARALLEL: $(out)
1700 endef # def_fetch_src_unpack_rule
1701 $(eval-opt-var def_fetch_src_unpack_rule)
1703 ## Processes a fetch source
1705 define def_fetch_src
1706 #$ (warning dbg: def_fetch_src: source='$(source)' target='$(target)')
1708 # common
1709 local srcname := $(notdir $(source))
1710 local inst := $(firstword \
1711 $($(target)_$(source)_INST)\
1712 $($(target)_$(srcname)_INST)\
1713 $($(source)_INST)\
1714 $($(srcname)_INST)\
1715 $($(target)_INST)\
1717 ifneq ($(patsubst %/,ok,$(inst)),ok)
1718 $(error kBuild: Bad or missing INST property for source '$(source)' in target '$(target)': $(inst))
1719 endif
1720 INSTARGET_$(target)_$(srcname) := $(inst)
1721 local fetchdir := $(firstword \
1722 $($(target)_$(source)_FETCHDIR)\
1723 $($(target)_$(srcname)_FETCHDIR)\
1724 $($(source)_FETCHDIR)\
1725 $($(srcname)_FETCHDIR)\
1726 $($(target)_FETCHDIR)\
1727 $(FETCHDIR)\
1728 $(PATH_TARGET)\
1730 local deps := \
1731 $($(target)_$(source)_DEPS)\
1732 $($(target)_$(srcname)_DEPS)\
1733 $($(source)_DEPS)\
1734 $($(srcname)_DEPS)\
1735 $($(target)_DEPS)
1736 local orderdeps := \
1737 $($(target)_$(source)_ORDERDEPS)\
1738 $($(target)_$(srcname)_ORDERDEPS)\
1739 $($(source)_ORDERDEPS)\
1740 $($(srcname)_ORDERDEPS)\
1741 $($(target)_ORDERDEPS)
1742 local md5 := $(firstword \
1743 $($(target)_$(source)_MD5)\
1744 $($(target)_$(srcname)_MD5)\
1745 $($(source)_MD5)\
1746 $($(srcname)_MD5)\
1747 $($(target)_MD5)\
1749 local size := $(firstword \
1750 $($(target)_$(source)_SIZE)\
1751 $($(target)_$(srcname)_SIZE)\
1752 $($(source)_SIZE)\
1753 $($(srcname)_SIZE)\
1754 $($(target)_SIZE)\
1756 clean_files += \
1757 $($(target)_$(source)_CLEAN)\
1758 $($(target)_$(srcname)_CLEAN)\
1759 $($(source)_CLEAN)\
1760 $($(srcname)_CLEAN)
1761 local dep := # not legal for fetch and unpack tools
1765 # The fetching.
1767 local out := $(fetchdir)/$(srcname)
1768 local archive := $(out)
1769 TARGET_$(target)_$(srcname) := $(out)
1770 local dirdep := $(call DIRDEP,$(fetchdir))
1771 local tool := $(firstword \
1772 $($(target)_$(source)_FETCHTOOL)\
1773 $($(target)_$(srcname)_FETCHTOOL)\
1774 $($(target)_$(source)_TOOL)\
1775 $($(target)_$(srcname)_TOOL)\
1776 $($(source)_FETCHTOOL)\
1777 $($(srcname)_FETCHTOOL)\
1778 $($(source)_TOOL)\
1779 $($(srcname)_TOOL)\
1780 $($(target)_FETCHTOOL)\
1781 $($(target)_TOOL)\
1783 local flags :=\
1784 $(TOOL_$(tool)_FETCHFLAGS)\
1785 $(FETCHFLAGS)\
1786 $($(target)_FETCHFLAGS)\
1787 $($(srcname)_FETCHFLAGS)\
1788 $($(source)_FETCHFLAGS)\
1789 $($(target)_$(srcname)_FETCHFLAGS)\
1790 $($(target)_$(source)_FETCHFLAGS)
1792 #$ (warning dbg: target=$(target) source=$(source) $(srcname)=$(srcname) tool=$(tool) out=$(out) flags=$(flags) dirdep=$(dirdep) fetchdir=$(fetchdir) md5=$(md5) size=$(size))
1794 ifndef TOOL_$(tool)_FETCH_CMDS
1795 $(warning kBuild: tools: \
1796 1 $($(target)_$(source)_FETCHTOOL)\
1797 2 $($(target)_$(srcname)_FETCHTOOL)\
1798 3 $($(target)_$(source)_TOOL)\
1799 4 $($(target)_$(srcname)_TOOL)\
1800 5 $($(source)_FETCHTOOL)\
1801 6 $($(srcname)_FETCHTOOL)\
1802 7 $($(source)_TOOL)\
1803 8 $($(srcname)_TOOL)\
1804 9 $($(target)_FETCHTOOL)\
1805 10 $($(target)_TOOL) )
1806 $(error kBuild: TOOL_$(tool)_FETCH_CMDS is not defined. source=$(source) target=$(target) )
1807 endif
1809 # call the tool
1810 $(target)_$(srcname)_FETCH_CMDS_ := $(TOOL_$(tool)_FETCH_CMDS)
1811 $(target)_$(srcname)_FETCH_OUTPUT_ := $(TOOL_$(tool)_FETCH_OUTPUT)
1812 $(target)_$(srcname)_FETCH_OUTPUT_MAYBE_ := $(TOOL_$(tool)_FETCH_OUTPUT_MAYBE)
1813 $(target)_$(srcname)_FETCH_DEPEND_ := $(TOOL_$(tool)_FETCH_DEPEND) $(deps)
1814 $(target)_$(srcname)_FETCH_DEPORD_ := $(TOOL_$(tool)_FETCH_DEPORD) $(dirdep) $(orderdeps)
1816 # generate the fetch rule.
1817 $(eval $(def_fetch_src_fetch_rule))
1821 # The unpacking / installing.
1823 local out := $(inst)_kBuild_$(target)_$(srcname)_unpacked.lst
1824 local dirdep := $(call DIRDEP,$(inst))
1825 local tool := $(firstword \
1826 $($(target)_$(source)_UNPACKTOOL)\
1827 $($(target)_$(srcname)_UNPACKTOOL)\
1828 $($(target)_$(source)_TOOL)\
1829 $($(target)_$(srcname)_TOOL)\
1830 $($(source)_UNPACKTOOL)\
1831 $($(srcname)_UNPACKTOOL)\
1832 $($(source)_TOOL)\
1833 $($(srcname)_TOOL)\
1834 $($(target)_UNPACKTOOL)\
1835 $($(target)_TOOL) \
1837 ifeq ($(tool),)
1838 local tool := $(toupper $(subst .,,$(suffix $(subst tar.,TAR,$(srcname)))))
1839 $(evalval def_tools_include)
1840 endif
1841 local flags :=\
1842 $(TOOL_$(tool)_UNPACKFLAGS)\
1843 $(UNPACKFLAGS)\
1844 $($(target)_UNPACKFLAGS)\
1845 $($(srcname)_UNPACKFLAGS)\
1846 $($(source)_UNPACKFLAGS)\
1847 $($(target)_$(srcname)_UNPACKFLAGS)\
1848 $($(target)_$(source)_UNPACKFLAGS)
1850 #$ (warning dbg: target=$(target) source=$(source) $(srcname)=$(srcname) tool=$(tool) out=$(out) flags=$(flags) dirdep=$(dirdep) inst=$(inst) md5=$(md5) size=$(size))
1851 ifndef TOOL_$(tool)_UNPACK_CMDS
1852 $(warning kBuild: tools: \
1853 1 $($(target)_$(source)_UNPACKTOOL)\
1854 2 $($(target)_$(srcname)_UNPACKTOOL)\
1855 3 $($(target)_$(source)_TOOL)\
1856 4 $($(target)_$(srcname)_TOOL)\
1857 5 $($(source)_UNPACKTOOL)\
1858 6 $($(srcname)_UNPACKTOOL)\
1859 7 $($(source)_TOOL)\
1860 8 $($(srcname)_TOOL)\
1861 9 $($(target)_UNPACKTOOL)\
1862 10 $($(target)_TOOL) \
1863 11 $(toupper $(subst tar.,TAR,$(ext $(srcname)))) \
1865 $(error kBuild: TOOL_$(tool)_UNPACK_CMDS is not defined. source=$(source) target=$(target) )
1866 endif
1868 # call the tool
1869 $(target)_$(srcname)_UNPACK_CMDS_ := $(TOOL_$(tool)_UNPACK_CMDS)
1870 $(target)_$(srcname)_UNPACK_OUTPUT_ := $(TOOL_$(tool)_UNPACK_OUTPUT)
1871 $(target)_$(srcname)_UNPACK_OUTPUT_MAYBE_ := $(TOOL_$(tool)_UNPACK_OUTPUT_MAYBE)
1872 $(target)_$(srcname)_UNPACK_DEPEND_ := $(TOOL_$(tool)_UNPACK_DEPEND) $(deps)
1873 $(target)_$(srcname)_UNPACK_DEPORD_ := $(TOOL_$(tool)_UNPACK_DEPORD) $(dirdep) $(orderdeps)
1875 # generate the fetch rule.
1876 $(eval $(def_fetch_src_unpack_rule))
1878 _DIRS += $(inst) $(fetchdir)
1880 endef # def_fetch_src
1881 $(eval-opt-var def_fetch_src)
1885 # Define the target level rules for a fetch.
1886 # @param target
1887 # @param out
1888 # @param inst
1889 # @param _TARGET_$(target)_UNPACKED
1890 # @param _TARGET_$(target)_DIGEST
1891 # @param bld_trg
1892 # @param bld_trg_arch
1893 define def_fetch_rules
1895 $(out).lst: $(_TARGET_$(target)_UNPACKED) | $(call DIRDEP,$(inst))
1896 %$$(call MSG_FETCH_OK,$(target))
1897 $$(QUIET)$$(RM) -f -- $$@ $$@.tmp
1898 $$(QUIET2)$$(APPEND) $$@.tmp '$(notdir $(out))'
1899 $$(QUIET)$(if $(_TARGET_$(target)_UNPACKED),$$(CAT_EXT) $(_TARGET_$(target)_UNPACKED) >> $$@.tmp)
1900 $$(QUIET)$$(MV) -f -- $$@.tmp $$@
1902 $(out)_unfetched:
1903 %$$(call MSG_UNFETCH,$(target))
1904 $$(QUIET)$$(RM) -f -- $$(addprefix $(inst),$$(shell $$(CAT_EXT) $(out).lst 2> /dev/null | $$(SED) -e '/\/$$$$/d'))
1905 $$(QUIET)$$(RMDIR) -p --ignore-fail-on-non-empty --ignore-fail-on-not-exist -- $$(dir $$@) \
1906 $$(addprefix $(inst),$$(sort $$(dir $$(shell $$(CAT_EXT) $(out).lst 2> /dev/null))))
1907 $$(QUIET)$$(RM) -f -- $(out).lst $(out)
1908 $$(QUIET)$$(RMDIR) -p --ignore-fail-on-non-empty --ignore-fail-on-not-exist -- $$(dir $$@)
1910 $(out): $(comp-vars _TARGET_$(target)_DIGEST_PREV,_TARGET_$(target)_DIGEST,FORCE) | $(call DIRDEP,$(inst))
1911 $$(QUIET)$$(RM) -f -- $$@
1912 %$$(if $$(_TARGET_$(target)_DIGEST),$$(if $$(eq $$(file-size $(out).lst),-1)\
1913 ,$$(call MSG_REFETCH,$(target)),$$(call MSG_FETCH,$(target))),$$(call MSG_UNFETCH,$(target)))
1914 $$(QUIET)$(TEST_EXT) -f $(out).lst -- $$(MAKE) -f $(MAKEFILE) --no-print-directory $(out)_unfetched
1915 $$(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 $$@))
1916 $$(QUIET2)$$(if $$(_TARGET_$(target)_DIGEST),$$(APPEND) $$@ "_TARGET_$(target)_DIGEST_PREV := $(_TARGET_$(target)_DIGEST)")
1918 .NOTPARALLEL: $(out).lst $(out)_unfetched $(out)
1920 endef
1924 # Deal with one fetch target.
1925 # @param target
1926 # @param bld_trg
1927 # @param bld_trg_arch
1928 define def_fetch
1929 # common
1930 INSTARGET_$(target) := $($(target)_INST)
1931 ifneq ($(patsubst %/,ok,$(INSTARGET_$(target))),ok)
1932 $(error kBuild: Bad or missing INST property for target '$(target)'. \
1933 $(target)_INST='$($(target)_INST)' ($(origin $(target)_INST)))
1934 endif
1935 _TARGET_$(target)_FETCHED :=
1936 _TARGET_$(target)_UNPACKED :=
1937 _TARGET_$(target)_DIGEST :=
1938 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))
1940 # The 'sources'.
1941 #$ (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)))
1942 $(foreach source,$($(target)_SOURCES) $($(target)_SOURCES.$(KBUILD_TYPE)) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)),\
1943 $(evalval def_fetch_src))
1945 # The target.
1946 local inst := $(INSTARGET_$(target))
1947 local out := $(inst)_kBuild_fetch_$(target)
1949 $(eval includedep $(out))
1951 $(eval $(def_fetch_rules))
1953 # Define the aliases here (doesn't work if defined in def_fetch_rules, just like includedep).
1954 $(target): $(out)
1955 $(target)_unfetch: $(out)_unfetched
1957 _FETCHES += $(out)
1958 _DOWNLOADS += $(_TARGET_$(target)_FETCHED)
1959 _UNPACKS += $(_TARGET_$(target)_UNPACKED)
1960 _UNFETCHES += $(out)_unfetched
1961 _DIRS += $(inst)
1962 _CLEAN_FILES += $(clean_files)
1964 endef
1965 $(eval-opt-var def_fetch)
1967 # Walk the FETCH target lists.
1968 bld_trg := $(KBUILD_TARGET)
1969 bld_trg_arch := $(KBUILD_TARGET_ARCH)
1970 $(foreach target, $(_ALL_FETCHES), \
1971 $(evalvalctx def_fetch))
1973 # some aliases.
1974 download: $(_DOWNLOADS)
1975 unpack: $(_UNPACKS)
1976 fetch: $(_FETCHES)
1977 unfetch: $(_UNFETCHES)
1979 ifdef KBUILD_PROFILE_SELF
1980 $(evalcall def_profile_self, done fetching targets)
1981 endif
1986 ## Patching.
1989 #define def_patch_src
1991 #endef
1994 ## Deal with one patch target.
1995 #define def_patch
1997 #$(foreach source,$($(target)_SOURCES) $($(target)_SOURCES.$(KBUILD_TYPE)) $($(target)_SOURCES.$(KBUILD_TARGET)) $($(target)_SOURCES.$(KBUILD_TARGET_ARCH)) $($(target)_SOURCES.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)),\
1998 # $(evalval def_patch_src))
2000 #_PATCHES +=
2001 #endef
2003 #$(foreach target, $(_ALL_PATCHES), \
2004 # $(evalval def_patch))
2009 # Object processing.
2012 ## wrapper the compile command dependency check.
2013 ifndef NO_COMPILE_CMDS_DEPS
2014 if1of ($(KMK_FEATURES),dot-must-make)
2015 _DEP_COMPILE_CMDS =
2016 # for debugging: $$(warning MUST_MAKE=$$$$(comp-cmds-ex $$$$($(target)_$(subst :,_,$(source))_CMDS_PREV_), $$$$(commands $$@)) -> $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_CMDS_PREV_),$$(commands $$@),FORCE))
2017 else
2018 _DEP_COMPILE_CMDS = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_CMDS_PREV_),$$(commands $(obj)),FORCE)
2019 endif
2020 else
2021 _DEP_COMPILE_CMDS =
2022 endif
2025 ## Generates the rules for building a specific object, and the aliases
2026 # for building a source file.
2027 # @param $(obj) The object file.
2028 define def_target_source_rule
2029 ifndef NO_COMPILE_CMDS_DEPS
2030 $(obj): .MUST_MAKE = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_CMDS_PREV_),$$(commands $$@),FORCE)
2031 endif
2032 ifdef TOOL_$(tool)_COMPILE_$(type)_USES_KOBJCACHE
2033 _OUT_FILES += $(outbase).koc
2034 $(outbase).koc +| $(obj) $($(target)_$(source)_OUTPUT_) $($(target)_$(source)_OUTPUT_MAYBE_) : \
2035 $($(target)_$(source)_DEPEND_) \
2036 $(value _DEP_COMPILE_CMDS) \
2038 $($(target)_$(source)_DEPORD_) \
2039 $$$$($(target)_INTERMEDIATES)
2040 %$$(call MSG_COMPILE,$(target),$(source),$$@,$(type))
2041 else
2042 $(obj) + $($(target)_$(source)_OUTPUT_) +| $($(target)_$(source)_OUTPUT_MAYBE_) : \
2043 $($(target)_$(source)_DEPEND_) \
2044 $(value _DEP_COMPILE_CMDS) \
2046 $($(target)_$(source)_DEPORD_) \
2047 $$$$($(target)_INTERMEDIATES)
2048 %$$(call MSG_COMPILE,$(target),$(source),$$@,$(type))
2049 ifdef TOOL_$(tool)_COMPILE_$(type)_DONT_PURGE_OUTPUT
2050 $$(QUIET)$$(RM) -f -- $(dep) $(obj) $($(target)_$(source)_OUTPUT_) $($(target)_OUTPUT_MAYBE_)
2051 endif
2052 endif
2054 $($(target)_$(source)_CMDS_)
2056 ifndef NO_COMPILE_CMDS_DEPS
2057 %$$(QUIET2)$$(APPEND) '$(dep)'
2058 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_CMDS_PREV_'
2059 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(obj)'
2060 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
2061 endif
2063 $(basename $(notdir $(obj))).o: $(obj)
2064 $(basename $(notdir $(obj))).obj: $(obj)
2066 ## @todo make this 'local cmds' in 0.2.x or when a new kb-src-one is added.
2067 $(target)_$(source)_CMDS_ :=
2068 endef # def_target_source_rule
2069 $(eval-opt-var def_target_source_rule)
2072 ## wrapper the link command dependency check.
2073 ifndef NO_LINK_CMDS_DEPS
2074 if1of ($(KMK_FEATURES),dot-must-make)
2075 _DEP_LINK_CMDS =
2076 else
2077 _DEP_LINK_CMDS = $$(comp-cmds-ex $$($(target)_CMDS_PREV_),$$(commands $(out)),FORCE)
2078 endif
2079 else
2080 _DEP_LINK_CMDS =
2081 endif
2083 ## Generate the link rule for a target.
2084 # @param $(target) The normalized target name.
2085 # @param $(dirdep) Directories we depend upon begin created before linking.
2086 # @param $(dep) The name of the dependency file.
2087 # @param $(out)
2088 # @param $($(target)_OUTPUT_) Output files from the link.
2089 # @param $($(target)_OUTPUT_MAYBE_) Output files that the link may perhaps create.
2090 # @param $($(target)_DEPEND_) Dependencies.
2091 # @param $($(target)_DEPORD_) Dependencies which should only affect build order.
2092 # @param $(cmds) The link commands.
2093 # @param $($(target)_CMDS_PREV_) The link commands from the previous run.
2094 define def_link_rule
2095 ifndef NO_LINK_CMDS_DEPS
2096 $(out): .MUST_MAKE = $$(comp-cmds-ex $$($(target)_CMDS_PREV_),$$(commands $$@),FORCE)
2097 endif
2098 $(out) + $($(target)_OUTPUT_) +| $($(target)_OUTPUT_MAYBE_) : \
2099 $$$$($(target)_DEPEND_) \
2100 $(value _DEP_LINK_CMDS) \
2102 $$$$($(target)_DEPORD_)
2103 %$$(call MSG_LINK,$(target),$$@,$(tool_do))
2104 $$(QUIET)$$(RM) -f -- $(dep) $(out) $($(target)_OUTPUT_) $($(target)_OUTPUT_MAYBE_)
2106 $(cmds)
2108 ifndef NO_LINK_CMDS_DEPS
2109 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_CMDS_PREV_'
2110 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
2111 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
2112 endif
2114 $(basename $(notdir $(out))):: $(out)
2116 endef # def_link_rule
2117 $(eval-opt-var def_link_rule)
2120 ## Generate the link & lib install rule
2121 # @param $(target) Normalized target name.
2122 # @param $(out) The build target.
2123 # @param $(INSTARGET_$(target)) The installation targets.
2124 # @param $(mode) The file mode (optional)
2125 define def_link_install_rule
2126 $(INSTARGET_$(target)) : $(out) | $(call DIRDEP,$(dir $(INSTARGET_$(target))))
2127 %$$(call MSG_INST_TRG,$(target),$(out),$$@)
2128 $$(QUIET)$$(INSTALL) $$(if $(mode),-m $(mode)) -- $(out) $$@
2130 ifdef KBUILD_DO_AUTO_INSTALL
2131 $(basename $(notdir $(out))):: $(INSTARGET_$(target))
2132 endif
2133 endef # def_link_install_rule
2136 ## def_src_handler_*
2138 # @{
2139 define def_src_handler_c
2140 local type := C
2141 $(kb-src-one 2)
2142 endef
2144 define def_src_handler_cxx
2145 local type := CXX
2146 $(kb-src-one 2)
2147 endef
2149 define def_src_handler_objc
2150 local type := OBJC
2151 $(kb-src-one 2)
2152 endef
2154 define def_src_handler_asm
2155 local type := AS
2156 $(kb-src-one 2)
2157 endef
2159 define def_src_handler_rc
2160 local type := RC
2161 $(kb-src-one 2)
2162 endef
2164 if $(KBUILD_VERSION_PATCH) != 4
2165 define def_src_handler_obj
2166 ifeq ($(defpath),)
2167 $(target)_2_OBJS += $(source)
2168 else
2169 $(target)_2_OBJS += $(abspathex $(source), $(defpath))
2170 endif
2171 endef
2172 else # legacy - remove
2173 define def_src_handler_obj
2174 ifeq ($(defpath),)
2175 $(target)_OBJS_ += $(source)
2176 else
2177 $(target)_OBJS_ += $(abspathex $(source), $(defpath))
2178 endif
2179 endef
2180 endif # legacy - remove
2181 ## @}
2183 ## Handle one source.
2185 define def_src_handler_one
2186 local suff := $(suffix $(source))
2187 local src_handler := $(firstword $(filter $(suff):%, $($(target)_$(source)_SRC_HANDLERS) $($(source)_SRC_HANDLERS) $(target_src_handlers) ))
2188 local handler := $(patsubst $(suff):%,%,$(src_handler))
2189 ifneq ($(handler),)
2190 $(evalvalctx $(handler))
2191 else
2192 othersrc += $(source)
2193 endif
2194 endef
2196 ## Generic macro for processing all target sources.
2197 # @param $(target) Normalized target name.
2198 # @param $(defpath)
2199 # @param much-more...
2200 # @returns othersrc, $(target)_OBJS_, ++
2201 define def_target_sources
2202 local target_src_handlers := $($(target)_SRC_HANDLERS) $(KBUILD_SRC_HANDLERS)
2203 $(foreach source,\
2204 $($(target)_SOURCES)\
2205 $($(target)_SOURCES.$(bld_trg))\
2206 $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch))\
2207 $($(target)_SOURCES.$(bld_trg_arch))\
2208 $($(target)_SOURCES.$(bld_trg_cpu))\
2209 $($(target)_SOURCES.$(bld_type))\
2210 ,$(evalval def_src_handler_one) )
2212 $(foreach source,\
2213 $($(target)_GEN_SOURCES_)\
2214 $($(target)_GEN_SOURCES_.$(bld_trg))\
2215 $($(target)_GEN_SOURCES_.$(bld_trg).$(bld_trg_arch))\
2216 $($(target)_GEN_SOURCES_.$(bld_trg_arch))\
2217 $($(target)_GEN_SOURCES_.$(bld_trg_cpu))\
2218 $($(target)_GEN_SOURCES_.$(bld_type))\
2219 ,$(evalval def_src_handler_one) )
2220 endef # def_target_sources
2221 $(eval-opt-var def_target_sources)
2225 ## Generic macro for generating the install rule(s) for a target
2226 # and update the globals with default out.
2228 # @param $(target) Normalized target name.
2229 # @param $(out) The output file.
2230 # @param $(definst) The default _INST value.
2231 # @param $(typevar) The name of the variable with all the root targets of its type.
2232 # @remark Only library uses this now.
2233 define def_target_install_pluss
2234 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))),)
2235 ifneq ($(strip $($(target)_INST.$(bld_trg).$(bld_trg_arch).$(bld_type))),)
2236 local inst := $(addprefix $(PATH_INS)/,$($(target)_INST.$(bld_trg).$(bld_trg_arch).$(bld_type)))
2237 else ifneq ($(strip $($(target)_INST.$(bld_trg).$(bld_trg_arch))),)
2238 local inst := $(addprefix $(PATH_INS)/,$($(target)_INST.$(bld_trg).$(bld_trg_arch)))
2239 else ifneq ($(strip $($(target)_INST.$(bld_trg).$(bld_type))),)
2240 local inst := $(addprefix $(PATH_INS)/,$($(target)_INST.$(bld_trg).$(bld_type)))
2241 else ifneq ($(strip $($(target)_INST.$(bld_trg_arch))),)
2242 local inst := $(addprefix $(PATH_INS)/,$($(target)_INST.$(bld_trg_arch)))
2243 else ifneq ($(strip $($(target)_INST.$(bld_trg))),)
2244 local inst := $(addprefix $(PATH_INS)/,$($(target)_INST.$(bld_trg)))
2245 else ifneq ($(strip $($(target)_INST.$(bld_type))),)
2246 local inst := $(addprefix $(PATH_INS)/,$($(target)_INST.$(bld_type)))
2247 else ifneq ($(strip $($(target)_INST)),)
2248 local inst := $(addprefix $(PATH_INS)/,$($(target)_INST))
2249 else
2250 local inst := $(definst)/
2251 endif
2252 INSTARGET_$(target) := $(patsubst %/,%/$(notdir $(out)),$(inst))
2254 $(eval $(def_link_install_rule))
2256 _INSTALLS_FILES += $(INSTARGET_$(target))
2258 ifdef KBUILD_DO_AUTO_INSTALL
2259 $(typevar) += $(INSTARGET_$(target))
2260 else
2261 $(typevar) += $(out)
2262 endif
2263 else # _NOINST
2264 $(typevar) += $(out)
2265 endif
2267 _OUT_FILES += $($(target)_OUTPUT_) $($(target)_OUTPUT_MAYBE_) $(out)
2268 _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))
2269 _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))
2270 _OBJS += $($(target)_OBJS_)
2272 endef # def_target_install_pluss
2277 # LIBRARIES
2280 ## Library (one).
2281 # @param $(target) Normalized library (target) name.
2282 define def_lib
2283 # library basics
2284 ## @todo prefix
2285 local bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE))
2286 local bld_trg := $(firstword $($(target)_BLD_TRG) $(KBUILD_TARGET))
2287 local bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(KBUILD_TARGET_ARCH))
2288 local bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(KBUILD_TARGET_CPU))
2289 local tool := $(call _TARGET_TOOL,$(target),AR)
2290 ifeq ($(tool),)
2291 $(error kBuild: Library target $(target) does not have a tool defined!)
2292 endif
2293 local name := $(firstword\
2294 $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\
2295 $($(target)_NAME.$(bld_trg_arch))\
2296 $($(target)_NAME.$(bld_trg))\
2297 $($(target)_NAME.$(bld_type))\
2298 $($(target)_NAME)\
2299 $(target))
2300 local outbase := $(call TARGET_BASE,$(name),$(target))
2301 ifndef PATH_$(target)
2302 PATH_$(target) := $(patsubst %/,%,$(dir $(outbase)))
2303 else ifneq ($(PATH_$(target)),$(patsubst %/,%,$(dir $(outbase))))
2304 $(error kBuild internal error: PATH_$(target)=$(PATH_$(target)) expected $(patsubst %/,%,$(dir $(outbase))))
2305 endif
2306 local suff := $(firstword\
2307 $($(target)_LIBSUFF.$(bld_trg).$(bld_trg_arch))\
2308 $($(target)_LIBSUFF.$(bld_trg))\
2309 $($(target)_LIBSUFF)\
2310 $(TOOL_$(tool)_ARLIBSUFF.$(bld_trg).$(bld_trg_arch))\
2311 $(TOOL_$(tool)_ARLIBSUFF.$(bld_trg))\
2312 $(TOOL_$(tool)_ARLIBSUFF)\
2313 $(SUFF_LIB))
2314 local out := $(outbase)$(suff)
2315 local defpath := $(firstword $($(target)_PATH) $($(target)_DEFPATH))
2316 TARGET_$(target) := $(out)
2317 # no local here - must be writable across some foreachs.
2318 othersrc :=
2319 $(target)_OBJS_ :=
2321 # Do units pre source callouts.
2322 local units := \
2323 $($(target)_USES.$(bld_trg).$(bld_trg_arch))\
2324 $($(target)_USES.$(bld_trg_arch))\
2325 $($(target)_USES.$(bld_trg))\
2326 $($(target)_USES.$(bld_type))\
2327 $($(target)_USES)
2328 $(foreach unit,$(units),$(evalval def_unit_$(unit)_target_pre))
2330 # source -> object
2331 $(evalval def_target_sources)
2333 # library linking
2334 local tool := $(call _TARGET_TOOL,$(target),AR)
2335 local name := $(firstword\
2336 $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\
2337 $($(target)_NAME.$(bld_trg_arch))\
2338 $($(target)_NAME.$(bld_trg))\
2339 $($(target)_NAME.$(bld_type))\
2340 $($(target)_NAME)\
2341 $(target))
2342 local outbase := $(call TARGET_BASE,$(name),$(target))
2343 local flags :=\
2344 $(TOOL_$(tool)_ARFLAGS)\
2345 $(TOOL_$(tool)_ARFLAGS.$(bld_type))\
2346 $(ARFLAGS)\
2347 $(ARFLAGS.$(bld_type))\
2348 $($(target)_ARFLAGS)\
2349 $($(target)_ARFLAGS.$(bld_type)) \
2350 $($(target)_ARFLAGS.$(bld_trg)) \
2351 $($(target)_ARFLAGS.$(bld_trg_arch)) \
2352 $($(target)_ARFLAGS.$(bld_trg).$(bld_trg_arch)) \
2353 $($(target)_ARFLAGS.$(bld_trg_cpu))
2354 local dirdep := $(call DIRDEP,$(dir $(out)))
2355 local deps := \
2356 $($(target)_DEPS.$(bld_trg_cpu)) \
2357 $($(target)_DEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
2358 $($(target)_DEPS.$(bld_trg).$(bld_trg_arch)) \
2359 $($(target)_DEPS.$(bld_trg).$(bld_type)) \
2360 $($(target)_DEPS.$(bld_trg_arch)) \
2361 $($(target)_DEPS.$(bld_trg)) \
2362 $($(target)_DEPS.$(bld_type)) \
2363 $($(target)_DEPS) \
2364 $($(target)_LNK_DEPS.$(bld_trg_cpu)) \
2365 $($(target)_LNK_DEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
2366 $($(target)_LNK_DEPS.$(bld_trg).$(bld_trg_arch)) \
2367 $($(target)_LNK_DEPS.$(bld_trg).$(bld_type)) \
2368 $($(target)_LNK_DEPS.$(bld_trg_arch)) \
2369 $($(target)_LNK_DEPS.$(bld_trg)) \
2370 $($(target)_LNK_DEPS.$(bld_type)) \
2371 $($(target)_LNK_DEPS)
2372 local orderdeps := \
2373 $($(target)_ORDERDEPS.$(bld_trg_cpu)) \
2374 $($(target)_ORDERDEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
2375 $($(target)_ORDERDEPS.$(bld_trg).$(bld_trg_arch)) \
2376 $($(target)_ORDERDEPS.$(bld_trg).$(bld_type)) \
2377 $($(target)_ORDERDEPS.$(bld_trg_arch)) \
2378 $($(target)_ORDERDEPS.$(bld_trg)) \
2379 $($(target)_ORDERDEPS.$(bld_type)) \
2380 $($(target)_ORDERDEPS) \
2381 $($(target)_LNK_ORDERDEPS.$(bld_trg_cpu)) \
2382 $($(target)_LNK_ORDERDEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
2383 $($(target)_LNK_ORDERDEPS.$(bld_trg).$(bld_trg_arch)) \
2384 $($(target)_LNK_ORDERDEPS.$(bld_trg).$(bld_type)) \
2385 $($(target)_LNK_ORDERDEPS.$(bld_trg_arch)) \
2386 $($(target)_LNK_ORDERDEPS.$(bld_trg)) \
2387 $($(target)_LNK_ORDERDEPS.$(bld_type)) \
2388 $($(target)_LNK_ORDERDEPS)
2390 # Adjust paths if we got a default path.
2391 ifneq ($(defpath),)
2392 $(target)_OBJS_ := $(abspathex $($(target)_OBJS_),$(defpath))
2393 local deps := $(abspathex $(deps),$(defpath))
2394 local orderdeps := $(abspathex $(orderdeps),$(defpath))
2395 othersrc := $(abspathex $(othersrc),$(defpath))
2396 endif
2399 # Custom pre-link actions.
2400 ## @todo bld_trg_cpu is missing here.
2401 ifdef $(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)
2402 local pre_cmds := $($(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type))
2403 else ifdef $(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch)
2404 local pre_cmds := $($(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch))
2405 else ifdef $(target)_PRE_CMDS.$(bld_trg).$(bld_type)
2406 local pre_cmds := $($(target)_PRE_CMDS.$(bld_trg).$(bld_type))
2407 else ifdef $(target)_PRE_CMDS.$(bld_trg_arch)
2408 local pre_cmds := $($(target)_PRE_CMDS.$(bld_trg_arch))
2409 else ifdef $(target)_PRE_CMDS.$(bld_trg)
2410 local pre_cmds := $($(target)_PRE_CMDS.$(bld_trg))
2411 else ifdef $(target)_PRE_CMDS.$(bld_type)
2412 local pre_cmds := $($(target)_PRE_CMDS.$(bld_type))
2413 else ifdef $(target)_PRE_CMDS
2414 local pre_cmds := $($(target)_PRE_CMDS)
2415 else ifdef PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)
2416 local pre_cmds := $(PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type))
2417 else ifdef PRE_CMDS.$(bld_trg).$(bld_trg_arch)
2418 local pre_cmds := $(PRE_CMDS.$(bld_trg).$(bld_trg_arch))
2419 else ifdef PRE_CMDS.$(bld_trg).$(bld_type)
2420 local pre_cmds := $(PRE_CMDS.$(bld_trg).$(bld_type))
2421 else ifdef PRE_CMDS.$(bld_trg_arch)
2422 local pre_cmds := $(PRE_CMDS.$(bld_trg_arch))
2423 else ifdef PRE_CMDS.$(bld_trg)
2424 local pre_cmds := $(PRE_CMDS.$(bld_trg))
2425 else ifdef PRE_CMDS.$(bld_type)
2426 local pre_cmds := $(PRE_CMDS.$(bld_type))
2427 else
2428 local pre_cmds := $(PRE_CMDS)
2429 endif
2431 # Custom post-link actions.
2432 ifdef $(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)
2433 local post_cmds := $($(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type))
2434 else ifdef $(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch)
2435 local post_cmds := $($(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch))
2436 else ifdef $(target)_POST_CMDS.$(bld_trg).$(bld_type)
2437 local post_cmds := $($(target)_POST_CMDS.$(bld_trg).$(bld_type))
2438 else ifdef $(target)_POST_CMDS.$(bld_trg_arch)
2439 local post_cmds := $($(target)_POST_CMDS.$(bld_trg_arch))
2440 else ifdef $(target)_POST_CMDS.$(bld_trg)
2441 local post_cmds := $($(target)_POST_CMDS.$(bld_trg))
2442 else ifdef $(target)_POST_CMDS.$(bld_type)
2443 local post_cmds := $($(target)_POST_CMDS.$(bld_type))
2444 else ifdef $(target)_POST_CMDS
2445 local post_cmds := $($(target)_POST_CMDS)
2446 else ifdef POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)
2447 local post_cmds := $(POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type))
2448 else ifdef POST_CMDS.$(bld_trg).$(bld_trg_arch)
2449 local post_cmds := $(POST_CMDS.$(bld_trg).$(bld_trg_arch))
2450 else ifdef POST_CMDS.$(bld_trg).$(bld_type)
2451 local post_cmds := $(POST_CMDS.$(bld_trg).$(bld_type))
2452 else ifdef POST_CMDS.$(bld_trg_arch)
2453 local post_cmds := $(POST_CMDS.$(bld_trg_arch))
2454 else ifdef POST_CMDS.$(bld_trg)
2455 local post_cmds := $(POST_CMDS.$(bld_trg))
2456 else ifdef POST_CMDS.$(bld_type)
2457 local post_cmds := $(POST_CMDS.$(bld_type))
2458 else
2459 local post_cmds := $(POST_CMDS)
2460 endif
2462 # eliminate this guy?
2463 local objs = $($(target)_OBJS_)
2465 # dependency file
2466 local dep := $(out)$(SUFF_DEP)
2467 ifndef NO_LINK_CMDS_DEPS
2468 _DEPFILES_INCLUDED += $(dep)
2469 ifdef KB_HAVE_INCLUDEDEP_QUEUE
2470 includedep-queue $(dep)
2471 else
2472 includedep $(dep)
2473 endif
2474 endif
2476 # check that the tool is defined.
2477 ifndef TOOL_$(tool)_LINK_LIBRARY_CMDS
2478 $(warning kBuild: tools: \
2479 1 $($(target)_$(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
2480 2 $($(target)_$(source)TOOL.$(bld_trg)) \
2481 3 $($(target)_$(source)TOOL) \
2482 4 $($(target)_TOOL.$(bld_trg).$(bld_trg_arch)) \
2483 5 $($(target)_TOOL.$(bld_trg)) \
2484 6 $($(target)_TOOL) \
2485 7 $($(source)TOOL) \
2486 8 $($(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
2487 9 $($(source)TOOL.$(bld_trg)) \
2488 10 $(TOOL.$(bld_trg).$(bld_trg_arch)) \
2489 11 $(TOOL.$(bld_trg)) \
2490 12 $(TOOL) )
2491 $(error kBuild: TOOL_$(tool)_LINK_LIBRARY_CMDS isn't defined! target=$(target) )
2492 endif
2494 # call the tool
2495 local cmds := $(TOOL_$(tool)_LINK_LIBRARY_CMDS)
2496 ifneq ($(pre_cmds),)
2497 local cmds := $(TAB)$(pre_cmds)$(NL)$(TAB)$(cmds)
2498 endif
2499 ifneq ($(post_cmds),)
2500 local cmds := $(cmds)$(NL)$(TAB)$(post_cmds)
2501 endif
2502 $(target)_OUTPUT_ := $(TOOL_$(tool)_LINK_LIBRARY_OUTPUT)
2503 $(target)_OUTPUT_MAYBE_ := $(TOOL_$(tool)_LINK_LIBRARY_OUTPUT_MAYBE)
2504 $(target)_DEPEND_ := $(TOOL_$(tool)_LINK_LIBRARY_DEPEND) $(deps) $($(target)_OBJS_)
2505 $(target)_DEPORD_ := $(TOOL_$(tool)_LINK_LIBRARY_DEPORD) $(dirdep) $(orderdeps)
2507 # generate the link rule.
2508 $(eval $(def_link_rule))
2510 # installing and globals
2511 $(evalval def_target_install_pluss)
2512 endef
2513 $(eval-opt-var def_lib)
2515 # Process libraries
2516 definst := $(PATH_LIB)
2517 typevar := _LIBS
2518 tool_do := LINK_LIBRARY
2519 mode := 0644
2520 $(foreach target, $(_ALL_LIBRARIES), $(evalval def_lib))
2522 ifdef KBUILD_PROFILE_SELF
2523 $(evalcall def_profile_self, done library targets)
2524 endif
2528 # Link operations.
2532 # Link prolog
2534 # @param $(target) Normalized target name.
2535 # @param $(EXT) EXE,DLL,SYS.
2536 # @param $(definst) The default _INST value.
2537 # @param $(typevar) The name of the variable with all the root targets of its type.
2538 define def_link_common
2539 # basics
2540 local bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE))
2541 local bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_$(bld_trg_base_var)))
2542 local bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_$(bld_trg_base_var)_ARCH))
2543 local bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_$(bld_trg_base_var)_CPU))
2545 local tool := $(call _TARGET_TOOL,$(target),LD)
2546 local name := $(firstword\
2547 $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\
2548 $($(target)_NAME.$(bld_trg_arch))\
2549 $($(target)_NAME.$(bld_trg))\
2550 $($(target)_NAME.$(bld_type))\
2551 $($(target)_NAME)\
2552 $(target))
2553 local outbase := $(call TARGET_BASE,$(name),$(target))
2554 ifndef PATH_$(target)
2555 PATH_$(target) := $(patsubst %/,%,$(dir $(outbase)))
2556 else ifneq ($(PATH_$(target)),$(patsubst %/,%,$(dir $(outbase))))
2557 $(error kBuild internal error: PATH_$(target)=$(PATH_$(target)) expected $(patsubst %/,%,$(dir $(outbase))))
2558 endif
2559 local suff := $(firstword \
2560 $($(target)_$(EXT)SUFF.$(bld_trg).$(bld_trg_arch))\
2561 $($(target)_$(EXT)SUFF.$(bld_trg))\
2562 $($(target)_$(EXT)SUFF)\
2563 $(TOOL_$(tool)_LD$(EXT)SUFF.$(bld_trg).$(bld_trg_arch))\
2564 $(TOOL_$(tool)_LD$(EXT)SUFF.$(bld_trg))\
2565 $(TOOL_$(tool)_LD$(EXT)SUFF)\
2566 $($(EXTPRE)SUFF_$(EXT)) )
2567 local out := $(outbase)$(suff)
2568 TARGET_$(target) := $(out)
2569 local defpath := $(firstword $($(target)_PATH) $($(target)_DEFPATH))
2570 # no local here - must be writable across some foreachs.
2571 othersrc :=
2572 $(target)_OBJS_ :=
2574 # Do units pre source callouts.
2575 local units := \
2576 $($(target)_USES.$(bld_trg).$(bld_trg_arch))\
2577 $($(target)_USES.$(bld_trg_arch))\
2578 $($(target)_USES.$(bld_trg))\
2579 $($(target)_USES.$(bld_type))\
2580 $($(target)_USES)
2581 $(foreach unit,$(units),$(evalval def_unit_$(unit)_target_pre))
2583 # source -> object
2584 $(evalval def_target_sources)
2586 # more link stuff.
2587 local tool := $(call _TARGET_TOOL,$(target),LD)
2588 local name := $(firstword\
2589 $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\
2590 $($(target)_NAME.$(bld_trg_arch))\
2591 $($(target)_NAME.$(bld_trg))\
2592 $($(target)_NAME.$(bld_type))\
2593 $($(target)_NAME)\
2594 $(target))
2595 local outbase := $(call TARGET_BASE,$(name),$(target))
2596 local flags :=\
2597 $(TOOL_$(tool)_LDFLAGS)\
2598 $(TOOL_$(tool)_LDFLAGS.$(bld_type))\
2599 $(TOOL_$(tool)_LDFLAGS.$(bld_trg))\
2600 $(TOOL_$(tool)_LDFLAGS.$(bld_trg_arch))\
2601 $(TOOL_$(tool)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\
2602 $(TOOL_$(tool)_LDFLAGS.$(bld_trg_cpu))\
2603 $(foreach sdk, $(SDKS) \
2604 $(SDKS.$(bld_type)) \
2605 $(SDKS.$(bld_trg)) \
2606 $(SDKS.$(bld_trg_arch)) \
2607 $(SDKS.$(bld_trg).$(bld_trg_arch)),\
2608 $(SDK_$(sdk)_LDFLAGS)\
2609 $(SDK_$(sdk)_LDFLAGS.$(bld_type))\
2610 $(SDK_$(sdk)_LDFLAGS.$(bld_trg))\
2611 $(SDK_$(sdk)_LDFLAGS.$(bld_trg_arch))\
2612 $(SDK_$(sdk)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\
2613 $(SDK_$(sdk)_LDFLAGS.$(bld_trg_cpu)))\
2614 $(LDFLAGS)\
2615 $(LDFLAGS.$(bld_type))\
2616 $(LDFLAGS.$(bld_trg))\
2617 $(LDFLAGS.$(bld_trg_arch))\
2618 $(LDFLAGS.$(bld_trg).$(bld_trg_arch))\
2619 $(LDFLAGS.$(bld_trg_cpu))\
2620 $(foreach sdk, $($(target)_SDKS) \
2621 $($(target)_SDKS.$(bld_type)) \
2622 $($(target)_SDKS.$(bld_trg)) \
2623 $($(target)_SDKS.$(bld_trg_arch)) \
2624 $($(target)_SDKS.$(bld_trg).$(bld_trg_arch)),\
2625 $(SDK_$(sdk)_LDFLAGS)\
2626 $(SDK_$(sdk)_LDFLAGS.$(bld_type))\
2627 $(SDK_$(sdk)_LDFLAGS.$(bld_trg))\
2628 $(SDK_$(sdk)_LDFLAGS.$(bld_trg_arch))\
2629 $(SDK_$(sdk)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\
2630 $(SDK_$(sdk)_LDFLAGS.$(bld_trg_cpu)))\
2631 $($(target)_LDFLAGS)\
2632 $($(target)_LDFLAGS.$(bld_type))\
2633 $($(target)_LDFLAGS.$(bld_trg))\
2634 $($(target)_LDFLAGS.$(bld_trg_arch))\
2635 $($(target)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\
2636 $($(target)_LDFLAGS.$(bld_trg_cpu))
2637 local libs :=\
2638 $($(target)_LIBS.$(bld_trg_cpu))\
2639 $($(target)_LIBS.$(bld_trg).$(bld_trg_arch))\
2640 $($(target)_LIBS.$(bld_trg_arch))\
2641 $($(target)_LIBS.$(bld_trg))\
2642 $($(target)_LIBS.$(bld_type))\
2643 $($(target)_LIBS)\
2644 $(foreach sdk, $($(target)_SDKS.$(bld_trg).$(bld_trg_arch)) \
2645 $($(target)_SDKS.$(bld_trg_arch)) \
2646 $($(target)_SDKS.$(bld_trg)) \
2647 $($(target)_SDKS.$(bld_type)) \
2648 $($(target)_SDKS),\
2649 $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
2650 $(SDK_$(sdk)_LIBS.$(bld_trg).$(bld_trg_arch))\
2651 $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
2652 $(SDK_$(sdk)_LIBS.$(bld_trg))\
2653 $(SDK_$(sdk)_LIBS.$(bld_type))\
2654 $(SDK_$(sdk)_LIBS))\
2655 $(LIBS.$(bld_trg_cpu))\
2656 $(LIBS.$(bld_trg).$(bld_trg_arch))\
2657 $(LIBS.$(bld_trg_arch))\
2658 $(LIBS.$(bld_trg))\
2659 $(LIBS.$(bld_type))\
2660 $(LIBS)\
2661 $(foreach sdk, $(SDKS.$(bld_trg).$(bld_trg_arch)) \
2662 $(SDKS.$(bld_trg_arch)) \
2663 $(SDKS.$(bld_trg)) \
2664 $(SDKS.$(bld_type)) \
2665 $(SDKS),\
2666 $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
2667 $(SDK_$(sdk)_LIBS.$(bld_trg).$(bld_trg_arch))\
2668 $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
2669 $(SDK_$(sdk)_LIBS.$(bld_trg))\
2670 $(SDK_$(sdk)_LIBS.$(bld_type))\
2671 $(SDK_$(sdk)_LIBS))\
2672 $(TOOL_$(tool)_LIBS.$(bld_trg_cpu))\
2673 $(TOOL_$(tool)_LIBS.$(bld_trg).$(bld_trg_arch))\
2674 $(TOOL_$(tool)_LIBS.$(bld_trg_arch))\
2675 $(TOOL_$(tool)_LIBS.$(bld_trg))\
2676 $(TOOL_$(tool)_LIBS.$(bld_type))\
2677 $(TOOL_$(tool)_LIBS)
2678 local libpath :=\
2679 $($(target)_LIBPATH.$(bld_trg_cpu))\
2680 $($(target)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
2681 $($(target)_LIBPATH.$(bld_trg_arch))\
2682 $($(target)_LIBPATH.$(bld_trg))\
2683 $($(target)_LIBPATH.$(bld_type))\
2684 $($(target)_LIBPATH)\
2685 $(foreach sdk, $($(target)_SDKS.$(bld_trg).$(bld_trg_arch)) \
2686 $($(target)_SDKS.$(bld_trg_arch)) \
2687 $($(target)_SDKS.$(bld_trg)) \
2688 $($(target)_SDKS.$(bld_type)) \
2689 $($(target)_SDKS),\
2690 $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
2691 $(SDK_$(sdk)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
2692 $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
2693 $(SDK_$(sdk)_LIBPATH.$(bld_trg))\
2694 $(SDK_$(sdk)_LIBPATH.$(bld_type))\
2695 $(SDK_$(sdk)_LIBPATH))\
2696 $(LIBPATH.$(bld_trg_cpu))\
2697 $(LIBPATH.$(bld_trg).$(bld_trg_arch))\
2698 $(LIBPATH.$(bld_trg_arch))\
2699 $(LIBPATH.$(bld_trg))\
2700 $(LIBPATH.$(bld_type))\
2701 $(LIBPATH)\
2702 $(foreach sdk, $(SDKS.$(bld_trg).$(bld_trg_arch)) \
2703 $(SDKS.$(bld_trg_arch)) \
2704 $(SDKS.$(bld_trg)) \
2705 $(SDKS.$(bld_type)) \
2706 $(SDKS),\
2707 $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
2708 $(SDK_$(sdk)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
2709 $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
2710 $(SDK_$(sdk)_LIBPATH.$(bld_trg))\
2711 $(SDK_$(sdk)_LIBPATH.$(bld_type))\
2712 $(SDK_$(sdk)_LIBPATH))\
2713 $(TOOL_$(tool)_LIBPATH.$(bld_trg_cpu))\
2714 $(TOOL_$(tool)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
2715 $(TOOL_$(tool)_LIBPATH.$(bld_trg_arch))\
2716 $(TOOL_$(tool)_LIBPATH.$(bld_trg))\
2717 $(TOOL_$(tool)_LIBPATH.$(bld_type))\
2718 $(TOOL_$(tool)_LIBPATH)
2719 local dirdep := $(call DIRDEP,$(dir $(out)))
2720 local deps := \
2721 $($(target)_DEPS.$(bld_trg_cpu)) \
2722 $($(target)_DEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
2723 $($(target)_DEPS.$(bld_trg).$(bld_trg_arch)) \
2724 $($(target)_DEPS.$(bld_trg).$(bld_type)) \
2725 $($(target)_DEPS.$(bld_trg_arch)) \
2726 $($(target)_DEPS.$(bld_trg)) \
2727 $($(target)_DEPS.$(bld_type)) \
2728 $($(target)_DEPS) \
2729 $($(target)_LNK_DEPS.$(bld_trg_cpu)) \
2730 $($(target)_LNK_DEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
2731 $($(target)_LNK_DEPS.$(bld_trg).$(bld_trg_arch)) \
2732 $($(target)_LNK_DEPS.$(bld_trg).$(bld_type)) \
2733 $($(target)_LNK_DEPS.$(bld_trg_arch)) \
2734 $($(target)_LNK_DEPS.$(bld_trg)) \
2735 $($(target)_LNK_DEPS.$(bld_type)) \
2736 $($(target)_LNK_DEPS)
2737 local orderdeps := \
2738 $($(target)_ORDERDEPS.$(bld_trg_cpu)) \
2739 $($(target)_ORDERDEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
2740 $($(target)_ORDERDEPS.$(bld_trg).$(bld_trg_arch)) \
2741 $($(target)_ORDERDEPS.$(bld_trg).$(bld_type)) \
2742 $($(target)_ORDERDEPS.$(bld_trg_arch)) \
2743 $($(target)_ORDERDEPS.$(bld_trg)) \
2744 $($(target)_ORDERDEPS.$(bld_type)) \
2745 $($(target)_ORDERDEPS) \
2746 $($(target)_LNK_ORDERDEPS.$(bld_trg_cpu)) \
2747 $($(target)_LNK_ORDERDEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
2748 $($(target)_LNK_ORDERDEPS.$(bld_trg).$(bld_trg_arch)) \
2749 $($(target)_LNK_ORDERDEPS.$(bld_trg).$(bld_type)) \
2750 $($(target)_LNK_ORDERDEPS.$(bld_trg_arch)) \
2751 $($(target)_LNK_ORDERDEPS.$(bld_trg)) \
2752 $($(target)_LNK_ORDERDEPS.$(bld_type)) \
2753 $($(target)_LNK_ORDERDEPS)
2755 # Adjust paths if we got a default path.
2756 ifneq ($(defpath),)
2757 local libpath := $(abspathex $(libpath),$(defpath))
2758 $(target)_OBJS_ := $(abspathex $($(target)_OBJS_),$(defpath))
2759 local deps := $(abspathex $(deps),$(defpath))
2760 local orderdeps := $(abspathex $(orderdeps),$(defpath))
2761 othersrc := $(abspathex $(othersrc),$(defpath))
2762 # libs are not subject to this because of the the -l<lib> stuff. Use $(<target>_DEFPATH)/lib if relative to current dir!
2763 endif
2765 # Custom pre-link actions.
2766 ifdef $(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)
2767 local pre_cmds := $($(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type))
2768 else ifdef $(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch)
2769 local pre_cmds := $($(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch))
2770 else ifdef $(target)_PRE_CMDS.$(bld_trg).$(bld_type)
2771 local pre_cmds := $($(target)_PRE_CMDS.$(bld_trg).$(bld_type))
2772 else ifdef $(target)_PRE_CMDS.$(bld_trg_arch)
2773 local pre_cmds := $($(target)_PRE_CMDS.$(bld_trg_arch))
2774 else ifdef $(target)_PRE_CMDS.$(bld_trg)
2775 local pre_cmds := $($(target)_PRE_CMDS.$(bld_trg))
2776 else ifdef $(target)_PRE_CMDS.$(bld_type)
2777 local pre_cmds := $($(target)_PRE_CMDS.$(bld_type))
2778 else ifdef $(target)_PRE_CMDS
2779 local pre_cmds := $($(target)_PRE_CMDS)
2780 else ifdef PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)
2781 local pre_cmds := $(PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type))
2782 else ifdef PRE_CMDS.$(bld_trg).$(bld_trg_arch)
2783 local pre_cmds := $(PRE_CMDS.$(bld_trg).$(bld_trg_arch))
2784 else ifdef PRE_CMDS.$(bld_trg).$(bld_type)
2785 local pre_cmds := $(PRE_CMDS.$(bld_trg).$(bld_type))
2786 else ifdef PRE_CMDS.$(bld_trg_arch)
2787 local pre_cmds := $(PRE_CMDS.$(bld_trg_arch))
2788 else ifdef PRE_CMDS.$(bld_trg)
2789 local pre_cmds := $(PRE_CMDS.$(bld_trg))
2790 else ifdef PRE_CMDS.$(bld_type)
2791 local pre_cmds := $(PRE_CMDS.$(bld_type))
2792 else
2793 local pre_cmds := $(PRE_CMDS)
2794 endif
2796 # Custom post-link actions.
2797 ifdef $(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)
2798 local post_cmds := $($(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type))
2799 else ifdef $(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch)
2800 local post_cmds := $($(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch))
2801 else ifdef $(target)_POST_CMDS.$(bld_trg).$(bld_type)
2802 local post_cmds := $($(target)_POST_CMDS.$(bld_trg).$(bld_type))
2803 else ifdef $(target)_POST_CMDS.$(bld_trg_arch)
2804 local post_cmds := $($(target)_POST_CMDS.$(bld_trg_arch))
2805 else ifdef $(target)_POST_CMDS.$(bld_trg)
2806 local post_cmds := $($(target)_POST_CMDS.$(bld_trg))
2807 else ifdef $(target)_POST_CMDS.$(bld_type)
2808 local post_cmds := $($(target)_POST_CMDS.$(bld_type))
2809 else ifdef $(target)_POST_CMDS
2810 local post_cmds := $($(target)_POST_CMDS)
2811 else ifdef POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)
2812 local post_cmds := $(POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type))
2813 else ifdef POST_CMDS.$(bld_trg).$(bld_trg_arch)
2814 local post_cmds := $(POST_CMDS.$(bld_trg).$(bld_trg_arch))
2815 else ifdef POST_CMDS.$(bld_trg).$(bld_type)
2816 local post_cmds := $(POST_CMDS.$(bld_trg).$(bld_type))
2817 else ifdef POST_CMDS.$(bld_trg_arch)
2818 local post_cmds := $(POST_CMDS.$(bld_trg_arch))
2819 else ifdef POST_CMDS.$(bld_trg)
2820 local post_cmds := $(POST_CMDS.$(bld_trg))
2821 else ifdef POST_CMDS.$(bld_type)
2822 local post_cmds := $(POST_CMDS.$(bld_type))
2823 else
2824 local post_cmds := $(POST_CMDS)
2825 endif
2827 # eliminate this guy?
2828 local objs = $($(target)_OBJS_)
2830 # installation targets
2831 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))),)
2832 ifneq ($(strip $($(target)_INST.$(bld_trg).$(bld_trg_arch).$(bld_type))),)
2833 local inst := $(addprefix $(PATH_INS)/,$($(target)_INST.$(bld_trg).$(bld_trg_arch).$(bld_type)))
2834 else ifneq ($(strip $($(target)_INST.$(bld_trg).$(bld_trg_arch))),)
2835 local inst := $(addprefix $(PATH_INS)/,$($(target)_INST.$(bld_trg).$(bld_trg_arch)))
2836 else ifneq ($(strip $($(target)_INST.$(bld_trg).$(bld_type))),)
2837 local inst := $(addprefix $(PATH_INS)/,$($(target)_INST.$(bld_trg).$(bld_type)))
2838 else ifneq ($(strip $($(target)_INST.$(bld_trg_arch))),)
2839 local inst := $(addprefix $(PATH_INS)/,$($(target)_INST.$(bld_trg_arch)))
2840 else ifneq ($(strip $($(target)_INST.$(bld_trg))),)
2841 local inst := $(addprefix $(PATH_INS)/,$($(target)_INST.$(bld_trg)))
2842 else ifneq ($(strip $($(target)_INST.$(bld_type))),)
2843 local inst := $(addprefix $(PATH_INS)/,$($(target)_INST.$(bld_type)))
2844 else ifneq ($(strip $($(target)_INST)),)
2845 local inst := $(addprefix $(PATH_INS)/,$($(target)_INST))
2846 else
2847 local inst := $(definst)/
2848 endif
2849 INSTARGET_$(target) := $(patsubst %/,%/$(notdir $(out)),$(inst))
2850 ifdef KBUILD_DO_AUTO_INSTALL
2851 $(typevar) += $(INSTARGET_$(target))
2852 else
2853 $(typevar) += $(out)
2854 endif
2855 # generate the install rule
2856 $(eval $(def_link_install_rule))
2858 else # NOINST
2859 INSTARGET_$(target) :=
2860 $(typevar) += $(out)
2861 endif # NOINST
2863 # dependency file
2864 local dep := $(outbase)$(SUFF_DEP)
2865 ifndef NO_LINK_CMDS_DEPS
2866 _DEPFILES_INCLUDED += $(dep)
2867 ifdef KB_HAVE_INCLUDEDEP_QUEUE
2868 includedep-queue $(dep)
2869 else
2870 includedep $(dep)
2871 endif
2872 endif
2874 # check that the tool is defined.
2875 ifndef TOOL_$(tool)_$(tool_do)_CMDS
2876 $(warning kBuild: tools: \
2877 1 $($(target)_$(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
2878 2 $($(target)_$(source)TOOL.$(bld_trg)) \
2879 3 $($(target)_$(source)TOOL) \
2880 4 $($(target)_TOOL.$(bld_trg).$(bld_trg_arch)) \
2881 5 $($(target)_TOOL.$(bld_trg)) \
2882 6 $($(target)_TOOL) \
2883 7 $($(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
2884 8 $($(source)TOOL.$(bld_trg)) \
2885 9 $($(source)TOOL) \
2886 10 $(TOOL.$(bld_trg).$(bld_trg_arch)) \
2887 11 $(TOOL.$(bld_trg)) \
2888 12 $(TOOL) )
2889 $(error kBuild: TOOL_$(tool)_$(tool_do)_CMDS isn't defined! target=$(target) )
2890 endif
2892 # call the tool
2893 local cmds := $(TOOL_$(tool)_$(tool_do)_CMDS)
2894 ifneq ($(pre_cmds),)
2895 local cmds := $(TAB)$(pre_cmds)$(NL)$(TAB)$(cmds)
2896 endif
2897 ifneq ($(post_cmds),)
2898 local cmds := $(cmds)$(NL)$(TAB)$(post_cmds)
2899 endif
2900 $(target)_OUTPUT_ := $(TOOL_$(tool)_$(tool_do)_OUTPUT)
2901 $(target)_OUTPUT_MAYBE_ := $(TOOL_$(tool)_$(tool_do)_OUTPUT_MAYBE)
2902 $(target)_DEPEND_ := $(TOOL_$(tool)_$(tool_do)_DEPEND) $(deps) $($(target)_OBJS_)
2903 $(target)_DEPORD_ := $(TOOL_$(tool)_$(tool_do)_DEPORD) $(dirdep) $(orderdeps)
2905 # generate the link rule.
2906 $(eval $(def_link_rule))
2909 # Update globals.
2910 _OBJS += $($(target)_OBJS_)
2911 _OUT_FILES += $($(target)_OUTPUT_) $($(target)_OUTPUT_MAYBE_) $(out)
2912 _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))
2913 _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))
2914 _INSTALLS_FILES += $(INSTARGET_$(target))
2916 endef # def_link_common
2917 $(eval-opt-var def_link_common)
2921 # BLDPROGS
2924 ## Build program (one).
2925 # @param $(target) Normalized target (program) name.
2926 define def_bldprog
2928 # set NOINST if not forced installation.
2929 ifndef $(target)_INST
2930 $(target)_NOINST := 1
2931 endif
2933 # do the usual stuff.
2934 $(evalval def_link_common)
2936 endef
2938 # Process build programs.
2939 EXT := EXE
2940 EXTPRE := HOST
2941 tool_do := LINK_PROGRAM
2942 definst := $(PATH_BIN)
2943 typevar := _BLDPROGS
2944 mode := 0755
2945 bld_trg_base_var := PLATFORM
2946 $(foreach target, $(_ALL_BLDPROGS), $(evalval def_bldprog))
2948 ifdef KBUILD_PROFILE_SELF
2949 $(evalcall def_profile_self, done build program targets)
2950 endif
2954 # DLLS
2957 # Process dlls
2958 EXT := DLL
2959 EXTPRE :=
2960 tool_do := LINK_DLL
2961 definst := $(PATH_DLL)
2962 typevar := _DLLS
2963 mode := 0644
2964 bld_trg_base_var := TARGET
2965 $(foreach target, $(_ALL_DLLS), $(evalval def_link_common))
2967 ifdef KBUILD_PROFILE_SELF
2968 $(evalcall def_profile_self, done dll targets)
2969 endif
2973 # IMPORT LIBRARIES
2975 # - On OS/2 and windows these are libraries.
2976 # - On other platforms they are fake DLLs.
2978 EXTPRE :=
2979 typevar := _IMPORT_LIBS
2980 mode := 0644
2981 bld_trg_base_var := TARGET
2982 ifeq ($(filter-out nt os2 win win64 win32,$(KBUILD_TARGET)),)
2983 EXT := LIB
2984 tool_do := LINK_LIBRARY
2985 definst := $(PATH_LIB)
2986 $(foreach target, $(_ALL_IMPORT_LIBS), $(evalval def_lib))
2987 else
2988 EXT := DLL
2989 tool_do := LINK_DLL
2990 definst := $(PATH_DLL)
2991 $(foreach target, $(_ALL_IMPORT_LIBS), $(evalval def_link_common))
2992 endif
2994 ifdef KBUILD_PROFILE_SELF
2995 $(evalcall def_profile_self, done import library targets)
2996 endif
3000 # PROGRAMS
3003 # Process programs
3004 EXT := EXE
3005 EXTPRE :=
3006 tool_do := LINK_PROGRAM
3007 definst := $(PATH_BIN)
3008 typevar := _PROGRAMS
3009 mode := 0755
3010 bld_trg_base_var := TARGET
3011 $(foreach target, $(_ALL_PROGRAMS), $(evalval def_link_common))
3013 ifdef KBUILD_PROFILE_SELF
3014 $(evalcall def_profile_self, done program targets)
3015 endif
3019 # SYSMODS
3022 # Process sysmods
3023 EXT := SYS
3024 EXTPRE :=
3025 tool_do := LINK_SYSMOD
3026 definst := $(PATH_SYS)
3027 typevar := _SYSMODS
3028 mode := 0644
3029 bld_trg_base_var := TARGET
3030 $(foreach target, $(_ALL_SYSMODS), $(evalval def_link_common))
3032 ifdef KBUILD_PROFILE_SELF
3033 $(evalcall def_profile_self, done sysmod targets)
3034 endif
3038 # MISCBINS
3041 # Process MISCBINS
3042 EXT := BIN
3043 EXTPRE :=
3044 tool_do := LINK_MISCBIN
3045 definst := $(PATH_BIN)
3046 typevar := _MISCBINS
3047 mode := 0644
3048 bld_trg_base_var := TARGET
3049 $(foreach target, $(_ALL_MISCBINS), $(evalval def_link_common))
3051 ifdef KBUILD_PROFILE_SELF
3052 $(evalcall def_profile_self, done misc binary targets)
3053 endif
3057 # OTHERS
3059 _OTHERS = $(OTHERS) $(OTHERS.$(KBUILD_TARGET)) $(OTHERS.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH))
3063 # INSTALLS
3066 ## generate the install rule
3067 define def_install_src_rule
3068 # the install rule
3069 $(insdst) : $(srcsrc) | $(call DIRDEP,$(dir $(insdst)))
3070 %$$(call MSG_INST_FILE,$(srcsrc),$(insdst))
3071 $$(QUIET)$(inscmd)
3072 endef
3073 $(eval-opt-var def_install_src_rule)
3075 ## install one file
3076 define def_install_src
3078 # deal with '=>' in the source file name.
3079 ifeq ($(src),=>)
3080 $(error kBuild: Install target '$(target)' has a bad source specifier containing '=>' without any file names)
3081 endif
3082 ifeq ($(substr $(src),1,2),=>)
3083 $(warning kBuild: Install target '$(target)' has a bad source specifier: $(src))
3084 endif
3085 ifeq ($(substr $(src),-2),=>)
3086 $(warning kBuild: Install target '$(target)' has a bad source specifier: $(src))
3087 endif
3088 local srcdst := $(subst =>, ,$(src))
3089 local srcsrc := $(firstword $(srcdst))
3090 local srcdstdir := $(dir $(word 2,$(srcdst)))
3091 local srcdst := $(word $(words $(srcdst)),$(srcdst))
3093 # _INSTFUN
3094 ifdef $(srcsrc)_INSTFUN
3095 local instfun := $(srcsrc)_INSTFUN
3096 else ifdef $(target)_INSTFUN
3097 local instfun := $(target)_INSTFUN
3098 else
3099 local instfun := _INSTALL_FILE
3100 endif
3102 # _INST
3103 ifdef $(srcsrc)_INST
3104 local inst := $(patsubst %/,%,$($(srcsrc)_INST))/$(dir $(srcdstdir))
3105 else ifdef $(target)_INST
3106 local inst := $(patsubst %/,%,$($(target)_INST))/$(dir $(srcdstdir))
3107 else
3108 local inst := $(dir $(srcdstdir))
3109 endif
3111 # calc target
3112 local insdst := $(call $(instfun),$(srcdst),$(target),$(inst),$(PATH_INS))
3113 #$(warning instfun=$(instfun) srcdst=$(srcdst) target=$(target) inst=$(inst) => insdst=$(insdst))
3115 # mode, uid and gid
3116 local mode := $(firstword \
3117 $($(target)_$(srcsrc)_MODE.$(bld_trg).$(bld_trg_arch)) \
3118 $($(target)_$(srcsrc)_MODE.$(bld_trg)) \
3119 $($(target)_$(srcsrc)_MODE) \
3120 $($(target)_$(srcdst)_MODE.$(bld_trg).$(bld_trg_arch)) \
3121 $($(target)_$(srcdst)_MODE.$(bld_trg)) \
3122 $($(target)_$(srcdst)_MODE) \
3123 $($(srcsrc)_MODE.$(bld_trg).$(bld_trg_arch)) \
3124 $($(srcsrc)_MODE.$(bld_trg)) \
3125 $($(srcsrc)_MODE) \
3126 $($(srcdst)_MODE.$(bld_trg).$(bld_trg_arch)) \
3127 $($(srcdst)_MODE.$(bld_trg)) \
3128 $($(srcdst)_MODE) \
3129 $($(target)_MODE.$(bld_trg).$(bld_trg_arch)) \
3130 $($(target)_MODE.$(bld_trg)) \
3131 $($(target)_MODE))
3132 local uid := $(firstword \
3133 $($(target)_$(srcsrc)_UID.$(bld_trg).$(bld_trg_arch)) \
3134 $($(target)_$(srcsrc)_UID.$(bld_trg)) \
3135 $($(target)_$(srcsrc)_UID) \
3136 $($(target)_$(srcdst)_UID.$(bld_trg).$(bld_trg_arch)) \
3137 $($(target)_$(srcdst)_UID.$(bld_trg)) \
3138 $($(target)_$(srcdst)_UID) \
3139 $($(srcsrc)_UID.$(bld_trg).$(bld_trg_arch)) \
3140 $($(srcsrc)_UID.$(bld_trg)) \
3141 $($(srcsrc)_UID) \
3142 $($(srcdst)_UID.$(bld_trg).$(bld_trg_arch)) \
3143 $($(srcdst)_UID.$(bld_trg)) \
3144 $($(srcdst)_UID) \
3145 $($(target)_UID.$(bld_trg).$(bld_trg_arch)) \
3146 $($(target)_UID.$(bld_trg)) \
3147 $($(target)_UID))
3148 local gid := $(firstword \
3149 $($(target)_$(srcsrc)_GID.$(bld_trg).$(bld_trg_arch)) \
3150 $($(target)_$(srcsrc)_GID.$(bld_trg)) \
3151 $($(target)_$(srcsrc)_GID) \
3152 $($(target)_$(srcdst)_GID.$(bld_trg).$(bld_trg_arch)) \
3153 $($(target)_$(srcdst)_GID.$(bld_trg)) \
3154 $($(target)_$(srcdst)_GID) \
3155 $($(srcsrc)_GID.$(bld_trg).$(bld_trg_arch)) \
3156 $($(srcsrc)_GID.$(bld_trg)) \
3157 $($(srcsrc)_GID) \
3158 $($(srcdst)_GID.$(bld_trg).$(bld_trg_arch)) \
3159 $($(srcdst)_GID.$(bld_trg)) \
3160 $($(srcdst)_GID) \
3161 $($(target)_GID.$(bld_trg).$(bld_trg_arch)) \
3162 $($(target)_GID.$(bld_trg)) \
3163 $($(target)_GID))
3164 local flags := \
3165 $($(target)_IFFLAGS) \
3166 $($(target)_IFFLAGS.$(bld_trg)) \
3167 $($(target)_IFFLAGS.$(bld_trg).$(bld_trg_arch)) \
3168 $($(srcdst)_IFFLAGS) \
3169 $($(srcdst)_IFFLAGS.$(bld_trg)) \
3170 $($(srcdst)_IFFLAGS.$(bld_trg).$(bld_trg_arch)) \
3171 $($(srcsrc)_IFFLAGS) \
3172 $($(srcsrc)_IFFLAGS.$(bld_trg)) \
3173 $($(srcsrc)_IFFLAGS.$(bld_trg).$(bld_trg_arch)) \
3174 $($(target)_$(srcdst)_IFFLAGS) \
3175 $($(target)_$(srcdst)_IFFLAGS.$(bld_trg)) \
3176 $($(target)_$(srcdst)_IFFLAGS.$(bld_trg).$(bld_trg_arch)) \
3177 $($(target)_$(srcsrc)_IFFLAGS) \
3178 $($(target)_$(srcsrc)_IFFLAGS.$(bld_trg)) \
3179 $($(target)_$(srcsrc)_IFFLAGS.$(bld_trg).$(bld_trg_arch))
3180 clean_files += \
3181 $($(srcdst)_CLEAN) \
3182 $($(srcdst)_CLEAN.$(bld_trg)) \
3183 $($(srcdst)_CLEAN.$(bld_trg).$(bld_trg_arch)) \
3184 $($(srcsrc)_CLEAN) \
3185 $($(srcsrc)_CLEAN.$(bld_trg)) \
3186 $($(srcsrc)_CLEAN.$(bld_trg).$(bld_trg_arch)) \
3187 $($(target)_$(srcdst)_CLEAN) \
3188 $($(target)_$(srcdst)_CLEAN.$(bld_trg)) \
3189 $($(target)_$(srcdst)_CLEAN.$(bld_trg).$(bld_trg_arch)) \
3190 $($(target)_$(srcsrc)_CLEAN) \
3191 $($(target)_$(srcsrc)_CLEAN.$(bld_trg)) \
3192 $($(target)_$(srcsrc)_CLEAN.$(bld_trg).$(bld_trg_arch))
3195 # Adjust the source if we got a default PATH. (This must be done this late!)
3196 local defpath := $(firstword $($(target)_PATH) $($(target)_DEFPATH))
3197 ifneq ($(defpath),)
3198 local srcsrc := $(abspathex $(srcsrc),$(defpath))
3199 endif
3201 # create the command
3202 ifdef $(srcsrc)_INSTALLER
3203 local inscmd := $(call $(srcsrc)_INSTALLER,$(srcsrc),$(insdst),$(target),$(flags))
3204 else ifdef $(target)_INSTALLER
3205 local inscmd := $(call $(target)_INSTALLER,$(srcsrc),$(insdst),$(target),$(flags))
3206 else
3207 local inscmd := $$(INSTALL)\
3208 $(if $(uid),-o $(uid))\
3209 $(if $(gid),-g $(gid))\
3210 $(if $(mode),-m $(mode))\
3211 $(flags) -- \
3212 $(srcsrc) $(insdst)
3213 endif
3215 # generate the rule (need double evaluation here)
3216 $(eval $(def_install_src_rule))
3218 INSTARGET_$(target) += $(insdst)
3219 endef # def_install_src
3220 $(eval-opt-var def_install_src)
3223 ## generate the symlink rule
3224 define def_install_symlink_rule
3225 # the install rule
3226 $(insdst) : | $(call DIRDEP,$(dir $(insdst)))
3227 %$$(call MSG_INST_SYM,$(insdst),$(symdst))
3228 $$(QUIET)$$(RM) -f -- $$@
3229 $$(QUIET)$$(LN_SYMLINK) $(symdst) $(insdst)
3230 endef # def_install_symlink_rule
3231 $(eval-opt-var def_install_symlink_rule)
3233 ## create one symlink
3234 define def_install_symlink
3236 # deal with '=>' in the source file name.
3237 local symdst := $(subst =>, ,$(src))
3238 local symlnk := $(firstword $(symdst))
3239 local symdst := $(word $(words $(symdst)),$(symdst))
3241 # _INSTFUN
3242 ifdef $(symlnk)_INSTFUN
3243 local instfun := $(symlnk)_INSTFUN
3244 else ifdef $(target)_INSTFUN
3245 local instfun := $(target)_INSTFUN
3246 else
3247 local instfun := _INSTALL_FILE
3248 endif
3250 # _INST
3251 ifdef $(symlnk)_INST
3252 local inst := $(patsubst %/,%,$($(symlnk)_INST))/$(dir $(symlnk))
3253 else ifdef $(target)_INST
3254 local inst := $(patsubst %/,%,$($(target)_INST))/$(dir $(symlnk))
3255 else
3256 local inst := $(dir $(symlnk))
3257 endif
3259 # calc target
3260 local insdst := $(call $(instfun),$(symlnk),$(target),$(inst),$(PATH_INS))
3261 #$(warning symlnk=$(symlnk) symdst=$(symdst) insdst=$(insdst) instfun=$(instfun) inst='$(inst)')
3263 # generate the rule (need double evaluation here)
3264 $(eval $(def_install_symlink_rule))
3266 INSTARGET_$(target) += $(insdst)
3267 endef # def_install_symlink
3268 $(optmize def_install_symlink)
3271 ## generate the install rule
3272 define def_install_directory_rule
3273 # the install rule
3274 $(insdst):
3275 %$$(call MSG_INST_DIR,$(insdst))
3276 $$(QUIET)$$(INSTALL) -d \
3277 $(if $(uid),-o $(uid))\
3278 $(if $(gid),-g $(gid))\
3279 $(if $(mode),-m $(mode))\
3280 $(flags) -- \
3281 $(insdst)
3283 .NOTPARALLEL: $(insdst)
3284 endef # def_install_directory_rule
3285 $(eval-opt-var def_install_directory_rule)
3288 ## create one directory
3289 define def_install_directory
3291 # _INST
3292 ifdef $(directory)_INST
3293 local inst := $(PATH_INS)/$(patsubst %/,%,$($(directory)_INST))
3294 else ifdef $(target)_INST
3295 local inst := $(PATH_INS)/$(patsubst %/,%,$($(target)_INST))
3296 else
3297 local inst := $(PATH_INS)
3298 endif
3300 local mode := $(firstword \
3301 $($(target)_$(directory)_MODE.$(bld_trg).$(bld_trg_arch)) \
3302 $($(target)_$(directory)_MODE.$(bld_trg)) \
3303 $($(target)_$(directory)_MODE) \
3304 $($(directory)_MODE.$(bld_trg).$(bld_trg_arch)) \
3305 $($(directory)_MODE.$(bld_trg)) \
3306 $($(directory)_MODE) \
3307 $($(target)_MODE.$(bld_trg).$(bld_trg_arch)) \
3308 $($(target)_MODE.$(bld_trg)) \
3309 $($(target)_MODE))
3310 local uid := $(firstword \
3311 $($(target)_$(directory)_UID.$(bld_trg).$(bld_trg_arch)) \
3312 $($(target)_$(directory)_UID.$(bld_trg)) \
3313 $($(target)_$(directory)_UID) \
3314 $($(directory)_UID.$(bld_trg).$(bld_trg_arch)) \
3315 $($(directory)_UID.$(bld_trg)) \
3316 $($(directory)_UID) \
3317 $($(target)_UID.$(bld_trg).$(bld_trg_arch)) \
3318 $($(target)_UID.$(bld_trg)) \
3319 $($(target)_UID))
3320 local gid := $(firstword \
3321 $($(target)_$(directory)_GID.$(bld_trg).$(bld_trg_arch)) \
3322 $($(target)_$(directory)_GID.$(bld_trg)) \
3323 $($(target)_$(directory)_GID) \
3324 $($(directory)_GID.$(bld_trg).$(bld_trg_arch)) \
3325 $($(directory)_GID.$(bld_trg)) \
3326 $($(directory)_GID) \
3327 $($(target)_GID.$(bld_trg).$(bld_trg_arch)) \
3328 $($(target)_GID.$(bld_trg)) \
3329 $($(target)_GID))
3330 local flags := \
3331 $($(target)_IDFLAGS)\
3332 $($(target)_IDFLAGS.$(bld_trg)) \
3333 $($(target)_IDFLAGS.$(bld_trg).$(bld_trg_arch)) \
3334 $($(directory)_IDFLAGS) \
3335 $($(directory)_IDFLAGS.$(bld_trg)) \
3336 $($(directory)_IDFLAGS.$(bld_trg).$(bld_trg_arch)) \
3337 $($(target)_$(directory)_IDFLAGS) \
3338 $($(target)_$(directory)_IDFLAGS.$(bld_trg)) \
3339 $($(target)_$(directory)_IDFLAGS.$(bld_trg).$(bld_trg_arch))
3341 local insdst := $(inst)/$(directory)/
3342 #$(warning directory=$(directory) inst=$(inst) insdst=$(insdst) mode=$(mode) gid=$(gid) uid=$(uid))
3344 # generate the rule (need double evaluation here)
3345 $(eval $(def_install_directory_rule))
3347 INSTARGET_DIRS_$(target) += $(insdst)
3348 endef # def_install_directory
3349 $(eval-opt-var def_install_directory)
3352 ## process one install target.
3353 define def_install
3354 # the basics.
3355 local bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE))
3356 local bld_trg := $(firstword $($(target)_BLD_TRG) $(KBUILD_TARGET))
3357 local bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(KBUILD_TARGET_ARCH))
3358 local bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(KBUILD_TARGET_CPU))
3360 INSTARGET_$(target) := $($(target)_GOALS)
3361 INSTARGET_DIRS_$(target) :=
3362 local outbase := $(call TARGET_BASE,$(target),$(target))
3363 ifndef PATH_$(target)
3364 PATH_$(target) := $(patsubst %/,%,$(dir $(outbase)))
3365 else ifneq ($(PATH_$(target)),$(patsubst %/,%,$(dir $(outbase))))
3366 $(error kBuild internal error: PATH_$(target)=$(PATH_$(target)) expected $(patsubst %/,%,$(dir $(outbase))))
3367 endif
3369 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))
3371 $(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)), \
3372 $(evalval def_install_directory))
3374 $(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)), \
3375 $(evalval def_install_src))
3377 $(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)), \
3378 $(evalval def_install_symlink))
3380 # the collection target
3381 local clean_files += $(PATH_TARGET)/$(target).ins
3382 TARGET_$(target) := $(PATH_TARGET)/$(target).ins
3383 $(TARGET_$(target)): $$(INSTARGET_$(target)) | $$(INSTARGET_DIRS_$(target)) $(call DIRDEP,$(PATH_TARGET))
3384 @$(QUIET2)$(APPEND) $@
3386 $(target): $$(TARGET_$(target))
3388 _INSTALLS += $(TARGET_$(target))
3389 _INSTALLS_FILES += $(INSTARGET_$(target))
3390 _INSTALLS_DIRS += $(INSTARGET_DIRS_$(target))
3391 _CLEAN_FILES += $(clean_files)
3392 _DIRS += $(PATH_$(target)) $($(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))
3393 endef # def_install
3394 $(eval-opt-var def_install)
3396 ## process all install targets
3397 $(foreach target, $(_ALL_INSTALLS), \
3398 $(evalvalctx def_install))
3400 ifdef KBUILD_PROFILE_SELF
3401 $(evalcall def_profile_self, done install targets)
3402 endif
3405 # TESTING
3407 _TESTING += $(TESTING) $(TESTING.$(KBUILD_TARGET)) $(TESTING.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) $(TESTING.$(KBUILD_TARGET_ARCH)) $(TESTING.$(KBUILD_TARGET_CPU))
3411 # PACKING
3413 _PACKING += $(PACKING) $(PACKING.$(KBUILD_TARGET)) $(PACKING.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) $(PACKING.$(KBUILD_TARGET_ARCH)) $(PACKING.$(KBUILD_TARGET_CPU))
3417 # DOCS
3422 # DIRECTORIES
3424 _DIR_ALL := $(sort $(addsuffix /,$(patsubst %/,%,$(_DIRS))) $(dir $(_OUT_FILES) $(_OBJS) $(_INSTALLS_FILES)))
3425 $(foreach directory,$(_INSTALLS_DIRS), $(eval _DIR_ALL := $(filter-out $(directory),$(_DIR_ALL))))
3428 define def_mkdir_rule
3429 $(directory):
3430 %$$(call MSG_MKDIR,$$@)
3431 $$(QUIET)$$(MKDIR) -p -- $$@
3432 endef
3434 $(foreach directory,$(_DIR_ALL),$(eval $(def_mkdir_rule)))
3436 ifdef KBUILD_PROFILE_SELF
3437 $(evalcall def_profile_self, done directories)
3438 endif
3442 # NOTHING
3444 do-nothing:
3445 %$(call MSG_NOTHING)
3446 ifdef KBUILD_PROFILE_SELF
3447 @$(ECHO) 'prof: $(call _KBUILD_FMT_ELAPSED_EX, $(nanots ), $(_KBUILD_TS_HEADER_START)) - $(call _KBUILD_FMT_ELAPSED_EX, $(nanots ), $(_KBUILD_TS_PREV)) - executing $@'
3448 ifeq ($(KBUILD_PROFILE_SELF),2)
3449 @$(ECHO) 'stat: $(make-stats )'
3450 endif
3451 endif
3455 # CLEAN UP
3457 do-clean:
3458 %$(call MSG_CLEAN)
3459 $(QUIET)$(RM) -f -- $(_OUT_FILES) $(_OBJS) $(_DEPFILES) $(_DEPFILES_INCLUDED) $(_CLEAN_FILES) $(OTHER_CLEAN)
3460 $(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)))
3465 # PASSES (including directory and makefile walking)
3469 # First, check whether we need to order the passes explicitly or not.
3470 # This depends on whether we're a leaf makefile or not. A leaf will
3471 # know all its dependencies, while a recursive one relies on the
3472 # order sub-directories and other makefiles are executed it.
3475 ## Setup a pass and check for optimizations.
3476 # @param $(PASS) Uppercase pass name.
3477 define def_pass_setup_and_optimize
3479 # The setup. ## @todo This is looks a bit weird...
3480 ifndef SUBDIRS_$(PASS)
3481 SUBDIRS_$(PASS) := $(SUBDIRS) $(SUBDIRS.$(KBUILD_TARGET)) $(SUBDIRS.$(KBUILD_TARGET.$(KBUILD_TARGET_ARCH)))
3482 endif
3483 ifndef SUBDIRS_AFTER_$(PASS)
3484 SUBDIRS_AFTER_$(PASS) := $(SUBDIRS_AFTER) $(SUBDIRS_AFTER.$(KBUILD_TARGET)) $(SUBDIRS_AFTER.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH))
3485 endif
3486 ifndef MAKEFILES_BEFORE_$(PASS)
3487 MAKEFILES_BEFORE_$(PASS) := $(MAKEFILES_BEFORE) $(MAKEFILES_BEFORE.$(KBUILD_TARGET)) $(MAKEFILES_BEFORE.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH))
3488 endif
3489 ifndef MAKEFILES_AFTER_$(PASS)
3490 MAKEFILES_AFTER_$(PASS) := $(MAKEFILES_AFTER) $(MAKEFILES_AFTER.$(KBUILD_TARGET)) $(MAKEFILES_AFTER.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH))
3491 endif
3493 # The check.
3494 ifeq ($(_KBUILD_STRICT_PASS_ORDER),nonstrict)
3495 ifneq ($(strip \
3496 $(SUBDIRS_$(PASS)) $(SUBDIRS_$(PASS).$(KBUILD_TARGET)) $(SUBDIRS_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \
3497 $(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(KBUILD_TARGET)) $(MAKEFILES_BEFORE_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \
3498 $(SUBDIRS_AFTER_$(PASS)) $(SUBDIRS_AFTER_$(PASS).$(KBUILD_TARGET)) $(SUBDIRS_AFTER_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \
3499 $(MAKEFILES_AFTER_$(PASS)) $(MAKEFILES_AFTER_$(PASS).$(KBUILD_TARGET)) $(MAKEFILES_AFTER_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \
3501 _KBUILD_STRICT_PASS_ORDER := strict
3502 endif
3503 endif # _KBUILD_STRICT_PASS_ORDER == nonstrict
3504 endef # def_pass_setup_and_optimize
3505 $(eval-opt-var def_pass_setup_and_optimize)
3507 ## PASS: Setup & optimization.
3508 # Check if we can apply the non-strict pass order optimzation (no SUBDIRS_* and MAKEFILES_*),
3509 # and set up the pass specific variables as we go along.
3510 _KBUILD_STRICT_PASS_ORDER := nonstrict
3511 $(foreach PASS, $(PASSES), $(evalval def_pass_setup_and_optimize))
3512 #$ (error _KBUILD_STRICT_PASS_ORDER=$(_KBUILD_STRICT_PASS_ORDER))
3514 ifeq ($(_KBUILD_STRICT_PASS_ORDER),strict)
3515 if !defined(KBUILD_SAFE_PARALLEL) || "$(KMK_OPT_JOBS)" == "1"
3516 _KBUILD_STRICT_PASS_ORDER := strict_unsafe
3517 endif
3518 endif
3521 ## Subdir
3522 # @param $(pass) Lowercase pass name.
3523 # @param $(PASS) Uppercase pass name.
3524 # @param $(subdir) Subdirectory
3525 # @param $(tag) tag to attach to the rule name.
3526 define def_pass_subdir
3527 pass_$(pass)$(tag):: $(dep)
3528 + $$(QUIET)$$(MAKE) -C $(subdir) -f $$(notdir $$(firstword $$(wildcard $$(addprefix $(subdir)/,$$(DEFAULT_MAKEFILE))))) pass_$(pass)
3529 endef
3531 ## Submakefile
3532 # @param $(pass) Lowercase pass name.
3533 # @param $(PASS) Uppercase pass name.
3534 # @param $(makefile) Makefile.
3535 # @param $(tag) tag to attach to the rule name.
3536 define def_pass_makefile
3537 pass_$(pass)$(tag):: $(dep)
3538 + $$(QUIET)$$(MAKE) -C $(patsubst %/,%,$(dir $(makefile))) -f $(notdir $(makefile)) pass_$(pass)
3539 endef
3541 ## Execute a pass, strict order.
3542 # @param $(pass) Lowercase pass name.
3543 # @param $(PASS) Uppercase pass name.
3544 define def_pass_strict
3545 $(eval tag:=_before)
3546 $(eval dep:= )
3547 $(foreach subdir, $(SUBDIRS_$(PASS)) $(SUBDIRS_$(PASS).$(KBUILD_TARGET)) $(SUBDIRS_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir)))
3548 $(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(KBUILD_TARGET)) $(MAKEFILES_BEFORE_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)),$(eval $(def_pass_makefile)))
3550 $(eval tag:=_after)
3551 $(eval dep:=pass_$(pass)_doit)
3552 $(foreach subdir, $(SUBDIRS_AFTER_$(PASS)) $(SUBDIRS_AFTER_$(PASS).$(KBUILD_TARGET)) $(SUBDIRS_AFTER_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir)))
3553 $(foreach makefile,$(MAKEFILES_AFTER_$(PASS)) $(MAKEFILES_AFTER_$(PASS).$(KBUILD_TARGET)) $(MAKEFILES_AFTER_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) ,$(eval $(def_pass_makefile)))
3555 .NOTPARALLEL: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_this
3556 .PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_this pass_$(pass)_doit
3557 pass_$(pass)_doit: $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var)))
3558 pass_$(pass)_this: pass_$(pass)_before
3559 + $$(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)_doit
3560 pass_$(pass)_after:: pass_$(pass)_this
3561 pass_$(pass): pass_$(pass)_after
3562 #$ (warning pass=$(pass) PASS=$(PASS): $(PASS_$(PASS)_trgs) $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var))))
3563 endef # def_pass_strict
3564 $(eval-opt-var def_pass_strict)
3566 ## Execute a pass, strict order.
3567 # @param $(pass) Lowercase pass name.
3568 # @param $(PASS) Uppercase pass name.
3569 define def_pass_strict_unsafe
3570 $(eval tag:=_before)
3571 $(eval dep:= )
3572 $(foreach subdir, $(SUBDIRS_$(PASS)) $(SUBDIRS_$(PASS).$(KBUILD_TARGET)) $(SUBDIRS_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir)))
3573 $(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(KBUILD_TARGET)) $(MAKEFILES_BEFORE_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)),$(eval $(def_pass_makefile)))
3575 $(eval tag:=_after)
3576 $(eval dep:=pass_$(pass)_doit)
3577 $(foreach subdir, $(SUBDIRS_AFTER_$(PASS)) $(SUBDIRS_AFTER_$(PASS).$(KBUILD_TARGET)) $(SUBDIRS_AFTER_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir)))
3578 $(foreach makefile,$(MAKEFILES_AFTER_$(PASS)) $(MAKEFILES_AFTER_$(PASS).$(KBUILD_TARGET)) $(MAKEFILES_AFTER_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) ,$(eval $(def_pass_makefile)))
3580 .PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_doit
3581 .NOTPARALLEL: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_doit
3582 pass_$(pass)_doit: pass_$(pass)_before \
3583 $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var)))
3584 pass_$(pass): \
3585 pass_$(pass)_before \
3586 pass_$(pass)_doit \
3587 pass_$(pass)_after
3588 #$ (warning pass=$(pass) PASS=$(PASS): $(PASS_$(PASS)_trgs) $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var))))
3589 endef # def_pass_strict_unsafe
3590 $(eval-opt-var def_pass_strict_unsafe)
3592 ## Execute a pass, non-strict pass ordering.
3593 # @param $(pass) Lowercase pass name.
3594 # @param $(PASS) Uppercase pass name.
3595 define def_pass_nonstrict
3596 .PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_doit
3597 pass_$(pass)_doit: $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$$$$($(var)))
3598 pass_$(pass): pass_$(pass)_doit
3599 endef # def_pass_nonstrict
3601 ## PASS: rules
3602 # Generate the rules for the defined passes.
3603 $(foreach PASS, $(PASSES), \
3604 $(eval pass := $(PASS_$(PASS)_pass)) \
3605 $(eval $(def_pass_$(_KBUILD_STRICT_PASS_ORDER))))
3608 ## Pass order, strict.
3609 # @param $(pass) Current pass name.
3610 # @param $(prev_pass) The previous pass name.
3611 define def_pass_order_strict
3612 .PHONY: pass_$(pass)_order
3613 .NOTPARALLEL: pass_$(pass)_order
3614 pass_$(pass)_order: $(pass_prev)
3615 %$$(call MSG_PASS,$$(if $$(PASS_$(PASS)),$$(PASS_$(PASS)),$(pass)))
3616 + $$(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)
3617 $(eval pass_prev := pass_$(pass)_order)
3618 endef # def_pass_order_strict
3619 $(eval-opt-var def_pass_order_strict)
3621 ## Pass order, strict unsafe.
3622 # @param $(pass) Current pass name.
3623 # @param $(prev_pass) The previous pass name.
3624 define def_pass_order_strict_unsafe
3625 .NOTPARALLEL: pass_$(pass)_order pass_$(pass)_banner
3626 .PHONY: pass_$(pass)_order pass_$(pass)_banner
3627 pass_$(pass)_banner: $(pass_prev)
3628 %$$(call MSG_PASS,$$(if $$(PASS_$(PASS)),$$(PASS_$(PASS)),$(pass)))
3629 pass_$(pass)_order: $(pass_prev) \
3630 pass_$(pass)_banner \
3631 pass_$(pass)
3632 $(eval pass_prev := pass_$(pass)_order)
3633 endef # def_pass_order_strict_unsafe
3634 $(eval-opt-var def_pass_order_strict_unsafe)
3636 ## Pass order, non-strict.
3637 # @param $(pass) Current pass name.
3638 # @param $(prev_pass) The previous pass name.
3639 define def_pass_order_nonstrict
3640 .PHONY: pass_$(pass)_order pass_$(pass)_banner
3641 pass_$(pass)_banner:
3642 %$$(call MSG_PASS,$$(if $$(PASS_$(PASS)),$$(PASS_$(PASS)),$(pass)))
3643 pass_$(pass)_order: \
3644 $(pass_prev) \
3645 pass_$(pass)_banner \
3646 pass_$(pass)
3647 $(eval pass_prev := pass_$(pass)_order)
3648 endef # def_pass_order_nonstrict
3649 $(eval-opt-var def_pass_order_nonstrict)
3651 ## PASS: order
3652 # Use dependencies to ensure correct pass order.
3653 pass_prev :=
3654 $(foreach PASS,$(DEFAULT_PASSES),\
3655 $(eval pass := $(PASS_$(PASS)_pass)) \
3656 $(eval $(def_pass_order_$(_KBUILD_STRICT_PASS_ORDER))))
3658 ifdef KBUILD_PROFILE_SELF
3659 $(evalcall def_profile_self, done passes)
3660 endif
3662 # Some common pass aliases
3663 ifndef KBUILD_NO_PASS_ALIASES
3664 .PHONY: clean
3665 clean: pass_clean
3667 .PHONY: nothing
3668 nothing: pass_nothing
3670 .PHONY: packing
3671 packing: pass_packing
3673 .PHONY: check
3674 check:: pass_testing
3676 .PHONY: test
3677 test:: pass_testing
3678 endif
3682 # THE MAIN RULES
3684 all_recursive: $(pass_prev)
3686 rebuild: clean
3687 + $(MAKE) -f $(firstword $(MAKEFILE_LIST)) all_recursive
3689 # @todo make this a non-default pass!
3690 uninstall::
3691 $(RM) -f -- $(_INSTALLS_FILES)
3693 install:: pass_installs
3695 # misc shortcuts (use secondary expansion here to save strcache[file] space).
3696 targets: bldprogs libraries dlls programs sysmods miscbins others installs
3697 objects: $$(_OBJS)
3698 bldprogs: $$(_BLDPROGS)
3699 libraries: $$(_LIBS) $$(_IMPORT_LIBS) $$(_OTHER_LIBRARIES)
3700 dlls: $$(_DLLS)
3701 programs: $$(_PROGRAMS)
3702 sysmods: $$(_SYSMODS)
3703 miscbins: $$(_MISCBINS)
3704 others: $$(_OTHERS)
3705 installs: $$(_INSTALLS) $$(_INSTALLS_DIRS) $$(_INSTALLS_FILES)
3710 # kBuild debugging stuff.
3712 ## @todo this doesn't work. Move to a debug unit and expand it.
3713 show_targets:
3714 @$(foreach target, $(_ALL_TARGETS),\
3715 @$(ECHO) "target: $(target)" $(NLTAB)\
3716 @$(ECHO) " PATH_$(target)=$(PATH_$(target))" $(NLTAB)\
3717 @$(ECHO) " TARGET_$(target)=$(TARGET_$(target))" $(NLTAB)\
3718 @$(ECHO) " INSTARGET_$(target)=$(INSTARGET_$(target))" $(NLTAB)\
3719 $(foreach prop,$(PROPS_SINGLE) $(PROPS_ACCUMULATE_L) $(PROPS_ACCUMULATE_R) OBJS_ CLEAN, \
3720 $(eval _tmp:=$(firstword $($(target)_BLD_TRG) $(KBUILD_TARGET))) \
3721 $(if $($(target)_$(prop).$(_tmp)),\
3722 @$(ECHO) " $(target)_$(prop).$(_tmp)=$($(target)_$(prop).$(_tmp))" $(NLTAB)) \
3723 $(if $($(target)_$(prop)), $(NLTAB)@$(ECHO) " $(target)_$(prop)=$($(target)_$(prop))" $(NLTAB)) \
3725 $(foreach prop,$(PROPS_DEFERRED), \
3726 $(eval _tmp:=$(firstword $($(target)_BLD_TRG) $(KBUILD_TARGET))) \
3727 $(if $(value $(target)_$(prop).$(_tmp)),\
3728 @$(ECHO) ' $(target)_$(prop).$(_tmp)=$(value $(TARGET)_$(prop).$(_tmp))' $(NLTAB)) \
3729 $(if $(value $(target)_$(prop)), $(NLTAB)@$(ECHO) ' $(target)_$(prop)=$(value $(target)_$(prop))' $(NLTAB)) \
3735 # Include dependency files.
3737 ifdef _DEPFILES
3738 # TODO: first works the second doesn't, provided _KB_INCLUDE_DEPS is undefined:
3739 # if "$(_KB_INCLUDE_DEPS)" == "1"
3740 # if $(_KB_INCLUDE_DEPS) == "1"
3742 ifdef KB_HAVE_INCLUDEDEP_QUEUE
3743 includedep-queue $(_DEPFILES)
3744 else
3745 $(foreach dep, $(_DEPFILES), $(eval includedep $(dep)))
3746 endif
3747 endif
3750 ifdef KBUILD_PROFILE_SELF
3751 $(evalcall def_profile_self, end of footer.kmk)
3752 _KBUILD_TS_FOOTER_END := $(_KBUILD_TS_PREV)
3754 ifneq ($(KBUILD_PROFILE_SELF),0)
3755 $(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)) )
3756 $(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)) )
3757 $(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)) )
3758 $(info prof: DEPFILES_INCLUDED=$(words $(_DEPFILES_INCLUDED)) DEPFILES=$(words $(_DEPFILES)) MAKEFILES=$(words $(MAKEFILE_LIST)) )
3759 endif
3760 endif
3763 # end-of-file-content
3764 __footer_kmk__ := target
3765 endif # __footer_kmk__