source: trunk/kBuild/footer-pass2-compiling-targets.kmk@ 3044

Last change on this file since 3044 was 2952, checked in by bird, 9 years ago

footer-pass2-compiling-targets.kmk: Fixed inverted TOOL_$(tool)_COMPILE_$(type)_DONT_PURGE_OUTPUT check. Added a 2nd unit pass def_unit_$(unit)_target_pre_2 for precompiled headers (see vccprecomp.kmk).

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