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