source: trunk/kBuild/footer.kmk@ 2435

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

kBuild: Deprecating PATH_<target> and <target>_PATH in favor of <target>_0_OUTDIR and <target>_DEFPATH.

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