source: trunk/kBuild/footer-pass1.kmk@ 2762

Last change on this file since 2762 was 2762, checked in by bird, 10 years ago

Use evalvalctx instead of evalval for most of the target processing to make sure there isn't leakage between tragets via supposedly local variables (which ended up being local at the foreach level instead of the evalval level). Avoid troubles like we had in def_pass1_link_common when PDBs was installed but not the actual binary, we ended up using the $(inst) value from the previous run. (VBoxDrv.sys w/ signing enabled.)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 14.6 KB
RevLine 
[72]1# $Id: footer-pass1.kmk 2762 2015-01-28 18:17:54Z bird $
2## @file
[2521]3# kBuild - Footer - Target lists - Pass 1.
[72]4#
[2521]5# This pass is for defining variables that might be referenced in
6# properties of other targets.
7#
[1547]8
9#
[2726]10# Copyright (c) 2004-2014 knut st. osmundsen <bird-kBuild-spam-xiv@anduin.net>
[72]11#
12# This file is part of kBuild.
13#
14# kBuild is free software; you can redistribute it and/or modify
15# it under the terms of the GNU General Public License as published by
[106]16# the Free Software Foundation; either version source of the License, or
[72]17# (at your option) any later version.
18#
19# kBuild is distributed in the hope that it will be useful,
20# but WITHOUT ANY WARRANTY; without even the implied warranty of
21# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22# GNU General Public License for more details.
23#
24# You should have received a copy of the GNU General Public License
25# along with kBuild; if not, write to the Free Software
[353]26# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
[72]27#
28#
[1547]29# As a special exception you are granted permission to include this file, via
[1599]30# the kmk include directive, as you wish without this in itself causing the
31# resulting makefile, program or whatever to be covered by the GPL license.
[1547]32# This exception does not however invalidate any other reasons why the makefile,
33# program, whatever should not be covered the GPL.
34#
35#
[72]36
37
[828]38# Don't do anything for fetch targets (yet).
39
40##
41# Link prolog for Pass 1.
42#
43# @param $(target) Normalized target name.
44# @param $(EXT) EXE,DLL,SYS,LIB.
45# @param $(EXTPRE) HOST or nothing.
46# @param $(definst) The default _INST value.
47# @param $(tool_prefix) LD or AR.
48# @param $(bld_trg_base_var) TARGET or PLATFORM.
49define def_pass1_link_common
50
[1504]51local bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE))
[1496]52local bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_$(bld_trg_base_var)))
53local bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_$(bld_trg_base_var)_ARCH))
54local bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_$(bld_trg_base_var)_CPU))
[828]55
[1496]56local tool := $(call _TARGET_TOOL,$(target),$(tool_prefix))
57local name := $(firstword\
[2433]58 $($(target)_NAME.$(bld_trg).$(bld_trg_arch).$(bld_type))\
[889]59 $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\
[2433]60 $($(target)_NAME.$(bld_trg).$(bld_type))\
[889]61 $($(target)_NAME.$(bld_trg_arch))\
62 $($(target)_NAME.$(bld_trg))\
63 $($(target)_NAME.$(bld_type))\
64 $($(target)_NAME)\
65 $(target))
[1496]66local outbase := $(call TARGET_BASE,$(name),$(target))
[2239]67$(target)_0_OUTDIR:= $(patsubst %/,%,$(dir $(outbase)))
[2436]68$(call KB_FN_ASSIGN_DEPRECATED,PATH_$(target),$($(target)_0_OUTDIR), $(target)_0_OUTDIR)
69
[2143]70## @todo fix the fun at the last line (AR != LIB => mess).
71local suff := $(firstword \
[828]72 $($(target)_$(EXT)SUFF.$(bld_trg).$(bld_trg_arch))\
73 $($(target)_$(EXT)SUFF.$(bld_trg))\
74 $($(target)_$(EXT)SUFF)\
75 $(TOOL_$(tool)_$(tool_prefix)$(EXT)SUFF.$(bld_trg).$(bld_trg_arch))\
76 $(TOOL_$(tool)_$(tool_prefix)$(EXT)SUFF.$(bld_trg))\
77 $(TOOL_$(tool)_$(tool_prefix)$(EXT)SUFF)\
[2143]78 $(if $(eq $(tool_prefix),AR),$(SUFF_LIB),$($(EXTPRE)SUFF_$(EXT))) )
[1496]79local out := $(outbase)$(suff)
[828]80
[2475]81# Object directory target variable.
[2238]82$(target)_1_TARGET := $(out)
[2436]83$(call KB_FN_ASSIGN_DEPRECATED,TARGET_$(target),$($(target)_1_TARGET), $(target)_1_TARGET)
[828]84
[2475]85# Staging and install directory target variables.
86local insttype := $(firstword \
[2523]87 $($(target)_INSTTYPE.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
[2475]88 $($(target)_INSTTYPE.$(bld_trg).$(bld_trg_arch)) \
[2523]89 $($(target)_INSTTYPE.$(bld_trg).$(bld_type)) \
[2475]90 $($(target)_INSTTYPE.$(bld_trg_arch)) \
91 $($(target)_INSTTYPE.$(bld_trg_cpu)) \
[2523]92 $($(target)_INSTTYPE.$(bld_trg)) \
[2475]93 $($(target)_INSTTYPE.$(bld_type)) \
[2523]94 $($(target)_INSTTYPE) \
[2475]95 )
96ifeq ($(insttype),)
97 ifneq ($(firstword \
98 $($(target)_NOINST) \
99 $($(target)_NOINST.$(bld_trg)) \
100 $($(target)_NOINST.$(bld_trg).$(bld_trg_arch)) \
101 $($(target)_NOINST.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
102 $($(target)_NOINST.$(bld_trg_arch)) \
103 $($(target)_NOINST.$(bld_trg_cpu)) \
104 $($(target)_NOINST.$(bld_type)) ),)
105 local insttype := none
[1697]106 else
[2475]107 local insttype := both
[1697]108 endif
[2475]109endif
110ifn1of ($(insttype), none both stage)
111 $(error kBuild: Unknown value '$(insttype)' for '$(target)_INSTTYPE'. Valid values are 'none', 'both' and 'stage'.)
112endif
113$(target)_1_INSTTYPE := $(insttype)
[828]114
[2475]115if1of ($(insttype), stage both)
[2523]116 local inst := $(strip $(firstdefined \
[2488]117 $(target)_INST.$(bld_trg).$(bld_trg_arch).$(bld_type) \
118 $(target)_INST.$(bld_trg).$(bld_trg_arch) \
119 $(target)_INST.$(bld_trg).$(bld_type) \
120 $(target)_INST.$(bld_trg_arch) \
[2523]121 $(target)_INST.$(bld_trg_cpu) \
[2488]122 $(target)_INST.$(bld_trg) \
123 $(target)_INST.$(bld_type) \
124 $(target)_INST \
[2517]125 definst \
126 ,value))
[2523]127 local stage := $(strip $(firstdefined \
128 $(target)_STAGE.$(bld_trg).$(bld_trg_arch).$(bld_type) \
129 $(target)_STAGE.$(bld_trg).$(bld_trg_arch) \
130 $(target)_STAGE.$(bld_trg).$(bld_type) \
131 $(target)_STAGE.$(bld_trg_arch) \
132 $(target)_STAGE.$(bld_trg_cpu) \
133 $(target)_STAGE.$(bld_trg) \
134 $(target)_STAGE.$(bld_type) \
135 $(target)_STAGE \
136 inst \
137 ,value))
[2475]138 $(target)_1_STAGE := $(stage)
[2511]139 if "$(substr $(stage),-1,1)" == "/" # Multicast support requires addprefix/suffix.
[2510]140 $(target)_1_STAGE_TARGET := $(addprefix $(PATH_STAGE)/,$(addsuffix $(notdir $(out)),$(stage)))
[2511]141 else if "$(stage)" == ""
142 $(target)_1_STAGE_TARGET := $(PATH_STAGE)/$(notdir $(out))
[2510]143 else
144 $(target)_1_STAGE_TARGET := $(addprefix $(PATH_STAGE)/,$(stage))
145 endif
[2475]146else
[2762]147 local inst :=
148 local stage :=
[2475]149 $(target)_1_STAGE :=
150 $(target)_1_STAGE_TARGET :=
151endif
152INSTARGET_$(target) := $($(target)_1_STAGE_TARGET)
[828]153
[2475]154if1of ($(insttype), both)
155 $(target)_1_INST := $(inst)
[2511]156 if "$(substr $(inst),-1,1)" == "/" # Multicast support requires addprefix/suffix.
[2510]157 $(target)_1_INST_TARGET := $(addprefix $(PATH_INS)/,$(addsuffix $(notdir $(out)),$(inst)))
[2511]158 else if "$(inst)" == ""
159 $(target)_1_INST_TARGET := $(PATH_INS)/$(notdir $(out))
[2510]160 else
161 $(target)_1_INST_TARGET := $(addprefix $(PATH_INS)/,$(inst))
162 endif
[2475]163else
164 $(target)_1_INST :=
165 $(target)_1_INST_TARGET :=
166endif
167
[2523]168# Debug info related stuff.
169local debug_insttype := $(firstword \
170 $($(target)_DEBUG_INSTTYPE.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
171 $($(target)_DEBUG_INSTTYPE.$(bld_trg).$(bld_trg_arch)) \
172 $($(target)_DEBUG_INSTTYPE.$(bld_trg).$(bld_type)) \
173 $($(target)_DEBUG_INSTTYPE.$(bld_trg_arch)) \
174 $($(target)_DEBUG_INSTTYPE.$(bld_trg_cpu)) \
175 $($(target)_DEBUG_INSTTYPE.$(bld_trg)) \
176 $($(target)_DEBUG_INSTTYPE.$(bld_type)) \
177 $($(target)_DEBUG_INSTTYPE) \
178 $(insttype) )
179ifn1of ($(debug_insttype), none both stage)
180 $(error kBuild: Unknown value '$(debug_insttype)' for '$(target)_DEBUG_INSTTYPE'. Valid values are 'none', 'both' and 'stage'.)
181endif
182$(target)_1_DEBUG_INSTTYPE := $(debug_insttype)
183
184if1of ($(debug_insttype), stage both)
185 local debug_stage := $(firstdefined \
186 $(target)_DEBUG_STAGE.$(bld_trg).$(bld_trg_arch).$(bld_type) \
187 $(target)_DEBUG_STAGE.$(bld_trg).$(bld_trg_arch) \
188 $(target)_DEBUG_STAGE.$(bld_trg).$(bld_type) \
189 $(target)_DEBUG_STAGE.$(bld_trg_arch) \
190 $(target)_DEBUG_STAGE.$(bld_trg_cpu) \
191 $(target)_DEBUG_STAGE.$(bld_trg) \
192 $(target)_DEBUG_STAGE.$(bld_type) \
193 $(target)_DEBUG_STAGE \
194 $(target)_DEBUG_INST.$(bld_trg).$(bld_trg_arch).$(bld_type) \
195 $(target)_DEBUG_INST.$(bld_trg).$(bld_trg_arch) \
196 $(target)_DEBUG_INST.$(bld_trg).$(bld_type) \
197 $(target)_DEBUG_INST.$(bld_trg_arch) \
198 $(target)_DEBUG_INST.$(bld_trg_cpu) \
199 $(target)_DEBUG_INST.$(bld_trg) \
200 $(target)_DEBUG_INST.$(bld_type) \
201 $(target)_DEBUG_INST)
202 ifneq ($(debug_stage),)
203 $(target)_1_DEBUG_STAGE := $($(debug_stage))
204 else
205 $(target)_1_DEBUG_STAGE := $(addprefix $(STAGE_DEBUG),$(stage))
206 endif
207 ifndef $(target)_1_DEBUG_STAGE
208 $(target)_1_DEBUG_STAGE := ./
209 endif
210else
211 $(target)_1_DEBUG_STAGE :=
212endif
213
214if1of ($(debug_insttype), both)
215 local debug_inst := $(firstdefined \
216 $(target)_DEBUG_INST.$(bld_trg).$(bld_trg_arch).$(bld_type) \
217 $(target)_DEBUG_INST.$(bld_trg).$(bld_trg_arch) \
218 $(target)_DEBUG_INST.$(bld_trg).$(bld_type) \
219 $(target)_DEBUG_INST.$(bld_trg_arch) \
220 $(target)_DEBUG_INST.$(bld_trg_cpu) \
221 $(target)_DEBUG_INST.$(bld_trg) \
222 $(target)_DEBUG_INST.$(bld_type) \
223 $(target)_DEBUG_INST)
224 ifneq ($(debug_inst),)
225 $(target)_1_DEBUG_INST := $($(debug_inst))
226 else
227 $(target)_1_DEBUG_INST := $(addprefix $(INST_DEBUG),$(inst))
228 endif
229 ifndef $(target)_1_DEBUG_INST
230 $(target)_1_DEBUG_INST := ./
231 endif
232else
233 $(target)_1_DEBUG_INST :=
234endif
235#$(warning $(NLTAB)$(target)_1_DEBUG_INST=$($(target)_1_DEBUG_INST)$(NLTAB)$(target)_1_DEBUG_STAGE=$($(target)_1_DEBUG_STAGE)$(NLTAB)insttype=$(insttype)$(NLTAB)debug_insttype=$(debug_insttype))
236
[2475]237endef # def_pass1_link_common
[1936]238$(eval-opt-var def_pass1_link_common)
[828]239
240
241#
242# BLDPROGS (Pass 1)
243#
244define def_pass1_bldprog
245# set NOINST if not forced installation before doing the usual stuff.
246ifndef $(target)_INST
[2475]247$(target)_INSTTYPE := none
[828]248endif
[2762]249$(evalvalctx def_pass1_link_common)
[828]250endef
251
252EXT := EXE
253EXTPRE := HOST
[2475]254definst := $(INST_BIN)
[828]255tool_prefix := LD
256bld_trg_base_var := PLATFORM
[1648]257$(foreach target, $(_ALL_BLDPROGS), \
[2762]258 $(evalvalctx def_pass1_bldprog))
[828]259
260
261#
262# LIBRARIES (Pass 1)
263#
264EXT := LIB
265EXTPRE :=
[2475]266definst := $(INST_LIB)
[828]267tool_prefix := AR
268bld_trg_base_var := TARGET
[1648]269$(foreach target, $(_ALL_LIBRARIES), \
[2762]270 $(evalvalctx def_pass1_link_common))
[828]271
272
273#
274# DLLS (Pass 1)
275#
276EXT := DLL
277EXTPRE :=
[2475]278definst := $(INST_DLL)
[828]279tool_prefix := LD
280bld_trg_base_var := TARGET
[1648]281$(foreach target, $(_ALL_DLLS), \
[2762]282 $(evalvalctx def_pass1_link_common))
[828]283
284
285#
286# IMPORT LIBRARIES (Pass 1)
287#
288# - On OS/2 and windows these are libraries.
289# - On other platforms they are fake DLLs.
290#
[1504]291if1of ($(KBUILD_TARGET), nt os2 win win64 win32)
[828]292 EXT := LIB
293 EXTPRE :=
[2475]294 definst := $(INST_LIB)
[828]295 tool_prefix := AR
296 bld_trg_base_var := TARGET
[1648]297 $(foreach target, $(_ALL_IMPORT_LIBS), \
[2762]298 $(evalvalctx def_pass1_link_common))
[828]299else
300 EXT := DLL
301 EXTPRE :=
[2475]302 definst := $(INST_DLL)
[828]303 tool_prefix := LD
304 bld_trg_base_var := TARGET
[1648]305 $(foreach target, $(_ALL_IMPORT_LIBS), \
[2762]306 $(evalvalctx def_pass1_link_common))
[828]307endif
308
309
310#
311# PROGRAMS (Pass 1)
312#
313EXT := EXE
314EXTPRE :=
[2475]315definst := $(INST_BIN)
[828]316tool_prefix := LD
317bld_trg_base_var := TARGET
[1648]318$(foreach target, $(_ALL_PROGRAMS), \
[2762]319 $(evalvalctx def_pass1_link_common))
[828]320
321
322#
323# SYSMODS (Pass 1)
324#
325EXT := SYS
326EXTPRE :=
[2475]327definst := $(INST_SYS)
[828]328tool_prefix := LD
329bld_trg_base_var := TARGET
[1648]330$(foreach target, $(_ALL_SYSMODS), \
[2762]331 $(evalvalctx def_pass1_link_common))
[828]332
333
334#
[2084]335# MISCBINS (Pass 1)
336#
337EXT := BIN
338EXTPRE :=
[2475]339definst := $(INST_BIN)
[2084]340tool_prefix := LD
341bld_trg_base_var := TARGET
342$(foreach target, $(_ALL_MISCBINS), \
[2762]343 $(evalvalctx def_pass1_link_common))
[2084]344
345
346#
[828]347# INSTALLS (Pass 1)
348# Note! INSTARGET_* for INSTALLS aren't available until later.
349#
350define def_pass1_install
[2241]351local bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE))
352local bld_trg := $(firstword $($(target)_BLD_TRG) $(KBUILD_TARGET))
353local bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(KBUILD_TARGET_ARCH))
354local bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(KBUILD_TARGET_CPU))
[2475]355# _1_TARGET
[2241]356$(target)_1_TARGET := $(PATH_TARGET)/$(target).ins
[2436]357$(call KB_FN_ASSIGN_DEPRECATED,TARGET_$(target),$($(target)_1_TARGET), $(target)_1_TARGET)
[2238]358
[2475]359# Determine and set 1_INSTTYPE.
360local insttype := $(firstword \
[2523]361 $($(target)_INSTTYPE.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
[2475]362 $($(target)_INSTTYPE.$(bld_trg).$(bld_trg_arch)) \
[2523]363 $($(target)_INSTTYPE.$(bld_trg).$(bld_type)) \
[2475]364 $($(target)_INSTTYPE.$(bld_trg_arch)) \
365 $($(target)_INSTTYPE.$(bld_trg_cpu)) \
[2523]366 $($(target)_INSTTYPE.$(bld_trg)) \
[2475]367 $($(target)_INSTTYPE.$(bld_type)) \
[2523]368 $($(target)_INSTTYPE) \
[2475]369 )
370ifeq ($(insttype),)
371 ifneq ($(firstword \
372 $($(target)_NOINST) \
373 $($(target)_NOINST.$(bld_trg)) \
374 $($(target)_NOINST.$(bld_trg).$(bld_trg_arch)) \
375 $($(target)_NOINST.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
376 $($(target)_NOINST.$(bld_trg_arch)) \
377 $($(target)_NOINST.$(bld_trg_cpu)) \
378 $($(target)_NOINST.$(bld_type)) ),)
379 local insttype := none
380 else
381 local insttype := both
382 endif
383endif
384ifn1of ($(insttype), none both stage)
385 $(error kBuild: Unknown value '$(insttype)' for '$(target)_INSTTYPE'. Valid values are 'none', 'both' and 'stage'.)
386endif
387$(target)_1_INSTTYPE := $(insttype)
388
389# Determine the actual INST and STAGE sub-dirs to use for this target.
390if1of ($(insttype), stage both)
[2517]391 local stage := $(strip $(firstdefined \
[2488]392 $(target)_STAGE.$(bld_trg).$(bld_trg_arch).$(bld_type) \
[2523]393 $(target)_STAGE.$(bld_trg).$(bld_trg_arch) \
394 $(target)_STAGE.$(bld_trg).$(bld_type) \
395 $(target)_STAGE.$(bld_trg_arch) \
396 $(target)_STAGE.$(bld_trg_cpu) \
397 $(target)_STAGE.$(bld_trg) \
398 $(target)_STAGE.$(bld_type) \
399 $(target)_STAGE \
[2488]400 $(target)_INST.$(bld_trg).$(bld_trg_arch).$(bld_type) \
401 $(target)_INST.$(bld_trg).$(bld_trg_arch) \
402 $(target)_INST.$(bld_trg).$(bld_type) \
403 $(target)_INST.$(bld_trg_arch) \
[2523]404 $(target)_INST.$(bld_trg_cpu) \
[2488]405 $(target)_INST.$(bld_trg) \
406 $(target)_INST.$(bld_type) \
407 $(target)_INST \
[2517]408 definst \
409 ,value))
[2488]410 if $(words $(stage)) > 1
411 $(warning kBuild: The STAGE/INST property of install '$(target)' specifies multiple location, that is not supported.)
412 local stage := $(word 1, $(stage))
413 endif
[2475]414 $(target)_1_STAGE := $(stage)
415else
416 $(target)_1_STAGE = $(error _1_STAGE not used)
417endif
418
419if1of ($(insttype), both)
[2517]420 local inst := $(strip $(firstdefined \
[2488]421 $(target)_INST.$(bld_trg).$(bld_trg_arch).$(bld_type) \
422 $(target)_INST.$(bld_trg).$(bld_trg_arch) \
423 $(target)_INST.$(bld_trg).$(bld_type) \
424 $(target)_INST.$(bld_trg_arch) \
[2523]425 $(target)_INST.$(bld_trg_cpu) \
[2488]426 $(target)_INST.$(bld_trg) \
427 $(target)_INST.$(bld_type) \
428 $(target)_INST \
[2517]429 definst \
430 ,value))
[2488]431 if $(words $(inst)) > 1
432 $(warning kBuild: The INST property of install '$(target)' specifies multiple location, that is not supported.)
433 local inst := $(word 1, $(inst))
434 endif
[2517]435 ifneq ($(root $(stage)),)
[2518]436 $(error kBuild: The effective INST property of install '$(target)' should not start with a root specification)
[2517]437 endif
[2475]438 $(target)_1_INST := $(inst)
439else
440 $(target)_1_INST = $(error _1_INST not used)
441endif
442
443# Block properties that we put off setting until pass 2 for INSTALLS.
444$(target)_1_STAGE_TARGET = $(error The '_1_STAGE_TARGET' property is not present on install targets. Use '_2_STAGE_TARGETS' instead (set by pass 2!).)
445$(target)_1_INST_TARGET = $(error The '_1_INST_TARGET' property is not present on install targets. Use '_2_INST_TARGETS' instead (set by pass 2!).)
446INSTARGET_$(target) = $(error The 'INSTARGET_' is deprecated and besides, it is being accessed to early. Consider '_2_STAGE_TARGETS' or '_2_INST_TARGETS'.)
447
[828]448# INSTARGET_ later.
[1754]449# PATH_*
[2241]450local outbase := $(call TARGET_BASE,$(target),$(target))
451$(target)_0_OUTDIR := $(patsubst %/,%,$(dir $(outbase)))
[2436]452$(call KB_FN_ASSIGN_DEPRECATED,PATH_$(target),$($(target)_0_OUTDIR), $(target)_0_OUTDIR)
[1754]453endef # def_pass1_install
[1936]454$(eval-opt-var def_pass1_install)
[2475]455
[1648]456$(foreach target, $(_ALL_INSTALLS), \
[2762]457 $(evalvalctx def_pass1_install))
[828]458
[988]459ifdef KBUILD_PROFILE_SELF
[2008]460 $(evalcall def_profile_self, done pass 1)
[988]461endif
[828]462
463
Note: See TracBrowser for help on using the repository browser.