source: trunk/kBuild/footer-pass2-compiling-targets.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: 35.3 KB
RevLine 
[72]1# $Id: footer-pass2-compiling-targets.kmk 2762 2015-01-28 18:17:54Z bird $
2## @file
[2521]3# kBuild - Footer - Target lists - Pass 2 - Compiling Targets.
[72]4#
[1547]5
6#
[2726]7# Copyright (c) 2004-2014 knut st. osmundsen <bird-kBuild-spam-xiv@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
34
35#
[73]36# Object processing.
37#
[72]38
[380]39## wrapper the compile command dependency check.
40ifndef NO_COMPILE_CMDS_DEPS
[2026]41 if1of ($(KMK_FEATURES),dot-must-make)
42 _DEP_COMPILE_CMDS =
43 # for debugging: $$(warning MUST_MAKE=$$$$(comp-cmds-ex $$$$($(target)_$(subst :,_,$(source))_CMDS_PREV_), $$$$(commands $$@)) -> $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_CMDS_PREV_),$$(commands $$@),FORCE))
44 else
45 _DEP_COMPILE_CMDS = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_CMDS_PREV_),$$(commands $(obj)),FORCE)
46 endif
[380]47else
[730]48 _DEP_COMPILE_CMDS =
[380]49endif
50
[2026]51
[749]52## Generates the rules for building a specific object, and the aliases
[380]53# for building a source file.
[353]54# @param $(obj) The object file.
[380]55define def_target_source_rule
[2026]56ifndef NO_COMPILE_CMDS_DEPS
57$(obj): .MUST_MAKE = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_CMDS_PREV_),$$(commands $$@),FORCE)
58endif
[1012]59ifdef TOOL_$(tool)_COMPILE_$(type)_USES_KOBJCACHE
[2196]60_OUT_FILES += $(outbase).koc
[1030]61$(outbase).koc +| $(obj) $($(target)_$(source)_OUTPUT_) $($(target)_$(source)_OUTPUT_MAYBE_) : \
[1007]62 $($(target)_$(source)_DEPEND_) \
[1456]63 $(value _DEP_COMPILE_CMDS) \
[1007]64 | \
[1426]65 $($(target)_$(source)_DEPORD_) \
[2355]66 $$$$($(target)_INTERMEDIATES) \
67 $$$$($(target)_INTERMEDIATES.$(bld_trg)) \
68 $$$$($(target)_INTERMEDIATES.$(bld_trg).$(bld_trg_arch)) \
69 $$$$($(target)_INTERMEDIATES.$(bld_trg_arch)) \
70 $$$$($(target)_INTERMEDIATES.$(bld_trg_cpu)) \
71 $$$$($(target)_INTERMEDIATES.$(bld_type))
[1496]72 %$$(call MSG_COMPILE,$(target),$(source),$$@,$(type))
[1007]73else
[1030]74$(obj) + $($(target)_$(source)_OUTPUT_) +| $($(target)_$(source)_OUTPUT_MAYBE_) : \
[380]75 $($(target)_$(source)_DEPEND_) \
[1456]76 $(value _DEP_COMPILE_CMDS) \
[380]77 | \
[1426]78 $($(target)_$(source)_DEPORD_) \
[2355]79 $$$$($(target)_INTERMEDIATES) \
80 $$$$($(target)_INTERMEDIATES.$(bld_trg)) \
81 $$$$($(target)_INTERMEDIATES.$(bld_trg).$(bld_trg_arch)) \
82 $$$$($(target)_INTERMEDIATES.$(bld_trg_arch)) \
83 $$$$($(target)_INTERMEDIATES.$(bld_trg_cpu)) \
84 $$$$($(target)_INTERMEDIATES.$(bld_type))
[1496]85 %$$(call MSG_COMPILE,$(target),$(source),$$@,$(type))
[1012]86ifdef TOOL_$(tool)_COMPILE_$(type)_DONT_PURGE_OUTPUT
[1599]87 $$(QUIET)$$(RM) -f -- $(dep) $(obj) $($(target)_$(source)_OUTPUT_) $($(target)_OUTPUT_MAYBE_)
[1007]88endif
[1012]89endif
[412]90
[380]91$($(target)_$(source)_CMDS_)
92
93ifndef NO_COMPILE_CMDS_DEPS
[1496]94 %$$(QUIET2)$$(APPEND) '$(dep)'
[1520]95 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_CMDS_PREV_'
[1496]96 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(obj)'
97 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
[770]98endif
[380]99
[749]100$(basename $(notdir $(obj))).o: $(obj)
101$(basename $(notdir $(obj))).obj: $(obj)
[1496]102
[2234]103## @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]104$(target)_$(source)_CMDS_ :=
[2234]105$(target)_$(source)_OUTPUT_ :=
106$(target)_$(source)_OUTPUT_MAYBE_ :=
107$(target)_$(source)_DEPEND_ :=
108$(target)_$(source)_DEPORD_ :=
[1936]109endef # def_target_source_rule
110$(eval-opt-var def_target_source_rule)
[205]111
[353]112
[380]113## wrapper the link command dependency check.
[1502]114ifndef NO_LINK_CMDS_DEPS
[2026]115 if1of ($(KMK_FEATURES),dot-must-make)
116 _DEP_LINK_CMDS =
117 else
118 _DEP_LINK_CMDS = $$(comp-cmds-ex $$($(target)_CMDS_PREV_),$$(commands $(out)),FORCE)
119 endif
[380]120else
[730]121 _DEP_LINK_CMDS =
[380]122endif
123
124## Generate the link rule for a target.
125# @param $(target) The normalized target name.
126# @param $(dirdep) Directories we depend upon begin created before linking.
127# @param $(dep) The name of the dependency file.
128# @param $(out)
[2234]129# @param $($(target)_2_OUTPUT) Output files from the link.
130# @param $($(target)_2_OUTPUT_MAYBE) Output files that the link may perhaps create.
131# @param $($(target)_2_DEPEND) Dependencies.
132# @param $($(target)_2_DEPORD) Dependencies which should only affect build order.
[1496]133# @param $(cmds) The link commands.
[380]134# @param $($(target)_CMDS_PREV_) The link commands from the previous run.
135define def_link_rule
[2531]136$$(call KB_FN_ASSERT_ABSPATH,out)
[2026]137ifndef NO_LINK_CMDS_DEPS
138$(out): .MUST_MAKE = $$(comp-cmds-ex $$($(target)_CMDS_PREV_),$$(commands $$@),FORCE)
139endif
[2523]140$(out) \
141+ $($(target)_2_OUTPUT) \
142+ $($(target)_2_OUTPUT_DEBUG_FILES) \
143+ $($(target)_2_OUTPUT_DEBUG_DIRS) \
144+| $($(target)_2_OUTPUT_MAYBE) : \
[2234]145 $$$$($(target)_2_DEPEND) \
[1456]146 $(value _DEP_LINK_CMDS) \
[380]147 | \
[2234]148 $$$$($(target)_2_DEPORD)
[1496]149 %$$(call MSG_LINK,$(target),$$@,$(tool_do))
[2523]150 $$(QUIET)$$(RM) -f -- $(dep) $(out) $($(target)_2_OUTPUT) $($(target)_2_OUTPUT_MAYBE) $($(target)_2_OUTPUT_DEBUG_FILES)
151ifdef $(target)_2_OUTPUT_DEBUG_DIRS
152 $$(QUIET)$$(RM) -Rf -- $($(target)_2_OUTPUT_DEBUG_DIRS)
153endif
[412]154
[1496]155$(cmds)
[380]156
[524]157ifndef NO_LINK_CMDS_DEPS
[1496]158 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_CMDS_PREV_'
159 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
160 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
[770]161endif
[380]162
[1686]163$(basename $(notdir $(out))):: $(out)
[719]164
[1936]165endef # def_link_rule
166$(eval-opt-var def_link_rule)
[380]167
168
169## Generate the link & lib install rule
[2475]170# Implicit parameters: target, out, $(target)_1_STAGE_TARGET, mode,
171# pre_install_cmds, post_install_cmds
[380]172define def_link_install_rule
[2531]173$$(call KB_FN_ASSERT_ABSPATH,$(target)_1_INST_TARGET)
[2488]174$($(target)_1_INST_TARGET): $(out) | $$$$(dir $$$$@)
[1496]175 %$$(call MSG_INST_TRG,$(target),$(out),$$@)
[2475]176 $(pre_install_cmds)
177
[2225]178 $$(QUIET)$$(INSTALL) $(if $(mode),-m $(mode)) $(if $(uid),-o $(uid)) $(if $(gid),-g $(gid)) -- $(out) $$@
[2475]179 $(post_install_cmds)
[719]180
[2475]181endef
[380]182
[2475]183
184## Generate the link & lib stage installation rule
185# Implicit parameters: target, out, $(target)_1_STAGE_TARGET, mode,
186# pre_install_cmds, post_install_cmds
187define def_link_stage_rule
[2531]188$$(call KB_FN_ASSERT_ABSPATH,$(target)_1_STAGE_TARGET)
[2488]189$($(target)_1_STAGE_TARGET): $(out) | $$$$(dir $$$$@)
[2475]190 %$$(call MSG_INST_TRG,$(target),$(out),$$@)
191 $(pre_install_cmds)
192
[2479]193 $$(QUIET)$$(INSTALL_STAGING) $(if $(mode),-m $(mode)) $(if $(uid),-o $(uid)) $(if $(gid),-g $(gid)) -- $(out) $$@
[2475]194 $(post_install_cmds)
195
196
197$(basename $(notdir $(out))):: $($(target)_1_STAGE_TARGET)
198
199endef
200
201
[1424]202## def_src_handler_*
203#
204# @{
205define def_src_handler_c
[1496]206local type := C
[1795]207 $(kb-src-one 2)
[1424]208endef
[73]209
[1424]210define def_src_handler_cxx
[1496]211local type := CXX
[1795]212 $(kb-src-one 2)
[1424]213endef
[73]214
[1424]215define def_src_handler_objc
[1496]216local type := OBJC
[1795]217 $(kb-src-one 2)
[1424]218endef
[1256]219
[2356]220define def_src_handler_objcxx
[2359]221local type := OBJCXX
[2356]222 $(kb-src-one 2)
223endef
224
[1424]225define def_src_handler_asm
[1496]226local type := AS
[1795]227 $(kb-src-one 2)
[1424]228endef
[353]229
[1424]230define def_src_handler_rc
[1496]231local type := RC
[1795]232 $(kb-src-one 2)
[1424]233endef
[641]234
[1424]235define def_src_handler_obj
[1434]236ifeq ($(defpath),)
[2080]237 $(target)_2_OBJS += $(source)
238else
239 $(target)_2_OBJS += $(abspathex $(source), $(defpath))
240endif
241endef
[1424]242## @}
[73]243
[1424]244## Handle one source.
245# .
246define def_src_handler_one
[1496]247local suff := $(suffix $(source))
248local src_handler := $(firstword $(filter $(suff):%, $($(target)_$(source)_SRC_HANDLERS) $($(source)_SRC_HANDLERS) $(target_src_handlers) ))
249local handler := $(patsubst $(suff):%,%,$(src_handler))
[1424]250ifneq ($(handler),)
[1625]251 $(evalvalctx $(handler))
[1424]252else
[1434]253 othersrc += $(source)
[1424]254endif
[2475]255endef # def_src_handler_one
[73]256
[1424]257## Generic macro for processing all target sources.
258# @param $(target) Normalized target name.
259# @param $(defpath)
260# @param much-more...
[2236]261# @returns othersrc, $(target)_2_OBJS, ++
[1424]262define def_target_sources
[1496]263local target_src_handlers := $($(target)_SRC_HANDLERS) $(KBUILD_SRC_HANDLERS)
[1424]264$(foreach source,\
[1429]265 $($(target)_SOURCES)\
266 $($(target)_SOURCES.$(bld_trg))\
[2433]267 $($(target)_SOURCES.$(bld_trg).$(bld_type))\
[1429]268 $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch))\
[2433]269 $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch).$(bld_type))\
[1429]270 $($(target)_SOURCES.$(bld_trg_arch))\
271 $($(target)_SOURCES.$(bld_trg_cpu))\
272 $($(target)_SOURCES.$(bld_type))\
[2762]273 ,$(evalvalctx def_src_handler_one) )
[1621]274
275$(foreach source,\
276 $($(target)_GEN_SOURCES_)\
277 $($(target)_GEN_SOURCES_.$(bld_trg))\
[2433]278 $($(target)_GEN_SOURCES_.$(bld_trg).$(bld_type))\
[1621]279 $($(target)_GEN_SOURCES_.$(bld_trg).$(bld_trg_arch))\
[2433]280 $($(target)_GEN_SOURCES_.$(bld_trg).$(bld_trg_arch).$(bld_type))\
[1621]281 $($(target)_GEN_SOURCES_.$(bld_trg_arch))\
282 $($(target)_GEN_SOURCES_.$(bld_trg_cpu))\
283 $($(target)_GEN_SOURCES_.$(bld_type))\
[2762]284 ,$(evalvalctx def_src_handler_one) )
[1936]285endef # def_target_sources
286$(eval-opt-var def_target_sources)
[1424]287
288
[2475]289##
[2523]290# Install a debug directory.
291# @param debug_dir The directory name.
292define def_link_install_debug_dir_rule
[2535]293local dir := $(debug_inst_path)/$(debug_inst2)$(debug_dir)
[2531]294$$(call KB_FN_ASSERT_ABSPATH,dir)
[2523]295$$(dir): | $$$$(dir $$$$(patsubst %/,%,$$$$@))
296 %$$(call MSG_INST_DIR,$$@)
297 $$(QUIET)$$(MKDIR) -p -- $$@
298$(target)_2_DEBUG_$(debug_var)_TARGET_DIRS += $$(dir)
299endef # def_link_install_debug_dir_rule
300
301##
[2531]302# Install a debug file.
[2523]303# @param debug_file Src=>Dst file pair.
304define def_link_install_debug_file_rule
[2535]305local dst := $(debug_inst_path)/$(debug_inst2)$(word 2, $(subst =>,$(SP),$(debug_file)))
[2531]306$$(call KB_FN_ASSERT_ABSPATH,dst)
307local src := $(word 1, $(subst =>,$(SP),$(debug_file)))
308$$(call KB_FN_ASSERT_ABSPATH,src)
309$$(dst): $$(src) | $$$$(dir $$$$@)
[2535]310 %$$(call MSG_INST_FILE,$$<,$$@)
[2523]311 $$(QUIET)$(debug_install_cmd) $(if $(mode),-m $(mode)) $(if $(uid),-o $(uid)) $(if $(gid),-g $(gid)) -- $$< $$@
312$(target)_2_DEBUG_$(debug_var)_TARGET_FILES += $$(dst)
313endef # def_link_install_debug_file_rule
314
315##
[2531]316# Install debug info to $(debug_inst), where debug_inst can be a directory or
[2523]317# file (just like $(inst) and $(stage). Used for both staging and installing.
318define def_target_install_only_debug
319if "$(substr $(debug_inst),-1,1)" == "/"
320 if "$(debug_inst)" == "./"
[2535]321 local debug_inst2 :=
322 else
323 local debug_inst2 := $(debug_inst)
[2523]324 endif
325 local debug_dirs := $(patsubst $($(target)_0_OUTDIR)/%,%,$($(target)_2_OUTPUT_DEBUG_DIRS))
326 ifneq ($(strip $(root $(debug_dirs))),)
327 $(error kBuild: Bad tool? debug_dirs='$(debug_dirs)', expected all to be under '$(outbase)')
328 endif
329 local debug_files := $(foreach file, $(patsubst $($(target)_0_OUTDIR)/%,%,$($(target)_2_OUTPUT_DEBUG_FILES)) \
330 ,$($(target)_0_OUTDIR)/$(file)=>$(file))
331else
[2535]332 local debug_notdir:= $(notdir $(debug_inst))
333 local debug_inst2 := $(dir $(debug_inst))
334 local debug_files := $(call TOOL_$(tool)_$(tool_do)_DEBUG_INSTALL_FN,$(out),$(outbase),$(debug_notdir))
[2523]335 local debug_dirs := $(filter %/,$(debug_files))
336 local debug_files := $(filter-out %/,$(debug_files))
337endif
338$(foreach debug_dir, $(debug_dirs), $(eval $(def_link_install_debug_dir_rule)))
339$(foreach debug_file, $(debug_files), $(eval $(def_link_install_debug_file_rule)))
340endef
341
342
[2475]343## Generic macro for generating the install rule(s) for a target.
[219]344#
[353]345# @param $(target) Normalized target name.
346# @param $(out) The output file.
347# @param $(typevar) The name of the variable with all the root targets of its type.
[2481]348# @param $(target_type_mode) The default file mode implied by the target type.
[2475]349define def_target_install_only
[2551]350if1of ($($(target)_1_INSTTYPE) $($(target)_1_DEBUG_INSTTYPE), both stage)
351 # Determin common variables.
[2225]352 local mode := $(firstword \
353 $($(target)_MODE.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
354 $($(target)_MODE.$(bld_trg).$(bld_trg_arch)) \
355 $($(target)_MODE.$(bld_trg).$(bld_type)) \
356 $($(target)_MODE.$(bld_trg_arch)) \
357 $($(target)_MODE.$(bld_trg)) \
358 $($(target)_MODE.$(bld_type)) \
[2483]359 $($(target)_MODE) \
360 $(target_type_mode) )
[2225]361 local uid := $(firstword \
362 $($(target)_UID.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
363 $($(target)_UID.$(bld_trg).$(bld_trg_arch)) \
364 $($(target)_UID.$(bld_trg).$(bld_type)) \
365 $($(target)_UID.$(bld_trg_arch)) \
366 $($(target)_UID.$(bld_trg)) \
367 $($(target)_UID.$(bld_type)) \
368 $($(target)_UID) )
369 local gid := $(firstword \
370 $($(target)_GID.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
371 $($(target)_GID.$(bld_trg).$(bld_trg_arch)) \
372 $($(target)_GID.$(bld_trg).$(bld_type)) \
373 $($(target)_GID.$(bld_trg_arch)) \
374 $($(target)_GID.$(bld_trg)) \
375 $($(target)_GID.$(bld_type)) \
376 $($(target)_GID) )
[2475]377 local pre_install_cmds := $(evalcall def_fn_prop_get_first_defined,PRE_INST_CMDS)
378 local post_install_cmds := $(evalcall def_fn_prop_get_first_defined,POST_INST_CMDS)
[2551]379endif
[219]380
[2551]381ifneq ($($(target)_1_INSTTYPE),none)
[2475]382 # Generate the rules
383 ifeq ($($(target)_1_INSTTYPE),both)
[353]384$(eval $(def_link_install_rule))
[2475]385 _INSTALLS_FILES += $($(target)_1_INST_TARGET)
[1697]386 endif
[2475]387$(eval $(def_link_stage_rule))
388 _STAGE_FILES += $($(target)_1_STAGE_TARGET)
389 $(typevar) += $($(target)_1_STAGE_TARGET)
390else # INSTTYPE == none
[1697]391 $(typevar) += $(out)
[2475]392endif # INSTTYPE == none
[353]393
[2523]394# Install debug info.
395$(target)_2_DEBUG_STAGE_TARGET_DIRS :=
396$(target)_2_DEBUG_STAGE_TARGET_FILES :=
397$(target)_2_DEBUG_INSTALL_TARGET_DIRS :=
398$(target)_2_DEBUG_INSTALL_TARGET_FILES :=
399
400if ( defined($(target)_2_OUTPUT_DEBUG_DIRS) \
401 || defined($(target)_2_OUTPUT_DEBUG_FILES) ) \
402 && "$($(target)_1_DEBUG_INSTTYPE)" != "none"
403 local mode := $(if $(mode),$(mode)$(COMMA)a-x,0644)
404
405 ifeq ($($(target)_1_DEBUG_INSTTYPE),both)
406 local debug_inst_path := $(PATH_INS)
407 local debug_install_cmd := $(INSTALL)
408 local debug_var := INSTALL
[2762]409 $(foreach debug_inst, $($(target)_1_DEBUG_INST), $(evalvalctx def_target_install_only_debug))
[2523]410 endif
411
412 local debug_inst_path := $(PATH_STAGE)
413 local debug_install_cmd := $(INSTALL_STAGING)
414 local debug_var := STAGE
415 if1of ($($(target)_1_DEBUG_INSTTYPE), stage both)
[2762]416 $(foreach debug_inst, $($(target)_1_DEBUG_STAGE), $(evalvalctx def_target_install_only_debug))
[2523]417 endif
418 if1of ($($(target)_1_INSTTYPE), stage both)
419 ifndef debug_nostage
[2762]420 $(foreach debug_inst,$($(target)_1_STAGE), $(evalvalctx def_target_install_only_debug))
[2523]421 endif
422 endif
423
424 _DEBUG_STAGE_DIRS += $($(target)_2_DEBUG_STAGE_TARGET_DIRS)
425 _DEBUG_STAGE_FILES += $($(target)_2_DEBUG_STAGE_TARGET_FILES)
426 _DEBUG_INSTALL_DIRS += $($(target)_2_DEBUG_INSTALL_TARGET_DIRS)
427 _DEBUG_INSTALL_FILES += $($(target)_2_DEBUG_INSTALL_TARGET_FILES)
428
429 $(basename $(notdir $(out))):: $($(target)_2_DEBUG_STAGE_TARGET_DIRS) $($(target)_2_DEBUG_STAGE_TARGET_FILES)
430endif
431
[2475]432endef # def_target_install_only
[353]433
[219]434
435
436#
[72]437# LIBRARIES
[73]438#
[72]439
440## Library (one).
[74]441# @param $(target) Normalized library (target) name.
[72]442define def_lib
[145]443# library basics
[222]444## @todo prefix
[1504]445local bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE))
446local bld_trg := $(firstword $($(target)_BLD_TRG) $(KBUILD_TARGET))
447local bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(KBUILD_TARGET_ARCH))
448local bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(KBUILD_TARGET_CPU))
[1496]449local tool := $(call _TARGET_TOOL,$(target),AR)
[78]450ifeq ($(tool),)
[353]451$(error kBuild: Library target $(target) does not have a tool defined!)
[78]452endif
[1496]453local name := $(firstword\
[2433]454 $($(target)_NAME.$(bld_trg).$(bld_trg_arch).$(bld_type))\
[889]455 $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\
[2433]456 $($(target)_NAME.$(bld_trg).$(bld_type))\
[889]457 $($(target)_NAME.$(bld_trg_arch))\
458 $($(target)_NAME.$(bld_trg))\
459 $($(target)_NAME.$(bld_type))\
460 $($(target)_NAME)\
461 $(target))
[1496]462local outbase := $(call TARGET_BASE,$(name),$(target))
[2239]463$(target)_0_OUTDIR:= $(patsubst %/,%,$(dir $(outbase)))
[2436]464$(call KB_FN_ASSIGN_DEPRECATED,PATH_$(target),$($(target)_0_OUTDIR), $(target)_0_OUTDIR)
[1496]465local suff := $(firstword\
[481]466 $($(target)_LIBSUFF.$(bld_trg).$(bld_trg_arch))\
[221]467 $($(target)_LIBSUFF.$(bld_trg))\
[126]468 $($(target)_LIBSUFF)\
[481]469 $(TOOL_$(tool)_ARLIBSUFF.$(bld_trg).$(bld_trg_arch))\
[221]470 $(TOOL_$(tool)_ARLIBSUFF.$(bld_trg))\
[126]471 $(TOOL_$(tool)_ARLIBSUFF)\
[353]472 $(SUFF_LIB))
[1496]473local out := $(outbase)$(suff)
[2434]474local defpath := $($(target)_DEFPATH)
475ifeq ($(defpath),)
476 local defpath := $($(target)_PATH)
477endif
[2238]478$(target)_1_TARGET:= $(out)
[2436]479$(call KB_FN_ASSIGN_DEPRECATED,TARGET_$(target),$($(target)_1_TARGET), $(target)_1_TARGET)
[1496]480# no local here - must be writable across some foreachs.
481othersrc :=
[2236]482$(target)_2_OBJS :=
[145]483
[1672]484# Do units pre source callouts.
485local units := \
486 $($(target)_USES.$(bld_trg).$(bld_trg_arch))\
487 $($(target)_USES.$(bld_trg_arch))\
488 $($(target)_USES.$(bld_trg))\
489 $($(target)_USES.$(bld_type))\
490 $($(target)_USES)
[2762]491$(foreach unit,$(units),$(evalvalctx def_unit_$(unit)_target_pre))
[1672]492
[145]493# source -> object
[1496]494$(evalval def_target_sources)
[145]495
496# library linking
[1496]497local tool := $(call _TARGET_TOOL,$(target),AR)
498local name := $(firstword\
[2433]499 $($(target)_NAME.$(bld_trg).$(bld_trg_arch).$(bld_type))\
[889]500 $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\
[2433]501 $($(target)_NAME.$(bld_trg).$(bld_type))\
[889]502 $($(target)_NAME.$(bld_trg_arch))\
503 $($(target)_NAME.$(bld_trg))\
504 $($(target)_NAME.$(bld_type))\
505 $($(target)_NAME)\
506 $(target))
[1496]507local outbase := $(call TARGET_BASE,$(name),$(target))
508local flags :=\
[74]509 $(TOOL_$(tool)_ARFLAGS)\
[221]510 $(TOOL_$(tool)_ARFLAGS.$(bld_type))\
[74]511 $(ARFLAGS)\
[221]512 $(ARFLAGS.$(bld_type))\
[74]513 $($(target)_ARFLAGS)\
[481]514 $($(target)_ARFLAGS.$(bld_type)) \
515 $($(target)_ARFLAGS.$(bld_trg)) \
516 $($(target)_ARFLAGS.$(bld_trg_arch)) \
517 $($(target)_ARFLAGS.$(bld_trg).$(bld_trg_arch)) \
518 $($(target)_ARFLAGS.$(bld_trg_cpu))
[1496]519local dirdep := $(call DIRDEP,$(dir $(out)))
[1702]520local deps := \
521 $($(target)_DEPS.$(bld_trg_cpu)) \
522 $($(target)_DEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
523 $($(target)_DEPS.$(bld_trg).$(bld_trg_arch)) \
524 $($(target)_DEPS.$(bld_trg).$(bld_type)) \
525 $($(target)_DEPS.$(bld_trg_arch)) \
526 $($(target)_DEPS.$(bld_trg)) \
527 $($(target)_DEPS.$(bld_type)) \
528 $($(target)_DEPS) \
529 $($(target)_LNK_DEPS.$(bld_trg_cpu)) \
530 $($(target)_LNK_DEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
531 $($(target)_LNK_DEPS.$(bld_trg).$(bld_trg_arch)) \
532 $($(target)_LNK_DEPS.$(bld_trg).$(bld_type)) \
533 $($(target)_LNK_DEPS.$(bld_trg_arch)) \
534 $($(target)_LNK_DEPS.$(bld_trg)) \
535 $($(target)_LNK_DEPS.$(bld_type)) \
536 $($(target)_LNK_DEPS)
537local orderdeps := \
538 $($(target)_ORDERDEPS.$(bld_trg_cpu)) \
539 $($(target)_ORDERDEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
540 $($(target)_ORDERDEPS.$(bld_trg).$(bld_trg_arch)) \
541 $($(target)_ORDERDEPS.$(bld_trg).$(bld_type)) \
542 $($(target)_ORDERDEPS.$(bld_trg_arch)) \
543 $($(target)_ORDERDEPS.$(bld_trg)) \
544 $($(target)_ORDERDEPS.$(bld_type)) \
545 $($(target)_ORDERDEPS) \
546 $($(target)_LNK_ORDERDEPS.$(bld_trg_cpu)) \
547 $($(target)_LNK_ORDERDEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
548 $($(target)_LNK_ORDERDEPS.$(bld_trg).$(bld_trg_arch)) \
549 $($(target)_LNK_ORDERDEPS.$(bld_trg).$(bld_type)) \
550 $($(target)_LNK_ORDERDEPS.$(bld_trg_arch)) \
551 $($(target)_LNK_ORDERDEPS.$(bld_trg)) \
552 $($(target)_LNK_ORDERDEPS.$(bld_type)) \
553 $($(target)_LNK_ORDERDEPS)
[72]554
[725]555# Adjust paths if we got a default path.
556ifneq ($(defpath),)
[1496]557 local deps := $(abspathex $(deps),$(defpath))
558 local orderdeps := $(abspathex $(orderdeps),$(defpath))
[1472]559 othersrc := $(abspathex $(othersrc),$(defpath))
[725]560endif
561
[859]562
563# Custom pre-link actions.
[2475]564local pre_cmds := $(evalcall def_fn_prop_get_first_defined,PRE_CMDS)
565local post_cmds := $(evalcall def_fn_prop_get_first_defined,POST_CMDS)
[859]566
[1424]567# eliminate this guy?
[2236]568local objs = $($(target)_2_OBJS)
[1424]569
[380]570# dependency file
[1496]571local dep := $(out)$(SUFF_DEP)
[524]572ifndef NO_LINK_CMDS_DEPS
[1798]573 _DEPFILES_INCLUDED += $(dep)
574 ifdef KB_HAVE_INCLUDEDEP_QUEUE
575 includedep-queue $(dep)
[1795]576 else
[1798]577 includedep $(dep)
[1795]578 endif
[380]579endif
[72]580
[380]581# check that the tool is defined.
582ifndef TOOL_$(tool)_LINK_LIBRARY_CMDS
583$(warning kBuild: tools: \
[481]584 1 $($(target)_$(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
585 2 $($(target)_$(source)TOOL.$(bld_trg)) \
586 3 $($(target)_$(source)TOOL) \
587 4 $($(target)_TOOL.$(bld_trg).$(bld_trg_arch)) \
588 5 $($(target)_TOOL.$(bld_trg)) \
589 6 $($(target)_TOOL) \
590 7 $($(source)TOOL) \
591 8 $($(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
592 9 $($(source)TOOL.$(bld_trg)) \
593 10 $(TOOL.$(bld_trg).$(bld_trg_arch)) \
594 11 $(TOOL.$(bld_trg)) \
595 12 $(TOOL) )
[380]596$(error kBuild: TOOL_$(tool)_LINK_LIBRARY_CMDS isn't defined! target=$(target) )
597endif
598
599# call the tool
[2523]600local cmds := $(TOOL_$(tool)_LINK_LIBRARY_CMDS)
[859]601ifneq ($(pre_cmds),)
[1496]602 local cmds := $(TAB)$(pre_cmds)$(NL)$(TAB)$(cmds)
[859]603endif
604ifneq ($(post_cmds),)
[2523]605 local cmds := $(cmds)$(NL)$(TAB)$(post_cmds)
[859]606endif
[2234]607$(target)_2_OUTPUT := $(TOOL_$(tool)_LINK_LIBRARY_OUTPUT)
608$(target)_2_OUTPUT_MAYBE := $(TOOL_$(tool)_LINK_LIBRARY_OUTPUT_MAYBE)
[2236]609$(target)_2_DEPEND := $(TOOL_$(tool)_LINK_LIBRARY_DEPEND) $(deps) $($(target)_2_OBJS)
[2234]610$(target)_2_DEPORD := $(TOOL_$(tool)_LINK_LIBRARY_DEPORD) $(dirdep) $(orderdeps)
[380]611
[412]612# generate the link rule.
[380]613$(eval $(def_link_rule))
614
[2475]615# installing and globals.
[2483]616local target_type_mode := a+r,u+w
[2475]617$(evalval def_target_install_only)
618
619_OUT_FILES += $($(target)_2_OUTPUT) $($(target)_2_OUTPUT_MAYBE) $(out)
620_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))
621_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))
622_OBJS += $($(target)_2_OBJS)
623
624endef # def_lib
[1936]625$(eval-opt-var def_lib)
[72]626
627# Process libraries
[859]628typevar := _LIBS
[776]629tool_do := LINK_LIBRARY
[380]630mode := 0644
[2762]631$(foreach target, $(_ALL_LIBRARIES), $(evalvalctx def_lib))
[72]632
[988]633ifdef KBUILD_PROFILE_SELF
[2008]634 $(evalcall def_profile_self, done library targets)
[988]635endif
[72]636
[988]637
[72]638#
[353]639# Link operations.
[72]640#
641
[353]642##
643# Link prolog
644#
645# @param $(target) Normalized target name.
646# @param $(EXT) EXE,DLL,SYS.
647# @param $(typevar) The name of the variable with all the root targets of its type.
[380]648define def_link_common
[353]649# basics
[1504]650local bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE))
[1496]651local bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_$(bld_trg_base_var)))
652local bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_$(bld_trg_base_var)_ARCH))
653local bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_$(bld_trg_base_var)_CPU))
[145]654
[1496]655local tool := $(call _TARGET_TOOL,$(target),LD)
656local name := $(firstword\
[2433]657 $($(target)_NAME.$(bld_trg).$(bld_trg_arch).$(bld_type))\
[889]658 $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\
[2433]659 $($(target)_NAME.$(bld_trg).$(bld_type))\
[889]660 $($(target)_NAME.$(bld_trg_arch))\
661 $($(target)_NAME.$(bld_trg))\
662 $($(target)_NAME.$(bld_type))\
663 $($(target)_NAME)\
664 $(target))
[1496]665local outbase := $(call TARGET_BASE,$(name),$(target))
[2239]666$(target)_0_OUTDIR:= $(patsubst %/,%,$(dir $(outbase)))
[2436]667$(call KB_FN_ASSIGN_DEPRECATED,PATH_$(target),$($(target)_0_OUTDIR), $(target)_0_OUTDIR)
[2143]668local suff := $(firstword \
669 $($(target)_$(EXT)SUFF.$(bld_trg).$(bld_trg_arch))\
670 $($(target)_$(EXT)SUFF.$(bld_trg))\
671 $($(target)_$(EXT)SUFF)\
672 $(TOOL_$(tool)_LD$(EXT)SUFF.$(bld_trg).$(bld_trg_arch))\
673 $(TOOL_$(tool)_LD$(EXT)SUFF.$(bld_trg))\
674 $(TOOL_$(tool)_LD$(EXT)SUFF)\
675 $($(EXTPRE)SUFF_$(EXT)) )
[1496]676local out := $(outbase)$(suff)
[2238]677$(target)_1_TARGET:= $(out)
[2436]678$(call KB_FN_ASSIGN_DEPRECATED,TARGET_$(target),$($(target)_1_TARGET), $(target)_1_TARGET)
[2434]679local defpath := $($(target)_DEFPATH)
680ifeq ($(defpath),)
681 local defpath := $($(target)_PATH)
682endif
[1496]683# no local here - must be writable across some foreachs.
684othersrc :=
[2236]685$(target)_2_OBJS :=
[353]686
[1672]687# Do units pre source callouts.
688local units := \
689 $($(target)_USES.$(bld_trg).$(bld_trg_arch))\
690 $($(target)_USES.$(bld_trg_arch))\
691 $($(target)_USES.$(bld_trg))\
692 $($(target)_USES.$(bld_type))\
693 $($(target)_USES)
[2762]694$(foreach unit,$(units),$(evalvalctx def_unit_$(unit)_target_pre))
[1672]695
[145]696# source -> object
[1496]697$(evalval def_target_sources)
[145]698
[744]699# more link stuff.
[1496]700local tool := $(call _TARGET_TOOL,$(target),LD)
701local name := $(firstword\
[2433]702 $($(target)_NAME.$(bld_trg).$(bld_trg_arch).$(bld_type))\
[889]703 $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\
[2433]704 $($(target)_NAME.$(bld_trg).$(bld_type))\
[889]705 $($(target)_NAME.$(bld_trg_arch))\
706 $($(target)_NAME.$(bld_trg))\
707 $($(target)_NAME.$(bld_type))\
708 $($(target)_NAME)\
709 $(target))
[1496]710local outbase := $(call TARGET_BASE,$(name),$(target))
711local flags :=\
[74]712 $(TOOL_$(tool)_LDFLAGS)\
[221]713 $(TOOL_$(tool)_LDFLAGS.$(bld_type))\
714 $(TOOL_$(tool)_LDFLAGS.$(bld_trg))\
715 $(TOOL_$(tool)_LDFLAGS.$(bld_trg_arch))\
[481]716 $(TOOL_$(tool)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\
[221]717 $(TOOL_$(tool)_LDFLAGS.$(bld_trg_cpu))\
[1242]718 $(foreach sdk, $(SDKS) \
719 $(SDKS.$(bld_type)) \
720 $(SDKS.$(bld_trg)) \
721 $(SDKS.$(bld_trg_arch)) \
722 $(SDKS.$(bld_trg).$(bld_trg_arch)),\
723 $(SDK_$(sdk)_LDFLAGS)\
724 $(SDK_$(sdk)_LDFLAGS.$(bld_type))\
725 $(SDK_$(sdk)_LDFLAGS.$(bld_trg))\
726 $(SDK_$(sdk)_LDFLAGS.$(bld_trg_arch))\
727 $(SDK_$(sdk)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\
728 $(SDK_$(sdk)_LDFLAGS.$(bld_trg_cpu)))\
[74]729 $(LDFLAGS)\
[221]730 $(LDFLAGS.$(bld_type))\
731 $(LDFLAGS.$(bld_trg))\
732 $(LDFLAGS.$(bld_trg_arch))\
[481]733 $(LDFLAGS.$(bld_trg).$(bld_trg_arch))\
[221]734 $(LDFLAGS.$(bld_trg_cpu))\
[1242]735 $(foreach sdk, $($(target)_SDKS) \
736 $($(target)_SDKS.$(bld_type)) \
737 $($(target)_SDKS.$(bld_trg)) \
738 $($(target)_SDKS.$(bld_trg_arch)) \
739 $($(target)_SDKS.$(bld_trg).$(bld_trg_arch)),\
740 $(SDK_$(sdk)_LDFLAGS)\
741 $(SDK_$(sdk)_LDFLAGS.$(bld_type))\
742 $(SDK_$(sdk)_LDFLAGS.$(bld_trg))\
743 $(SDK_$(sdk)_LDFLAGS.$(bld_trg_arch))\
744 $(SDK_$(sdk)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\
745 $(SDK_$(sdk)_LDFLAGS.$(bld_trg_cpu)))\
[74]746 $($(target)_LDFLAGS)\
[221]747 $($(target)_LDFLAGS.$(bld_type))\
748 $($(target)_LDFLAGS.$(bld_trg))\
749 $($(target)_LDFLAGS.$(bld_trg_arch))\
[481]750 $($(target)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\
[353]751 $($(target)_LDFLAGS.$(bld_trg_cpu))
[1496]752local libs :=\
[221]753 $($(target)_LIBS.$(bld_trg_cpu))\
[481]754 $($(target)_LIBS.$(bld_trg).$(bld_trg_arch))\
[221]755 $($(target)_LIBS.$(bld_trg_arch))\
756 $($(target)_LIBS.$(bld_trg))\
757 $($(target)_LIBS.$(bld_type))\
[74]758 $($(target)_LIBS)\
[592]759 $(foreach sdk, $($(target)_SDKS.$(bld_trg).$(bld_trg_arch)) \
760 $($(target)_SDKS.$(bld_trg_arch)) \
761 $($(target)_SDKS.$(bld_trg)) \
762 $($(target)_SDKS.$(bld_type)) \
763 $($(target)_SDKS),\
[353]764 $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
[481]765 $(SDK_$(sdk)_LIBS.$(bld_trg).$(bld_trg_arch))\
[353]766 $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
767 $(SDK_$(sdk)_LIBS.$(bld_trg))\
768 $(SDK_$(sdk)_LIBS.$(bld_type))\
769 $(SDK_$(sdk)_LIBS))\
[221]770 $(LIBS.$(bld_trg_cpu))\
[481]771 $(LIBS.$(bld_trg).$(bld_trg_arch))\
[221]772 $(LIBS.$(bld_trg_arch))\
773 $(LIBS.$(bld_trg))\
774 $(LIBS.$(bld_type))\
[74]775 $(LIBS)\
[592]776 $(foreach sdk, $(SDKS.$(bld_trg).$(bld_trg_arch)) \
777 $(SDKS.$(bld_trg_arch)) \
778 $(SDKS.$(bld_trg)) \
779 $(SDKS.$(bld_type)) \
780 $(SDKS),\
[353]781 $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
[481]782 $(SDK_$(sdk)_LIBS.$(bld_trg).$(bld_trg_arch))\
[353]783 $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
784 $(SDK_$(sdk)_LIBS.$(bld_trg))\
785 $(SDK_$(sdk)_LIBS.$(bld_type))\
786 $(SDK_$(sdk)_LIBS))\
[221]787 $(TOOL_$(tool)_LIBS.$(bld_trg_cpu))\
[481]788 $(TOOL_$(tool)_LIBS.$(bld_trg).$(bld_trg_arch))\
[221]789 $(TOOL_$(tool)_LIBS.$(bld_trg_arch))\
790 $(TOOL_$(tool)_LIBS.$(bld_trg))\
791 $(TOOL_$(tool)_LIBS.$(bld_type))\
[353]792 $(TOOL_$(tool)_LIBS)
[1496]793local libpath :=\
[221]794 $($(target)_LIBPATH.$(bld_trg_cpu))\
[481]795 $($(target)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
[221]796 $($(target)_LIBPATH.$(bld_trg_arch))\
797 $($(target)_LIBPATH.$(bld_trg))\
798 $($(target)_LIBPATH.$(bld_type))\
[74]799 $($(target)_LIBPATH)\
[592]800 $(foreach sdk, $($(target)_SDKS.$(bld_trg).$(bld_trg_arch)) \
801 $($(target)_SDKS.$(bld_trg_arch)) \
802 $($(target)_SDKS.$(bld_trg)) \
803 $($(target)_SDKS.$(bld_type)) \
804 $($(target)_SDKS),\
[353]805 $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
[481]806 $(SDK_$(sdk)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
[353]807 $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
808 $(SDK_$(sdk)_LIBPATH.$(bld_trg))\
809 $(SDK_$(sdk)_LIBPATH.$(bld_type))\
810 $(SDK_$(sdk)_LIBPATH))\
[221]811 $(LIBPATH.$(bld_trg_cpu))\
[481]812 $(LIBPATH.$(bld_trg).$(bld_trg_arch))\
[221]813 $(LIBPATH.$(bld_trg_arch))\
814 $(LIBPATH.$(bld_trg))\
815 $(LIBPATH.$(bld_type))\
[74]816 $(LIBPATH)\
[592]817 $(foreach sdk, $(SDKS.$(bld_trg).$(bld_trg_arch)) \
818 $(SDKS.$(bld_trg_arch)) \
819 $(SDKS.$(bld_trg)) \
820 $(SDKS.$(bld_type)) \
821 $(SDKS),\
[353]822 $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
[481]823 $(SDK_$(sdk)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
[353]824 $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
825 $(SDK_$(sdk)_LIBPATH.$(bld_trg))\
826 $(SDK_$(sdk)_LIBPATH.$(bld_type))\
827 $(SDK_$(sdk)_LIBPATH))\
[221]828 $(TOOL_$(tool)_LIBPATH.$(bld_trg_cpu))\
[481]829 $(TOOL_$(tool)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
[221]830 $(TOOL_$(tool)_LIBPATH.$(bld_trg_arch))\
831 $(TOOL_$(tool)_LIBPATH.$(bld_trg))\
832 $(TOOL_$(tool)_LIBPATH.$(bld_type))\
[353]833 $(TOOL_$(tool)_LIBPATH)
[1496]834local dirdep := $(call DIRDEP,$(dir $(out)))
[1702]835local deps := \
836 $($(target)_DEPS.$(bld_trg_cpu)) \
837 $($(target)_DEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
838 $($(target)_DEPS.$(bld_trg).$(bld_trg_arch)) \
839 $($(target)_DEPS.$(bld_trg).$(bld_type)) \
840 $($(target)_DEPS.$(bld_trg_arch)) \
841 $($(target)_DEPS.$(bld_trg)) \
842 $($(target)_DEPS.$(bld_type)) \
843 $($(target)_DEPS) \
844 $($(target)_LNK_DEPS.$(bld_trg_cpu)) \
845 $($(target)_LNK_DEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
846 $($(target)_LNK_DEPS.$(bld_trg).$(bld_trg_arch)) \
847 $($(target)_LNK_DEPS.$(bld_trg).$(bld_type)) \
848 $($(target)_LNK_DEPS.$(bld_trg_arch)) \
849 $($(target)_LNK_DEPS.$(bld_trg)) \
850 $($(target)_LNK_DEPS.$(bld_type)) \
851 $($(target)_LNK_DEPS)
852local orderdeps := \
853 $($(target)_ORDERDEPS.$(bld_trg_cpu)) \
854 $($(target)_ORDERDEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
855 $($(target)_ORDERDEPS.$(bld_trg).$(bld_trg_arch)) \
856 $($(target)_ORDERDEPS.$(bld_trg).$(bld_type)) \
857 $($(target)_ORDERDEPS.$(bld_trg_arch)) \
858 $($(target)_ORDERDEPS.$(bld_trg)) \
859 $($(target)_ORDERDEPS.$(bld_type)) \
860 $($(target)_ORDERDEPS) \
861 $($(target)_LNK_ORDERDEPS.$(bld_trg_cpu)) \
862 $($(target)_LNK_ORDERDEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
863 $($(target)_LNK_ORDERDEPS.$(bld_trg).$(bld_trg_arch)) \
864 $($(target)_LNK_ORDERDEPS.$(bld_trg).$(bld_type)) \
865 $($(target)_LNK_ORDERDEPS.$(bld_trg_arch)) \
866 $($(target)_LNK_ORDERDEPS.$(bld_trg)) \
867 $($(target)_LNK_ORDERDEPS.$(bld_type)) \
868 $($(target)_LNK_ORDERDEPS)
[353]869
[725]870# Adjust paths if we got a default path.
871ifneq ($(defpath),)
[1496]872 local libpath := $(abspathex $(libpath),$(defpath))
873 local deps := $(abspathex $(deps),$(defpath))
874 local orderdeps := $(abspathex $(orderdeps),$(defpath))
[1472]875 othersrc := $(abspathex $(othersrc),$(defpath))
[1755]876 # libs are not subject to this because of the the -l<lib> stuff. Use $(<target>_DEFPATH)/lib if relative to current dir!
[725]877endif
878
[2523]879# Debug info.
880local ld_debug := $(evalcall def_fn_prop_get_first_defined,LD_DEBUG)
881local debug_inst := $(evalcall def_fn_prop_get_first_defined,DEBUG_INST)
882local debug_stage := $(evalcall def_fn_prop_get_first_defined,DEBUG_STAGE)
883local debug_nostage := $(evalcall def_fn_prop_get_first_word,DEBUG_NOSTAGE)
884
[2475]885# Custom pre/post-link actions.
[2523]886local pre_cmds := $(evalcall def_fn_prop_get_first_defined,PRE_CMDS)
887local post_cmds := $(evalcall def_fn_prop_get_first_defined,POST_CMDS)
[72]888
[1424]889# eliminate this guy?
[2236]890local objs = $($(target)_2_OBJS)
[1424]891
[380]892# dependency file
[1496]893local dep := $(outbase)$(SUFF_DEP)
[524]894ifndef NO_LINK_CMDS_DEPS
[2188]895 _DEPFILES_INCLUDED += $(dep)
[1798]896 ifdef KB_HAVE_INCLUDEDEP_QUEUE
897 includedep-queue $(dep)
[1795]898 else
[1798]899 includedep $(dep)
[1795]900 endif
[380]901endif
[353]902
[380]903# check that the tool is defined.
904ifndef TOOL_$(tool)_$(tool_do)_CMDS
905$(warning kBuild: tools: \
[481]906 1 $($(target)_$(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
907 2 $($(target)_$(source)TOOL.$(bld_trg)) \
908 3 $($(target)_$(source)TOOL) \
909 4 $($(target)_TOOL.$(bld_trg).$(bld_trg_arch)) \
910 5 $($(target)_TOOL.$(bld_trg)) \
911 6 $($(target)_TOOL) \
912 7 $($(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
913 8 $($(source)TOOL.$(bld_trg)) \
914 9 $($(source)TOOL) \
915 10 $(TOOL.$(bld_trg).$(bld_trg_arch)) \
916 11 $(TOOL.$(bld_trg)) \
917 12 $(TOOL) )
[380]918$(error kBuild: TOOL_$(tool)_$(tool_do)_CMDS isn't defined! target=$(target) )
919endif
[353]920
[380]921# call the tool
[1496]922local cmds := $(TOOL_$(tool)_$(tool_do)_CMDS)
[859]923ifneq ($(pre_cmds),)
[1496]924 local cmds := $(TAB)$(pre_cmds)$(NL)$(TAB)$(cmds)
[859]925endif
926ifneq ($(post_cmds),)
[1496]927 local cmds := $(cmds)$(NL)$(TAB)$(post_cmds)
[859]928endif
[2523]929$(target)_2_OUTPUT := $(TOOL_$(tool)_$(tool_do)_OUTPUT)
930$(target)_2_OUTPUT_MAYBE := $(TOOL_$(tool)_$(tool_do)_OUTPUT_MAYBE)
931if1of ($(ld_debug), split)
932 $(target)_2_OUTPUT_DEBUG_FILES := $(filter-out %/,$(TOOL_$(tool)_$(tool_do)_OUTPUT_DEBUG))
933 $(target)_2_OUTPUT_DEBUG_DIRS := $(filter %/,$(TOOL_$(tool)_$(tool_do)_OUTPUT_DEBUG))
934else
935 $(target)_2_OUTPUT_DEBUG_FILES :=
936 $(target)_2_OUTPUT_DEBUG_DIRS :=
937endif
938$(target)_2_DEPEND := $(TOOL_$(tool)_$(tool_do)_DEPEND) $(deps) $($(target)_2_OBJS)
939$(target)_2_DEPORD := $(TOOL_$(tool)_$(tool_do)_DEPORD) $(dirdep) $(orderdeps)
[353]940
[412]941# generate the link rule.
[380]942$(eval $(def_link_rule))
943
[2523]944# installation targets
945local target_type_mode :=
946$(evalval def_target_install_only)
[412]947
[380]948# Update globals.
[2236]949_OBJS += $($(target)_2_OBJS)
[2234]950_OUT_FILES += $($(target)_2_OUTPUT) $($(target)_2_OUTPUT_MAYBE) $(out)
[905]951_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))
952_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]953_INSTALLS_FILES += $(INSTARGET_$(target))
[353]954
[1936]955endef # def_link_common
956$(eval-opt-var def_link_common)
[353]957
958
959#
960# BLDPROGS
961#
962
963# Process build programs.
964EXT := EXE
965EXTPRE := HOST
[380]966tool_do := LINK_PROGRAM
[353]967typevar := _BLDPROGS
[380]968mode := 0755
[353]969bld_trg_base_var := PLATFORM
[2762]970$(foreach target, $(_ALL_BLDPROGS), $(evalvalctx def_link_common))
[353]971
[988]972ifdef KBUILD_PROFILE_SELF
[2008]973 $(evalcall def_profile_self, done build program targets)
[988]974endif
[353]975
976
977#
978# DLLS
979#
980
[189]981# Process dlls
[353]982EXT := DLL
983EXTPRE :=
[380]984tool_do := LINK_DLL
[353]985typevar := _DLLS
[830]986mode := 0644
[353]987bld_trg_base_var := TARGET
[2762]988$(foreach target, $(_ALL_DLLS), $(evalvalctx def_link_common))
[74]989
[988]990ifdef KBUILD_PROFILE_SELF
[2008]991 $(evalcall def_profile_self, done dll targets)
[988]992endif
[74]993
[988]994
[72]995#
[830]996# IMPORT LIBRARIES
[72]997#
[219]998# - On OS/2 and windows these are libraries.
[189]999# - On other platforms they are fake DLLs.
[830]1000#
1001EXTPRE :=
1002typevar := _IMPORT_LIBS
1003mode := 0644
1004bld_trg_base_var := TARGET
[1504]1005ifeq ($(filter-out nt os2 win win64 win32,$(KBUILD_TARGET)),)
[830]1006 EXT := LIB
1007 tool_do := LINK_LIBRARY
[2762]1008 $(foreach target, $(_ALL_IMPORT_LIBS), $(evalvalctx def_lib))
[189]1009else
[830]1010 EXT := DLL
1011 tool_do := LINK_DLL
[2762]1012 $(foreach target, $(_ALL_IMPORT_LIBS), $(evalvalctx def_link_common))
[189]1013endif
[72]1014
[988]1015ifdef KBUILD_PROFILE_SELF
[2008]1016 $(evalcall def_profile_self, done import library targets)
[988]1017endif
[189]1018
[988]1019
[189]1020#
1021# PROGRAMS
1022#
1023
[353]1024# Process programs
1025EXT := EXE
1026EXTPRE :=
[380]1027tool_do := LINK_PROGRAM
[353]1028typevar := _PROGRAMS
[380]1029mode := 0755
[353]1030bld_trg_base_var := TARGET
[2762]1031$(foreach target, $(_ALL_PROGRAMS), $(evalvalctx def_link_common))
[130]1032
[988]1033ifdef KBUILD_PROFILE_SELF
[2008]1034 $(evalcall def_profile_self, done program targets)
[988]1035endif
[130]1036
[189]1037
[72]1038#
[83]1039# SYSMODS
[72]1040#
1041
[130]1042# Process sysmods
[353]1043EXT := SYS
1044EXTPRE :=
[380]1045tool_do := LINK_SYSMOD
[353]1046typevar := _SYSMODS
[380]1047mode := 0644
[353]1048bld_trg_base_var := TARGET
[2762]1049$(foreach target, $(_ALL_SYSMODS), $(evalvalctx def_link_common))
[83]1050
[988]1051ifdef KBUILD_PROFILE_SELF
[2008]1052 $(evalcall def_profile_self, done sysmod targets)
[988]1053endif
[83]1054
[988]1055
[72]1056#
[2084]1057# MISCBINS
1058#
1059
1060# Process MISCBINS
1061EXT := BIN
1062EXTPRE :=
1063tool_do := LINK_MISCBIN
1064typevar := _MISCBINS
1065mode := 0644
1066bld_trg_base_var := TARGET
[2762]1067$(foreach target, $(_ALL_MISCBINS), $(evalvalctx def_link_common))
[2084]1068
1069ifdef KBUILD_PROFILE_SELF
1070 $(evalcall def_profile_self, done misc binary targets)
1071endif
1072
Note: See TracBrowser for help on using the repository browser.