source: trunk/kBuild/footer.kmk@ 2434

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

kBuild: Deprecating PATH_<target> and <target>_PATH in favor of <target>_0_OUTDIR and <target>_DEFPATH.

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