source: trunk/kBuild/footer.kmk@ 1411

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

Fixed _KEYWORDS collecting, didn't work right previously. Started on keyword inheritance.

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