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

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

kBuild: debug info installation support, core hacking + mac os x.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 14.9 KB
RevLine 
[72]1# $Id: footer-pass1.kmk 2523 2011-07-31 23:45:20Z 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 \
[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
147 $(target)_1_STAGE :=
148 $(target)_1_STAGE_TARGET :=
149endif
150INSTARGET_$(target) := $($(target)_1_STAGE_TARGET)
[828]151
[2475]152if1of ($(insttype), both)
153 $(target)_1_INST := $(inst)
[2511]154 if "$(substr $(inst),-1,1)" == "/" # Multicast support requires addprefix/suffix.
[2510]155 $(target)_1_INST_TARGET := $(addprefix $(PATH_INS)/,$(addsuffix $(notdir $(out)),$(inst)))
[2511]156 else if "$(inst)" == ""
157 $(target)_1_INST_TARGET := $(PATH_INS)/$(notdir $(out))
[2510]158 else
159 $(target)_1_INST_TARGET := $(addprefix $(PATH_INS)/,$(inst))
160 endif
[2475]161else
162 $(target)_1_INST :=
163 $(target)_1_INST_TARGET :=
164endif
165
[2523]166# Debug info related stuff.
167local debug_insttype := $(firstword \
168 $($(target)_DEBUG_INSTTYPE.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
169 $($(target)_DEBUG_INSTTYPE.$(bld_trg).$(bld_trg_arch)) \
170 $($(target)_DEBUG_INSTTYPE.$(bld_trg).$(bld_type)) \
171 $($(target)_DEBUG_INSTTYPE.$(bld_trg_arch)) \
172 $($(target)_DEBUG_INSTTYPE.$(bld_trg_cpu)) \
173 $($(target)_DEBUG_INSTTYPE.$(bld_trg)) \
174 $($(target)_DEBUG_INSTTYPE.$(bld_type)) \
175 $($(target)_DEBUG_INSTTYPE) \
176 $(insttype) )
177ifn1of ($(debug_insttype), none both stage)
178 $(error kBuild: Unknown value '$(debug_insttype)' for '$(target)_DEBUG_INSTTYPE'. Valid values are 'none', 'both' and 'stage'.)
179endif
180$(target)_1_DEBUG_INSTTYPE := $(debug_insttype)
181
182if1of ($(debug_insttype), stage both)
183 ifn1of ($(insttype), stage both)
184 $(error kBuild: DEBUG_INSTTYPE=$(debug_insttype) and INSTTYPE=$(insttype) for target '$(target)' are not compatible)
185 endif
186 local debug_stage := $(firstdefined \
187 $(target)_DEBUG_STAGE.$(bld_trg).$(bld_trg_arch).$(bld_type) \
188 $(target)_DEBUG_STAGE.$(bld_trg).$(bld_trg_arch) \
189 $(target)_DEBUG_STAGE.$(bld_trg).$(bld_type) \
190 $(target)_DEBUG_STAGE.$(bld_trg_arch) \
191 $(target)_DEBUG_STAGE.$(bld_trg_cpu) \
192 $(target)_DEBUG_STAGE.$(bld_trg) \
193 $(target)_DEBUG_STAGE.$(bld_type) \
194 $(target)_DEBUG_STAGE \
195 $(target)_DEBUG_INST.$(bld_trg).$(bld_trg_arch).$(bld_type) \
196 $(target)_DEBUG_INST.$(bld_trg).$(bld_trg_arch) \
197 $(target)_DEBUG_INST.$(bld_trg).$(bld_type) \
198 $(target)_DEBUG_INST.$(bld_trg_arch) \
199 $(target)_DEBUG_INST.$(bld_trg_cpu) \
200 $(target)_DEBUG_INST.$(bld_trg) \
201 $(target)_DEBUG_INST.$(bld_type) \
202 $(target)_DEBUG_INST)
203 ifneq ($(debug_stage),)
204 $(target)_1_DEBUG_STAGE := $($(debug_stage))
205 else
206 $(target)_1_DEBUG_STAGE := $(addprefix $(STAGE_DEBUG),$(stage))
207 endif
208 ifndef $(target)_1_DEBUG_STAGE
209 $(target)_1_DEBUG_STAGE := ./
210 endif
211else
212 $(target)_1_DEBUG_STAGE :=
213endif
214
215if1of ($(debug_insttype), both)
216 ifn1of ($(insttype), both)
217 $(error kBuild: DEBUG_INSTTYPE=$(debug_insttype) and INSTTYPE=$(insttype) for target '$(target)' are not compatible)
218 endif
219 local debug_inst := $(firstdefined \
220 $(target)_DEBUG_INST.$(bld_trg).$(bld_trg_arch).$(bld_type) \
221 $(target)_DEBUG_INST.$(bld_trg).$(bld_trg_arch) \
222 $(target)_DEBUG_INST.$(bld_trg).$(bld_type) \
223 $(target)_DEBUG_INST.$(bld_trg_arch) \
224 $(target)_DEBUG_INST.$(bld_trg_cpu) \
225 $(target)_DEBUG_INST.$(bld_trg) \
226 $(target)_DEBUG_INST.$(bld_type) \
227 $(target)_DEBUG_INST)
228 ifneq ($(debug_inst),)
229 $(target)_1_DEBUG_INST := $($(debug_inst))
230 else
231 $(target)_1_DEBUG_INST := $(addprefix $(INST_DEBUG),$(inst))
232 endif
233 ifndef $(target)_1_DEBUG_INST
234 $(target)_1_DEBUG_INST := ./
235 endif
236else
237 $(target)_1_DEBUG_INST :=
238endif
239#$(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))
240
[2475]241endef # def_pass1_link_common
[1936]242$(eval-opt-var def_pass1_link_common)
[828]243
244
245#
246# BLDPROGS (Pass 1)
247#
248define def_pass1_bldprog
249# set NOINST if not forced installation before doing the usual stuff.
250ifndef $(target)_INST
[2475]251$(target)_INSTTYPE := none
[828]252endif
[1496]253$(evalval def_pass1_link_common)
[828]254endef
255
256EXT := EXE
257EXTPRE := HOST
[2475]258definst := $(INST_BIN)
[828]259tool_prefix := LD
260bld_trg_base_var := PLATFORM
[1648]261$(foreach target, $(_ALL_BLDPROGS), \
[1496]262 $(evalval def_pass1_bldprog))
[828]263
264
265#
266# LIBRARIES (Pass 1)
267#
268EXT := LIB
269EXTPRE :=
[2475]270definst := $(INST_LIB)
[828]271tool_prefix := AR
272bld_trg_base_var := TARGET
[1648]273$(foreach target, $(_ALL_LIBRARIES), \
[1496]274 $(evalval def_pass1_link_common))
[828]275
276
277#
278# DLLS (Pass 1)
279#
280EXT := DLL
281EXTPRE :=
[2475]282definst := $(INST_DLL)
[828]283tool_prefix := LD
284bld_trg_base_var := TARGET
[1648]285$(foreach target, $(_ALL_DLLS), \
[1496]286 $(evalval def_pass1_link_common))
[828]287
288
289#
290# IMPORT LIBRARIES (Pass 1)
291#
292# - On OS/2 and windows these are libraries.
293# - On other platforms they are fake DLLs.
294#
[1504]295if1of ($(KBUILD_TARGET), nt os2 win win64 win32)
[828]296 EXT := LIB
297 EXTPRE :=
[2475]298 definst := $(INST_LIB)
[828]299 tool_prefix := AR
300 bld_trg_base_var := TARGET
[1648]301 $(foreach target, $(_ALL_IMPORT_LIBS), \
[1496]302 $(evalval def_pass1_link_common))
[828]303else
304 EXT := DLL
305 EXTPRE :=
[2475]306 definst := $(INST_DLL)
[828]307 tool_prefix := LD
308 bld_trg_base_var := TARGET
[1648]309 $(foreach target, $(_ALL_IMPORT_LIBS), \
[1496]310 $(evalval def_pass1_link_common))
[828]311endif
312
313
314#
315# PROGRAMS (Pass 1)
316#
317EXT := EXE
318EXTPRE :=
[2475]319definst := $(INST_BIN)
[828]320tool_prefix := LD
321bld_trg_base_var := TARGET
[1648]322$(foreach target, $(_ALL_PROGRAMS), \
[1496]323 $(evalval def_pass1_link_common))
[828]324
325
326#
327# SYSMODS (Pass 1)
328#
329EXT := SYS
330EXTPRE :=
[2475]331definst := $(INST_SYS)
[828]332tool_prefix := LD
333bld_trg_base_var := TARGET
[1648]334$(foreach target, $(_ALL_SYSMODS), \
[1496]335 $(evalval def_pass1_link_common))
[828]336
337
338#
[2084]339# MISCBINS (Pass 1)
340#
341EXT := BIN
342EXTPRE :=
[2475]343definst := $(INST_BIN)
[2084]344tool_prefix := LD
345bld_trg_base_var := TARGET
346$(foreach target, $(_ALL_MISCBINS), \
347 $(evalval def_pass1_link_common))
348
349
350#
[828]351# INSTALLS (Pass 1)
352# Note! INSTARGET_* for INSTALLS aren't available until later.
353#
354define def_pass1_install
[2241]355local bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE))
356local bld_trg := $(firstword $($(target)_BLD_TRG) $(KBUILD_TARGET))
357local bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(KBUILD_TARGET_ARCH))
358local bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(KBUILD_TARGET_CPU))
[2475]359# _1_TARGET
[2241]360$(target)_1_TARGET := $(PATH_TARGET)/$(target).ins
[2436]361$(call KB_FN_ASSIGN_DEPRECATED,TARGET_$(target),$($(target)_1_TARGET), $(target)_1_TARGET)
[2238]362
[2475]363# Determine and set 1_INSTTYPE.
364local insttype := $(firstword \
[2523]365 $($(target)_INSTTYPE.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
[2475]366 $($(target)_INSTTYPE.$(bld_trg).$(bld_trg_arch)) \
[2523]367 $($(target)_INSTTYPE.$(bld_trg).$(bld_type)) \
[2475]368 $($(target)_INSTTYPE.$(bld_trg_arch)) \
369 $($(target)_INSTTYPE.$(bld_trg_cpu)) \
[2523]370 $($(target)_INSTTYPE.$(bld_trg)) \
[2475]371 $($(target)_INSTTYPE.$(bld_type)) \
[2523]372 $($(target)_INSTTYPE) \
[2475]373 )
374ifeq ($(insttype),)
375 ifneq ($(firstword \
376 $($(target)_NOINST) \
377 $($(target)_NOINST.$(bld_trg)) \
378 $($(target)_NOINST.$(bld_trg).$(bld_trg_arch)) \
379 $($(target)_NOINST.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
380 $($(target)_NOINST.$(bld_trg_arch)) \
381 $($(target)_NOINST.$(bld_trg_cpu)) \
382 $($(target)_NOINST.$(bld_type)) ),)
383 local insttype := none
384 else
385 local insttype := both
386 endif
387endif
388ifn1of ($(insttype), none both stage)
389 $(error kBuild: Unknown value '$(insttype)' for '$(target)_INSTTYPE'. Valid values are 'none', 'both' and 'stage'.)
390endif
391$(target)_1_INSTTYPE := $(insttype)
392
393# Determine the actual INST and STAGE sub-dirs to use for this target.
394if1of ($(insttype), stage both)
[2517]395 local stage := $(strip $(firstdefined \
[2488]396 $(target)_STAGE.$(bld_trg).$(bld_trg_arch).$(bld_type) \
[2523]397 $(target)_STAGE.$(bld_trg).$(bld_trg_arch) \
398 $(target)_STAGE.$(bld_trg).$(bld_type) \
399 $(target)_STAGE.$(bld_trg_arch) \
400 $(target)_STAGE.$(bld_trg_cpu) \
401 $(target)_STAGE.$(bld_trg) \
402 $(target)_STAGE.$(bld_type) \
403 $(target)_STAGE \
[2488]404 $(target)_INST.$(bld_trg).$(bld_trg_arch).$(bld_type) \
405 $(target)_INST.$(bld_trg).$(bld_trg_arch) \
406 $(target)_INST.$(bld_trg).$(bld_type) \
407 $(target)_INST.$(bld_trg_arch) \
[2523]408 $(target)_INST.$(bld_trg_cpu) \
[2488]409 $(target)_INST.$(bld_trg) \
410 $(target)_INST.$(bld_type) \
411 $(target)_INST \
[2517]412 definst \
413 ,value))
[2488]414 if $(words $(stage)) > 1
415 $(warning kBuild: The STAGE/INST property of install '$(target)' specifies multiple location, that is not supported.)
416 local stage := $(word 1, $(stage))
417 endif
[2475]418 $(target)_1_STAGE := $(stage)
419else
420 $(target)_1_STAGE = $(error _1_STAGE not used)
421endif
422
423if1of ($(insttype), both)
[2517]424 local inst := $(strip $(firstdefined \
[2488]425 $(target)_INST.$(bld_trg).$(bld_trg_arch).$(bld_type) \
426 $(target)_INST.$(bld_trg).$(bld_trg_arch) \
427 $(target)_INST.$(bld_trg).$(bld_type) \
428 $(target)_INST.$(bld_trg_arch) \
[2523]429 $(target)_INST.$(bld_trg_cpu) \
[2488]430 $(target)_INST.$(bld_trg) \
431 $(target)_INST.$(bld_type) \
432 $(target)_INST \
[2517]433 definst \
434 ,value))
[2488]435 if $(words $(inst)) > 1
436 $(warning kBuild: The INST property of install '$(target)' specifies multiple location, that is not supported.)
437 local inst := $(word 1, $(inst))
438 endif
[2517]439 ifneq ($(root $(stage)),)
[2518]440 $(error kBuild: The effective INST property of install '$(target)' should not start with a root specification)
[2517]441 endif
[2475]442 $(target)_1_INST := $(inst)
443else
444 $(target)_1_INST = $(error _1_INST not used)
445endif
446
447# Block properties that we put off setting until pass 2 for INSTALLS.
448$(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!).)
449$(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!).)
450INSTARGET_$(target) = $(error The 'INSTARGET_' is deprecated and besides, it is being accessed to early. Consider '_2_STAGE_TARGETS' or '_2_INST_TARGETS'.)
451
[828]452# INSTARGET_ later.
[1754]453# PATH_*
[2241]454local outbase := $(call TARGET_BASE,$(target),$(target))
455$(target)_0_OUTDIR := $(patsubst %/,%,$(dir $(outbase)))
[2436]456$(call KB_FN_ASSIGN_DEPRECATED,PATH_$(target),$($(target)_0_OUTDIR), $(target)_0_OUTDIR)
[1754]457endef # def_pass1_install
[1936]458$(eval-opt-var def_pass1_install)
[2475]459
[1648]460$(foreach target, $(_ALL_INSTALLS), \
[1496]461 $(evalval def_pass1_install))
[828]462
[988]463ifdef KBUILD_PROFILE_SELF
[2008]464 $(evalcall def_profile_self, done pass 1)
[988]465endif
[828]466
467
Note: See TracBrowser for help on using the repository browser.