source: trunk/kBuild/footer.kmk@ 2436

Last change on this file since 2436 was 2436, checked in by bird, 15 years ago

footer.kmk: Deprecate TARGET_<target> and PATH_<target> use.

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