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

Last change on this file since 2521 was 2521, checked in by bird, 14 years ago

footer.kmk: Split it up into several files.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 12.1 KB
RevLine 
[72]1# $Id: footer-pass1.kmk 2521 2011-07-26 18:18:19Z 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#
[2521]10# Copyright (c) 2004-2011 knut st. osmundsen <bird-kBuild-spamx@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 \
87 $($(target)_INSTTYPE) \
88 $($(target)_INSTTYPE.$(bld_trg)) \
89 $($(target)_INSTTYPE.$(bld_trg).$(bld_trg_arch)) \
90 $($(target)_INSTTYPE.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
91 $($(target)_INSTTYPE.$(bld_trg_arch)) \
92 $($(target)_INSTTYPE.$(bld_trg_cpu)) \
93 $($(target)_INSTTYPE.$(bld_type)) \
94 )
95ifeq ($(insttype),)
96 ifneq ($(firstword \
97 $($(target)_NOINST) \
98 $($(target)_NOINST.$(bld_trg)) \
99 $($(target)_NOINST.$(bld_trg).$(bld_trg_arch)) \
100 $($(target)_NOINST.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
101 $($(target)_NOINST.$(bld_trg_arch)) \
102 $($(target)_NOINST.$(bld_trg_cpu)) \
103 $($(target)_NOINST.$(bld_type)) ),)
104 local insttype := none
[1697]105 else
[2475]106 local insttype := both
[1697]107 endif
[2475]108endif
109ifn1of ($(insttype), none both stage)
110 $(error kBuild: Unknown value '$(insttype)' for '$(target)_INSTTYPE'. Valid values are 'none', 'both' and 'stage'.)
111endif
112$(target)_1_INSTTYPE := $(insttype)
[828]113
[2475]114if1of ($(insttype), stage both)
[2517]115 local stage := $(strip $(firstdefined \
[2488]116 $(target)_STAGE.$(bld_trg).$(bld_trg_arch).$(bld_type) \
117 $(target)_INST.$(bld_trg).$(bld_trg_arch).$(bld_type) \
118 $(target)_STAGE.$(bld_trg).$(bld_trg_arch) \
119 $(target)_INST.$(bld_trg).$(bld_trg_arch) \
120 $(target)_STAGE.$(bld_trg).$(bld_type) \
121 $(target)_INST.$(bld_trg).$(bld_type) \
122 $(target)_STAGE.$(bld_trg_arch) \
123 $(target)_INST.$(bld_trg_arch) \
124 $(target)_STAGE.$(bld_trg) \
125 $(target)_INST.$(bld_trg) \
126 $(target)_STAGE.$(bld_type) \
127 $(target)_INST.$(bld_type) \
128 $(target)_STAGE \
129 $(target)_INST \
[2517]130 definst \
131 ,value))
[2475]132 $(target)_1_STAGE := $(stage)
[2511]133 if "$(substr $(stage),-1,1)" == "/" # Multicast support requires addprefix/suffix.
[2510]134 $(target)_1_STAGE_TARGET := $(addprefix $(PATH_STAGE)/,$(addsuffix $(notdir $(out)),$(stage)))
[2511]135 else if "$(stage)" == ""
136 $(target)_1_STAGE_TARGET := $(PATH_STAGE)/$(notdir $(out))
[2510]137 else
138 $(target)_1_STAGE_TARGET := $(addprefix $(PATH_STAGE)/,$(stage))
139 endif
[2475]140else
141 $(target)_1_STAGE :=
142 $(target)_1_STAGE_TARGET :=
143endif
144INSTARGET_$(target) := $($(target)_1_STAGE_TARGET)
[828]145
[2475]146if1of ($(insttype), both)
[2517]147 local inst := $(strip $(firstdefined \
[2488]148 $(target)_INST.$(bld_trg).$(bld_trg_arch).$(bld_type) \
149 $(target)_INST.$(bld_trg).$(bld_trg_arch) \
150 $(target)_INST.$(bld_trg).$(bld_type) \
151 $(target)_INST.$(bld_trg_arch) \
152 $(target)_INST.$(bld_trg) \
153 $(target)_INST.$(bld_type) \
154 $(target)_INST \
[2517]155 definst \
156 ,value))
[2475]157 $(target)_1_INST := $(inst)
[2511]158 if "$(substr $(inst),-1,1)" == "/" # Multicast support requires addprefix/suffix.
[2510]159 $(target)_1_INST_TARGET := $(addprefix $(PATH_INS)/,$(addsuffix $(notdir $(out)),$(inst)))
[2511]160 else if "$(inst)" == ""
161 $(target)_1_INST_TARGET := $(PATH_INS)/$(notdir $(out))
[2510]162 else
163 $(target)_1_INST_TARGET := $(addprefix $(PATH_INS)/,$(inst))
164 endif
[2475]165else
166 $(target)_1_INST :=
167 $(target)_1_INST_TARGET :=
168endif
169
170endef # def_pass1_link_common
[1936]171$(eval-opt-var def_pass1_link_common)
[828]172
173
174#
175# BLDPROGS (Pass 1)
176#
177define def_pass1_bldprog
178# set NOINST if not forced installation before doing the usual stuff.
179ifndef $(target)_INST
[2475]180$(target)_INSTTYPE := none
[828]181endif
[1496]182$(evalval def_pass1_link_common)
[828]183endef
184
185EXT := EXE
186EXTPRE := HOST
[2475]187definst := $(INST_BIN)
[828]188tool_prefix := LD
189bld_trg_base_var := PLATFORM
[1648]190$(foreach target, $(_ALL_BLDPROGS), \
[1496]191 $(evalval def_pass1_bldprog))
[828]192
193
194#
195# LIBRARIES (Pass 1)
196#
197EXT := LIB
198EXTPRE :=
[2475]199definst := $(INST_LIB)
[828]200tool_prefix := AR
201bld_trg_base_var := TARGET
[1648]202$(foreach target, $(_ALL_LIBRARIES), \
[1496]203 $(evalval def_pass1_link_common))
[828]204
205
206#
207# DLLS (Pass 1)
208#
209EXT := DLL
210EXTPRE :=
[2475]211definst := $(INST_DLL)
[828]212tool_prefix := LD
213bld_trg_base_var := TARGET
[1648]214$(foreach target, $(_ALL_DLLS), \
[1496]215 $(evalval def_pass1_link_common))
[828]216
217
218#
219# IMPORT LIBRARIES (Pass 1)
220#
221# - On OS/2 and windows these are libraries.
222# - On other platforms they are fake DLLs.
223#
[1504]224if1of ($(KBUILD_TARGET), nt os2 win win64 win32)
[828]225 EXT := LIB
226 EXTPRE :=
[2475]227 definst := $(INST_LIB)
[828]228 tool_prefix := AR
229 bld_trg_base_var := TARGET
[1648]230 $(foreach target, $(_ALL_IMPORT_LIBS), \
[1496]231 $(evalval def_pass1_link_common))
[828]232else
233 EXT := DLL
234 EXTPRE :=
[2475]235 definst := $(INST_DLL)
[828]236 tool_prefix := LD
237 bld_trg_base_var := TARGET
[1648]238 $(foreach target, $(_ALL_IMPORT_LIBS), \
[1496]239 $(evalval def_pass1_link_common))
[828]240endif
241
242
243#
244# PROGRAMS (Pass 1)
245#
246EXT := EXE
247EXTPRE :=
[2475]248definst := $(INST_BIN)
[828]249tool_prefix := LD
250bld_trg_base_var := TARGET
[1648]251$(foreach target, $(_ALL_PROGRAMS), \
[1496]252 $(evalval def_pass1_link_common))
[828]253
254
255#
256# SYSMODS (Pass 1)
257#
258EXT := SYS
259EXTPRE :=
[2475]260definst := $(INST_SYS)
[828]261tool_prefix := LD
262bld_trg_base_var := TARGET
[1648]263$(foreach target, $(_ALL_SYSMODS), \
[1496]264 $(evalval def_pass1_link_common))
[828]265
266
267#
[2084]268# MISCBINS (Pass 1)
269#
270EXT := BIN
271EXTPRE :=
[2475]272definst := $(INST_BIN)
[2084]273tool_prefix := LD
274bld_trg_base_var := TARGET
275$(foreach target, $(_ALL_MISCBINS), \
276 $(evalval def_pass1_link_common))
277
278
279#
[828]280# INSTALLS (Pass 1)
281# Note! INSTARGET_* for INSTALLS aren't available until later.
282#
283define def_pass1_install
[2241]284local bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE))
285local bld_trg := $(firstword $($(target)_BLD_TRG) $(KBUILD_TARGET))
286local bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(KBUILD_TARGET_ARCH))
287local bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(KBUILD_TARGET_CPU))
[2475]288# _1_TARGET
[2241]289$(target)_1_TARGET := $(PATH_TARGET)/$(target).ins
[2436]290$(call KB_FN_ASSIGN_DEPRECATED,TARGET_$(target),$($(target)_1_TARGET), $(target)_1_TARGET)
[2238]291
[2475]292# Determine and set 1_INSTTYPE.
293local insttype := $(firstword \
294 $($(target)_INSTTYPE) \
295 $($(target)_INSTTYPE.$(bld_trg)) \
296 $($(target)_INSTTYPE.$(bld_trg).$(bld_trg_arch)) \
297 $($(target)_INSTTYPE.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
298 $($(target)_INSTTYPE.$(bld_trg_arch)) \
299 $($(target)_INSTTYPE.$(bld_trg_cpu)) \
300 $($(target)_INSTTYPE.$(bld_type)) \
301 )
302ifeq ($(insttype),)
303 ifneq ($(firstword \
304 $($(target)_NOINST) \
305 $($(target)_NOINST.$(bld_trg)) \
306 $($(target)_NOINST.$(bld_trg).$(bld_trg_arch)) \
307 $($(target)_NOINST.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
308 $($(target)_NOINST.$(bld_trg_arch)) \
309 $($(target)_NOINST.$(bld_trg_cpu)) \
310 $($(target)_NOINST.$(bld_type)) ),)
311 local insttype := none
312 else
313 local insttype := both
314 endif
315endif
316ifn1of ($(insttype), none both stage)
317 $(error kBuild: Unknown value '$(insttype)' for '$(target)_INSTTYPE'. Valid values are 'none', 'both' and 'stage'.)
318endif
319$(target)_1_INSTTYPE := $(insttype)
320
321# Determine the actual INST and STAGE sub-dirs to use for this target.
322if1of ($(insttype), stage both)
[2517]323 local stage := $(strip $(firstdefined \
[2488]324 $(target)_STAGE.$(bld_trg).$(bld_trg_arch).$(bld_type) \
325 $(target)_INST.$(bld_trg).$(bld_trg_arch).$(bld_type) \
326 $(target)_STAGE.$(bld_trg).$(bld_trg_arch) \
327 $(target)_INST.$(bld_trg).$(bld_trg_arch) \
328 $(target)_STAGE.$(bld_trg).$(bld_type) \
329 $(target)_INST.$(bld_trg).$(bld_type) \
330 $(target)_STAGE.$(bld_trg_arch) \
331 $(target)_INST.$(bld_trg_arch) \
332 $(target)_STAGE.$(bld_trg) \
333 $(target)_INST.$(bld_trg) \
334 $(target)_STAGE.$(bld_type) \
335 $(target)_INST.$(bld_type) \
336 $(target)_STAGE \
337 $(target)_INST \
[2517]338 definst \
339 ,value))
[2488]340 if $(words $(stage)) > 1
341 $(warning kBuild: The STAGE/INST property of install '$(target)' specifies multiple location, that is not supported.)
342 local stage := $(word 1, $(stage))
343 endif
[2475]344 $(target)_1_STAGE := $(stage)
345else
346 $(target)_1_STAGE = $(error _1_STAGE not used)
347endif
348
349if1of ($(insttype), both)
[2517]350 local inst := $(strip $(firstdefined \
[2488]351 $(target)_INST.$(bld_trg).$(bld_trg_arch).$(bld_type) \
352 $(target)_INST.$(bld_trg).$(bld_trg_arch) \
353 $(target)_INST.$(bld_trg).$(bld_type) \
354 $(target)_INST.$(bld_trg_arch) \
355 $(target)_INST.$(bld_trg) \
356 $(target)_INST.$(bld_type) \
357 $(target)_INST \
[2517]358 definst \
359 ,value))
[2488]360 if $(words $(inst)) > 1
361 $(warning kBuild: The INST property of install '$(target)' specifies multiple location, that is not supported.)
362 local inst := $(word 1, $(inst))
363 endif
[2517]364 ifneq ($(root $(stage)),)
[2518]365 $(error kBuild: The effective INST property of install '$(target)' should not start with a root specification)
[2517]366 endif
[2475]367 $(target)_1_INST := $(inst)
368else
369 $(target)_1_INST = $(error _1_INST not used)
370endif
371
372# Block properties that we put off setting until pass 2 for INSTALLS.
373$(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!).)
374$(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!).)
375INSTARGET_$(target) = $(error The 'INSTARGET_' is deprecated and besides, it is being accessed to early. Consider '_2_STAGE_TARGETS' or '_2_INST_TARGETS'.)
376
[828]377# INSTARGET_ later.
[1754]378# PATH_*
[2241]379local outbase := $(call TARGET_BASE,$(target),$(target))
380$(target)_0_OUTDIR := $(patsubst %/,%,$(dir $(outbase)))
[2436]381$(call KB_FN_ASSIGN_DEPRECATED,PATH_$(target),$($(target)_0_OUTDIR), $(target)_0_OUTDIR)
[1754]382endef # def_pass1_install
[1936]383$(eval-opt-var def_pass1_install)
[2475]384
[1648]385$(foreach target, $(_ALL_INSTALLS), \
[1496]386 $(evalval def_pass1_install))
[828]387
[988]388ifdef KBUILD_PROFILE_SELF
[2008]389 $(evalcall def_profile_self, done pass 1)
[988]390endif
[828]391
392
Note: See TracBrowser for help on using the repository browser.