source: trunk/kBuild/footer.kmk@ 1521

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

removed a $(warning ) that was left behind.

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