source: trunk/kBuild/footer.kmk@ 2433

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

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

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