source: trunk/kBuild/footer.kmk@ 1614

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

Added a CLEAN attribute to the install sources. Extended the cleaning of fetches a bit so it matches the others.

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