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
Line 
1# $Id: footer-pass1.kmk 2521 2011-07-26 18:18:19Z bird $
2## @file
3# kBuild - Footer - Target lists - Pass 1.
4#
5# This pass is for defining variables that might be referenced in
6# properties of other targets.
7#
8
9#
10# Copyright (c) 2004-2011 knut st. osmundsen <bird-kBuild-spamx@anduin.net>
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
16# the Free Software Foundation; either version source of the License, or
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
26# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27#
28#
29# As a special exception you are granted permission to include this file, via
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.
32# This exception does not however invalidate any other reasons why the makefile,
33# program, whatever should not be covered the GPL.
34#
35#
36
37
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
51local bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE))
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))
55
56local tool := $(call _TARGET_TOOL,$(target),$(tool_prefix))
57local name := $(firstword\
58 $($(target)_NAME.$(bld_trg).$(bld_trg_arch).$(bld_type))\
59 $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\
60 $($(target)_NAME.$(bld_trg).$(bld_type))\
61 $($(target)_NAME.$(bld_trg_arch))\
62 $($(target)_NAME.$(bld_trg))\
63 $($(target)_NAME.$(bld_type))\
64 $($(target)_NAME)\
65 $(target))
66local outbase := $(call TARGET_BASE,$(name),$(target))
67$(target)_0_OUTDIR:= $(patsubst %/,%,$(dir $(outbase)))
68$(call KB_FN_ASSIGN_DEPRECATED,PATH_$(target),$($(target)_0_OUTDIR), $(target)_0_OUTDIR)
69
70## @todo fix the fun at the last line (AR != LIB => mess).
71local suff := $(firstword \
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)\
78 $(if $(eq $(tool_prefix),AR),$(SUFF_LIB),$($(EXTPRE)SUFF_$(EXT))) )
79local out := $(outbase)$(suff)
80
81# Object directory target variable.
82$(target)_1_TARGET := $(out)
83$(call KB_FN_ASSIGN_DEPRECATED,TARGET_$(target),$($(target)_1_TARGET), $(target)_1_TARGET)
84
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
105 else
106 local insttype := both
107 endif
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)
113
114if1of ($(insttype), stage both)
115 local stage := $(strip $(firstdefined \
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 \
130 definst \
131 ,value))
132 $(target)_1_STAGE := $(stage)
133 if "$(substr $(stage),-1,1)" == "/" # Multicast support requires addprefix/suffix.
134 $(target)_1_STAGE_TARGET := $(addprefix $(PATH_STAGE)/,$(addsuffix $(notdir $(out)),$(stage)))
135 else if "$(stage)" == ""
136 $(target)_1_STAGE_TARGET := $(PATH_STAGE)/$(notdir $(out))
137 else
138 $(target)_1_STAGE_TARGET := $(addprefix $(PATH_STAGE)/,$(stage))
139 endif
140else
141 $(target)_1_STAGE :=
142 $(target)_1_STAGE_TARGET :=
143endif
144INSTARGET_$(target) := $($(target)_1_STAGE_TARGET)
145
146if1of ($(insttype), both)
147 local inst := $(strip $(firstdefined \
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 \
155 definst \
156 ,value))
157 $(target)_1_INST := $(inst)
158 if "$(substr $(inst),-1,1)" == "/" # Multicast support requires addprefix/suffix.
159 $(target)_1_INST_TARGET := $(addprefix $(PATH_INS)/,$(addsuffix $(notdir $(out)),$(inst)))
160 else if "$(inst)" == ""
161 $(target)_1_INST_TARGET := $(PATH_INS)/$(notdir $(out))
162 else
163 $(target)_1_INST_TARGET := $(addprefix $(PATH_INS)/,$(inst))
164 endif
165else
166 $(target)_1_INST :=
167 $(target)_1_INST_TARGET :=
168endif
169
170endef # def_pass1_link_common
171$(eval-opt-var def_pass1_link_common)
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
180$(target)_INSTTYPE := none
181endif
182$(evalval def_pass1_link_common)
183endef
184
185EXT := EXE
186EXTPRE := HOST
187definst := $(INST_BIN)
188tool_prefix := LD
189bld_trg_base_var := PLATFORM
190$(foreach target, $(_ALL_BLDPROGS), \
191 $(evalval def_pass1_bldprog))
192
193
194#
195# LIBRARIES (Pass 1)
196#
197EXT := LIB
198EXTPRE :=
199definst := $(INST_LIB)
200tool_prefix := AR
201bld_trg_base_var := TARGET
202$(foreach target, $(_ALL_LIBRARIES), \
203 $(evalval def_pass1_link_common))
204
205
206#
207# DLLS (Pass 1)
208#
209EXT := DLL
210EXTPRE :=
211definst := $(INST_DLL)
212tool_prefix := LD
213bld_trg_base_var := TARGET
214$(foreach target, $(_ALL_DLLS), \
215 $(evalval def_pass1_link_common))
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#
224if1of ($(KBUILD_TARGET), nt os2 win win64 win32)
225 EXT := LIB
226 EXTPRE :=
227 definst := $(INST_LIB)
228 tool_prefix := AR
229 bld_trg_base_var := TARGET
230 $(foreach target, $(_ALL_IMPORT_LIBS), \
231 $(evalval def_pass1_link_common))
232else
233 EXT := DLL
234 EXTPRE :=
235 definst := $(INST_DLL)
236 tool_prefix := LD
237 bld_trg_base_var := TARGET
238 $(foreach target, $(_ALL_IMPORT_LIBS), \
239 $(evalval def_pass1_link_common))
240endif
241
242
243#
244# PROGRAMS (Pass 1)
245#
246EXT := EXE
247EXTPRE :=
248definst := $(INST_BIN)
249tool_prefix := LD
250bld_trg_base_var := TARGET
251$(foreach target, $(_ALL_PROGRAMS), \
252 $(evalval def_pass1_link_common))
253
254
255#
256# SYSMODS (Pass 1)
257#
258EXT := SYS
259EXTPRE :=
260definst := $(INST_SYS)
261tool_prefix := LD
262bld_trg_base_var := TARGET
263$(foreach target, $(_ALL_SYSMODS), \
264 $(evalval def_pass1_link_common))
265
266
267#
268# MISCBINS (Pass 1)
269#
270EXT := BIN
271EXTPRE :=
272definst := $(INST_BIN)
273tool_prefix := LD
274bld_trg_base_var := TARGET
275$(foreach target, $(_ALL_MISCBINS), \
276 $(evalval def_pass1_link_common))
277
278
279#
280# INSTALLS (Pass 1)
281# Note! INSTARGET_* for INSTALLS aren't available until later.
282#
283define def_pass1_install
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))
288# _1_TARGET
289$(target)_1_TARGET := $(PATH_TARGET)/$(target).ins
290$(call KB_FN_ASSIGN_DEPRECATED,TARGET_$(target),$($(target)_1_TARGET), $(target)_1_TARGET)
291
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)
323 local stage := $(strip $(firstdefined \
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 \
338 definst \
339 ,value))
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
344 $(target)_1_STAGE := $(stage)
345else
346 $(target)_1_STAGE = $(error _1_STAGE not used)
347endif
348
349if1of ($(insttype), both)
350 local inst := $(strip $(firstdefined \
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 \
358 definst \
359 ,value))
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
364 ifneq ($(root $(stage)),)
365 $(error kBuild: The effective INST property of install '$(target)' should not start with a root specification)
366 endif
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
377# INSTARGET_ later.
378# PATH_*
379local outbase := $(call TARGET_BASE,$(target),$(target))
380$(target)_0_OUTDIR := $(patsubst %/,%,$(dir $(outbase)))
381$(call KB_FN_ASSIGN_DEPRECATED,PATH_$(target),$($(target)_0_OUTDIR), $(target)_0_OUTDIR)
382endef # def_pass1_install
383$(eval-opt-var def_pass1_install)
384
385$(foreach target, $(_ALL_INSTALLS), \
386 $(evalval def_pass1_install))
387
388ifdef KBUILD_PROFILE_SELF
389 $(evalcall def_profile_self, done pass 1)
390endif
391
392
Note: See TracBrowser for help on using the repository browser.