source: trunk/kBuild/footer.kmk@ 2433

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

footer.kmk: Need to support all standard permutations for TOOLS, NAMES and SOURCES. Fixed a couple of typos in the NOINST area.

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