source: trunk/kBuild/footer.kmk@ 2477

Last change on this file since 2477 was 2477, checked in by bird, 14 years ago

footer.kmk: Install fixes.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 127.5 KB
Line 
1# $Id: footer.kmk 2477 2011-07-20 09:51:55Z bird $
2## @file
3# kBuild - File included at top of makefile.
4#
5
6#
7# Copyright (c) 2004-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net>
8#
9# This file is part of kBuild.
10#
11# kBuild is free software; you can redistribute it and/or modify
12# it under the terms of the GNU General Public License as published by
13# the Free Software Foundation; either version source of the License, or
14# (at your option) any later version.
15#
16# kBuild is distributed in the hope that it will be useful,
17# but WITHOUT ANY WARRANTY; without even the implied warranty of
18# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19# GNU General Public License for more details.
20#
21# You should have received a copy of the GNU General Public License
22# along with kBuild; if not, write to the Free Software
23# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24#
25#
26# As a special exception you are granted permission to include this file, via
27# the kmk include directive, as you wish without this in itself causing the
28# resulting makefile, program or whatever to be covered by the GPL license.
29# This exception does not however invalidate any other reasons why the makefile,
30# program, whatever should not be covered the GPL.
31#
32#
33
34ifndef __footer_kmk__
35# start-of-file-content
36ifdef KBUILD_PROFILE_SELF
37 $(evalcall def_profile_self, start of footer.kmk)
38 _KBUILD_TS_FOOTER_START := $(_KBUILD_TS_PREV)
39endif
40
41#
42# Variables.
43# (Some of these need initialization before including definitions using them.)
44#
45
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))
58
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)
72
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)
85
86# all $(KBUILD_HOST) targets.
87_ALL_HOST_TARGETS = \
88 $(_ALL_BLDPROGS)
89
90# all targets making use of srcname.
91_ALL_SRCNAME_TARGETS = \
92 $(_ALL_FETCHES) \
93 $(_ALL_PATCHES)
94
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))
97
98# included dependency files.
99_DEPFILES_INCLUDED :=
100
101
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 :=
106
107# Files which only requires cleaning up.
108_CLEAN_FILES :=
109
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_STAGE_FILES :=
124_STAGE_DIRS :=
125_INSTALLS :=
126_INSTALLS_FILES :=
127_INSTALLS_DIRS :=
128_OTHERS :=
129_PACKING :=
130_DIRS := $(PATH_TARGET)/ $(PATH_TARGET) $(BLDDIRS)
131_IMPORT_LIBS :=
132
133# misc
134pass_prev :=
135
136
137
138#
139# Footer macros
140#
141
142## Figure out the tool for a target.
143# @param $1 normalized target.
144# @param $2 tooltype.
145# @param bld_trg build target.
146# @param bld_trg_arch build target architecture.
147# @param bld_type build target type.
148if 0
149_TARGET_TOOL = $(strip $(firstword \
150 $($(1)_$(2)TOOL.$(bld_trg).$(bld_trg_arch)) \
151 $($(1)_$(2)TOOL.$(bld_trg)) \
152 $($(1)_$(2)TOOL) \
153 $($(1)_TOOL.$(bld_trg).$(bld_trg_arch)) \
154 $($(1)_TOOL.$(bld_trg)) \
155 $($(1)_TOOL) \
156 $($(2)TOOL.$(bld_trg).$(bld_trg_arch)) \
157 $($(2)TOOL.$(bld_trg)) \
158 $($(2)TOOL) \
159 $(TOOL.$(bld_trg).$(bld_trg_arch)) \
160 $(TOOL.$(bld_trg)) \
161 $(TOOL) \
162))
163else
164_TARGET_TOOL = $(strip $(firstword \
165 $($(1)_$(2)TOOL.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
166 $($(1)_$(2)TOOL.$(bld_trg).$(bld_trg_arch)) \
167 $($(1)_$(2)TOOL.$(bld_trg).$(bld_type)) \
168 $($(1)_$(2)TOOL.$(bld_trg_arch)) \
169 $($(1)_$(2)TOOL.$(bld_trg)) \
170 $($(1)_$(2)TOOL.$(bld_type)) \
171 $($(1)_$(2)TOOL) \
172 $($(1)_TOOL.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
173 $($(1)_TOOL.$(bld_trg).$(bld_trg_arch)) \
174 $($(1)_TOOL.$(bld_trg).$(bld_type)) \
175 $($(1)_TOOL.$(bld_trg_arch)) \
176 $($(1)_TOOL.$(bld_trg)) \
177 $($(1)_TOOL.$(bld_type)) \
178 $($(1)_TOOL) \
179 $($(2)TOOL.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
180 $($(2)TOOL.$(bld_trg).$(bld_trg_arch)) \
181 $($(2)TOOL.$(bld_trg).$(bld_type)) \
182 $($(2)TOOL.$(bld_trg_arch)) \
183 $($(2)TOOL.$(bld_trg)) \
184 $($(2)TOOL.$(bld_type)) \
185 $($(2)TOOL) \
186 $(TOOL.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
187 $(TOOL.$(bld_trg).$(bld_trg_arch)) \
188 $(TOOL.$(bld_trg).$(bld_type)) \
189 $(TOOL.$(bld_trg_arch)) \
190 $(TOOL.$(bld_trg)) \
191 $(TOOL.$(bld_type)) \
192 $(TOOL) \
193))
194endif
195
196## Figure out the actual name of an installed file.
197# @param $1 The file to install.
198# @param $2 The target name.
199# @param $3 The _INST value (can be empty).
200# @param $4 The installation root directory.
201_INSTALL_FILE = $(patsubst %/,%/$(notdir $(1)),$(if $(3),$(4)/$(3),$(4)/))
202
203
204
205## Converts a variable from simple to recursive flavor.
206# This is used by def_inherit_template_one_accumulate_l and def_inherit_template_one_accumulate_r.
207# @param $1 The variable name.
208define def_simple_2_recursive
209$1_DEFERRED := $$($1)
210$1 = $$($1_DEFERRED)
211endef
212
213
214## Inherit one keyword in a non-accumulative manner.
215# @param $(trg) Target object.
216# @param $(prop) The property.
217# @param $(src_key) Source keyword.
218# @param $(trg_key) Target keyword.
219define def_inherit_one_keyword
220ifdef $(trg)_$(prop).$(src_key)
221 ifndef $(trg)_$(prop).$(trg_key)
222 $(trg)_$(prop).$(trg_key) = $($(trg)_$(prop).$(src_key))
223 endif
224endif
225endef
226
227
228# EXPAND_BY = overriding
229
230## Inherit one keyword in a non-accumulative manner.
231# @param $(trg) Target object.
232# @param $(prop) The property.
233# @param $(src_key) Source keyword.
234# @param $(trg_key) Target keyword.
235define def_inherit_one_keyword_overriding_now_l
236ifdef $(trg)_$(prop).$(src_key)
237 ifndef $(trg)_$(prop).$(trg_key)
238 $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(src_key))
239 endif
240endif
241endef
242
243## @copydoc def_inherit_one_overriding_now_l
244define def_inherit_one_keyword_overriding_now_r
245ifdef $(trg)_$(prop).$(src_key)
246 ifndef $(trg)_$(prop).$(trg_key)
247 $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(src_key))
248 endif
249endif
250endef
251
252## Inherit one keyword in a non-accumulative manner, deferred expansion.
253# @param $(trg) Target object.
254# @param $(prop) The property.
255# @param $(src_key) Source keyword.
256# @param $(trg_key) Target keyword.
257# @remark This define relies on double evaluation
258define def_inherit_one_keyword_overriding_deferred
259ifdef $(trg)_$(prop).$(src_key)
260 ifndef $(trg)_$(prop).$(trg_key)
261 $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key))
262 endif
263endif
264endef
265
266## @copydoc def_inherit_one_overriding_deferred
267define def_inherit_one_keyword_overriding_deferred_l
268ifdef $(trg)_$(prop).$(src_key)
269 ifndef $(trg)_$(prop).$(trg_key)
270 $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key))
271 endif
272endif
273endef
274
275## @copydoc def_inherit_one_overriding_deferred
276define def_inherit_one_keyword_overriding_deferred_r
277ifdef $(trg)_$(prop).$(src_key)
278 ifndef $(trg)_$(prop).$(trg_key)
279 $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key))
280 endif
281endif
282endef
283
284
285# EXPAND_BY = prepending
286
287## Inherit one keyword in a prepending manner.
288# @param $(trg) Target object.
289# @param $(prop) The property.
290# @param $(src_key) Source keyword.
291# @param $(trg_key) Target keyword.
292define def_inherit_one_keyword_prepending_now_l
293ifdef $(trg)_$(prop).$(src_key)
294 $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(src_key)) $($(trg)_$(prop).$(trg_key))
295endif
296endef
297
298## @copydoc def_inherit_one_prepending_now_l
299define def_inherit_one_keyword_prepending_now_r
300ifdef $(trg)_$(prop).$(src_key)
301 $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(trg_key)) $($(trg)_$(prop).$(src_key))
302endif
303endef
304
305## Inherit one keyword in a non-accumulative manner, deferred expansion.
306# @param $(trg) Target object.
307# @param $(prop) The property.
308# @param $(src_key) Source keyword.
309# @param $(trg_key) Target keyword.
310# @remark This define relies on double evaluation
311define def_inherit_one_keyword_prepending_deferred
312ifdef $(trg)_$(prop).$(src_key)
313 ifndef $(trg)_$(prop).$(trg_key)
314 $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key))
315 endif
316endif
317endef
318
319## Inherit one keyword in a prepending manner, deferred expansion.
320# @param $(trg) Target object.
321# @param $(prop) The property.
322# @param $(src_key) Source keyword.
323# @param $(trg_key) Target keyword.
324define def_inherit_one_keyword_prepending_deferred_l
325ifdef $(trg)_$(prop).$(src_key)
326 ifeq ($$(flavor $(trg)_$(prop).$(trg_key)),simple)
327 $$(evalcall2 def_simple_2_recursive,$(trg)_$(prop).$(trg_key))
328 endif
329 $(trg)_$(prop).$(trg_key) <= $$($(trg)_$(prop).$(src_key))
330endif
331endef
332
333## @copydoc def_inherit_one_prepending_deferred_l
334define def_inherit_one_keyword_prepending_deferred_r
335ifdef $(trg)_$(prop).$(src_key)
336 ifeq ($$(flavor $(trg)_$(prop).$(trg_key)),simple)
337 $$(evalcall2 def_simple_2_recursive,$(trg)_$(prop).$(trg_key))
338 endif
339 $(trg)_$(prop).$(trg_key) += $$($(trg)_$(prop).$(src_key))
340endif
341endef
342
343
344# EXPAND_BY = appending
345
346## Inherit one keyword in an appending manner.
347# @param $(trg) Target object.
348# @param $(prop) The property.
349# @param $(src_key) Source keyword.
350# @param $(trg_key) Target keyword.
351define def_inherit_one_keyword_appending_now_l
352ifdef $(trg)_$(prop).$(src_key)
353 $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(trg_key)) $($(trg)_$(prop).$(src_key))
354endif
355endef
356
357## @copydoc def_inherit_one_appending_now_l
358define def_inherit_one_keyword_appending_now_r
359ifdef $(trg)_$(prop).$(src_key)
360 $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(src_key)) $($(trg)_$(prop).$(trg_key))
361endif
362endef
363
364## Inherit one keyword in a non-accumulative manner, deferred expansion.
365# @param $(trg) Target object.
366# @param $(prop) The property.
367# @param $(src_key) Source keyword.
368# @param $(trg_key) Target keyword.
369# @remark This define relies on double evaluation
370define def_inherit_one_keyword_appending_deferred
371ifdef $(trg)_$(prop).$(src_key)
372 ifndef $(trg)_$(prop).$(trg_key)
373 $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key))
374 endif
375endif
376endef
377
378## Inherit one keyword in an appending manner, deferred expansion.
379# @param $(trg) Target object.
380# @param $(prop) The property.
381# @param $(src_key) Source keyword.
382# @param $(trg_key) Target keyword.
383define def_inherit_one_keyword_appending_deferred_l
384ifdef $(trg)_$(prop).$(src_key)
385 ifeq ($$(flavor $(trg)_$(prop).$(trg_key)),simple)
386 $$(evalcall2 def_simple_2_recursive,$(trg)_$(prop).$(trg_key))
387 endif
388 $(trg)_$(prop).$(trg_key) += $$($(trg)_$(prop).$(src_key))
389endif
390endef
391
392## @copydoc def_inherit_one_appending_deferred_l
393define def_inherit_one_keyword_appending_deferred_r
394ifdef $(trg)_$(prop).$(src_key)
395 ifeq ($$(flavor $(trg)_$(prop).$(trg_key)),simple)
396 $$(evalcall2 def_simple_2_recursive,$(trg)_$(prop).$(trg_key))
397 endif
398 $(trg)_$(prop).$(trg_key) <= $$($(trg)_$(prop).$(src_key))
399endif
400endef
401
402
403## Worker for def_inherit that deals with one keyword that makes
404# use of inheritance.
405# @param prefix_keyword key_prefix:keyword. The cool join/split game as usual.
406# @param trg Object to consider for inheriting.
407# @param properties List of the properties with straight expansion.
408# @param properties_now_l List of the properties with immediate expansion, accumulating on the left side.
409# @param properties_now_r List of the properties with immediate expansion, accumulating on the right side.
410# @param properties_deferred List of the properties with deferred expansion (e.g. function), non-accumulative .
411# @param properties_deferred_l List of the properties with deferred expansion (e.g. function), accumulating on the left side.
412# @param properties_deferred_r List of the properties with deferred expansion (e.g. function), accumulating on the right side.
413define def_inherit_keyword
414local prefix := $(word 1,$(subst :, ,$(prefix_keyword)))
415local trg_key := $(word 2,$(subst :, ,$(prefix_keyword)))
416local src_key := $($(prefix)_$(trg_key)_EXTENDS)
417local by := $($(prefix)_$(trg_key)_EXTENDS_BY)
418
419# Inherit the properties.
420$(foreach prop, $(properties), $(eval $(def_inherit_one_keyword)))
421$(foreach prop, $(properties_now_l), $(eval $(def_inherit_one_keyword_$(by)_now_l)))
422$(foreach prop, $(properties_now_r), $(eval $(def_inherit_one_keyword_$(by)_now_r)))
423$(foreach prop, $(properties_deferred), $(eval $(def_inherit_one_keyword_$(by)_deferred)))
424$(foreach prop, $(properties_deferred_l), $(eval $(def_inherit_one_keyword_$(by)_deferred_l)))
425$(foreach prop, $(properties_deferred_r), $(eval $(def_inherit_one_keyword_$(by)_deferred_r)))
426
427endef # def_inherit_keyword
428
429
430## Inherit one template property in a non-accumulative manner.
431# @param $(prop) Property name
432# @param $(src) Source (parent) object.
433# @param $(trg) Target (child) object.
434define def_inherit_one
435ifdef $(src)_$(prop)
436 ifndef $(trg)_$(prop)
437 $(trg)_$(prop) = $($(src)_$(prop))
438 endif
439endif
440endef
441
442
443# EXPAND_BY = overriding
444
445## Inherit one template property in a non-accumulative manner.
446# @param $(prop) Property name
447# @param $(src) Source (parent) object.
448# @param $(trg) Target (child) object.
449define def_inherit_one_overriding_now_l
450ifdef $(src)_$(prop)
451 ifndef $(trg)_$(prop)
452 $(trg)_$(prop) := $($(src)_$(prop))
453 endif
454endif
455endef
456
457## @copydoc def_inherit_one_overriding_now_l
458define def_inherit_one_overriding_now_r
459ifdef $(src)_$(prop)
460 ifndef $(trg)_$(prop)
461 $(trg)_$(prop) := $($(src)_$(prop))
462 endif
463endif
464endef
465
466## Inherit one template property in a non-accumulative manner, deferred expansion.
467# @param $(prop) Property name
468# @param $(src) Source
469# @param $(trg) Target
470# @remark This define relies on double evaluation
471define def_inherit_one_overriding_deferred
472ifdef $(src)_$(prop)
473 ifndef $(trg)_$(prop)
474 $(trg)_$(prop) = $$($(src)_$(prop))
475 endif
476endif
477endef
478
479## @copydoc def_inherit_one_overriding_deferred
480define def_inherit_one_overriding_deferred_l
481ifdef $(src)_$(prop)
482 ifndef $(trg)_$(prop)
483 $(trg)_$(prop) = $$($(src)_$(prop))
484 endif
485endif
486endef
487
488## @copydoc def_inherit_one_overriding_deferred
489define def_inherit_one_overriding_deferred_r
490ifdef $(src)_$(prop)
491 ifndef $(trg)_$(prop)
492 $(trg)_$(prop) = $$($(src)_$(prop))
493 endif
494endif
495endef
496
497
498# EXPAND_BY = prepending
499
500## Inherit one template property in a prepending manner.
501# @param $(prop) Property name
502# @param $(src) Source (parent) object.
503# @param $(trg) Target (child) object.
504define def_inherit_one_prepending_now_l
505ifdef $(src)_$(prop)
506 $(trg)_$(prop) := $($(src)_$(prop)) $($(trg)_$(prop))
507endif
508endef
509
510## @copydoc def_inherit_one_prepending_now_l
511define def_inherit_one_prepending_now_r
512ifdef $(src)_$(prop)
513 $(trg)_$(prop) := $($(trg)_$(prop)) $($(src)_$(prop))
514endif
515endef
516
517## Inherit one template property in a non-accumulative manner, deferred expansion.
518# @param $(prop) Property name
519# @param $(src) Source
520# @param $(trg) Target
521# @remark This define relies on double evaluation
522define def_inherit_one_prepending_deferred
523ifdef $(src)_$(prop)
524 ifndef $(trg)_$(prop)
525 $(trg)_$(prop) = $$($(src)_$(prop))
526 endif
527endif
528endef
529
530## Inherit one template property in a prepending manner, deferred expansion.
531# @param $(prop) Property name
532# @param $(src) Source (parent) object.
533# @param $(trg) Target (child) object.
534define def_inherit_one_prepending_deferred_l
535ifdef $(src)_$(prop)
536 ifeq ($$(flavor $(trg)_$(prop)),simple)
537 $$(evalcall2 def_simple_2_recursive,$(trg)_$(prop))
538 endif
539 $(trg)_$(prop) <= $$($(src)_$(prop))
540endif
541endef
542
543## @copydoc def_inherit_one_prepending_deferred_l
544define def_inherit_one_prepending_deferred_r
545ifdef $(src)_$(prop)
546 ifeq ($$(flavor $(trg)_$(prop)),simple)
547 $$(evalcall2 def_simple_2_recursive,$(trg)_$(prop))
548 endif
549 $(trg)_$(prop) += $$($(src)_$(prop))
550endif
551endef
552
553
554# EXPAND_BY = appending
555
556## Inherit one template property in an appending manner.
557# @param $(prop) Property name
558# @param $(src) Source (parent) object.
559# @param $(trg) Target (child) object.
560define def_inherit_one_appending_now_l
561ifdef $(src)_$(prop)
562 $(trg)_$(prop) := $($(trg)_$(prop)) $($(src)_$(prop))
563endif
564endef
565
566## @copydoc def_inherit_one_appending_now_l
567define def_inherit_one_appending_now_r
568ifdef $(src)_$(prop)
569 $(trg)_$(prop) := $($(src)_$(prop)) $($(trg)_$(prop))
570endif
571endef
572
573## Inherit one template property in a non-accumulative manner, deferred expansion.
574# @param $(prop) Property name
575# @param $(src) Source
576# @param $(trg) Target
577# @remark This define relies on double evaluation
578define def_inherit_one_appending_deferred
579ifdef $(src)_$(prop)
580 ifndef $(trg)_$(prop)
581 $(trg)_$(prop) = $$($(src)_$(prop))
582 endif
583endif
584endef
585
586## Inherit one template property in an appending manner, deferred expansion.
587# @param $(prop) Property name
588# @param $(src) Source (parent) object.
589# @param $(trg) Target (child) object.
590define def_inherit_one_appending_deferred_l
591ifdef $(src)_$(prop)
592 ifeq ($$(flavor $(trg)_$(prop)),simple)
593 $$(evalcall2 def_simple_2_recursive,$(trg)_$(prop))
594 endif
595 $(trg)_$(prop) += $$($(src)_$(prop))
596endif
597endef
598
599## @copydoc def_inherit_one_appending_deferred_l
600define def_inherit_one_appending_deferred_r
601ifdef $(src)_$(prop)
602 ifeq ($$(flavor $(trg)_$(prop)),simple)
603 $$(evalcall2 def_simple_2_recursive,$(trg)_$(prop))
604 endif
605 $(trg)_$(prop) <= $$($(src)_$(prop))
606endif
607endef
608
609
610## combines the specified properties $(1) with the $(_KEYWORDS) list.
611_INHERIT_JOIN_KEYWORDS = $(1) $(foreach keyword,$(_KEYWORDS), $(addsuffix .$(keyword), $(1)))
612
613
614## Generic inheritance for use with targets templates and tools.
615# @param trg Object to consider for inheriting.
616# @param src_prefix What to prefix the value found in EXTENDS with to get the object.
617# @param load_function Load function for stuff that needs
618# @param properties List of the properties with straight expansion.
619# @param properties_now_l List of the properties with immediate expansion, accumulating on the left side.
620# @param properties_now_r List of the properties with immediate expansion, accumulating on the right side.
621# @param properties_deferred List of the properties with deferred expansion (e.g. function), non-accumulative .
622# @param properties_deferred_l List of the properties with deferred expansion (e.g. function), accumulating on the left side.
623# @param properties_deferred_r List of the properties with deferred expansion (e.g. function), accumulating on the right side.
624define def_inherit
625
626# Load it - loading is a mess, fix.
627ifneq ($(load_function),)
628 local loading := $(patsubst $(src_prefix)%,%,$(trg))
629 $(evalvalctx $(load_function))
630endif
631
632local src := $(strip $($(trg)_EXTENDS))
633ifneq ($(src),)
634 ifndef $(trg)_EXTENDS_STATUS_
635 $(trg)_EXTENDS_STATUS_ := 0
636
637 # Load the source.
638 ifneq ($(load_function),)
639 local loading := $(src)
640 $(evalvalctx $(load_function))
641 endif
642
643 # less typing.
644 local src := $(src_prefix)$(src)
645
646 # Recursivly process the parent (src) if it's inherting from somebody too.
647 ifdef $(src)_EXTENDS
648 ifneq ($($(src)_EXTENDS_STATUS_),42)
649 # 'foreach' will create 'trg' in a new variable context hiding
650 # out current variable. 'src' OTOH will be overwritten.
651 $(foreach trg, $(src), $(evalval def_inherit))
652 local src := $(src_prefix)$(strip $($(trg)_EXTENDS))
653 endif
654 endif
655
656 # Get & check EXTENDS_BY.
657 local by = $(strip $($(trg)_EXTENDS_BY))
658 ifeq ($(by),)
659 local by = overriding
660 else ifn1of ($(by), overriding appending prepending)
661 $(error kBuild: Invalid EXTENDS_BY value '$(by)' on '$(trg)'!)
662 endif
663
664 # Inherit the properties.
665 $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties)), $(eval $(def_inherit_one)))
666 $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties_now_l)), $(eval $(def_inherit_one_$(by)_now_l)))
667 $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties_now_r)), $(eval $(def_inherit_one_$(by)_now_r)))
668 $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties_deferred)), $(eval $(def_inherit_one_$(by)_deferred)))
669 $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties_deferred_l)), $(eval $(def_inherit_one_$(by)_deferred_l)))
670 $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties_deferred_r)), $(eval $(def_inherit_one_$(by)_deferred_r)))
671
672 # Mark the target as done.
673 $(trg)_EXTENDS_STATUS_ := 42
674 else
675 # Check for inheritance loops.
676 ifneq ($($(trg)_EXTENDS_STATUS_),42)
677 $(error kBuild: Target inheritance loop! target=$(trg) $(trg)_EXTENDS_STATUS_=$($(trg)_EXTENDS_STATUS_))
678 endif
679 endif
680endif
681
682# Keyword inheritance.
683$(foreach prefix_keyword, $(join $(_KEYWORDS_PREFIX), $(addprefix :,$(_KEYWORDS_EXTENDS))), $(evalval def_inherit_keyword))
684
685endef # def_inherit
686
687
688#
689# Load global units before doing any inheriting so they can add new properties.
690#
691# This only applies to the guys listed in the global USES since there is
692# no reliable way to deal with things on a target level without first
693# applying templates. So, to avoid having USES mess up all targets,
694# we'll make the global and per-target USES property work differently:
695# The global USES does not apply to targets, just globally.
696#
697
698## Unit load function.
699# @param loading The unit name
700define def_unit_load_function
701ifndef UNIT_$(loading)
702 UNIT_$(loading)_KMK_FILE := $(firstword $(foreach path, $(KBUILD_UNIT_PATHS) $(KBUILD_PATH)/units $(KBUILD_DEFAULT_PATHS), $(wildcard $(path)/$(loading).kmk)))
703 ifeq ($(UNIT_$(loading)_KMK_FILE),)
704 $(error kBuild: Cannot find include file for the unit '$(loading)'! Searched: $(KBUILD_UNIT_PATHS) $(KBUILD_PATH)/units $(KBUILD_DEFAULT_PATHS))
705 endif
706 include $(UNIT_$(loading)_KMK_FILE)
707 ifndef UNIT_$(loading)
708 $(warning kBuild: UNIT_$(loading) was not defined by $(UNIT_$(loading)_KMK_FILE)!)
709 endif
710endif
711endef # def_unit_load_function
712
713$(foreach loading, \
714 $(USES.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \
715 $(USES.$(KBUILD_TARGET_CPU)) \
716 $(USES.$(KBUILD_TARGET_ARCH)) \
717 $(USES.$(KBUILD_TARGET)) \
718 $(USES.$(KBUILD_HOST).$(KBUILD_HOST_ARCH)) \
719 $(USES.$(KBUILD_HOST_CPU)) \
720 $(USES.$(KBUILD_HOST_ARCH)) \
721 $(USES.$(KBUILD_TARGET)) \
722 $(USES.$(KBUILD_TYPE)) \
723 $(USES),$(evalval def_unit_load_function))
724
725
726#
727# Determin all the templates that is being used and make
728# sure they are present before we try collect keywords.
729#
730_TEMPLATES := $(TEMPLATE)
731define def_templates
732ifdef $(target)_TEMPLATE
733 ifneq ("$($(target)_TEMPLATE)","$(strip $($(target)_TEMPLATE))")
734 $$(error kBuild: The template name of target '$(target)' contains tabs ($($(target)_TEMPLATE))). Please remove them)
735 endif
736 _TEMPLATES += $($(target)_TEMPLATE)
737endif
738endef # def_templates
739$(foreach target, $(_ALL_TARGETS), $(eval $(def_templates)))
740_TEMPLATES := $(sort $(_TEMPLATES))
741
742## Template load function.
743# @param loading The template name. This is prefixed.
744define def_templates_load_function
745ifndef TEMPLATE_$(loading)
746 TEMPLATE_$(loading)_KMK_FILE := $(firstword $(foreach path, $(KBUILD_TEMPLATE_PATHS) $(KBUILD_PATH)/templates $(KBUILD_DEFAULT_PATHS), $(wildcard $(path)/$(loading).kmk)))
747 ifeq ($(TEMPLATE_$(loading)_KMK_FILE),)
748 $(error kBuild: Cannot find include file for the template '$(loading)'! Searched: $(KBUILD_TEMPLATE_PATHS) $(KBUILD_PATH)/templates $(KBUILD_DEFAULT_PATHS))
749 endif
750 include $(TEMPLATE_$(loading)_KMK_FILE)
751 ifndef TEMPLATE_$(loading)
752 $(warning kBuild: TEMPLATE_$(loading) was not defined by $(TEMPLATE_$(loading)_KMK_FILE)!)
753 endif
754endif
755endef # def_templates_load_function
756$(foreach loading, $(_TEMPLATES), $(evalval def_templates_load_function))
757
758
759#
760# Determin the keywords required for correct inherting and setup keyword inheritance.
761#
762# This means walking all the lists of immediate template and targets and
763# pick up all the BLD_T* keywords. Since templates that are referenced
764# indirectly in the inheritance hierarchy, the result from this exercise
765# might not be 100% accurate... :-/
766#
767_BLD_TYPES := $(KBUILD_TYPE)
768_BLD_TARGETS := $(KBUILD_TARGET) $(KBUILD_HOSTS)
769_BLD_ARCHES := $(KBUILD_TARGET_ARCH) $(KBUILD_HOST_ARCH)
770_BLD_CPUS := $(KBUILD_TARGET_CPU) $(KBUILD_HOST_CPU)
771
772define def_collect_bld_xyz
773ifdef $(src)_BLD_TYPE
774 ifn1of ($($(src)_BLD_TYPE), $(KBUILD_BLD_TYPES))
775 $(error kBuild: $(src)_BLD_TYPE=$($(src)_BLD_TYPE) not in KBUILD_BLD_TYPES={$(KBUILD_BLD_TYPES)}!)
776 endif
777 _BLD_TYPES += $($(src)_BLD_TYPE)
778endif
779ifdef $(src)_BLD_TRG
780 ifn1of ($($(src)_BLD_TRG), $(KBUILD_OSES))
781 $(error kBuild: $(src)_BLD_TRG=$($(src)_BLD_TRG) not in KBUILD_OSES={$(KBUILD_OSES)}!)
782 endif
783 _BLD_TARGETS += $($(src)_BLD_TRG)
784endif
785ifdef $(src)_BLD_TRG_ARCH
786 ifn1of ($($(src)_BLD_TRG_ARCH), $(KBUILD_ARCHES))
787 $(error kBuild: $(src)_BLD_TRG_ARCH=$($(src)_BLD_TRG_ARCH) not in KBUILD_ARCHES={$(KBUILD_ARCHES)}!)
788 endif
789 _BLD_ARCHES += $($(src)_BLD_TRG_ARCH)
790endif
791ifdef $(src)_BLD_TRG_CPU
792 if1of ($($(src)_BLD_CPU), $(KBUILD_ARCHES) $(KBUILD_OSES) $(KBUILD_BLD_TYPES))
793 $(error kBuild: $(src)_BLD_TRG_CPU=$($(src)_BLD_TRG_CPU) found in KBUILD_ARCHES, KBUILD_OSES or KBUILD_BLD_TYPES!)
794 endif
795 _BLD_CPUS += $($(src)_BLD_TRG_CPU)
796endif
797endef # def_collect_bld_xyz
798$(foreach src, $(addprefix TEMPLATE_, $(_TEMPLATES)) $(_ALL_TARGETS) \
799 ,$(evalval def_collect_bld_xyz))
800
801# Drop duplicate values.
802# WARNING! These list might not include keywords only involved in inheritance.
803_BLD_TYPES := $(sort $(_BLD_TYPES))
804_BLD_TARGETS := $(sort $(_BLD_TARGETS))
805_BLD_ARCHES := $(sort $(_BLD_ARCHES))
806_BLD_CPUS := $(sort $(_BLD_CPUS))
807
808## Look for keywords which extends others and order them.
809# @param keyword
810# @param prefix
811# @param valid
812define def_keyword_ordering
813# Check for EXTENDS, fix and validate it if found.
814local src := $(strip $($(prefix)_$(keyword)_EXTENDS))
815ifneq ($(src),)
816 ifndef $(prefix)_$(keyword)_EXTENDS_STATUS_
817 ifn1of ($(src), $(valid))
818 $(error kBuild: $(keyword) tries to extend unknown keyword '$(src)'! (known = $(valid)))
819 endif
820
821 # Recursivly process the parent (src).
822 ifneq ($($(prefix)_$(src)_EXTENDS_STATUS_),42)
823 $(prefix)_$(keyword)_EXTENDS_STATUS_ := 0
824 # 'foreach' will create 'keyword' in a new variable context hiding
825 # out current variable. 'src' OTOH will be overwritten.
826 $(foreach keyword, $(src), $(evalval def_keyword_ordering))
827 local src := $(strip $($(prefix)_$(keyword)_EXTENDS))
828 endif
829
830 # Check and strip EXTENDS_BY.
831 local by = $(strip $($(prefix)_$(keyword)_EXTENDS_BY))
832 ifeq ($(by),)
833 local by = overriding
834 else ifn1of ($(by), overriding appending prepending)
835 $(error kBuild: Invalid EXTENDS_BY value '$(by)' on '$(keyword)'!)
836 endif
837
838 # Update the attributes with stripped
839 $(prefix)_$(keyword)_EXTENDS_BY := $(by)
840 $(prefix)_$(keyword)_EXTENDS := $(src)
841
842 # Add it to the list and mark it as done.
843 _KEYWORDS_EXTENDS += $(keyword)
844 _KEYWORDS_PREFIX += $(prefix)
845 $(prefix)_$(keyword)_EXTENDS_STATUS_ := 42
846 else
847 # Check for inheritance loops.
848 ifneq ($($(trg)_EXTENDS_STATUS_),42)
849 $(error kBuild: Keyword inheritance loop! keyword=$(keyword) $(prefix)_$(keyword)_EXTENDS_STATUS_=$($(prefix)_$(keyword)_EXTENDS_STATUS_))
850 endif
851 endif
852else
853 # Add it to the ordered list and mark it as done.
854 _KEYWORDS_ORDERED += $(keyword)
855 $(prefix)_$(src)_EXTENDS_STATUS_ := 42
856endif
857endef # def_keyword_ordering
858$(eval-opt-var def_keyword_ordering)
859
860# Look for keywords which extends others and their parents, and from this
861# construct two lists.
862_KEYWORDS_ORDERED :=
863_KEYWORDS_EXTENDS :=
864_KEYWORDS_PREFIX :=
865
866prefix := BLD_TYPE
867valid := $(KBUILD_BLD_TYPES)
868$(foreach keyword, $(_BLD_TYPES) , $(evalval def_keyword_ordering))
869
870prefix := BLD_TRG
871valid := $(KBUILD_OSES)
872$(foreach keyword, $(_BLD_TARGETS), $(evalval def_keyword_ordering))
873
874prefix := BLD_ARCH
875valid := $(KBUILD_ARCHES)
876$(foreach keyword, $(_BLD_ARCHES) , $(evalval def_keyword_ordering))
877
878prefix := BLD_CPU
879valid := $(KBUILD_CPUS)
880$(foreach keyword, $(_BLD_CPUS) , $(evalval def_keyword_ordering))
881
882## @todo Inherit bld_trg.bld_arch for too?
883
884# Construct all the possible keywords.
885_KEYWORDS := $(_KEYWORDS_ORDERED) $(_KEYWORDS_EXTENDS) \
886 $(foreach bld_trg,$(_BLD_TARGETS),$(addprefix $(bld_trg).,$(_BLD_ARCHES)))
887
888ifdef KBUILD_PROFILE_SELF
889 $(evalcall def_profile_self, done keywords)
890endif
891
892
893#
894# Target inheritance.
895#
896# This has to be done on a per target list basis as to avoid adding
897# incorrect properties that will wast memory, time, and may confuse
898# later strictness checks. This also has to be done *before* templates
899# are applied to the targets. Since we're doing that part rather
900# early on, the target inheritance feature is a bit restricted at
901# the moment. However, this will be addressed in a little(?) while.
902#
903
904src_prefix :=
905load_function :=
906properties_deferred_l :=
907properties_deferred_r :=
908
909# Fetches.
910properties := $(PROPS_FETCHES_SINGLE)
911properties_now_l := $(PROPS_FETCHES_ACCUMULATE_L)
912properties_now_r := $(PROPS_FETCHES_ACCUMULATE_R)
913properties_deferred := $(PROPS_FETCHES_DEFERRED)
914$(foreach trg, $(_ALL_FETCHES),$(evalval def_inherit))
915
916## Patches. - not implemented yet.
917#properties := $(PROPS_PATCHES_SINGLE)
918#properties_now_l := $(PROPS_PATCHES_ACCUMULATE_L)
919#properties_now_r := $(PROPS_PATCHES_ACCUMULATE_R)
920#properties_deferred := $(PROPS_PATCHES_DEFERRED)
921#$(foreach trg, $(_ALL_PATCHES),$(evalval def_inherit))
922
923# Programs and build programs.
924properties := $(PROPS_PROGRAMS_SINGLE)
925properties_now_l := $(PROPS_PROGRAMS_ACCUMULATE_L)
926properties_now_r := $(PROPS_PROGRAMS_ACCUMULATE_R)
927properties_deferred := $(PROPS_PROGRAMS_DEFERRED)
928$(foreach trg, $(_ALL_BLDPROGS) $(_ALL_PROGRAMS),$(evalval def_inherit))
929
930# Libraries and import libraries.
931properties := $(PROPS_LIBRARIES_SINGLE)
932properties_now_l := $(PROPS_LIBRARIES_ACCUMULATE_L)
933properties_now_r := $(PROPS_LIBRARIES_ACCUMULATE_R)
934properties_deferred := $(PROPS_LIBRARIES_DEFERRED)
935if1of ($(KBUILD_TARGET), nt os2 win)
936 $(foreach trg, $(_ALL_LIBRARIES) $(_ALL_IMPORT_LIBS),$(evalval def_inherit))
937else
938 $(foreach trg, $(_ALL_LIBRARIES),$(evalval def_inherit))
939endif
940
941# DLLs.
942properties := $(PROPS_DLLS_SINGLE)
943properties_now_l := $(PROPS_DLLS_ACCUMULATE_L)
944properties_now_r := $(PROPS_DLLS_ACCUMULATE_R)
945properties_deferred := $(PROPS_DLLS_DEFERRED)
946if1of ($(KBUILD_TARGET), nt os2 win)
947 $(foreach trg, $(_ALL_DLLS),$(evalval def_inherit))
948else
949 $(foreach trg, $(_ALL_DLLS) $(_ALL_IMPORT_LIBS),$(evalval def_inherit))
950endif
951
952# System modules.
953properties := $(PROPS_SYSMODS_SINGLE)
954properties_now_l := $(PROPS_SYSMODS_ACCUMULATE_L)
955properties_now_r := $(PROPS_SYSMODS_ACCUMULATE_R)
956properties_deferred := $(PROPS_SYSMODS_DEFERRED)
957$(foreach trg, $(_ALL_SYSMODS),$(evalval def_inherit))
958
959# Misc binaries.
960properties := $(PROPS_MISCBINS_SINGLE)
961properties_now_l := $(PROPS_MISCBINS_ACCUMULATE_L)
962properties_now_r := $(PROPS_MISCBINS_ACCUMULATE_R)
963properties_deferred := $(PROPS_MISCBINS_DEFERRED)
964$(foreach trg, $(_ALL_MISCBINS),$(evalval def_inherit))
965
966# Installs.
967properties := $(PROPS_INSTALLS_SINGLE)
968properties_now_l := $(PROPS_INSTALLS_ACCUMULATE_L)
969properties_now_r := $(PROPS_INSTALLS_ACCUMULATE_R)
970properties_deferred := $(PROPS_INSTALLS_DEFERRED)
971$(foreach trg, $(_ALL_INSTALLS),$(evalval def_inherit))
972
973ifdef KBUILD_PROFILE_SELF
974 $(evalcall def_profile_self, done target inheritance)
975endif
976
977
978#
979# Template Inheritance.
980#
981# This is much the same as with target inheritance, except we cannot
982# restrict the properties involved since we haven't got a clue which
983# target platforms/archs are using them. But, we can drop the instance
984# expansion we're doing for targets since there won't be any more
985# changes to either the source nor the target templates beyond this
986# exercise.
987#
988
989src_prefix := TEMPLATE_
990load_function := def_templates_load_function
991properties :=
992properties_now_l :=
993properties_now_r :=
994properties_deferred := $(PROPS_SINGLE) $(PROPS_DEFERRED)
995properties_deferred_l := $(PROPS_ACCUMULATE_L)
996properties_deferred_r := $(PROPS_ACCUMULATE_R)
997$(foreach trg, $(addprefix TEMPLATE_,$(_TEMPLATES)),$(evalval def_inherit))
998
999# done inheriting.
1000src_prefix :=
1001load_function :=
1002properties :=
1003properties_now_l :=
1004properties_now_r :=
1005properties_deferred :=
1006properties_deferred_l :=
1007properties_deferred_r :=
1008
1009ifdef KBUILD_PROFILE_SELF
1010 $(evalcall def_profile_self, done template inheritance)
1011endif
1012
1013
1014
1015
1016#
1017# Template/Target Expansion.
1018#
1019# Extend all targets with the values from the template. Doing this up front
1020# allows more generic code and less mess down in the pass 2 target handling.
1021# However it does eat a good deal of memory.
1022#
1023
1024define def_inherit_template_workaround_target
1025local _tmpl := $(firstword $($(target)_TEMPLATE) $(TEMPLATE))
1026local _bld_type := $(firstword $($(target)_BLD_TYPE) $(TEMPLATE_$(_tmpl)_BLD_TYPE) $(KBUILD_TYPE))
1027local _bld_trg := $(firstword $($(target)_BLD_TRG) $(TEMPLATE_$(_tmpl)_BLD_TRG) $(KBUILD_TARGET))
1028local _bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(TEMPLATE_$(_tmpl)_BLD_TRG_ARCH) $(KBUILD_TARGET_ARCH))
1029local _bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(TEMPLATE_$(_tmpl)_BLD_TRG_CPU) $(KBUILD_TARGET_CPU))
1030$(kb-exp-tmpl 1,$(target),$(_bld_trg),$(_bld_trg_arch),$(_bld_trg_cpu),$(_bld_type))
1031endef # def_inherit_template_workaround_target
1032#$(kb-exp-tmpl 1,$(_ALL_TARGET_TARGETS),$(KBUILD_TARGET),$(KBUILD_TARGET_ARCH),$(KBUILD_TARGET_CPU),$(KBUILD_TYPE))
1033$(foreach target,$(_ALL_TARGET_TARGETS),$(evalval def_inherit_template_workaround_target))
1034
1035define def_inherit_template_workaround_host
1036local _tmpl := $(firstword $($(target)_TEMPLATE) $(TEMPLATE))
1037local _bld_type := $(firstword $($(target)_BLD_TYPE) $(TEMPLATE_$(_tmpl)_BLD_TYPE) $(KBUILD_TYPE))
1038local _bld_trg := $(firstword $($(target)_BLD_TRG) $(TEMPLATE_$(_tmpl)_BLD_TRG) $(KBUILD_HOST))
1039local _bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(TEMPLATE_$(_tmpl)_BLD_TRG_ARCH) $(KBUILD_HOST_ARCH))
1040local _bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(TEMPLATE_$(_tmpl)_BLD_TRG_CPU) $(KBUILD_HOST_CPU))
1041$(kb-exp-tmpl 1,$(target),$(_bld_trg),$(_bld_trg_arch),$(_bld_trg_cpu),$(_bld_type))
1042endef # def_inherit_template_workaround_target
1043#$(kb-exp-tmpl 1,$(_ALL_HOST_TARGETS),$(KBUILD_HOST),$(KBUILD_HOST_ARCH),$(KBUILD_HOST_CPU),$(KBUILD_TYPE))
1044$(foreach target,$(_ALL_HOST_TARGETS),$(evalval def_inherit_template_workaround_host))
1045
1046ifdef KBUILD_PROFILE_SELF
1047 $(evalcall def_profile_self, done template/target expansion)
1048endif
1049
1050
1051#
1052# Include tools, sdks and units.
1053#
1054# The first part of this exercise is to figure out which TOOLS and SDKS
1055# that should be included.
1056#
1057_TOOLS := $(TOOL.$(KBUILD_TARGET)) $(TOOL.$(KBUILD_TARGET_ARCH)) $(TOOL.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \
1058 $(TOOL.$(KBUILD_HOST)) $(TOOL.$(KBUILD_HOST_ARCH)) $(TOOL.$(KBUILD_HOST).$(KBUILD_HOST_ARCH)) \
1059 $(TOOL)
1060_SDKS := $(SDKS.$(KBUILD_TARGET)) $(SDKS.$(KBUILD_TARGET_ARCH)) $(SDKS.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \
1061 $(SDKS.$(KBUILD_HOST)) $(SDKS.$(KBUILD_HOST_ARCH)) $(SDKS.$(KBUILD_HOST).$(KBUILD_HOST_ARCH)) \
1062 $(SDKS.$(KBUILD_TYPE)) \
1063 $(SDKS)
1064_USES := $(USES.$(KBUILD_TARGET)) $(USES.$(KBUILD_TARGET_ARCH)) $(USES.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \
1065 $(USES.$(KBUILD_HOST)) $(USES.$(KBUILD_HOST_ARCH)) $(USES.$(KBUILD_HOST).$(KBUILD_HOST_ARCH)) \
1066 $(USES.$(KBUILD_TYPE)) \
1067 $(USES)
1068define def_tools_sdks_target_source
1069$(eval _TOOLS += $(foreach prop, $(PROPS_TOOLS), \
1070 $($(source)_$(prop).$(_bld_trg)) \
1071 $($(target)_$(source)_$(prop).$(_bld_trg)) \
1072 $($(source)_$(prop).$(_bld_trg).$(_bld_trg_arch)) \
1073 $($(target)_$(source)_$(prop).$(_bld_trg).$(_bld_trg_arch)) \
1074 $($(source)_$(prop).$(_bld_trg_arch)) \
1075 $($(target)_$(source)_$(prop).$(_bld_trg_arch)) \
1076 $($(source)_$(prop)) \
1077 $($(target)_$(source)_$(prop))))
1078$(eval _SDKS += \
1079 $($(source)_SDKS.$(_bld_trg)) \
1080 $($(target)_$(source)_SDKS.$(_bld_trg)) \
1081 $($(source)_SDKS.$(_bld_trg).$(_bld_trg_arch)) \
1082 $($(target)_$(source)_SDKS.$(_bld_trg).$(_bld_trg_arch)) \
1083 $($(source)_SDKS.$(_bld_trg_arch)) \
1084 $($(target)_$(source)_SDKS.$(_bld_trg_arch)) \
1085 $($(source)_SDKS.$(KBUILD_TYPE)) \
1086 $($(target)_$(source)_SDKS.$(KBUILD_TYPE)) \
1087 $($(source)_SDKS) \
1088 $($(target)_$(source)_SDKS))
1089$(eval _USES += \
1090 $($(source)_USES.$(_bld_trg)) \
1091 $($(target)_$(source)_USES.$(_bld_trg)) \
1092 $($(source)_USES.$(_bld_trg).$(_bld_trg_arch)) \
1093 $($(target)_$(source)_USES.$(_bld_trg).$(_bld_trg_arch)) \
1094 $($(source)_USES.$(_bld_trg_arch)) \
1095 $($(target)_$(source)_USES.$(_bld_trg_arch)) \
1096 $($(source)_USES.$(KBUILD_TYPE)) \
1097 $($(target)_$(source)_USES.$(KBUILD_TYPE)) \
1098 $($(source)_USES) \
1099 $($(target)_$(source)_USES))
1100endef # def_tools_sdks_target_source
1101$(eval-opt-var def_tools_sdks_target_source)
1102
1103define def_tools_sdks_target
1104local _bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE))
1105local _bld_trg := $(firstword $($(target)_BLD_TRG) $(bld_trg))
1106local _bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(bld_trg_arch))
1107local _bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(bld_trg_cpu))
1108
1109$(eval _TOOLS += $(foreach prop, $(PROPS_TOOLS), \
1110 $($(target)_$(prop).$(_bld_trg)) \
1111 $($(target)_$(prop).$(_bld_trg_arch)) \
1112 $($(target)_$(prop).$(_bld_trg).$(_bld_trg_arch)) \
1113 $($(target)_$(prop))))
1114$(eval _SDKS += \
1115 $($(target)_SDKS.$(_bld_trg)) \
1116 $($(target)_SDKS.$(_bld_trg_arch)) \
1117 $($(target)_SDKS.$(_bld_trg).$(_bld_trg_arch)) \
1118 $($(target)_SDKS))
1119$(eval _USES += \
1120 $($(target)_USES.$(_bld_trg)) \
1121 $($(target)_USES.$(_bld_trg_arch)) \
1122 $($(target)_USES.$(_bld_trg).$(_bld_trg_arch)) \
1123 $($(target)_USES))
1124$(foreach source, \
1125 $($(target)_SOURCES.$(_bld_trg)) \
1126 $($(target)_SOURCES.$(_bld_trg_arch)) \
1127 $($(target)_SOURCES.$(_bld_trg).$(_bld_trg_arch)) \
1128 $($(target)_SOURCES.$(_bld_trg_cpu)) \
1129 $($(target)_SOURCES.$(_bld_type)) \
1130 $($(target)_SOURCES) \
1131 , $(evalval def_tools_sdks_target_source))
1132endef # def_tools_sdks_target
1133$(eval-opt-var def_tools_sdks_target)
1134
1135define def_tools_srcname_target
1136local _bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE))
1137local _bld_trg := $(firstword $($(target)_BLD_TRG) $(bld_trg))
1138local _bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(bld_trg_arch))
1139local _bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(bld_trg_cpu))
1140
1141$(foreach source, $(notdir\
1142 $($(target)_SOURCES.$(_bld_trg)) \
1143 $($(target)_SOURCES.$(_bld_trg_arch)) \
1144 $($(target)_SOURCES.$(_bld_trg).$(_bld_trg_arch)) \
1145 $($(target)_SOURCES.$(_bld_trg_cpu)) \
1146 $($(target)_SOURCES.$(_bld_type)) \
1147 $($(target)_SOURCES) \
1148 ), $(evalval def_tools_sdks_target_source))
1149endef # def_tools_srcname_target
1150$(eval-opt-var def_tools_srcname_target)
1151
1152bld_trg := $(KBUILD_TARGET)
1153bld_trg_arch := $(KBUILD_TARGET_ARCH)
1154bld_trg_cpu := $(KBUILD_TARGET_CPU)
1155$(foreach target, $(_ALL_TARGET_TARGETS), $(evalval def_tools_sdks_target))
1156$(foreach target, $(_ALL_SRCNAME_TARGETS), $(evalval def_tools_srcname_target))
1157
1158bld_trg := $(KBUILD_HOST)
1159bld_trg_arch := $(KBUILD_HOST_ARCH)
1160bld_trg_cpu := $(KBUILD_HOST_CPU)
1161$(foreach target, $(_ALL_HOST_TARGETS), $(evalval def_tools_sdks_target))
1162
1163_TOOLS := $(sort $(_TOOLS))
1164_SDKS := $(sort $(_SDKS))
1165
1166## Tool load function.
1167# @param loading The tool name
1168define def_tools_load_function
1169ifndef TOOL_$(loading)
1170 TOOL_$(loading)_KMK_FILE := $(firstword $(foreach path, $(KBUILD_TOOL_PATHS) $(KBUILD_PATH)/tools $(KBUILD_DEFAULT_PATHS), $(wildcard $(path)/$(loading).kmk)))
1171 ifeq ($(TOOL_$(loading)_KMK_FILE),)
1172 $(error kBuild: Cannot find include file for the tool '$(loading)'! Searched: $(KBUILD_TOOL_PATHS) $(KBUILD_PATH)/tools $(KBUILD_DEFAULT_PATHS))
1173 endif
1174 include $(TOOL_$(loading)_KMK_FILE)
1175 ifndef TOOL_$(loading)
1176 $(warning kBuild: TOOL_$(loading) was not defined by $(TOOL_$(loading)_KMK_FILE)!)
1177 endif
1178endif
1179endef # def_tools_include
1180
1181## SDK load function.
1182# @param loading The tool name
1183define def_sdk_load_function
1184ifndef SDK_$(loading)
1185 SDK_$(loading)_KMK_FILE := $(firstword $(foreach path, $(KBUILD_SDK_PATHS) $(KBUILD_PATH)/sdks $(KBUILD_DEFAULT_PATHS), $(wildcard $(path)/$(loading).kmk)))
1186 ifeq ($(SDK_$(loading)_KMK_FILE),)
1187 $(error kBuild: Cannot find include file for the SDK '$(loading)'! Searched: $(KBUILD_SDK_PATHS) $(KBUILD_PATH)/sdks $(KBUILD_DEFAULT_PATHS))
1188 endif
1189 include $(SDK_$(loading)_KMK_FILE)
1190 ifndef SDK_$(loading)
1191 $(warning kBuild: SDK_$(loading) was not defined by $(SDK_$(loading)_KMK_FILE)!)
1192 endif
1193endif
1194endef # def_sdk_load_function
1195
1196
1197properties :=
1198properties_now_l :=
1199properties_now_r :=
1200properties_deferred := $(PROPS_SINGLE) $(PROPS_DEFERRED)
1201properties_deferred_l := $(PROPS_ACCUMULATE_L)
1202properties_deferred_r := $(PROPS_ACCUMULATE_R)
1203
1204src_prefix := SDK_
1205load_function := def_sdk_load_function
1206$(foreach trg, $(addprefix SDK_,$(_SDKS)), $(evalval def_inherit))
1207
1208properties_deferred := $(PROPS_SINGLE) $(PROPS_DEFERRED) $(PROPS_TOOLS_ONLY)
1209src_prefix := TOOL_
1210load_function := def_tools_load_function
1211$(foreach trg, $(addprefix TOOL_,$(_TOOLS)), $(evalval def_inherit))
1212
1213# done inheriting.
1214src_prefix :=
1215load_function :=
1216properties :=
1217properties_now_l :=
1218properties_now_r :=
1219properties_deferred :=
1220properties_deferred_l :=
1221properties_deferred_r :=
1222
1223# No inheriting for the uses, they're just global 'code'.
1224$(foreach loading, $(_USES), $(evalval def_unit_load_function))
1225
1226
1227ifdef KBUILD_PROFILE_SELF
1228 $(evalcall def_profile_self, done tools + sdks + units)
1229endif
1230
1231
1232
1233#
1234#
1235# Target lists - Pass 1
1236#
1237# This pass is for defining variables that might be referenced in
1238# properties of other targets.
1239#
1240#
1241
1242# Don't do anything for fetch targets (yet).
1243
1244##
1245# Link prolog for Pass 1.
1246#
1247# @param $(target) Normalized target name.
1248# @param $(EXT) EXE,DLL,SYS,LIB.
1249# @param $(EXTPRE) HOST or nothing.
1250# @param $(definst) The default _INST value.
1251# @param $(tool_prefix) LD or AR.
1252# @param $(bld_trg_base_var) TARGET or PLATFORM.
1253define def_pass1_link_common
1254
1255local bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE))
1256local bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_$(bld_trg_base_var)))
1257local bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_$(bld_trg_base_var)_ARCH))
1258local bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_$(bld_trg_base_var)_CPU))
1259
1260local tool := $(call _TARGET_TOOL,$(target),$(tool_prefix))
1261local name := $(firstword\
1262 $($(target)_NAME.$(bld_trg).$(bld_trg_arch).$(bld_type))\
1263 $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\
1264 $($(target)_NAME.$(bld_trg).$(bld_type))\
1265 $($(target)_NAME.$(bld_trg_arch))\
1266 $($(target)_NAME.$(bld_trg))\
1267 $($(target)_NAME.$(bld_type))\
1268 $($(target)_NAME)\
1269 $(target))
1270local outbase := $(call TARGET_BASE,$(name),$(target))
1271$(target)_0_OUTDIR:= $(patsubst %/,%,$(dir $(outbase)))
1272$(call KB_FN_ASSIGN_DEPRECATED,PATH_$(target),$($(target)_0_OUTDIR), $(target)_0_OUTDIR)
1273
1274## @todo fix the fun at the last line (AR != LIB => mess).
1275local suff := $(firstword \
1276 $($(target)_$(EXT)SUFF.$(bld_trg).$(bld_trg_arch))\
1277 $($(target)_$(EXT)SUFF.$(bld_trg))\
1278 $($(target)_$(EXT)SUFF)\
1279 $(TOOL_$(tool)_$(tool_prefix)$(EXT)SUFF.$(bld_trg).$(bld_trg_arch))\
1280 $(TOOL_$(tool)_$(tool_prefix)$(EXT)SUFF.$(bld_trg))\
1281 $(TOOL_$(tool)_$(tool_prefix)$(EXT)SUFF)\
1282 $(if $(eq $(tool_prefix),AR),$(SUFF_LIB),$($(EXTPRE)SUFF_$(EXT))) )
1283local out := $(outbase)$(suff)
1284
1285# Object directory target variable.
1286$(target)_1_TARGET := $(out)
1287$(call KB_FN_ASSIGN_DEPRECATED,TARGET_$(target),$($(target)_1_TARGET), $(target)_1_TARGET)
1288
1289# Staging and install directory target variables.
1290local insttype := $(firstword \
1291 $($(target)_INSTTYPE) \
1292 $($(target)_INSTTYPE.$(bld_trg)) \
1293 $($(target)_INSTTYPE.$(bld_trg).$(bld_trg_arch)) \
1294 $($(target)_INSTTYPE.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
1295 $($(target)_INSTTYPE.$(bld_trg_arch)) \
1296 $($(target)_INSTTYPE.$(bld_trg_cpu)) \
1297 $($(target)_INSTTYPE.$(bld_type)) \
1298 )
1299ifeq ($(insttype),)
1300 ifneq ($(firstword \
1301 $($(target)_NOINST) \
1302 $($(target)_NOINST.$(bld_trg)) \
1303 $($(target)_NOINST.$(bld_trg).$(bld_trg_arch)) \
1304 $($(target)_NOINST.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
1305 $($(target)_NOINST.$(bld_trg_arch)) \
1306 $($(target)_NOINST.$(bld_trg_cpu)) \
1307 $($(target)_NOINST.$(bld_type)) ),)
1308 local insttype := none
1309 else
1310 local insttype := both
1311 endif
1312endif
1313ifn1of ($(insttype), none both stage)
1314 $(error kBuild: Unknown value '$(insttype)' for '$(target)_INSTTYPE'. Valid values are 'none', 'both' and 'stage'.)
1315endif
1316$(target)_1_INSTTYPE := $(insttype)
1317
1318if1of ($(insttype), stage both)
1319 local stage := $(strip $(firstword \
1320 $($(target)_STAGE.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
1321 $($(target)_INST.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
1322 $($(target)_STAGE.$(bld_trg).$(bld_trg_arch)) \
1323 $($(target)_INST.$(bld_trg).$(bld_trg_arch)) \
1324 $($(target)_STAGE.$(bld_trg).$(bld_type)) \
1325 $($(target)_INST.$(bld_trg).$(bld_type)) \
1326 $($(target)_STAGE.$(bld_trg_arch)) \
1327 $($(target)_INST.$(bld_trg_arch)) \
1328 $($(target)_STAGE.$(bld_trg)) \
1329 $($(target)_INST.$(bld_trg)) \
1330 $($(target)_STAGE.$(bld_type)) \
1331 $($(target)_INST.$(bld_type)) \
1332 $($(target)_STAGE) \
1333 $($(target)_INST) \
1334 $(definst) ))
1335 $(target)_1_STAGE := $(stage)
1336 $(target)_1_STAGE_TARGET := $(PATH_STAGE)/$(stage)$(notdir $(out))
1337else
1338 $(target)_1_STAGE :=
1339 $(target)_1_STAGE_TARGET :=
1340endif
1341INSTARGET_$(target) := $($(target)_1_STAGE_TARGET)
1342
1343if1of ($(insttype), both)
1344 local inst := $(strip $(firstword \
1345 $($(target)_INST.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
1346 $($(target)_INST.$(bld_trg).$(bld_trg_arch)) \
1347 $($(target)_INST.$(bld_trg).$(bld_type)) \
1348 $($(target)_INST.$(bld_trg_arch)) \
1349 $($(target)_INST.$(bld_trg)) \
1350 $($(target)_INST.$(bld_type)) \
1351 $($(target)_INST) \
1352 $(definst) ))
1353 $(target)_1_INST := $(inst)
1354 $(target)_1_INST_TARGET := $(PATH_INS)/$(inst)$(notdir $(out))
1355else
1356 $(target)_1_INST :=
1357 $(target)_1_INST_TARGET :=
1358endif
1359
1360endef # def_pass1_link_common
1361$(eval-opt-var def_pass1_link_common)
1362
1363
1364#
1365# BLDPROGS (Pass 1)
1366#
1367define def_pass1_bldprog
1368# set NOINST if not forced installation before doing the usual stuff.
1369ifndef $(target)_INST
1370$(target)_INSTTYPE := none
1371endif
1372$(evalval def_pass1_link_common)
1373endef
1374
1375EXT := EXE
1376EXTPRE := HOST
1377definst := $(INST_BIN)
1378tool_prefix := LD
1379bld_trg_base_var := PLATFORM
1380$(foreach target, $(_ALL_BLDPROGS), \
1381 $(evalval def_pass1_bldprog))
1382
1383
1384#
1385# LIBRARIES (Pass 1)
1386#
1387EXT := LIB
1388EXTPRE :=
1389definst := $(INST_LIB)
1390tool_prefix := AR
1391bld_trg_base_var := TARGET
1392$(foreach target, $(_ALL_LIBRARIES), \
1393 $(evalval def_pass1_link_common))
1394
1395
1396#
1397# DLLS (Pass 1)
1398#
1399EXT := DLL
1400EXTPRE :=
1401definst := $(INST_DLL)
1402tool_prefix := LD
1403bld_trg_base_var := TARGET
1404$(foreach target, $(_ALL_DLLS), \
1405 $(evalval def_pass1_link_common))
1406
1407
1408#
1409# IMPORT LIBRARIES (Pass 1)
1410#
1411# - On OS/2 and windows these are libraries.
1412# - On other platforms they are fake DLLs.
1413#
1414if1of ($(KBUILD_TARGET), nt os2 win win64 win32)
1415 EXT := LIB
1416 EXTPRE :=
1417 definst := $(INST_LIB)
1418 tool_prefix := AR
1419 bld_trg_base_var := TARGET
1420 $(foreach target, $(_ALL_IMPORT_LIBS), \
1421 $(evalval def_pass1_link_common))
1422else
1423 EXT := DLL
1424 EXTPRE :=
1425 definst := $(INST_DLL)
1426 tool_prefix := LD
1427 bld_trg_base_var := TARGET
1428 $(foreach target, $(_ALL_IMPORT_LIBS), \
1429 $(evalval def_pass1_link_common))
1430endif
1431
1432
1433#
1434# PROGRAMS (Pass 1)
1435#
1436EXT := EXE
1437EXTPRE :=
1438definst := $(INST_BIN)
1439tool_prefix := LD
1440bld_trg_base_var := TARGET
1441$(foreach target, $(_ALL_PROGRAMS), \
1442 $(evalval def_pass1_link_common))
1443
1444
1445#
1446# SYSMODS (Pass 1)
1447#
1448EXT := SYS
1449EXTPRE :=
1450definst := $(INST_SYS)
1451tool_prefix := LD
1452bld_trg_base_var := TARGET
1453$(foreach target, $(_ALL_SYSMODS), \
1454 $(evalval def_pass1_link_common))
1455
1456
1457#
1458# MISCBINS (Pass 1)
1459#
1460EXT := BIN
1461EXTPRE :=
1462definst := $(INST_BIN)
1463tool_prefix := LD
1464bld_trg_base_var := TARGET
1465$(foreach target, $(_ALL_MISCBINS), \
1466 $(evalval def_pass1_link_common))
1467
1468
1469#
1470# INSTALLS (Pass 1)
1471# Note! INSTARGET_* for INSTALLS aren't available until later.
1472#
1473define def_pass1_install
1474local bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE))
1475local bld_trg := $(firstword $($(target)_BLD_TRG) $(KBUILD_TARGET))
1476local bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(KBUILD_TARGET_ARCH))
1477local bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(KBUILD_TARGET_CPU))
1478# _1_TARGET
1479$(target)_1_TARGET := $(PATH_TARGET)/$(target).ins
1480$(call KB_FN_ASSIGN_DEPRECATED,TARGET_$(target),$($(target)_1_TARGET), $(target)_1_TARGET)
1481
1482# Determine and set 1_INSTTYPE.
1483local insttype := $(firstword \
1484 $($(target)_INSTTYPE) \
1485 $($(target)_INSTTYPE.$(bld_trg)) \
1486 $($(target)_INSTTYPE.$(bld_trg).$(bld_trg_arch)) \
1487 $($(target)_INSTTYPE.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
1488 $($(target)_INSTTYPE.$(bld_trg_arch)) \
1489 $($(target)_INSTTYPE.$(bld_trg_cpu)) \
1490 $($(target)_INSTTYPE.$(bld_type)) \
1491 )
1492ifeq ($(insttype),)
1493 ifneq ($(firstword \
1494 $($(target)_NOINST) \
1495 $($(target)_NOINST.$(bld_trg)) \
1496 $($(target)_NOINST.$(bld_trg).$(bld_trg_arch)) \
1497 $($(target)_NOINST.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
1498 $($(target)_NOINST.$(bld_trg_arch)) \
1499 $($(target)_NOINST.$(bld_trg_cpu)) \
1500 $($(target)_NOINST.$(bld_type)) ),)
1501 local insttype := none
1502 else
1503 local insttype := both
1504 endif
1505endif
1506ifn1of ($(insttype), none both stage)
1507 $(error kBuild: Unknown value '$(insttype)' for '$(target)_INSTTYPE'. Valid values are 'none', 'both' and 'stage'.)
1508endif
1509$(target)_1_INSTTYPE := $(insttype)
1510
1511# Determine the actual INST and STAGE sub-dirs to use for this target.
1512if1of ($(insttype), stage both)
1513 local stage := $(strip $(firstword \
1514 $($(target)_STAGE.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
1515 $($(target)_INST.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
1516 $($(target)_STAGE.$(bld_trg).$(bld_trg_arch)) \
1517 $($(target)_INST.$(bld_trg).$(bld_trg_arch)) \
1518 $($(target)_STAGE.$(bld_trg).$(bld_type)) \
1519 $($(target)_INST.$(bld_trg).$(bld_type)) \
1520 $($(target)_STAGE.$(bld_trg_arch)) \
1521 $($(target)_INST.$(bld_trg_arch)) \
1522 $($(target)_STAGE.$(bld_trg)) \
1523 $($(target)_INST.$(bld_trg)) \
1524 $($(target)_STAGE.$(bld_type)) \
1525 $($(target)_INST.$(bld_type)) \
1526 $($(target)_STAGE) \
1527 $($(target)_INST) \
1528 $(definst) ))
1529 $(target)_1_STAGE := $(stage)
1530else
1531 $(target)_1_STAGE = $(error _1_STAGE not used)
1532endif
1533
1534if1of ($(insttype), both)
1535 local inst := $(strip $(firstword \
1536 $($(target)_INST.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
1537 $($(target)_INST.$(bld_trg).$(bld_trg_arch)) \
1538 $($(target)_INST.$(bld_trg).$(bld_type)) \
1539 $($(target)_INST.$(bld_trg_arch)) \
1540 $($(target)_INST.$(bld_trg)) \
1541 $($(target)_INST.$(bld_type)) \
1542 $($(target)_INST) \
1543 $(definst) ))
1544 $(target)_1_INST := $(inst)
1545else
1546 $(target)_1_INST = $(error _1_INST not used)
1547endif
1548
1549# Block properties that we put off setting until pass 2 for INSTALLS.
1550$(target)_1_STAGE_TARGET = $(error The '_1_STAGE_TARGET' property is not present on install targets. Use '_2_STAGE_TARGETS' instead (set by pass 2!).)
1551$(target)_1_INST_TARGET = $(error The '_1_INST_TARGET' property is not present on install targets. Use '_2_INST_TARGETS' instead (set by pass 2!).)
1552INSTARGET_$(target) = $(error The 'INSTARGET_' is deprecated and besides, it is being accessed to early. Consider '_2_STAGE_TARGETS' or '_2_INST_TARGETS'.)
1553
1554# INSTARGET_ later.
1555# PATH_*
1556local outbase := $(call TARGET_BASE,$(target),$(target))
1557$(target)_0_OUTDIR := $(patsubst %/,%,$(dir $(outbase)))
1558$(call KB_FN_ASSIGN_DEPRECATED,PATH_$(target),$($(target)_0_OUTDIR), $(target)_0_OUTDIR)
1559endef # def_pass1_install
1560$(eval-opt-var def_pass1_install)
1561
1562$(foreach target, $(_ALL_INSTALLS), \
1563 $(evalval def_pass1_install))
1564
1565ifdef KBUILD_PROFILE_SELF
1566 $(evalcall def_profile_self, done pass 1)
1567endif
1568
1569
1570
1571
1572#
1573#
1574# Target lists - Pass 2
1575#
1576#
1577
1578
1579## @page pg_fetches Fetching Tools, Sources and Similar.
1580#
1581# The targets listed in the the FETCHES target list have the following attributes:
1582# SOURCES
1583# INST
1584# FETCHTOOL
1585# FETCHFLAGS
1586# FETCHDIR
1587# UNPACKTOOL
1588# UNPACKFLAGS
1589#
1590# As usual the target name is an alias for 'creating' the target. Other
1591# aliases are:
1592# pass_fetches
1593# fetch
1594# unfetch
1595# download
1596# unpack
1597#
1598# @remark
1599#
1600# This is a little bit complex because we must guarantee that if a source file
1601# changes only sligtly we must refetch it and to a proper unpacking of it. It
1602# is also a desire that fetched archives and unpacked files can be deleted to
1603# save space.
1604#
1605# Thus, we must be able to cleanup what we've unpacked should any of the
1606# sources be removed. We do this by maintaining a file listing the files
1607# and directories that was unpacked. This operation is named 'unfetch'.
1608#
1609# We make use of the SIZE and MD5 attributes for each of the sources to
1610# create a digest that is stored in the primary target file. Subsequent
1611# runswill compare their digest with it to decide if a refetch is required.
1612# When a refetch is found necessary, an 'unfetch' is performed first to
1613# clean out old files and directores. Note even changes in source order
1614# will cause a refetch due to the way the digest is constructed and
1615# evaluated.
1616#
1617# By not depending directly on the archives (nor on any unpacked files)
1618# but on a goal made up from the archive name, size and md5, we allow
1619# the user to delete the archives. Naturally, this means we'll have to
1620# check and fetch missing archives before attempting to unpack them.
1621#
1622# @remark
1623#
1624# This feature will *NOT* work correctly with vanilla GNU make becuase
1625# it makes use of includedep to avoid too many unnecessary files.
1626#
1627# @todo
1628# 0. Move the fetches out into a unit.
1629# 1. Download corruption / continuation.
1630# 2. It's quite possible that there is one too many indirect dependency now...
1631#
1632
1633## generates the fetch rule
1634define def_fetch_src_fetch_rule
1635# Indirect goal for downloading something.
1636.PRECIOUS: $(out)
1637$(out) + $($(target)_$(srcname)_FETCH_2_OUTPUT) +| $($(target)_$(srcname)_FETCH_2_OUTPUT_MAYBE) : \
1638 | $($(target)_$(srcname)_FETCH_2_DEPORD)
1639 %$$(call MSG_FETCH_DL,$(target),$(source),$(out))
1640 @## @todo do fancy stuff like download continuation.
1641 $$(QUIET)$$(RM) -f -- $(out)
1642 $(cmds)
1643 $$(QUIET)$(if $(md5),$$(MD5SUM_EXT) -b -C $(md5) $(out))
1644
1645
1646
1647# Intermediate goal for making sure the md5 and size matches. it will (re) fetch the archive if necessary.
1648$(out).checked_$(md5)_$(size): $($(target)_$(srcname)_FETCH_2_DEPEND) | $($(target)_$(srcname)_FETCH_2_DEPORD)
1649 %$$(call MSG_FETCH_CHK,$(target),$(source),$(out))
1650 $$(QUIET)$$(RM) -f -- $$@
1651 @# (re)fetch the file if it doesn't exist or if it doesn't matches the md5.
1652 @## @todo do fancy stuff like download continuation.
1653 $$(QUIET)( test -f $(out) && $(if $(md5),$$(MD5SUM_EXT) -b -C $(md5) $(out), true) ) \
1654 || ( $$(RM_EXT) -f $(out) \
1655 && $$(MAKE) $(out) -f $(MAKEFILE) --no-print-directory )
1656 $$(QUIET2)$$(APPEND) $$@
1657
1658_TARGET_$(target)_FETCHED += $(out) $(out).checked_$(md5)_$(size)
1659
1660# Just a little precaution.
1661.NOTPARALLEL: $(out) $(out).checked_$(md5)_$(size)
1662
1663endef # def_fetch_src_fetch_rule
1664$(eval-opt-var def_fetch_src_fetch_rule)
1665
1666## generates the unpack rule
1667define def_fetch_src_unpack_rule
1668# This is the unpack rule. it has an order-only dependency on the download check.
1669$(out) + $($(target)_$(srcname)_UNPACK_2_OUTPUT) +| $($(target)_$(srcname)_UNPACK_2_OUTPUT_MAYBE) : \
1670 $($(target)_$(srcname)_UNPACK_2_DEPEND) \
1671 | $($(target)_$(srcname)_UNPACK_2_DEPORD) \
1672 $(archive).checked_$(md5)_$(size) \
1673 $(dir $(out))
1674 %$$(call MSG_FETCH_UP,$(target),$(archive),$(inst))
1675 $$(QUIET)$$(RM) -f -- $(out)
1676 $$(QUIET)$$(MKDIR) -p -- $(dir $(out))
1677 @# if the source archive doesn't exist fetch it (may have been deleted to save space).
1678 $$(QUIET)test -f $(archive) \
1679 || ( $$(RM_EXT) -f $(archive).checked_$(md5)_$(size) \
1680 && $$(MAKE) $(archive).checked_$(md5)_$(size) -f $(MAKEFILE) --no-print-directory )
1681 $(cmds)
1682 $$(QUIET2)$$(APPEND) $(out) $(notdir $(archive).checked_$(md5)_$(size))
1683 $$(QUIET2)$$(APPEND) $(out) $(notdir $(out))
1684
1685$(eval _TARGET_$(target)_UNPACKED += $(out))
1686_TARGET_$(target)_DIGEST := $(_TARGET_$(target)_DIGEST)-$(srcname)_$(md5)_$(size)
1687
1688.NOTPARALLEL: $(out)
1689
1690endef # def_fetch_src_unpack_rule
1691$(eval-opt-var def_fetch_src_unpack_rule)
1692
1693## Processes a fetch source
1694#
1695define def_fetch_src
1696#$ (warning dbg: def_fetch_src: source='$(source)' target='$(target)')
1697
1698# common
1699local srcname := $(notdir $(source))
1700local inst := $(firstword \
1701 $($(target)_$(source)_INST)\
1702 $($(target)_$(srcname)_INST)\
1703 $($(source)_INST)\
1704 $($(srcname)_INST)\
1705 $($(target)_INST)\
1706)
1707ifneq ($(patsubst %/,ok,$(inst)),ok)
1708$(error kBuild: Bad or missing INST property for source '$(source)' in target '$(target)': $(inst))
1709endif
1710## @todo Install-revamp: FIXME
1711INSTARGET_$(target)_$(srcname) := $(inst)
1712local fetchdir := $(firstword \
1713 $($(target)_$(source)_FETCHDIR)\
1714 $($(target)_$(srcname)_FETCHDIR)\
1715 $($(source)_FETCHDIR)\
1716 $($(srcname)_FETCHDIR)\
1717 $($(target)_FETCHDIR)\
1718 $(FETCHDIR)\
1719 $(PATH_TARGET)\
1720)
1721local deps := \
1722 $($(target)_$(source)_DEPS)\
1723 $($(target)_$(srcname)_DEPS)\
1724 $($(source)_DEPS)\
1725 $($(srcname)_DEPS)\
1726 $($(target)_DEPS)
1727local orderdeps := \
1728 $($(target)_$(source)_ORDERDEPS)\
1729 $($(target)_$(srcname)_ORDERDEPS)\
1730 $($(source)_ORDERDEPS)\
1731 $($(srcname)_ORDERDEPS)\
1732 $($(target)_ORDERDEPS)
1733local md5 := $(firstword \
1734 $($(target)_$(source)_MD5)\
1735 $($(target)_$(srcname)_MD5)\
1736 $($(source)_MD5)\
1737 $($(srcname)_MD5)\
1738 $($(target)_MD5)\
1739)
1740local size := $(firstword \
1741 $($(target)_$(source)_SIZE)\
1742 $($(target)_$(srcname)_SIZE)\
1743 $($(source)_SIZE)\
1744 $($(srcname)_SIZE)\
1745 $($(target)_SIZE)\
1746)
1747clean_files += \
1748 $($(target)_$(source)_CLEAN)\
1749 $($(target)_$(srcname)_CLEAN)\
1750 $($(source)_CLEAN)\
1751 $($(srcname)_CLEAN)
1752local dep := # not legal for fetch and unpack tools
1753
1754
1755#
1756# The fetching.
1757#
1758local out := $(fetchdir)/$(srcname)
1759local archive := $(out)
1760$(target)_$(srcname)_1_TARGET = $(TARGET_$(target)_$(srcname))
1761$(call KB_FN_ASSIGN_DEPRECATED,TARGET_$(target)_$(srcname),$(TARGET_$(target)_$(srcname)),TARGET_$(target)_$(srcname))
1762
1763local dirdep := $(call DIRDEP,$(fetchdir))
1764local tool := $(firstword \
1765 $($(target)_$(source)_FETCHTOOL)\
1766 $($(target)_$(srcname)_FETCHTOOL)\
1767 $($(target)_$(source)_TOOL)\
1768 $($(target)_$(srcname)_TOOL)\
1769 $($(source)_FETCHTOOL)\
1770 $($(srcname)_FETCHTOOL)\
1771 $($(source)_TOOL)\
1772 $($(srcname)_TOOL)\
1773 $($(target)_FETCHTOOL)\
1774 $($(target)_TOOL)\
1775 )
1776local flags :=\
1777 $(TOOL_$(tool)_FETCHFLAGS)\
1778 $(FETCHFLAGS)\
1779 $($(target)_FETCHFLAGS)\
1780 $($(srcname)_FETCHFLAGS)\
1781 $($(source)_FETCHFLAGS)\
1782 $($(target)_$(srcname)_FETCHFLAGS)\
1783 $($(target)_$(source)_FETCHFLAGS)
1784
1785#$ (warning dbg: target=$(target) source=$(source) $(srcname)=$(srcname) tool=$(tool) out=$(out) flags=$(flags) dirdep=$(dirdep) fetchdir=$(fetchdir) md5=$(md5) size=$(size))
1786
1787ifndef TOOL_$(tool)_FETCH_CMDS
1788$(warning kBuild: tools: \
1789 1 $($(target)_$(source)_FETCHTOOL)\
1790 2 $($(target)_$(srcname)_FETCHTOOL)\
1791 3 $($(target)_$(source)_TOOL)\
1792 4 $($(target)_$(srcname)_TOOL)\
1793 5 $($(source)_FETCHTOOL)\
1794 6 $($(srcname)_FETCHTOOL)\
1795 7 $($(source)_TOOL)\
1796 8 $($(srcname)_TOOL)\
1797 9 $($(target)_FETCHTOOL)\
1798 10 $($(target)_TOOL) )
1799$(error kBuild: TOOL_$(tool)_FETCH_CMDS is not defined. source=$(source) target=$(target) )
1800endif
1801
1802# call the tool
1803local cmds := $(TOOL_$(tool)_FETCH_CMDS)
1804$(target)_$(srcname)_FETCH_2_OUTPUT := $(TOOL_$(tool)_FETCH_OUTPUT)
1805$(target)_$(srcname)_FETCH_2_OUTPUT_MAYBE := $(TOOL_$(tool)_FETCH_OUTPUT_MAYBE)
1806$(target)_$(srcname)_FETCH_2_DEPEND := $(TOOL_$(tool)_FETCH_DEPEND) $(deps)
1807$(target)_$(srcname)_FETCH_2_DEPORD := $(TOOL_$(tool)_FETCH_DEPORD) $(dirdep) $(orderdeps)
1808
1809# generate the fetch rule.
1810$(eval $(def_fetch_src_fetch_rule))
1811
1812
1813#
1814# The unpacking / installing.
1815#
1816local out := $(inst)_kBuild_$(target)_$(srcname)_unpacked.lst
1817local dirdep := $(call DIRDEP,$(inst))
1818local tool := $(firstword \
1819 $($(target)_$(source)_UNPACKTOOL)\
1820 $($(target)_$(srcname)_UNPACKTOOL)\
1821 $($(target)_$(source)_TOOL)\
1822 $($(target)_$(srcname)_TOOL)\
1823 $($(source)_UNPACKTOOL)\
1824 $($(srcname)_UNPACKTOOL)\
1825 $($(source)_TOOL)\
1826 $($(srcname)_TOOL)\
1827 $($(target)_UNPACKTOOL)\
1828 $($(target)_TOOL) \
1829 )
1830ifeq ($(tool),)
1831local tool := $(toupper $(subst .,,$(suffix $(subst tar.,TAR,$(srcname)))))
1832$(evalval def_tools_include)
1833endif
1834local flags :=\
1835 $(TOOL_$(tool)_UNPACKFLAGS)\
1836 $(UNPACKFLAGS)\
1837 $($(target)_UNPACKFLAGS)\
1838 $($(srcname)_UNPACKFLAGS)\
1839 $($(source)_UNPACKFLAGS)\
1840 $($(target)_$(srcname)_UNPACKFLAGS)\
1841 $($(target)_$(source)_UNPACKFLAGS)
1842
1843#$ (warning dbg: target=$(target) source=$(source) $(srcname)=$(srcname) tool=$(tool) out=$(out) flags=$(flags) dirdep=$(dirdep) inst=$(inst) md5=$(md5) size=$(size))
1844ifndef TOOL_$(tool)_UNPACK_CMDS
1845$(warning kBuild: tools: \
1846 1 $($(target)_$(source)_UNPACKTOOL)\
1847 2 $($(target)_$(srcname)_UNPACKTOOL)\
1848 3 $($(target)_$(source)_TOOL)\
1849 4 $($(target)_$(srcname)_TOOL)\
1850 5 $($(source)_UNPACKTOOL)\
1851 6 $($(srcname)_UNPACKTOOL)\
1852 7 $($(source)_TOOL)\
1853 8 $($(srcname)_TOOL)\
1854 9 $($(target)_UNPACKTOOL)\
1855 10 $($(target)_TOOL) \
1856 11 $(toupper $(subst tar.,TAR,$(ext $(srcname)))) \
1857 )
1858$(error kBuild: TOOL_$(tool)_UNPACK_CMDS is not defined. source=$(source) target=$(target) )
1859endif
1860
1861# call the tool
1862local cmds := $(TOOL_$(tool)_UNPACK_CMDS)
1863$(target)_$(srcname)_UNPACK_2_OUTPUT := $(TOOL_$(tool)_UNPACK_OUTPUT)
1864$(target)_$(srcname)_UNPACK_2_OUTPUT_MAYBE := $(TOOL_$(tool)_UNPACK_OUTPUT_MAYBE)
1865$(target)_$(srcname)_UNPACK_2_DEPEND := $(TOOL_$(tool)_UNPACK_DEPEND) $(deps)
1866$(target)_$(srcname)_UNPACK_2_DEPORD := $(TOOL_$(tool)_UNPACK_DEPORD) $(dirdep) $(orderdeps)
1867
1868# generate the fetch rule.
1869$(eval $(def_fetch_src_unpack_rule))
1870
1871_DIRS += $(inst) $(fetchdir)
1872
1873endef # def_fetch_src
1874$(eval-opt-var def_fetch_src)
1875
1876
1877##
1878# Define the target level rules for a fetch.
1879# @param target
1880# @param out
1881# @param inst
1882# @param _TARGET_$(target)_UNPACKED
1883# @param _TARGET_$(target)_DIGEST
1884# @param bld_trg
1885# @param bld_trg_arch
1886define def_fetch_rules
1887
1888$(out).lst: $(_TARGET_$(target)_UNPACKED) | $(call DIRDEP,$(inst))
1889 %$$(call MSG_FETCH_OK,$(target))
1890 $$(QUIET)$$(RM) -f -- $$@ $$@.tmp
1891 $$(QUIET2)$$(APPEND) $$@.tmp '$(notdir $(out))'
1892 $$(QUIET)$(if $(_TARGET_$(target)_UNPACKED),$$(CAT_EXT) $(_TARGET_$(target)_UNPACKED) >> $$@.tmp)
1893 $$(QUIET)$$(MV) -f -- $$@.tmp $$@
1894
1895$(out)_unfetched:
1896 %$$(call MSG_UNFETCH,$(target))
1897 $$(QUIET)$$(RM) -f -- $$(addprefix $(inst),$$(shell $$(CAT_EXT) $(out).lst 2> /dev/null | $$(SED) -e '/\/$$$$/d'))
1898 $$(QUIET)$$(RMDIR) -p --ignore-fail-on-non-empty --ignore-fail-on-not-exist -- $$(dir $$@) \
1899 $$(addprefix $(inst),$$(sort $$(dir $$(shell $$(CAT_EXT) $(out).lst 2> /dev/null))))
1900 $$(QUIET)$$(RM) -f -- $(out).lst $(out)
1901 $$(QUIET)$$(RMDIR) -p --ignore-fail-on-non-empty --ignore-fail-on-not-exist -- $$(dir $$@)
1902
1903$(out): $(comp-vars _TARGET_$(target)_DIGEST_PREV,_TARGET_$(target)_DIGEST,FORCE) | $(call DIRDEP,$(inst))
1904 $$(QUIET)$$(RM) -f -- $$@
1905 %$$(if $$(_TARGET_$(target)_DIGEST),$$(if $$(eq $$(file-size $(out).lst),-1)\
1906 ,$$(call MSG_REFETCH,$(target)),$$(call MSG_FETCH,$(target))),$$(call MSG_UNFETCH,$(target)))
1907 $$(QUIET)$(TEST_EXT) -f $(out).lst -- $$(MAKE) -f $(MAKEFILE) --no-print-directory $(out)_unfetched
1908 $$(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 $$@))
1909 $$(QUIET2)$$(if $$(_TARGET_$(target)_DIGEST),$$(APPEND) $$@ "_TARGET_$(target)_DIGEST_PREV := $(_TARGET_$(target)_DIGEST)")
1910
1911.NOTPARALLEL: $(out).lst $(out)_unfetched $(out)
1912
1913endef
1914
1915
1916##
1917# Deal with one fetch target.
1918# @param target
1919# @param bld_trg
1920# @param bld_trg_arch
1921define def_fetch
1922# common
1923## @todo Install-revamp: FIXME
1924INSTARGET_$(target) := $($(target)_INST)
1925ifneq ($(patsubst %/,ok,$(INSTARGET_$(target))),ok)
1926$(error kBuild: Bad or missing INST property for target '$(target)'. \
1927 $(target)_INST='$($(target)_INST)' ($(origin $(target)_INST)))
1928endif
1929_TARGET_$(target)_FETCHED :=
1930_TARGET_$(target)_UNPACKED :=
1931_TARGET_$(target)_DIGEST :=
1932local clean_files := $($(target)_CLEAN) $($(target)_CLEAN.$(bld_trg)) $($(target)_CLEAN.$(bld_trg).$(bld_trg_arch)) $($(target)_CLEAN.$(bld_trg_arch)) $($(target)_CLEAN.$(KBUILD_TYPE))
1933
1934# The 'sources'.
1935#$ (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)))
1936$(foreach source,$($(target)_SOURCES) $($(target)_SOURCES.$(KBUILD_TYPE)) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)),\
1937 $(evalval def_fetch_src))
1938
1939# The target.
1940local inst := $(INSTARGET_$(target))
1941local out := $(inst)_kBuild_fetch_$(target)
1942
1943$(eval includedep $(out))
1944
1945$(eval $(def_fetch_rules))
1946
1947# Define the aliases here (doesn't work if defined in def_fetch_rules, just like includedep).
1948$(target): $(out)
1949$(target)_unfetch: $(out)_unfetched
1950
1951_FETCHES += $(out)
1952_DOWNLOADS += $(_TARGET_$(target)_FETCHED)
1953_UNPACKS += $(_TARGET_$(target)_UNPACKED)
1954_UNFETCHES += $(out)_unfetched
1955_DIRS += $(inst)
1956_CLEAN_FILES += $(clean_files)
1957
1958endef
1959$(eval-opt-var def_fetch)
1960
1961# Walk the FETCH target lists.
1962bld_trg := $(KBUILD_TARGET)
1963bld_trg_arch := $(KBUILD_TARGET_ARCH)
1964$(foreach target, $(_ALL_FETCHES), \
1965 $(evalvalctx def_fetch))
1966
1967# some aliases.
1968download: $(_DOWNLOADS)
1969unpack: $(_UNPACKS)
1970fetch: $(_FETCHES)
1971unfetch: $(_UNFETCHES)
1972
1973ifdef KBUILD_PROFILE_SELF
1974 $(evalcall def_profile_self, done fetching targets)
1975endif
1976
1977
1978
1979##
1980## Patching.
1981##
1982##
1983#define def_patch_src
1984#
1985#endef
1986#
1987#
1988## Deal with one patch target.
1989#define def_patch
1990#
1991#$(foreach source,$($(target)_SOURCES) $($(target)_SOURCES.$(KBUILD_TYPE)) $($(target)_SOURCES.$(KBUILD_TARGET)) $($(target)_SOURCES.$(KBUILD_TARGET_ARCH)) $($(target)_SOURCES.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)),\
1992# $(evalval def_patch_src))
1993#
1994#_PATCHES +=
1995#endef
1996#
1997#$(foreach target, $(_ALL_PATCHES), \
1998# $(evalval def_patch))
1999#
2000
2001
2002#
2003# Object processing.
2004#
2005
2006## wrapper the compile command dependency check.
2007ifndef NO_COMPILE_CMDS_DEPS
2008 if1of ($(KMK_FEATURES),dot-must-make)
2009 _DEP_COMPILE_CMDS =
2010 # for debugging: $$(warning MUST_MAKE=$$$$(comp-cmds-ex $$$$($(target)_$(subst :,_,$(source))_CMDS_PREV_), $$$$(commands $$@)) -> $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_CMDS_PREV_),$$(commands $$@),FORCE))
2011 else
2012 _DEP_COMPILE_CMDS = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_CMDS_PREV_),$$(commands $(obj)),FORCE)
2013 endif
2014else
2015 _DEP_COMPILE_CMDS =
2016endif
2017
2018
2019## Generates the rules for building a specific object, and the aliases
2020# for building a source file.
2021# @param $(obj) The object file.
2022define def_target_source_rule
2023ifndef NO_COMPILE_CMDS_DEPS
2024$(obj): .MUST_MAKE = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_CMDS_PREV_),$$(commands $$@),FORCE)
2025endif
2026ifdef TOOL_$(tool)_COMPILE_$(type)_USES_KOBJCACHE
2027_OUT_FILES += $(outbase).koc
2028$(outbase).koc +| $(obj) $($(target)_$(source)_OUTPUT_) $($(target)_$(source)_OUTPUT_MAYBE_) : \
2029 $($(target)_$(source)_DEPEND_) \
2030 $(value _DEP_COMPILE_CMDS) \
2031 | \
2032 $($(target)_$(source)_DEPORD_) \
2033 $$$$($(target)_INTERMEDIATES) \
2034 $$$$($(target)_INTERMEDIATES.$(bld_trg)) \
2035 $$$$($(target)_INTERMEDIATES.$(bld_trg).$(bld_trg_arch)) \
2036 $$$$($(target)_INTERMEDIATES.$(bld_trg_arch)) \
2037 $$$$($(target)_INTERMEDIATES.$(bld_trg_cpu)) \
2038 $$$$($(target)_INTERMEDIATES.$(bld_type))
2039 %$$(call MSG_COMPILE,$(target),$(source),$$@,$(type))
2040else
2041$(obj) + $($(target)_$(source)_OUTPUT_) +| $($(target)_$(source)_OUTPUT_MAYBE_) : \
2042 $($(target)_$(source)_DEPEND_) \
2043 $(value _DEP_COMPILE_CMDS) \
2044 | \
2045 $($(target)_$(source)_DEPORD_) \
2046 $$$$($(target)_INTERMEDIATES) \
2047 $$$$($(target)_INTERMEDIATES.$(bld_trg)) \
2048 $$$$($(target)_INTERMEDIATES.$(bld_trg).$(bld_trg_arch)) \
2049 $$$$($(target)_INTERMEDIATES.$(bld_trg_arch)) \
2050 $$$$($(target)_INTERMEDIATES.$(bld_trg_cpu)) \
2051 $$$$($(target)_INTERMEDIATES.$(bld_type))
2052 %$$(call MSG_COMPILE,$(target),$(source),$$@,$(type))
2053ifdef TOOL_$(tool)_COMPILE_$(type)_DONT_PURGE_OUTPUT
2054 $$(QUIET)$$(RM) -f -- $(dep) $(obj) $($(target)_$(source)_OUTPUT_) $($(target)_OUTPUT_MAYBE_)
2055endif
2056endif
2057
2058$($(target)_$(source)_CMDS_)
2059
2060ifndef NO_COMPILE_CMDS_DEPS
2061 %$$(QUIET2)$$(APPEND) '$(dep)'
2062 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_CMDS_PREV_'
2063 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(obj)'
2064 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
2065endif
2066
2067$(basename $(notdir $(obj))).o: $(obj)
2068$(basename $(notdir $(obj))).obj: $(obj)
2069
2070## @todo make this 'local cmds,output,output_maybe,depend and depord' in 0.2.x or when a new kb-src-one is added.
2071$(target)_$(source)_CMDS_ :=
2072$(target)_$(source)_OUTPUT_ :=
2073$(target)_$(source)_OUTPUT_MAYBE_ :=
2074$(target)_$(source)_DEPEND_ :=
2075$(target)_$(source)_DEPORD_ :=
2076endef # def_target_source_rule
2077$(eval-opt-var def_target_source_rule)
2078
2079
2080## wrapper the link command dependency check.
2081ifndef NO_LINK_CMDS_DEPS
2082 if1of ($(KMK_FEATURES),dot-must-make)
2083 _DEP_LINK_CMDS =
2084 else
2085 _DEP_LINK_CMDS = $$(comp-cmds-ex $$($(target)_CMDS_PREV_),$$(commands $(out)),FORCE)
2086 endif
2087else
2088 _DEP_LINK_CMDS =
2089endif
2090
2091## Generate the link rule for a target.
2092# @param $(target) The normalized target name.
2093# @param $(dirdep) Directories we depend upon begin created before linking.
2094# @param $(dep) The name of the dependency file.
2095# @param $(out)
2096# @param $($(target)_2_OUTPUT) Output files from the link.
2097# @param $($(target)_2_OUTPUT_MAYBE) Output files that the link may perhaps create.
2098# @param $($(target)_2_DEPEND) Dependencies.
2099# @param $($(target)_2_DEPORD) Dependencies which should only affect build order.
2100# @param $(cmds) The link commands.
2101# @param $($(target)_CMDS_PREV_) The link commands from the previous run.
2102define def_link_rule
2103ifndef NO_LINK_CMDS_DEPS
2104$(out): .MUST_MAKE = $$(comp-cmds-ex $$($(target)_CMDS_PREV_),$$(commands $$@),FORCE)
2105endif
2106$(out) + $($(target)_2_OUTPUT) +| $($(target)_2_OUTPUT_MAYBE) : \
2107 $$$$($(target)_2_DEPEND) \
2108 $(value _DEP_LINK_CMDS) \
2109 | \
2110 $$$$($(target)_2_DEPORD)
2111 %$$(call MSG_LINK,$(target),$$@,$(tool_do))
2112 $$(QUIET)$$(RM) -f -- $(dep) $(out) $($(target)_2_OUTPUT) $($(target)_2_OUTPUT_MAYBE)
2113
2114$(cmds)
2115
2116ifndef NO_LINK_CMDS_DEPS
2117 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_CMDS_PREV_'
2118 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
2119 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
2120endif
2121
2122$(basename $(notdir $(out))):: $(out)
2123
2124endef # def_link_rule
2125$(eval-opt-var def_link_rule)
2126
2127
2128## Generate the link & lib install rule
2129# Implicit parameters: target, out, $(target)_1_STAGE_TARGET, mode,
2130# pre_install_cmds, post_install_cmds
2131define def_link_install_rule
2132$($(target)_1_INST_TARGET): $(out) | $(dir $($(target)_1_INST_TARGET))
2133 %$$(call MSG_INST_TRG,$(target),$(out),$$@)
2134 $(pre_install_cmds)
2135
2136 $$(QUIET)$$(INSTALL) $(if $(mode),-m $(mode)) $(if $(uid),-o $(uid)) $(if $(gid),-g $(gid)) -- $(out) $$@
2137 $(post_install_cmds)
2138
2139
2140endef
2141
2142
2143## Generate the link & lib stage installation rule
2144# Implicit parameters: target, out, $(target)_1_STAGE_TARGET, mode,
2145# pre_install_cmds, post_install_cmds
2146define def_link_stage_rule
2147$($(target)_1_STAGE_TARGET): $(out) | $(dir $($(target)_1_STAGE_TARGET))
2148 %$$(call MSG_INST_TRG,$(target),$(out),$$@)
2149 $(pre_install_cmds)
2150
2151 $$(QUIET)$$(INSTALL) $(if $(mode),-m $(mode)) $(if $(uid),-o $(uid)) $(if $(gid),-g $(gid)) -- $(out) $$@
2152 $(post_install_cmds)
2153
2154
2155$(basename $(notdir $(out))):: $($(target)_1_STAGE_TARGET)
2156
2157endef
2158
2159
2160## def_src_handler_*
2161#
2162# @{
2163define def_src_handler_c
2164local type := C
2165 $(kb-src-one 2)
2166endef
2167
2168define def_src_handler_cxx
2169local type := CXX
2170 $(kb-src-one 2)
2171endef
2172
2173define def_src_handler_objc
2174local type := OBJC
2175 $(kb-src-one 2)
2176endef
2177
2178define def_src_handler_objcxx
2179local type := OBJCXX
2180 $(kb-src-one 2)
2181endef
2182
2183define def_src_handler_asm
2184local type := AS
2185 $(kb-src-one 2)
2186endef
2187
2188define def_src_handler_rc
2189local type := RC
2190 $(kb-src-one 2)
2191endef
2192
2193define def_src_handler_obj
2194ifeq ($(defpath),)
2195 $(target)_2_OBJS += $(source)
2196else
2197 $(target)_2_OBJS += $(abspathex $(source), $(defpath))
2198endif
2199endef
2200## @}
2201
2202## Handle one source.
2203# .
2204define def_src_handler_one
2205local suff := $(suffix $(source))
2206local src_handler := $(firstword $(filter $(suff):%, $($(target)_$(source)_SRC_HANDLERS) $($(source)_SRC_HANDLERS) $(target_src_handlers) ))
2207local handler := $(patsubst $(suff):%,%,$(src_handler))
2208ifneq ($(handler),)
2209 $(evalvalctx $(handler))
2210else
2211 othersrc += $(source)
2212endif
2213endef # def_src_handler_one
2214
2215## Generic macro for processing all target sources.
2216# @param $(target) Normalized target name.
2217# @param $(defpath)
2218# @param much-more...
2219# @returns othersrc, $(target)_2_OBJS, ++
2220define def_target_sources
2221local target_src_handlers := $($(target)_SRC_HANDLERS) $(KBUILD_SRC_HANDLERS)
2222$(foreach source,\
2223 $($(target)_SOURCES)\
2224 $($(target)_SOURCES.$(bld_trg))\
2225 $($(target)_SOURCES.$(bld_trg).$(bld_type))\
2226 $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch))\
2227 $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch).$(bld_type))\
2228 $($(target)_SOURCES.$(bld_trg_arch))\
2229 $($(target)_SOURCES.$(bld_trg_cpu))\
2230 $($(target)_SOURCES.$(bld_type))\
2231 ,$(evalval def_src_handler_one) )
2232
2233$(foreach source,\
2234 $($(target)_GEN_SOURCES_)\
2235 $($(target)_GEN_SOURCES_.$(bld_trg))\
2236 $($(target)_GEN_SOURCES_.$(bld_trg).$(bld_type))\
2237 $($(target)_GEN_SOURCES_.$(bld_trg).$(bld_trg_arch))\
2238 $($(target)_GEN_SOURCES_.$(bld_trg).$(bld_trg_arch).$(bld_type))\
2239 $($(target)_GEN_SOURCES_.$(bld_trg_arch))\
2240 $($(target)_GEN_SOURCES_.$(bld_trg_cpu))\
2241 $($(target)_GEN_SOURCES_.$(bld_type))\
2242 ,$(evalval def_src_handler_one) )
2243endef # def_target_sources
2244$(eval-opt-var def_target_sources)
2245
2246
2247##
2248# Function for getting the first defined propert value.
2249#
2250# @param 1 The property name.
2251# @note Implicit parameters: target, bld_trg, bld_trg_arch, bld_trg_cpu, bld_type.
2252# @returns Expanded property value.
2253#
2254## @todo bld_trg_cpu is missing here.
2255define def_fn_prop_get_first_defined
2256ifdef $(target)_$(1).$(bld_trg).$(bld_trg_arch).$(bld_type)
2257 local .RETURN := $($(target)_$(1).$(bld_trg).$(bld_trg_arch).$(bld_type))
2258else ifdef $(target)_$(1).$(bld_trg).$(bld_trg_arch)
2259 local .RETURN := $($(target)_$(1).$(bld_trg).$(bld_trg_arch))
2260else ifdef $(target)_$(1).$(bld_trg).$(bld_type)
2261 local .RETURN := $($(target)_$(1).$(bld_trg).$(bld_type))
2262else ifdef $(target)_$(1).$(bld_trg_arch)
2263 local .RETURN := $($(target)_$(1).$(bld_trg_arch))
2264else ifdef $(target)_$(1).$(bld_trg)
2265 local .RETURN := $($(target)_$(1).$(bld_trg))
2266else ifdef $(target)_$(1).$(bld_type)
2267 local .RETURN := $($(target)_$(1).$(bld_type))
2268else ifdef $(target)_$(1)
2269 local .RETURN := $($(target)_$(1))
2270else ifdef $(1).$(bld_trg).$(bld_trg_arch).$(bld_type)
2271 local .RETURN := $($(1).$(bld_trg).$(bld_trg_arch).$(bld_type))
2272else ifdef $(1).$(bld_trg).$(bld_trg_arch)
2273 local .RETURN := $($(1).$(bld_trg).$(bld_trg_arch))
2274else ifdef $(1).$(bld_trg).$(bld_type)
2275 local .RETURN := $($(1).$(bld_trg).$(bld_type))
2276else ifdef $(1).$(bld_trg_arch)
2277 local .RETURN := $($(1).$(bld_trg_arch))
2278else ifdef $(1).$(bld_trg)
2279 local .RETURN := $($(1).$(bld_trg))
2280else ifdef $(1).$(bld_type)
2281 local .RETURN := $($(1).$(bld_type))
2282else
2283 local .RETURN := $($(1))
2284endif
2285endef # def_fn_prop_get_first_defined
2286
2287
2288## Generic macro for generating the install rule(s) for a target.
2289#
2290# @param $(target) Normalized target name.
2291# @param $(out) The output file.
2292# @param $(definst) The default _INST value.
2293# @param $(typevar) The name of the variable with all the root targets of its type.
2294define def_target_install_only
2295ifneq ($($(target)_1_INSTTYPE),none)
2296 local mode := $(firstword \
2297 $($(target)_MODE.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
2298 $($(target)_MODE.$(bld_trg).$(bld_trg_arch)) \
2299 $($(target)_MODE.$(bld_trg).$(bld_type)) \
2300 $($(target)_MODE.$(bld_trg_arch)) \
2301 $($(target)_MODE.$(bld_trg)) \
2302 $($(target)_MODE.$(bld_type)) \
2303 $($(target)_MODE) )
2304 local uid := $(firstword \
2305 $($(target)_UID.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
2306 $($(target)_UID.$(bld_trg).$(bld_trg_arch)) \
2307 $($(target)_UID.$(bld_trg).$(bld_type)) \
2308 $($(target)_UID.$(bld_trg_arch)) \
2309 $($(target)_UID.$(bld_trg)) \
2310 $($(target)_UID.$(bld_type)) \
2311 $($(target)_UID) )
2312 local gid := $(firstword \
2313 $($(target)_GID.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
2314 $($(target)_GID.$(bld_trg).$(bld_trg_arch)) \
2315 $($(target)_GID.$(bld_trg).$(bld_type)) \
2316 $($(target)_GID.$(bld_trg_arch)) \
2317 $($(target)_GID.$(bld_trg)) \
2318 $($(target)_GID.$(bld_type)) \
2319 $($(target)_GID) )
2320 local pre_install_cmds := $(evalcall def_fn_prop_get_first_defined,PRE_INST_CMDS)
2321 local post_install_cmds := $(evalcall def_fn_prop_get_first_defined,POST_INST_CMDS)
2322
2323 # Generate the rules
2324 ifeq ($($(target)_1_INSTTYPE),both)
2325$(eval $(def_link_install_rule))
2326 _INSTALLS_FILES += $($(target)_1_INST_TARGET)
2327 endif
2328$(eval $(def_link_stage_rule))
2329 _STAGE_FILES += $($(target)_1_STAGE_TARGET)
2330 $(typevar) += $($(target)_1_STAGE_TARGET)
2331else # INSTTYPE == none
2332 $(typevar) += $(out)
2333endif # INSTTYPE == none
2334
2335endef # def_target_install_only
2336
2337
2338
2339#
2340# LIBRARIES
2341#
2342
2343## Library (one).
2344# @param $(target) Normalized library (target) name.
2345define def_lib
2346# library basics
2347## @todo prefix
2348local bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE))
2349local bld_trg := $(firstword $($(target)_BLD_TRG) $(KBUILD_TARGET))
2350local bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(KBUILD_TARGET_ARCH))
2351local bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(KBUILD_TARGET_CPU))
2352local tool := $(call _TARGET_TOOL,$(target),AR)
2353ifeq ($(tool),)
2354$(error kBuild: Library target $(target) does not have a tool defined!)
2355endif
2356local name := $(firstword\
2357 $($(target)_NAME.$(bld_trg).$(bld_trg_arch).$(bld_type))\
2358 $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\
2359 $($(target)_NAME.$(bld_trg).$(bld_type))\
2360 $($(target)_NAME.$(bld_trg_arch))\
2361 $($(target)_NAME.$(bld_trg))\
2362 $($(target)_NAME.$(bld_type))\
2363 $($(target)_NAME)\
2364 $(target))
2365local outbase := $(call TARGET_BASE,$(name),$(target))
2366$(target)_0_OUTDIR:= $(patsubst %/,%,$(dir $(outbase)))
2367$(call KB_FN_ASSIGN_DEPRECATED,PATH_$(target),$($(target)_0_OUTDIR), $(target)_0_OUTDIR)
2368local suff := $(firstword\
2369 $($(target)_LIBSUFF.$(bld_trg).$(bld_trg_arch))\
2370 $($(target)_LIBSUFF.$(bld_trg))\
2371 $($(target)_LIBSUFF)\
2372 $(TOOL_$(tool)_ARLIBSUFF.$(bld_trg).$(bld_trg_arch))\
2373 $(TOOL_$(tool)_ARLIBSUFF.$(bld_trg))\
2374 $(TOOL_$(tool)_ARLIBSUFF)\
2375 $(SUFF_LIB))
2376local out := $(outbase)$(suff)
2377local defpath := $($(target)_DEFPATH)
2378ifeq ($(defpath),)
2379 local defpath := $($(target)_PATH)
2380endif
2381$(target)_1_TARGET:= $(out)
2382$(call KB_FN_ASSIGN_DEPRECATED,TARGET_$(target),$($(target)_1_TARGET), $(target)_1_TARGET)
2383# no local here - must be writable across some foreachs.
2384othersrc :=
2385$(target)_2_OBJS :=
2386
2387# Do units pre source callouts.
2388local units := \
2389 $($(target)_USES.$(bld_trg).$(bld_trg_arch))\
2390 $($(target)_USES.$(bld_trg_arch))\
2391 $($(target)_USES.$(bld_trg))\
2392 $($(target)_USES.$(bld_type))\
2393 $($(target)_USES)
2394$(foreach unit,$(units),$(evalval def_unit_$(unit)_target_pre))
2395
2396# source -> object
2397$(evalval def_target_sources)
2398
2399# library linking
2400local tool := $(call _TARGET_TOOL,$(target),AR)
2401local name := $(firstword\
2402 $($(target)_NAME.$(bld_trg).$(bld_trg_arch).$(bld_type))\
2403 $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\
2404 $($(target)_NAME.$(bld_trg).$(bld_type))\
2405 $($(target)_NAME.$(bld_trg_arch))\
2406 $($(target)_NAME.$(bld_trg))\
2407 $($(target)_NAME.$(bld_type))\
2408 $($(target)_NAME)\
2409 $(target))
2410local outbase := $(call TARGET_BASE,$(name),$(target))
2411local flags :=\
2412 $(TOOL_$(tool)_ARFLAGS)\
2413 $(TOOL_$(tool)_ARFLAGS.$(bld_type))\
2414 $(ARFLAGS)\
2415 $(ARFLAGS.$(bld_type))\
2416 $($(target)_ARFLAGS)\
2417 $($(target)_ARFLAGS.$(bld_type)) \
2418 $($(target)_ARFLAGS.$(bld_trg)) \
2419 $($(target)_ARFLAGS.$(bld_trg_arch)) \
2420 $($(target)_ARFLAGS.$(bld_trg).$(bld_trg_arch)) \
2421 $($(target)_ARFLAGS.$(bld_trg_cpu))
2422local dirdep := $(call DIRDEP,$(dir $(out)))
2423local deps := \
2424 $($(target)_DEPS.$(bld_trg_cpu)) \
2425 $($(target)_DEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
2426 $($(target)_DEPS.$(bld_trg).$(bld_trg_arch)) \
2427 $($(target)_DEPS.$(bld_trg).$(bld_type)) \
2428 $($(target)_DEPS.$(bld_trg_arch)) \
2429 $($(target)_DEPS.$(bld_trg)) \
2430 $($(target)_DEPS.$(bld_type)) \
2431 $($(target)_DEPS) \
2432 $($(target)_LNK_DEPS.$(bld_trg_cpu)) \
2433 $($(target)_LNK_DEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
2434 $($(target)_LNK_DEPS.$(bld_trg).$(bld_trg_arch)) \
2435 $($(target)_LNK_DEPS.$(bld_trg).$(bld_type)) \
2436 $($(target)_LNK_DEPS.$(bld_trg_arch)) \
2437 $($(target)_LNK_DEPS.$(bld_trg)) \
2438 $($(target)_LNK_DEPS.$(bld_type)) \
2439 $($(target)_LNK_DEPS)
2440local orderdeps := \
2441 $($(target)_ORDERDEPS.$(bld_trg_cpu)) \
2442 $($(target)_ORDERDEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
2443 $($(target)_ORDERDEPS.$(bld_trg).$(bld_trg_arch)) \
2444 $($(target)_ORDERDEPS.$(bld_trg).$(bld_type)) \
2445 $($(target)_ORDERDEPS.$(bld_trg_arch)) \
2446 $($(target)_ORDERDEPS.$(bld_trg)) \
2447 $($(target)_ORDERDEPS.$(bld_type)) \
2448 $($(target)_ORDERDEPS) \
2449 $($(target)_LNK_ORDERDEPS.$(bld_trg_cpu)) \
2450 $($(target)_LNK_ORDERDEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
2451 $($(target)_LNK_ORDERDEPS.$(bld_trg).$(bld_trg_arch)) \
2452 $($(target)_LNK_ORDERDEPS.$(bld_trg).$(bld_type)) \
2453 $($(target)_LNK_ORDERDEPS.$(bld_trg_arch)) \
2454 $($(target)_LNK_ORDERDEPS.$(bld_trg)) \
2455 $($(target)_LNK_ORDERDEPS.$(bld_type)) \
2456 $($(target)_LNK_ORDERDEPS)
2457
2458# Adjust paths if we got a default path.
2459ifneq ($(defpath),)
2460 local deps := $(abspathex $(deps),$(defpath))
2461 local orderdeps := $(abspathex $(orderdeps),$(defpath))
2462 othersrc := $(abspathex $(othersrc),$(defpath))
2463endif
2464
2465
2466# Custom pre-link actions.
2467local pre_cmds := $(evalcall def_fn_prop_get_first_defined,PRE_CMDS)
2468local post_cmds := $(evalcall def_fn_prop_get_first_defined,POST_CMDS)
2469
2470# eliminate this guy?
2471local objs = $($(target)_2_OBJS)
2472
2473# dependency file
2474local dep := $(out)$(SUFF_DEP)
2475ifndef NO_LINK_CMDS_DEPS
2476 _DEPFILES_INCLUDED += $(dep)
2477 ifdef KB_HAVE_INCLUDEDEP_QUEUE
2478 includedep-queue $(dep)
2479 else
2480 includedep $(dep)
2481 endif
2482endif
2483
2484# check that the tool is defined.
2485ifndef TOOL_$(tool)_LINK_LIBRARY_CMDS
2486$(warning kBuild: tools: \
2487 1 $($(target)_$(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
2488 2 $($(target)_$(source)TOOL.$(bld_trg)) \
2489 3 $($(target)_$(source)TOOL) \
2490 4 $($(target)_TOOL.$(bld_trg).$(bld_trg_arch)) \
2491 5 $($(target)_TOOL.$(bld_trg)) \
2492 6 $($(target)_TOOL) \
2493 7 $($(source)TOOL) \
2494 8 $($(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
2495 9 $($(source)TOOL.$(bld_trg)) \
2496 10 $(TOOL.$(bld_trg).$(bld_trg_arch)) \
2497 11 $(TOOL.$(bld_trg)) \
2498 12 $(TOOL) )
2499$(error kBuild: TOOL_$(tool)_LINK_LIBRARY_CMDS isn't defined! target=$(target) )
2500endif
2501
2502# call the tool
2503local cmds := $(TOOL_$(tool)_LINK_LIBRARY_CMDS)
2504ifneq ($(pre_cmds),)
2505 local cmds := $(TAB)$(pre_cmds)$(NL)$(TAB)$(cmds)
2506endif
2507ifneq ($(post_cmds),)
2508 local cmds := $(cmds)$(NL)$(TAB)$(post_cmds)
2509endif
2510$(target)_2_OUTPUT := $(TOOL_$(tool)_LINK_LIBRARY_OUTPUT)
2511$(target)_2_OUTPUT_MAYBE := $(TOOL_$(tool)_LINK_LIBRARY_OUTPUT_MAYBE)
2512$(target)_2_DEPEND := $(TOOL_$(tool)_LINK_LIBRARY_DEPEND) $(deps) $($(target)_2_OBJS)
2513$(target)_2_DEPORD := $(TOOL_$(tool)_LINK_LIBRARY_DEPORD) $(dirdep) $(orderdeps)
2514
2515# generate the link rule.
2516$(eval $(def_link_rule))
2517
2518# installing and globals.
2519$(evalval def_target_install_only)
2520
2521_OUT_FILES += $($(target)_2_OUTPUT) $($(target)_2_OUTPUT_MAYBE) $(out)
2522_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))
2523_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))
2524_OBJS += $($(target)_2_OBJS)
2525
2526endef # def_lib
2527$(eval-opt-var def_lib)
2528
2529# Process libraries
2530typevar := _LIBS
2531tool_do := LINK_LIBRARY
2532mode := 0644
2533$(foreach target, $(_ALL_LIBRARIES), $(evalval def_lib))
2534
2535ifdef KBUILD_PROFILE_SELF
2536 $(evalcall def_profile_self, done library targets)
2537endif
2538
2539
2540#
2541# Link operations.
2542#
2543
2544##
2545# Link prolog
2546#
2547# @param $(target) Normalized target name.
2548# @param $(EXT) EXE,DLL,SYS.
2549# @param $(typevar) The name of the variable with all the root targets of its type.
2550define def_link_common
2551# basics
2552local bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE))
2553local bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_$(bld_trg_base_var)))
2554local bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_$(bld_trg_base_var)_ARCH))
2555local bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_$(bld_trg_base_var)_CPU))
2556
2557local tool := $(call _TARGET_TOOL,$(target),LD)
2558local name := $(firstword\
2559 $($(target)_NAME.$(bld_trg).$(bld_trg_arch).$(bld_type))\
2560 $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\
2561 $($(target)_NAME.$(bld_trg).$(bld_type))\
2562 $($(target)_NAME.$(bld_trg_arch))\
2563 $($(target)_NAME.$(bld_trg))\
2564 $($(target)_NAME.$(bld_type))\
2565 $($(target)_NAME)\
2566 $(target))
2567local outbase := $(call TARGET_BASE,$(name),$(target))
2568$(target)_0_OUTDIR:= $(patsubst %/,%,$(dir $(outbase)))
2569$(call KB_FN_ASSIGN_DEPRECATED,PATH_$(target),$($(target)_0_OUTDIR), $(target)_0_OUTDIR)
2570local suff := $(firstword \
2571 $($(target)_$(EXT)SUFF.$(bld_trg).$(bld_trg_arch))\
2572 $($(target)_$(EXT)SUFF.$(bld_trg))\
2573 $($(target)_$(EXT)SUFF)\
2574 $(TOOL_$(tool)_LD$(EXT)SUFF.$(bld_trg).$(bld_trg_arch))\
2575 $(TOOL_$(tool)_LD$(EXT)SUFF.$(bld_trg))\
2576 $(TOOL_$(tool)_LD$(EXT)SUFF)\
2577 $($(EXTPRE)SUFF_$(EXT)) )
2578local out := $(outbase)$(suff)
2579$(target)_1_TARGET:= $(out)
2580$(call KB_FN_ASSIGN_DEPRECATED,TARGET_$(target),$($(target)_1_TARGET), $(target)_1_TARGET)
2581local defpath := $($(target)_DEFPATH)
2582ifeq ($(defpath),)
2583 local defpath := $($(target)_PATH)
2584endif
2585# no local here - must be writable across some foreachs.
2586othersrc :=
2587$(target)_2_OBJS :=
2588
2589# Do units pre source callouts.
2590local units := \
2591 $($(target)_USES.$(bld_trg).$(bld_trg_arch))\
2592 $($(target)_USES.$(bld_trg_arch))\
2593 $($(target)_USES.$(bld_trg))\
2594 $($(target)_USES.$(bld_type))\
2595 $($(target)_USES)
2596$(foreach unit,$(units),$(evalval def_unit_$(unit)_target_pre))
2597
2598# source -> object
2599$(evalval def_target_sources)
2600
2601# more link stuff.
2602local tool := $(call _TARGET_TOOL,$(target),LD)
2603local name := $(firstword\
2604 $($(target)_NAME.$(bld_trg).$(bld_trg_arch).$(bld_type))\
2605 $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\
2606 $($(target)_NAME.$(bld_trg).$(bld_type))\
2607 $($(target)_NAME.$(bld_trg_arch))\
2608 $($(target)_NAME.$(bld_trg))\
2609 $($(target)_NAME.$(bld_type))\
2610 $($(target)_NAME)\
2611 $(target))
2612local outbase := $(call TARGET_BASE,$(name),$(target))
2613local flags :=\
2614 $(TOOL_$(tool)_LDFLAGS)\
2615 $(TOOL_$(tool)_LDFLAGS.$(bld_type))\
2616 $(TOOL_$(tool)_LDFLAGS.$(bld_trg))\
2617 $(TOOL_$(tool)_LDFLAGS.$(bld_trg_arch))\
2618 $(TOOL_$(tool)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\
2619 $(TOOL_$(tool)_LDFLAGS.$(bld_trg_cpu))\
2620 $(foreach sdk, $(SDKS) \
2621 $(SDKS.$(bld_type)) \
2622 $(SDKS.$(bld_trg)) \
2623 $(SDKS.$(bld_trg_arch)) \
2624 $(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 $(LDFLAGS)\
2632 $(LDFLAGS.$(bld_type))\
2633 $(LDFLAGS.$(bld_trg))\
2634 $(LDFLAGS.$(bld_trg_arch))\
2635 $(LDFLAGS.$(bld_trg).$(bld_trg_arch))\
2636 $(LDFLAGS.$(bld_trg_cpu))\
2637 $(foreach sdk, $($(target)_SDKS) \
2638 $($(target)_SDKS.$(bld_type)) \
2639 $($(target)_SDKS.$(bld_trg)) \
2640 $($(target)_SDKS.$(bld_trg_arch)) \
2641 $($(target)_SDKS.$(bld_trg).$(bld_trg_arch)),\
2642 $(SDK_$(sdk)_LDFLAGS)\
2643 $(SDK_$(sdk)_LDFLAGS.$(bld_type))\
2644 $(SDK_$(sdk)_LDFLAGS.$(bld_trg))\
2645 $(SDK_$(sdk)_LDFLAGS.$(bld_trg_arch))\
2646 $(SDK_$(sdk)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\
2647 $(SDK_$(sdk)_LDFLAGS.$(bld_trg_cpu)))\
2648 $($(target)_LDFLAGS)\
2649 $($(target)_LDFLAGS.$(bld_type))\
2650 $($(target)_LDFLAGS.$(bld_trg))\
2651 $($(target)_LDFLAGS.$(bld_trg_arch))\
2652 $($(target)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\
2653 $($(target)_LDFLAGS.$(bld_trg_cpu))
2654local libs :=\
2655 $($(target)_LIBS.$(bld_trg_cpu))\
2656 $($(target)_LIBS.$(bld_trg).$(bld_trg_arch))\
2657 $($(target)_LIBS.$(bld_trg_arch))\
2658 $($(target)_LIBS.$(bld_trg))\
2659 $($(target)_LIBS.$(bld_type))\
2660 $($(target)_LIBS)\
2661 $(foreach sdk, $($(target)_SDKS.$(bld_trg).$(bld_trg_arch)) \
2662 $($(target)_SDKS.$(bld_trg_arch)) \
2663 $($(target)_SDKS.$(bld_trg)) \
2664 $($(target)_SDKS.$(bld_type)) \
2665 $($(target)_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 $(LIBS.$(bld_trg_cpu))\
2673 $(LIBS.$(bld_trg).$(bld_trg_arch))\
2674 $(LIBS.$(bld_trg_arch))\
2675 $(LIBS.$(bld_trg))\
2676 $(LIBS.$(bld_type))\
2677 $(LIBS)\
2678 $(foreach sdk, $(SDKS.$(bld_trg).$(bld_trg_arch)) \
2679 $(SDKS.$(bld_trg_arch)) \
2680 $(SDKS.$(bld_trg)) \
2681 $(SDKS.$(bld_type)) \
2682 $(SDKS),\
2683 $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
2684 $(SDK_$(sdk)_LIBS.$(bld_trg).$(bld_trg_arch))\
2685 $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
2686 $(SDK_$(sdk)_LIBS.$(bld_trg))\
2687 $(SDK_$(sdk)_LIBS.$(bld_type))\
2688 $(SDK_$(sdk)_LIBS))\
2689 $(TOOL_$(tool)_LIBS.$(bld_trg_cpu))\
2690 $(TOOL_$(tool)_LIBS.$(bld_trg).$(bld_trg_arch))\
2691 $(TOOL_$(tool)_LIBS.$(bld_trg_arch))\
2692 $(TOOL_$(tool)_LIBS.$(bld_trg))\
2693 $(TOOL_$(tool)_LIBS.$(bld_type))\
2694 $(TOOL_$(tool)_LIBS)
2695local libpath :=\
2696 $($(target)_LIBPATH.$(bld_trg_cpu))\
2697 $($(target)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
2698 $($(target)_LIBPATH.$(bld_trg_arch))\
2699 $($(target)_LIBPATH.$(bld_trg))\
2700 $($(target)_LIBPATH.$(bld_type))\
2701 $($(target)_LIBPATH)\
2702 $(foreach sdk, $($(target)_SDKS.$(bld_trg).$(bld_trg_arch)) \
2703 $($(target)_SDKS.$(bld_trg_arch)) \
2704 $($(target)_SDKS.$(bld_trg)) \
2705 $($(target)_SDKS.$(bld_type)) \
2706 $($(target)_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 $(LIBPATH.$(bld_trg_cpu))\
2714 $(LIBPATH.$(bld_trg).$(bld_trg_arch))\
2715 $(LIBPATH.$(bld_trg_arch))\
2716 $(LIBPATH.$(bld_trg))\
2717 $(LIBPATH.$(bld_type))\
2718 $(LIBPATH)\
2719 $(foreach sdk, $(SDKS.$(bld_trg).$(bld_trg_arch)) \
2720 $(SDKS.$(bld_trg_arch)) \
2721 $(SDKS.$(bld_trg)) \
2722 $(SDKS.$(bld_type)) \
2723 $(SDKS),\
2724 $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
2725 $(SDK_$(sdk)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
2726 $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
2727 $(SDK_$(sdk)_LIBPATH.$(bld_trg))\
2728 $(SDK_$(sdk)_LIBPATH.$(bld_type))\
2729 $(SDK_$(sdk)_LIBPATH))\
2730 $(TOOL_$(tool)_LIBPATH.$(bld_trg_cpu))\
2731 $(TOOL_$(tool)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
2732 $(TOOL_$(tool)_LIBPATH.$(bld_trg_arch))\
2733 $(TOOL_$(tool)_LIBPATH.$(bld_trg))\
2734 $(TOOL_$(tool)_LIBPATH.$(bld_type))\
2735 $(TOOL_$(tool)_LIBPATH)
2736local dirdep := $(call DIRDEP,$(dir $(out)))
2737local deps := \
2738 $($(target)_DEPS.$(bld_trg_cpu)) \
2739 $($(target)_DEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
2740 $($(target)_DEPS.$(bld_trg).$(bld_trg_arch)) \
2741 $($(target)_DEPS.$(bld_trg).$(bld_type)) \
2742 $($(target)_DEPS.$(bld_trg_arch)) \
2743 $($(target)_DEPS.$(bld_trg)) \
2744 $($(target)_DEPS.$(bld_type)) \
2745 $($(target)_DEPS) \
2746 $($(target)_LNK_DEPS.$(bld_trg_cpu)) \
2747 $($(target)_LNK_DEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
2748 $($(target)_LNK_DEPS.$(bld_trg).$(bld_trg_arch)) \
2749 $($(target)_LNK_DEPS.$(bld_trg).$(bld_type)) \
2750 $($(target)_LNK_DEPS.$(bld_trg_arch)) \
2751 $($(target)_LNK_DEPS.$(bld_trg)) \
2752 $($(target)_LNK_DEPS.$(bld_type)) \
2753 $($(target)_LNK_DEPS)
2754local orderdeps := \
2755 $($(target)_ORDERDEPS.$(bld_trg_cpu)) \
2756 $($(target)_ORDERDEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
2757 $($(target)_ORDERDEPS.$(bld_trg).$(bld_trg_arch)) \
2758 $($(target)_ORDERDEPS.$(bld_trg).$(bld_type)) \
2759 $($(target)_ORDERDEPS.$(bld_trg_arch)) \
2760 $($(target)_ORDERDEPS.$(bld_trg)) \
2761 $($(target)_ORDERDEPS.$(bld_type)) \
2762 $($(target)_ORDERDEPS) \
2763 $($(target)_LNK_ORDERDEPS.$(bld_trg_cpu)) \
2764 $($(target)_LNK_ORDERDEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
2765 $($(target)_LNK_ORDERDEPS.$(bld_trg).$(bld_trg_arch)) \
2766 $($(target)_LNK_ORDERDEPS.$(bld_trg).$(bld_type)) \
2767 $($(target)_LNK_ORDERDEPS.$(bld_trg_arch)) \
2768 $($(target)_LNK_ORDERDEPS.$(bld_trg)) \
2769 $($(target)_LNK_ORDERDEPS.$(bld_type)) \
2770 $($(target)_LNK_ORDERDEPS)
2771
2772# Adjust paths if we got a default path.
2773ifneq ($(defpath),)
2774 local libpath := $(abspathex $(libpath),$(defpath))
2775 local deps := $(abspathex $(deps),$(defpath))
2776 local orderdeps := $(abspathex $(orderdeps),$(defpath))
2777 othersrc := $(abspathex $(othersrc),$(defpath))
2778 # libs are not subject to this because of the the -l<lib> stuff. Use $(<target>_DEFPATH)/lib if relative to current dir!
2779endif
2780
2781# Custom pre/post-link actions.
2782local pre_cmds := $(evalcall def_fn_prop_get_first_defined,PRE_CMDS)
2783local post_cmds := $(evalcall def_fn_prop_get_first_defined,POST_CMDS)
2784
2785# eliminate this guy?
2786local objs = $($(target)_2_OBJS)
2787
2788# installation targets
2789$(evalval def_target_install_only)
2790
2791# dependency file
2792local dep := $(outbase)$(SUFF_DEP)
2793ifndef NO_LINK_CMDS_DEPS
2794 _DEPFILES_INCLUDED += $(dep)
2795 ifdef KB_HAVE_INCLUDEDEP_QUEUE
2796 includedep-queue $(dep)
2797 else
2798 includedep $(dep)
2799 endif
2800endif
2801
2802# check that the tool is defined.
2803ifndef TOOL_$(tool)_$(tool_do)_CMDS
2804$(warning kBuild: tools: \
2805 1 $($(target)_$(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
2806 2 $($(target)_$(source)TOOL.$(bld_trg)) \
2807 3 $($(target)_$(source)TOOL) \
2808 4 $($(target)_TOOL.$(bld_trg).$(bld_trg_arch)) \
2809 5 $($(target)_TOOL.$(bld_trg)) \
2810 6 $($(target)_TOOL) \
2811 7 $($(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
2812 8 $($(source)TOOL.$(bld_trg)) \
2813 9 $($(source)TOOL) \
2814 10 $(TOOL.$(bld_trg).$(bld_trg_arch)) \
2815 11 $(TOOL.$(bld_trg)) \
2816 12 $(TOOL) )
2817$(error kBuild: TOOL_$(tool)_$(tool_do)_CMDS isn't defined! target=$(target) )
2818endif
2819
2820# call the tool
2821local cmds := $(TOOL_$(tool)_$(tool_do)_CMDS)
2822ifneq ($(pre_cmds),)
2823 local cmds := $(TAB)$(pre_cmds)$(NL)$(TAB)$(cmds)
2824endif
2825ifneq ($(post_cmds),)
2826 local cmds := $(cmds)$(NL)$(TAB)$(post_cmds)
2827endif
2828$(target)_2_OUTPUT := $(TOOL_$(tool)_$(tool_do)_OUTPUT)
2829$(target)_2_OUTPUT_MAYBE := $(TOOL_$(tool)_$(tool_do)_OUTPUT_MAYBE)
2830$(target)_2_DEPEND := $(TOOL_$(tool)_$(tool_do)_DEPEND) $(deps) $($(target)_2_OBJS)
2831$(target)_2_DEPORD := $(TOOL_$(tool)_$(tool_do)_DEPORD) $(dirdep) $(orderdeps)
2832
2833# generate the link rule.
2834$(eval $(def_link_rule))
2835
2836
2837# Update globals.
2838_OBJS += $($(target)_2_OBJS)
2839_OUT_FILES += $($(target)_2_OUTPUT) $($(target)_2_OUTPUT_MAYBE) $(out)
2840_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))
2841_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))
2842_INSTALLS_FILES += $(INSTARGET_$(target))
2843
2844endef # def_link_common
2845$(eval-opt-var def_link_common)
2846
2847
2848#
2849# BLDPROGS
2850#
2851
2852# Process build programs.
2853EXT := EXE
2854EXTPRE := HOST
2855tool_do := LINK_PROGRAM
2856typevar := _BLDPROGS
2857mode := 0755
2858bld_trg_base_var := PLATFORM
2859$(foreach target, $(_ALL_BLDPROGS), $(evalval def_link_common))
2860
2861ifdef KBUILD_PROFILE_SELF
2862 $(evalcall def_profile_self, done build program targets)
2863endif
2864
2865
2866#
2867# DLLS
2868#
2869
2870# Process dlls
2871EXT := DLL
2872EXTPRE :=
2873tool_do := LINK_DLL
2874typevar := _DLLS
2875mode := 0644
2876bld_trg_base_var := TARGET
2877$(foreach target, $(_ALL_DLLS), $(evalval def_link_common))
2878
2879ifdef KBUILD_PROFILE_SELF
2880 $(evalcall def_profile_self, done dll targets)
2881endif
2882
2883
2884#
2885# IMPORT LIBRARIES
2886#
2887# - On OS/2 and windows these are libraries.
2888# - On other platforms they are fake DLLs.
2889#
2890EXTPRE :=
2891typevar := _IMPORT_LIBS
2892mode := 0644
2893bld_trg_base_var := TARGET
2894ifeq ($(filter-out nt os2 win win64 win32,$(KBUILD_TARGET)),)
2895 EXT := LIB
2896 tool_do := LINK_LIBRARY
2897 $(foreach target, $(_ALL_IMPORT_LIBS), $(evalval def_lib))
2898else
2899 EXT := DLL
2900 tool_do := LINK_DLL
2901 $(foreach target, $(_ALL_IMPORT_LIBS), $(evalval def_link_common))
2902endif
2903
2904ifdef KBUILD_PROFILE_SELF
2905 $(evalcall def_profile_self, done import library targets)
2906endif
2907
2908
2909#
2910# PROGRAMS
2911#
2912
2913# Process programs
2914EXT := EXE
2915EXTPRE :=
2916tool_do := LINK_PROGRAM
2917typevar := _PROGRAMS
2918mode := 0755
2919bld_trg_base_var := TARGET
2920$(foreach target, $(_ALL_PROGRAMS), $(evalval def_link_common))
2921
2922ifdef KBUILD_PROFILE_SELF
2923 $(evalcall def_profile_self, done program targets)
2924endif
2925
2926
2927#
2928# SYSMODS
2929#
2930
2931# Process sysmods
2932EXT := SYS
2933EXTPRE :=
2934tool_do := LINK_SYSMOD
2935typevar := _SYSMODS
2936mode := 0644
2937bld_trg_base_var := TARGET
2938$(foreach target, $(_ALL_SYSMODS), $(evalval def_link_common))
2939
2940ifdef KBUILD_PROFILE_SELF
2941 $(evalcall def_profile_self, done sysmod targets)
2942endif
2943
2944
2945#
2946# MISCBINS
2947#
2948
2949# Process MISCBINS
2950EXT := BIN
2951EXTPRE :=
2952tool_do := LINK_MISCBIN
2953typevar := _MISCBINS
2954mode := 0644
2955bld_trg_base_var := TARGET
2956$(foreach target, $(_ALL_MISCBINS), $(evalval def_link_common))
2957
2958ifdef KBUILD_PROFILE_SELF
2959 $(evalcall def_profile_self, done misc binary targets)
2960endif
2961
2962
2963#
2964# OTHERS
2965#
2966_OTHERS = $(OTHERS) $(OTHERS.$(KBUILD_TARGET)) $(OTHERS.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH))
2967
2968
2969#
2970# INSTALLS
2971#
2972
2973##
2974# Generate the staging rules.
2975#
2976define def_install_src_rule_staging
2977$(stagedst) : $(srcsrc) | $(dir $(stagedst))
2978 %$$(call MSG_INST_FILE,$(srcsrc),$(stagedst))
2979 $$(QUIET)$(stagecmd)
2980endef
2981$(eval-opt-var def_install_src_rule_staging)
2982
2983define def_install_src_rule_installing
2984$(instdst) : $(srcsrc) | $(dir $(instdst))
2985 %$$(call MSG_INST_FILE,$(srcsrc),$(instdst))
2986 $$(QUIET)$(instcmd)
2987endef
2988$(eval-opt-var def_install_src_rule_installing)
2989
2990##
2991# Install one file.
2992#
2993define def_install_src
2994
2995# deal with '=>' in the source file name.
2996ifeq ($(src),=>)
2997 $(error kBuild: Install target '$(target)' has a bad source specifier containing '=>' without any file names)
2998endif
2999ifeq ($(substr $(src),1,2),=>)
3000 $(warning kBuild: Install target '$(target)' has a bad source specifier: $(src))
3001endif
3002ifeq ($(substr $(src),-2),=>)
3003 $(warning kBuild: Install target '$(target)' has a bad source specifier: $(src))
3004endif
3005local srcdst := $(subst =>, ,$(src))
3006local srcsrc := $(firstword $(srcdst))
3007local srcdstdir := $(dir $(word 2,$(srcdst)))
3008local srcdst := $(word $(words $(srcdst)),$(srcdst))
3009
3010# Calc destinations.
3011ifdef $(srcsrc)_INSTFUN
3012 local instfun := $(srcsrc)_INSTFUN
3013else
3014 local instfun := $(top_instfun)
3015endif
3016
3017local stage := $(firstword $($(srcsrc)_STAGE) $($(srcsrc)_INST) $($(target)_1_STAGE))
3018ifneq ($(substr $(stage),-1),/)
3019 $(warning kBuild: File $(srcsrc) in install target $(target) has a STAGE property without a trailing slash.)
3020 local stage := $(stage)/
3021endif
3022local stage := $(stage)$(dir $(srcdstdir))
3023local stagedst := $(call $(instfun),$(srcdst),$(target),$(stage),$(PATH_STAGE))
3024
3025local inst := $(firstword $($(srcsrc)_INST) $($(target)_1_INST))
3026ifneq ($(substr $(inst),-1),/)
3027 $(warning kBuild: File $(srcsrc) in install target $(target) has a INST property without a trailing slash.)
3028 local inst := $(inst)/
3029endif
3030local inst := $(inst)$(dir $(srcdstdir))
3031local instdst := $(call $(instfun),$(srcdst),$(target),$(inst),$(PATH_INS))
3032
3033#$(warning instfun=$(instfun) srcdst=$(srcdst) target=$(target) inst=$(inst) => instdst=$(instdst); stage=$(stage) => stagedst=$(stagedst))
3034
3035# mode, uid and gid
3036local mode := $(firstword \
3037 $($(target)_$(srcsrc)_MODE.$(bld_trg).$(bld_trg_arch)) \
3038 $($(target)_$(srcsrc)_MODE.$(bld_trg)) \
3039 $($(target)_$(srcsrc)_MODE) \
3040 $($(target)_$(srcdst)_MODE.$(bld_trg).$(bld_trg_arch)) \
3041 $($(target)_$(srcdst)_MODE.$(bld_trg)) \
3042 $($(target)_$(srcdst)_MODE) \
3043 $($(srcsrc)_MODE.$(bld_trg).$(bld_trg_arch)) \
3044 $($(srcsrc)_MODE.$(bld_trg)) \
3045 $($(srcsrc)_MODE) \
3046 $($(srcdst)_MODE.$(bld_trg).$(bld_trg_arch)) \
3047 $($(srcdst)_MODE.$(bld_trg)) \
3048 $($(srcdst)_MODE) \
3049 $(top_mode))
3050local uid := $(firstword \
3051 $($(target)_$(srcsrc)_UID.$(bld_trg).$(bld_trg_arch)) \
3052 $($(target)_$(srcsrc)_UID.$(bld_trg)) \
3053 $($(target)_$(srcsrc)_UID) \
3054 $($(target)_$(srcdst)_UID.$(bld_trg).$(bld_trg_arch)) \
3055 $($(target)_$(srcdst)_UID.$(bld_trg)) \
3056 $($(target)_$(srcdst)_UID) \
3057 $($(srcsrc)_UID.$(bld_trg).$(bld_trg_arch)) \
3058 $($(srcsrc)_UID.$(bld_trg)) \
3059 $($(srcsrc)_UID) \
3060 $($(srcdst)_UID.$(bld_trg).$(bld_trg_arch)) \
3061 $($(srcdst)_UID.$(bld_trg)) \
3062 $($(srcdst)_UID) \
3063 $(top_uid))
3064local gid := $(firstword \
3065 $($(target)_$(srcsrc)_GID.$(bld_trg).$(bld_trg_arch)) \
3066 $($(target)_$(srcsrc)_GID.$(bld_trg)) \
3067 $($(target)_$(srcsrc)_GID) \
3068 $($(target)_$(srcdst)_GID.$(bld_trg).$(bld_trg_arch)) \
3069 $($(target)_$(srcdst)_GID.$(bld_trg)) \
3070 $($(target)_$(srcdst)_GID) \
3071 $($(srcsrc)_GID.$(bld_trg).$(bld_trg_arch)) \
3072 $($(srcsrc)_GID.$(bld_trg)) \
3073 $($(srcsrc)_GID) \
3074 $($(srcdst)_GID.$(bld_trg).$(bld_trg_arch)) \
3075 $($(srcdst)_GID.$(bld_trg)) \
3076 $($(srcdst)_GID) \
3077 $(top_gid))
3078local flags := \
3079 $(top_ifflags) \
3080 $($(srcdst)_IFFLAGS) \
3081 $($(srcdst)_IFFLAGS.$(bld_trg)) \
3082 $($(srcdst)_IFFLAGS.$(bld_trg).$(bld_trg_arch)) \
3083 $($(srcsrc)_IFFLAGS) \
3084 $($(srcsrc)_IFFLAGS.$(bld_trg)) \
3085 $($(srcsrc)_IFFLAGS.$(bld_trg).$(bld_trg_arch)) \
3086 $($(target)_$(srcdst)_IFFLAGS) \
3087 $($(target)_$(srcdst)_IFFLAGS.$(bld_trg)) \
3088 $($(target)_$(srcdst)_IFFLAGS.$(bld_trg).$(bld_trg_arch)) \
3089 $($(target)_$(srcsrc)_IFFLAGS) \
3090 $($(target)_$(srcsrc)_IFFLAGS.$(bld_trg)) \
3091 $($(target)_$(srcsrc)_IFFLAGS.$(bld_trg).$(bld_trg_arch))
3092clean_files += \
3093 $($(srcdst)_CLEAN) \
3094 $($(srcdst)_CLEAN.$(bld_trg)) \
3095 $($(srcdst)_CLEAN.$(bld_trg).$(bld_trg_arch)) \
3096 $($(srcsrc)_CLEAN) \
3097 $($(srcsrc)_CLEAN.$(bld_trg)) \
3098 $($(srcsrc)_CLEAN.$(bld_trg).$(bld_trg_arch)) \
3099 $($(target)_$(srcdst)_CLEAN) \
3100 $($(target)_$(srcdst)_CLEAN.$(bld_trg)) \
3101 $($(target)_$(srcdst)_CLEAN.$(bld_trg).$(bld_trg_arch)) \
3102 $($(target)_$(srcsrc)_CLEAN) \
3103 $($(target)_$(srcsrc)_CLEAN.$(bld_trg)) \
3104 $($(target)_$(srcsrc)_CLEAN.$(bld_trg).$(bld_trg_arch))
3105
3106
3107# Adjust the source if we got a default PATH. (This must be done this late!)
3108ifdef $(target)_DEFPATH
3109local defpath := $($(target)_DEFPATH)
3110else ifdef $(target)_PATH
3111local defpath := $($(target)_PATH)
3112else
3113local defpath :=
3114endif
3115ifneq ($(defpath),)
3116 local srcsrc := $(abspathex $(srcsrc),$(defpath))
3117endif
3118
3119# create the commands
3120ifdef $(srcsrc)_INSTALLER
3121 local stagecmd := $(call $(srcsrc)_INSTALLER,$(srcsrc),$(stagedst),$(target),$(flags))
3122 local instcmd := $(call $(srcsrc)_INSTALLER,$(srcsrc),$(instdst),$(target),$(flags))
3123else ifdef $(target)_INSTALLER
3124 local stagecmd := $(call $(target)_INSTALLER,$(srcsrc),$(stagedst),$(target),$(flags))
3125 local instcmd := $(call $(target)_INSTALLER,$(srcsrc),$(instdst),$(target),$(flags))
3126else
3127 local stagecmd := $$(INSTALL)\
3128 $(if $(uid),-o $(uid))\
3129 $(if $(gid),-g $(gid))\
3130 $(if $(mode),-m $(mode))\
3131 $(flags) -- \
3132 $(srcsrc) $(stagedst)
3133 local instcmd := $$(INSTALL)\
3134 $(if $(uid),-o $(uid))\
3135 $(if $(gid),-g $(gid))\
3136 $(if $(mode),-m $(mode))\
3137 $(flags) -- \
3138 $(srcsrc) $(instdst)
3139endif
3140
3141# Generate the staging rule (requires double evaluation).
3142$(eval $(def_install_src_rule_staging))
3143$(target)_2_STAGE_TARGETS += $(stagedst)
3144
3145# Generate the install rule
3146ifeq ($(insttype),both)
3147 $(eval $(def_install_src_rule_installing))
3148 $(target)_2_INST_TARGETS += $(instdst)
3149endif
3150
3151endef # def_install_src
3152$(eval-opt-var def_install_src)
3153
3154
3155##
3156# Generate the symlink rules.
3157#
3158define def_install_symlink_rule_staging
3159$(stagedst) : | $(dir $(stagedst))
3160 %$$(call MSG_INST_SYM,$(stagedst),$(symdst))
3161 $$(QUIET)$$(RM) -f -- $$@
3162 $$(QUIET)$$(LN_SYMLINK) $(symdst) $(stagedst)
3163endef
3164$(eval-opt-var def_install_symlink_rule_staging)
3165
3166define def_install_symlink_rule_installing
3167$(instdst) : | $(dir $(instdst))
3168 %$$(call MSG_INST_SYM,$(instdst),$(symdst))
3169 $$(QUIET)$$(RM) -f -- $$@
3170 $$(QUIET)$$(LN_SYMLINK) $(symdst) $(instdst)
3171endef
3172$(eval-opt-var def_install_symlink_rule_installing)
3173
3174
3175##
3176# Create one symlink.
3177#
3178define def_install_symlink
3179
3180# deal with '=>' in the source file name.
3181local symdst := $(subst =>, ,$(src))
3182local symlnk := $(firstword $(symdst))
3183local symdst := $(word $(words $(symdst)),$(symdst))
3184
3185# Calc destinations
3186ifdef $(symlnk)_INSTFUN
3187 local instfun := $(symlnk)_INSTFUN
3188else
3189 local instfun := $(top_instfun)
3190endif
3191
3192local stage := $(firstword $($(symlnk)_STAGE) $(symlnk)_INST) $($(target)_1_STAGE))
3193ifneq ($(substr $(stage),-1),/)
3194 $(warning kBuild: Symlink $(symlnk) in install target $(target) has a STAGE property without a trailing slash.)
3195 local stage := $(stage)/
3196endif
3197local stage := $(stage)$(dir $(srcdstdir))
3198local stagedst := $(call $(instfun),$(symlnk),$(target),$(stage),$(PATH_STAGE))
3199
3200local inst := $(firstword $($(symlnk)_INST) $($(target)_1_INST))
3201ifneq ($(substr $(inst),-1),/)
3202 $(warning kBuild: Symlnk $(symlnk) in install target $(target) has a INST property without a trailing slash.)
3203 local inst := $(inst)/
3204endif
3205local inst := $(inst)$(dir $(srcdstdir))
3206local instdst := $(call $(instfun),$(symlnk),$(target),$(inst),$(PATH_INS))
3207#$(warning symlnk=$(symlnk) symdst=$(symdst) instdst=$(instdst) stagedst=$(stagedst) instfun=$(instfun) inst=$(inst) stage='$(stage)')
3208
3209# Generate the staging rule (requires double evaluation).
3210$(eval $(def_install_symlink_rule_staging))
3211$(target)_2_STAGE_TARGETS += $(stagedst)
3212
3213# Generate the install rule.
3214ifeq ($(instmode),both)
3215 $(eval $(def_install_symlink_rule_installing))
3216 $(target)_2_INST_TARGETS += $(instdst)
3217endif
3218
3219endef # def_install_symlink
3220$(optmize def_install_symlink)
3221
3222
3223##
3224# Generate an directory installtion rule.
3225# Note. Used both for staging and real install rules.
3226#
3227define def_install_directory_rule
3228# the install rule
3229$(insdst):
3230 %$$(call MSG_INST_DIR,$(insdst))
3231 $$(QUIET)$$(INSTALL) -d \
3232 $(if $(uid),-o $(uid))\
3233 $(if $(gid),-g $(gid))\
3234 $(if $(mode),-m $(mode))\
3235 $(flags) -- \
3236 $(insdst)
3237
3238.NOTPARALLEL: $(insdst)
3239endef # def_install_directory_rule
3240$(eval-opt-var def_install_directory_rule)
3241
3242##
3243# Create one directory.
3244#
3245define def_install_directory
3246
3247# gather common properties.
3248ifdef $(directory)_INST
3249 local inst := $($(directory)_INST)
3250else
3251 local inst := $($(target)_1_INST)
3252endif
3253ifneq ($(substr $(inst),-1),/)
3254 $(warning kBuild: Directory $(directory) in install target $(target) has a INST property without a trailing slash.)
3255 local inst := $(inst)/
3256endif
3257ifdef $(directory)_STAGE
3258 local stage := $($(directory)_STAGE)
3259else ifdef $(directory)_INST
3260 local stage := $($(directory)_INST)
3261else
3262 local stage := $($(target)_1_STAGE)
3263endif
3264ifneq ($(substr $(stage),-1),/)
3265 $(warning kBuild: Directory $(directory) in install target $(target) has a INST property without a trailing slash.)
3266 local stage := $(stage)/
3267endif
3268
3269local mode := $(firstword \
3270 $($(target)_$(directory)_MODE.$(bld_trg).$(bld_trg_arch)) \
3271 $($(target)_$(directory)_MODE.$(bld_trg)) \
3272 $($(target)_$(directory)_MODE) \
3273 $($(directory)_MODE.$(bld_trg).$(bld_trg_arch)) \
3274 $($(directory)_MODE.$(bld_trg)) \
3275 $($(directory)_MODE) \
3276 $(top_mode) )
3277local uid := $(firstword \
3278 $($(target)_$(directory)_UID.$(bld_trg).$(bld_trg_arch)) \
3279 $($(target)_$(directory)_UID.$(bld_trg)) \
3280 $($(target)_$(directory)_UID) \
3281 $($(directory)_UID.$(bld_trg).$(bld_trg_arch)) \
3282 $($(directory)_UID.$(bld_trg)) \
3283 $($(directory)_UID) \
3284 $(top_uid) )
3285local gid := $(firstword \
3286 $($(target)_$(directory)_GID.$(bld_trg).$(bld_trg_arch)) \
3287 $($(target)_$(directory)_GID.$(bld_trg)) \
3288 $($(target)_$(directory)_GID) \
3289 $($(directory)_GID.$(bld_trg).$(bld_trg_arch)) \
3290 $($(directory)_GID.$(bld_trg)) \
3291 $($(directory)_GID) \
3292 $(top_gid) )
3293local flags := \
3294 $(top_idflags) \
3295 $($(directory)_IDFLAGS) \
3296 $($(directory)_IDFLAGS.$(bld_trg)) \
3297 $($(directory)_IDFLAGS.$(bld_trg).$(bld_trg_arch)) \
3298 $($(target)_$(directory)_IDFLAGS) \
3299 $($(target)_$(directory)_IDFLAGS.$(bld_trg)) \
3300 $($(target)_$(directory)_IDFLAGS.$(bld_trg).$(bld_trg_arch)) \
3301 #$(warning directory=$(directory) inst=$(inst) stage=$(stage) mode=$(mode) gid=$(gid) uid=$(uid))
3302
3303# The staging rule (requires double evaluation).
3304local insdst := $(PATH_STAGE)$(stage)$(directory)/
3305$(target)_2_STAGE_DIR_TARGETS += $(insdst)
3306$(eval $(def_install_directory_rule))
3307
3308# The install rule.
3309ifeq ($(insttype),both)
3310 local insdst := $(PATH_INS)$(inst)$(directory)/
3311 $(target)_2_INST_DIR_TARGETS += $(insdst)
3312 $(eval $(def_install_directory_rule))
3313endif
3314
3315endef # def_install_directory
3316$(eval-opt-var def_install_directory)
3317
3318
3319##
3320# Process one install target.
3321#
3322define def_install
3323# the basics.
3324local bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE))
3325local bld_trg := $(firstword $($(target)_BLD_TRG) $(KBUILD_TARGET))
3326local bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(KBUILD_TARGET_ARCH))
3327local bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(KBUILD_TARGET_CPU))
3328local insttype := $($(target)_1_INSTTYPE)
3329
3330ifneq ($(insttype),none)
3331 $(target)_2_STAGE_TARGETS := $($(target)_GOALS) $($(target)_STAGE_ONLY_GOALS)
3332else
3333 $(target)_2_STAGE_TARGETS :=
3334endif
3335$(target)_2_STAGE_DIR_TARGETS :=
3336
3337ifeq ($(insttype),both)
3338 $(target)_2_INST_TARGETS := $($(target)_GOALS) $($(target)_INST_ONLY_GOALS)
3339else
3340 $(target)_2_INST_TARGETS :=
3341endif
3342$(target)_2_INST_DIR_TARGETS :=
3343
3344
3345local outbase := $(call TARGET_BASE,$(target),$(target))
3346$(target)_0_OUTDIR := $(patsubst %/,%,$(dir $(outbase)))
3347$(call KB_FN_ASSIGN_DEPRECATED,PATH_$(target),$($(target)_0_OUTDIR), $(target)_0_OUTDIR)
3348
3349ifneq ($(insttype),none)
3350 # cache top level target properties.
3351 local top_mode := $(firstword \
3352 $($(target)_MODE.$(bld_trg).$(bld_trg_arch)) \
3353 $($(target)_MODE.$(bld_trg)) \
3354 $($(target)_MODE) )
3355 local top_uid := $(firstword \
3356 $($(target)_UID.$(bld_trg).$(bld_trg_arch)) \
3357 $($(target)_UID.$(bld_trg)) \
3358 $($(target)_UID) )
3359 local top_gid := $(firstword \
3360 $($(target)_GID.$(bld_trg).$(bld_trg_arch)) \
3361 $($(target)_GID.$(bld_trg)) \
3362 $($(target)_GID) )
3363 local top_ifflags := \
3364 $($(target)_IFFLAGS) \
3365 $($(target)_IFFLAGS.$(bld_trg)) \
3366 $($(target)_IFFLAGS.$(bld_trg).$(bld_trg_arch))
3367 local top_idflags := \
3368 $($(target)_IDFLAGS) \
3369 $($(target)_IDFLAGS.$(bld_trg)) \
3370 $($(target)_IDFLAGS.$(bld_trg).$(bld_trg_arch))
3371 ifdef $(target)_INSTFUN
3372 local top_instfun := $(target)_INSTFUN
3373 else
3374 local top_instfun := _INSTALL_FILE
3375 endif
3376
3377 $(foreach directory, \
3378 $($(target)_DIRS) \
3379 $($(target)_DIRS.$(bld_trg)) \
3380 $($(target)_DIRS.$(bld_trg).$(bld_trg_arch)) \
3381 $($(target)_DIRS.$(bld_trg_arch)) \
3382 $($(target)_DIRS.$(bld_trg_cpu)) \
3383 $($(target)_DIRS.$(bld_type)), \
3384 $(evalval def_install_directory))
3385
3386 local clean_files := \
3387 $($(target)_CLEAN) \
3388 $($(target)_CLEAN.$(bld_trg)) \
3389 $($(target)_CLEAN.$(bld_trg).$(bld_trg_arch)) \
3390 $($(target)_CLEAN.$(bld_trg_arch)) \
3391 $($(target)_CLEAN.$(bld_trg_cpu)) \
3392 $($(target)_CLEAN.$(bld_type))
3393
3394 $(foreach src,\
3395 $($(target)_SOURCES) \
3396 $($(target)_SOURCES.$(bld_trg)) \
3397 $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) \
3398 $($(target)_SOURCES.$(bld_trg_arch)) \
3399 $($(target)_SOURCES.$(bld_trg_cpu)) \
3400 $($(target)_SOURCES.$(bld_type)), \
3401 $(evalval def_install_src))
3402
3403 $(foreach src,\
3404 $($(target)_SYMLINKS) \
3405 $($(target)_SYMLINKS.$(bld_trg)) \
3406 $($(target)_SYMLINKS.$(bld_trg).$(bld_trg_arch)) \
3407 $($(target)_SYMLINKS.$(bld_trg_arch)) \
3408 $($(target)_SYMLINKS.$(bld_trg_cpu)) \
3409 $($(target)_SYMLINKS.$(bld_type)), \
3410 $(evalval def_install_symlink))
3411else # none
3412 local clean_files :=
3413endif
3414
3415# The collection targets (staging only).
3416local clean_files += $($(target)_1_TARGET)
3417$($(target)_1_TARGET): $$($(target)_2_STAGE_TARGETS) | $$($(target)_2_STAGE_DIR_TARGETS) $$(dir $$@)
3418 @$(QUIET2)$(APPEND) $@
3419
3420$(target): $$($(target)_1_TARGET)
3421
3422# Update Global lists.
3423_INSTALLS += $($(target)_1_TARGET)
3424_STAGE_FILES += $($(target)_2_STAGE_TARGETS)
3425_STAGE_DIRS += $($(target)_2_STAGE_DIR_TARGETS)
3426_INSTALLS_FILES += $($(target)_2_INST_TARGETS)
3427_INSTALLS_DIRS += $($(target)_2_INST_DIR_TARGETS)
3428_CLEAN_FILES += $(clean_files)
3429_DIRS += \
3430 $($(target)_0_OUTDIR) \
3431 $($(target)_BLDDIRS) \
3432 $($(target)_BLDDIRS.$(bld_trg)) \
3433 $($(target)_BLDDIRS.$(bld_trg).$(bld_trg_arch)) \
3434 $($(target)_BLDDIRS.$(bld_trg_arch)) \
3435 $($(target)_BLDDIRS.$(bld_trg_cpu)) \
3436 $($(target)_BLDDIRS.$(bld_type))
3437
3438# Deprecated properties.
3439INSTARGET_$(target) := $($(target)_2_STAGE_TARGETS)
3440INSTARGET_DIRS_$(target) := $($(target)_2_STAGE_DIR_TARGETS)
3441
3442endef # def_install
3443$(eval-opt-var def_install)
3444
3445## process all install targets
3446$(foreach target, $(_ALL_INSTALLS), \
3447 $(evalvalctx def_install))
3448
3449ifdef KBUILD_PROFILE_SELF
3450 $(evalcall def_profile_self, done install targets)
3451endif
3452
3453#
3454# Some introspection targets that can be useful for package maintainers.
3455#
3456.PHONY: kbuild-show-install-files kbuild-show-install-dirs
3457kbuild-show-install-files::
3458 $(addprefix $(NL)$(TAB)$(QUIET)$(ECHO) , $(subst $(PATH_INS)/,,$(_INSTALLS_FILES)))
3459
3460kbuild-show-install-dirs::
3461 $(addprefix $(NL)$(TAB)$(QUIET)$(ECHO) , $(subst $(PATH_INS)/,,$(_INSTALLS_DIRS)))
3462
3463kbuild-show-stage-files::
3464 $(addprefix $(NL)$(TAB)$(QUIET)$(ECHO) , $(subst $(PATH_STAGE)/,,$(_STAGE_FILES)))
3465
3466kbuild-show-stage-dirs::
3467 $(addprefix $(NL)$(TAB)$(QUIET)$(ECHO) , $(subst $(PATH_STAGE)/,,$(_STAGE_DIRS)))
3468
3469
3470#
3471# TESTING
3472#
3473_TESTING += $(TESTING) \
3474 $(TESTING.$(KBUILD_TARGET)) \
3475 $(TESTING.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \
3476 $(TESTING.$(KBUILD_TARGET_ARCH)) \
3477 $(TESTING.$(KBUILD_TARGET_CPU))
3478
3479
3480#
3481# PACKING
3482#
3483_PACKING += $(PACKING) \
3484 $(PACKING.$(KBUILD_TARGET)) \
3485 $(PACKING.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \
3486 $(PACKING.$(KBUILD_TARGET_ARCH)) \
3487 $(PACKING.$(KBUILD_TARGET_CPU))
3488
3489
3490#
3491# DOCS
3492#
3493
3494
3495#
3496# DIRECTORIES
3497#
3498_DIR_ALL := $(sort $(addsuffix /,$(patsubst %/,%,$(_DIRS))) $(dir $(_OUT_FILES) $(_OBJS) $(_INSTALLS_FILES) $(_STAGE_FILES)))
3499$(foreach directory,$(_INSTALLS_DIRS) $(_STAGE_DIRS), $(eval _DIR_ALL := $(filter-out $(directory),$(_DIR_ALL))))
3500
3501
3502define def_mkdir_rule
3503$(directory):
3504 %$$(call MSG_MKDIR,$$@)
3505 $$(QUIET)$$(MKDIR) -p -- $$@
3506endef
3507
3508$(foreach directory,$(_DIR_ALL),$(eval $(def_mkdir_rule)))
3509
3510ifdef KBUILD_PROFILE_SELF
3511 $(evalcall def_profile_self, done directories)
3512endif
3513
3514
3515#
3516# NOTHING
3517#
3518do-nothing:
3519 %$(call MSG_NOTHING)
3520ifdef KBUILD_PROFILE_SELF
3521 @$(ECHO) 'prof: $(call _KBUILD_FMT_ELAPSED_EX, $(nanots ), $(_KBUILD_TS_HEADER_START)) - $(call _KBUILD_FMT_ELAPSED_EX, $(nanots ), $(_KBUILD_TS_PREV)) - executing $@'
3522 ifeq ($(KBUILD_PROFILE_SELF),2)
3523 @$(ECHO) 'stat: $(make-stats )'
3524 endif
3525endif
3526
3527
3528#
3529# CLEAN UP
3530#
3531do-clean:
3532 %$(call MSG_CLEAN)
3533 $(QUIET)$(RM) -f -- \
3534 $(_OUT_FILES) \
3535 $(_OBJS) \
3536 $(_DEPFILES) \
3537 $(_DEPFILES_INCLUDED) \
3538 $(_CLEAN_FILES) \
3539 $(OTHER_CLEAN) \
3540 $(_STAGE_FILES)
3541 $(QUIET)$(RMDIR) -p --ignore-fail-on-non-empty --ignore-fail-on-not-exist -- \
3542 $(rsort $(dir $(_OUT_FILES) \
3543 $(_OBJS) \
3544 $(_DEPFILES) \
3545 $(_DEPFILES_INCLUDED) \
3546 $(_CLEAN_FILES) \
3547 $(OTHER_CLEAN))\
3548 $(_STAGE_DIRS) )
3549
3550
3551
3552#
3553# PASSES (including directory and makefile walking)
3554#
3555
3556#
3557# First, check whether we need to order the passes explicitly or not.
3558# This depends on whether we're a leaf makefile or not. A leaf will
3559# know all its dependencies, while a recursive one relies on the
3560# order sub-directories and other makefiles are executed it.
3561#
3562
3563## Setup a pass and check for optimizations.
3564# @param $(PASS) Uppercase pass name.
3565define def_pass_setup_and_optimize
3566
3567# The setup. ## @todo This is looks a bit weird...
3568ifndef SUBDIRS_$(PASS)
3569 SUBDIRS_$(PASS) := $(SUBDIRS) $(SUBDIRS.$(KBUILD_TARGET)) $(SUBDIRS.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH))
3570endif
3571ifndef SUBDIRS_AFTER_$(PASS)
3572 SUBDIRS_AFTER_$(PASS) := $(SUBDIRS_AFTER) $(SUBDIRS_AFTER.$(KBUILD_TARGET)) $(SUBDIRS_AFTER.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH))
3573endif
3574ifndef MAKEFILES_BEFORE_$(PASS)
3575 MAKEFILES_BEFORE_$(PASS) := $(MAKEFILES_BEFORE) $(MAKEFILES_BEFORE.$(KBUILD_TARGET)) $(MAKEFILES_BEFORE.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH))
3576endif
3577ifndef MAKEFILES_AFTER_$(PASS)
3578 MAKEFILES_AFTER_$(PASS) := $(MAKEFILES_AFTER) $(MAKEFILES_AFTER.$(KBUILD_TARGET)) $(MAKEFILES_AFTER.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH))
3579endif
3580
3581# The check.
3582ifeq ($(_KBUILD_STRICT_PASS_ORDER),nonstrict)
3583 ifneq ($(strip \
3584 $(SUBDIRS_$(PASS)) $(SUBDIRS_$(PASS).$(KBUILD_TARGET)) $(SUBDIRS_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \
3585 $(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(KBUILD_TARGET)) $(MAKEFILES_BEFORE_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \
3586 $(SUBDIRS_AFTER_$(PASS)) $(SUBDIRS_AFTER_$(PASS).$(KBUILD_TARGET)) $(SUBDIRS_AFTER_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \
3587 $(MAKEFILES_AFTER_$(PASS)) $(MAKEFILES_AFTER_$(PASS).$(KBUILD_TARGET)) $(MAKEFILES_AFTER_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \
3588 ),)
3589 _KBUILD_STRICT_PASS_ORDER := strict
3590 endif
3591endif # _KBUILD_STRICT_PASS_ORDER == nonstrict
3592endef # def_pass_setup_and_optimize
3593$(eval-opt-var def_pass_setup_and_optimize)
3594
3595## PASS: Setup & optimization.
3596# Check if we can apply the non-strict pass order optimzation (no SUBDIRS_* and MAKEFILES_*),
3597# and set up the pass specific variables as we go along.
3598_KBUILD_STRICT_PASS_ORDER := nonstrict
3599$(foreach PASS, $(PASSES), $(evalval def_pass_setup_and_optimize))
3600#$ (error _KBUILD_STRICT_PASS_ORDER=$(_KBUILD_STRICT_PASS_ORDER))
3601
3602ifeq ($(_KBUILD_STRICT_PASS_ORDER),strict)
3603 if !defined(KBUILD_SAFE_PARALLEL) || "$(KMK_OPT_JOBS)" == "1"
3604_KBUILD_STRICT_PASS_ORDER := strict_unsafe
3605 endif
3606endif
3607
3608
3609## Subdir
3610# @param $(pass) Lowercase pass name.
3611# @param $(PASS) Uppercase pass name.
3612# @param $(subdir) Subdirectory
3613# @param $(tag) tag to attach to the rule name.
3614define def_pass_subdir
3615pass_$(pass)$(tag):: $(dep)
3616 + $$(QUIET)$$(MAKE) -C $(subdir) -f $$(notdir $$(firstword $$(wildcard $$(addprefix $(subdir)/,$$(DEFAULT_MAKEFILE))))) pass_$(pass)
3617endef
3618
3619## Submakefile
3620# @param $(pass) Lowercase pass name.
3621# @param $(PASS) Uppercase pass name.
3622# @param $(makefile) Makefile.
3623# @param $(tag) tag to attach to the rule name.
3624define def_pass_makefile
3625pass_$(pass)$(tag):: $(dep)
3626 + $$(QUIET)$$(MAKE) -C $(patsubst %/,%,$(dir $(makefile))) -f $(notdir $(makefile)) pass_$(pass)
3627endef
3628
3629## Execute a pass, strict order.
3630# @param $(pass) Lowercase pass name.
3631# @param $(PASS) Uppercase pass name.
3632define def_pass_strict
3633$(eval tag:=_before)
3634$(eval dep:= )
3635$(foreach subdir, $(SUBDIRS_$(PASS)) $(SUBDIRS_$(PASS).$(KBUILD_TARGET)) $(SUBDIRS_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir)))
3636$(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(KBUILD_TARGET)) $(MAKEFILES_BEFORE_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)),$(eval $(def_pass_makefile)))
3637
3638$(eval tag:=_after)
3639$(eval dep:=pass_$(pass)_doit)
3640$(foreach subdir, $(SUBDIRS_AFTER_$(PASS)) $(SUBDIRS_AFTER_$(PASS).$(KBUILD_TARGET)) $(SUBDIRS_AFTER_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir)))
3641$(foreach makefile,$(MAKEFILES_AFTER_$(PASS)) $(MAKEFILES_AFTER_$(PASS).$(KBUILD_TARGET)) $(MAKEFILES_AFTER_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) ,$(eval $(def_pass_makefile)))
3642
3643.NOTPARALLEL: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_this
3644.PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_this pass_$(pass)_doit
3645pass_$(pass)_doit: $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var)))
3646pass_$(pass)_this: pass_$(pass)_before
3647 + $$(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)_doit
3648pass_$(pass)_after:: pass_$(pass)_this
3649pass_$(pass): pass_$(pass)_after
3650#$ (warning pass=$(pass) PASS=$(PASS): $(PASS_$(PASS)_trgs) $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var))))
3651endef # def_pass_strict
3652$(eval-opt-var def_pass_strict)
3653
3654## Execute a pass, strict order.
3655# @param $(pass) Lowercase pass name.
3656# @param $(PASS) Uppercase pass name.
3657define def_pass_strict_unsafe
3658$(eval tag:=_before)
3659$(eval dep:= )
3660$(foreach subdir, $(SUBDIRS_$(PASS)) $(SUBDIRS_$(PASS).$(KBUILD_TARGET)) $(SUBDIRS_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir)))
3661$(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(KBUILD_TARGET)) $(MAKEFILES_BEFORE_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)),$(eval $(def_pass_makefile)))
3662
3663$(eval tag:=_after)
3664$(eval dep:=pass_$(pass)_doit)
3665$(foreach subdir, $(SUBDIRS_AFTER_$(PASS)) $(SUBDIRS_AFTER_$(PASS).$(KBUILD_TARGET)) $(SUBDIRS_AFTER_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir)))
3666$(foreach makefile,$(MAKEFILES_AFTER_$(PASS)) $(MAKEFILES_AFTER_$(PASS).$(KBUILD_TARGET)) $(MAKEFILES_AFTER_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) ,$(eval $(def_pass_makefile)))
3667
3668.PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_doit
3669.NOTPARALLEL: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_doit
3670pass_$(pass)_doit: pass_$(pass)_before \
3671 $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var)))
3672pass_$(pass): \
3673 pass_$(pass)_before \
3674 pass_$(pass)_doit \
3675 pass_$(pass)_after
3676#$ (warning pass=$(pass) PASS=$(PASS): $(PASS_$(PASS)_trgs) $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var))))
3677endef # def_pass_strict_unsafe
3678$(eval-opt-var def_pass_strict_unsafe)
3679
3680## Execute a pass, non-strict pass ordering.
3681# @param $(pass) Lowercase pass name.
3682# @param $(PASS) Uppercase pass name.
3683define def_pass_nonstrict
3684.PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_doit
3685pass_$(pass)_doit: $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$$$$($(var)))
3686pass_$(pass): pass_$(pass)_doit
3687endef # def_pass_nonstrict
3688
3689## PASS: rules
3690# Generate the rules for the defined passes.
3691$(foreach PASS, $(PASSES), \
3692 $(eval pass := $(PASS_$(PASS)_pass)) \
3693 $(eval $(def_pass_$(_KBUILD_STRICT_PASS_ORDER))))
3694
3695
3696## Pass order, strict.
3697# @param $(pass) Current pass name.
3698# @param $(prev_pass) The previous pass name.
3699define def_pass_order_strict
3700.PHONY: pass_$(pass)_order
3701.NOTPARALLEL: pass_$(pass)_order
3702pass_$(pass)_order: $(pass_prev)
3703 %$$(call MSG_PASS,$$(if $$(PASS_$(PASS)),$$(PASS_$(PASS)),$(pass)))
3704 + $$(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)
3705$(eval pass_prev := pass_$(pass)_order)
3706endef # def_pass_order_strict
3707$(eval-opt-var def_pass_order_strict)
3708
3709## Pass order, strict unsafe.
3710# @param $(pass) Current pass name.
3711# @param $(prev_pass) The previous pass name.
3712define def_pass_order_strict_unsafe
3713.NOTPARALLEL: pass_$(pass)_order pass_$(pass)_banner
3714.PHONY: pass_$(pass)_order pass_$(pass)_banner
3715pass_$(pass)_banner: $(pass_prev)
3716 %$$(call MSG_PASS,$$(if $$(PASS_$(PASS)),$$(PASS_$(PASS)),$(pass)))
3717pass_$(pass)_order: $(pass_prev) \
3718 pass_$(pass)_banner \
3719 pass_$(pass)
3720$(eval pass_prev := pass_$(pass)_order)
3721endef # def_pass_order_strict_unsafe
3722$(eval-opt-var def_pass_order_strict_unsafe)
3723
3724## Pass order, non-strict.
3725# @param $(pass) Current pass name.
3726# @param $(prev_pass) The previous pass name.
3727define def_pass_order_nonstrict
3728.PHONY: pass_$(pass)_order pass_$(pass)_banner
3729pass_$(pass)_banner:
3730 %$$(call MSG_PASS,$$(if $$(PASS_$(PASS)),$$(PASS_$(PASS)),$(pass)))
3731pass_$(pass)_order: \
3732 $(pass_prev) \
3733 pass_$(pass)_banner \
3734 pass_$(pass)
3735$(eval pass_prev := pass_$(pass)_order)
3736endef # def_pass_order_nonstrict
3737$(eval-opt-var def_pass_order_nonstrict)
3738
3739## PASS: order
3740# Use dependencies to ensure correct pass order.
3741pass_prev :=
3742$(foreach PASS,$(DEFAULT_PASSES),\
3743 $(eval pass := $(PASS_$(PASS)_pass)) \
3744 $(eval $(def_pass_order_$(_KBUILD_STRICT_PASS_ORDER))))
3745
3746ifdef KBUILD_PROFILE_SELF
3747 $(evalcall def_profile_self, done passes)
3748endif
3749
3750# Some common pass aliases
3751ifndef KBUILD_NO_PASS_ALIASES
3752.PHONY: clean
3753clean: pass_clean
3754
3755.PHONY: nothing
3756nothing: pass_nothing
3757
3758.PHONY: staging
3759staging: pass_staging
3760
3761.PHONY: packing
3762packing: pass_packing
3763
3764 ifndef KBUILD_NO_TESTING_PASS_ALIASES
3765.PHONY: check
3766check:: pass_testing
3767
3768.PHONY: test
3769test:: pass_testing
3770 endif # KBUILD_NO_TESTING_PASS_ALIASES
3771endif # KBUILD_NO_PASS_ALIASES
3772
3773
3774#
3775# THE MAIN RULES
3776#
3777all_recursive: $(pass_prev)
3778
3779rebuild: clean
3780 + $(MAKE) -f $(firstword $(MAKEFILE_LIST)) all_recursive
3781
3782# @todo make this a non-default pass!
3783uninstall::
3784 $(RM) -f -- $(_INSTALLS_FILES)
3785
3786install:: pass_installs
3787
3788# misc shortcuts (use secondary expansion here to save strcache[file] space).
3789targets: bldprogs libraries dlls programs sysmods miscbins others installs
3790objects: $$(_OBJS)
3791bldprogs: $$(_BLDPROGS)
3792libraries: $$(_LIBS) $$(_IMPORT_LIBS) $$(_OTHER_LIBRARIES)
3793dlls: $$(_DLLS)
3794programs: $$(_PROGRAMS)
3795sysmods: $$(_SYSMODS)
3796miscbins: $$(_MISCBINS)
3797others: $$(_OTHERS)
3798stagings: $$(_INSTALLS) $$(_STAGE_DIRS) $$(_STAGE_FILES)
3799installs: $$(_INSTALLS_DIRS) $$(_INSTALLS_FILES)
3800
3801
3802
3803#
3804# kBuild debugging stuff.
3805#
3806## @todo this doesn't work. Move to a debug unit and expand it.
3807show_targets:
3808 @$(foreach target, $(_ALL_TARGETS),\
3809 @$(ECHO) "target: $(target)" $(NLTAB)\
3810 @$(ECHO) " $(target)_0_OUTDIR=$($(target)_0_OUTDIR)" $(NLTAB)\
3811 @$(ECHO) " $(target)_1_TARGET=$($(target)_1_TARGET)" $(NLTAB)\
3812 @$(ECHO) " INSTARGET_$(target)=$(INSTARGET_$(target))" $(NLTAB)\
3813$(foreach prop,$(PROPS_SINGLE) $(PROPS_ACCUMULATE_L) $(PROPS_ACCUMULATE_R) 2_OBJS CLEAN, \
3814 $(eval _tmp:=$(firstword $($(target)_BLD_TRG) $(KBUILD_TARGET))) \
3815 $(if $($(target)_$(prop).$(_tmp)),\
3816 @$(ECHO) " $(target)_$(prop).$(_tmp)=$($(target)_$(prop).$(_tmp))" $(NLTAB)) \
3817 $(if $($(target)_$(prop)), $(NLTAB)@$(ECHO) " $(target)_$(prop)=$($(target)_$(prop))" $(NLTAB)) \
3818)\
3819$(foreach prop,$(PROPS_DEFERRED), \
3820 $(eval _tmp:=$(firstword $($(target)_BLD_TRG) $(KBUILD_TARGET))) \
3821 $(if $(value $(target)_$(prop).$(_tmp)),\
3822 @$(ECHO) ' $(target)_$(prop).$(_tmp)=$(value $(TARGET)_$(prop).$(_tmp))' $(NLTAB)) \
3823 $(if $(value $(target)_$(prop)), $(NLTAB)@$(ECHO) ' $(target)_$(prop)=$(value $(target)_$(prop))' $(NLTAB)) \
3824))
3825
3826
3827
3828#
3829# Include dependency files.
3830#
3831ifdef _DEPFILES
3832 # TODO: first works the second doesn't, provided _KB_INCLUDE_DEPS is undefined:
3833 # if "$(_KB_INCLUDE_DEPS)" == "1"
3834 # if $(_KB_INCLUDE_DEPS) == "1"
3835
3836 ifdef KB_HAVE_INCLUDEDEP_QUEUE
3837 includedep-queue $(_DEPFILES)
3838 else
3839 $(foreach dep, $(_DEPFILES), $(eval includedep $(dep)))
3840 endif
3841endif
3842
3843
3844ifdef KBUILD_PROFILE_SELF
3845 $(evalcall def_profile_self, end of footer.kmk)
3846 _KBUILD_TS_FOOTER_END := $(_KBUILD_TS_PREV)
3847
3848 ifneq ($(KBUILD_PROFILE_SELF),0)
3849 $(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)) )
3850 $(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)) )
3851 $(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)) )
3852 $(info prof: DEPFILES_INCLUDED=$(words $(_DEPFILES_INCLUDED)) DEPFILES=$(words $(_DEPFILES)) MAKEFILES=$(words $(MAKEFILE_LIST)) )
3853 endif
3854endif
3855
3856
3857# end-of-file-content
3858__footer_kmk__ := target
3859endif # !defined(__footer_kmk__)
3860
Note: See TracBrowser for help on using the repository browser.