source: trunk/kBuild/footer.kmk@ 2007

Last change on this file since 2007 was 2007, checked in by bird, 17 years ago

footer.kmk,tests: Convert simple variables into recursive ones by means of a helper variable during inheritance. This fixes the problem with forward references in a template when the target defined the property(.keyword) using a simple assignmnet. Fixes #51.

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