source: trunk/kBuild/footer.kmk@ 2080

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

footer.kmk: $(target)_2_OBJS fix.

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