| [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.
 | 
|---|
 | 40 | ifndef 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] | 47 | else
 | 
|---|
| [730] | 48 |  _DEP_COMPILE_CMDS =
 | 
|---|
| [380] | 49 | endif
 | 
|---|
 | 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] | 55 | define def_target_source_rule
 | 
|---|
| [2026] | 56 | ifndef NO_COMPILE_CMDS_DEPS
 | 
|---|
 | 57 | $(obj): .MUST_MAKE = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_CMDS_PREV_),$$(commands $$@),FORCE)
 | 
|---|
 | 58 | endif
 | 
|---|
| [1012] | 59 | ifdef 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] | 73 | else
 | 
|---|
| [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] | 86 | ifndef TOOL_$(tool)_COMPILE_$(type)_DONT_PURGE_OUTPUT
 | 
|---|
| [1599] | 87 |         $$(QUIET)$$(RM) -f -- $(dep) $(obj) $($(target)_$(source)_OUTPUT_) $($(target)_OUTPUT_MAYBE_)
 | 
|---|
| [1007] | 88 | endif
 | 
|---|
| [1012] | 89 | endif
 | 
|---|
| [412] | 90 | 
 | 
|---|
| [380] | 91 | $($(target)_$(source)_CMDS_)
 | 
|---|
 | 92 | 
 | 
|---|
 | 93 | ifndef 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] | 98 | endif
 | 
|---|
| [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] | 109 | endef # 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] | 114 | ifndef 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] | 120 | else
 | 
|---|
| [730] | 121 |  _DEP_LINK_CMDS =
 | 
|---|
| [380] | 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)
 | 
|---|
| [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.
 | 
|---|
 | 136 | define def_link_rule
 | 
|---|
| [2531] | 137 | $$(call KB_FN_ASSERT_ABSPATH,out)
 | 
|---|
| [2026] | 138 | ifndef NO_LINK_CMDS_DEPS
 | 
|---|
 | 139 | $(out): .MUST_MAKE = $$(comp-cmds-ex $$($(target)_CMDS_PREV_),$$(commands $$@),FORCE)
 | 
|---|
 | 140 | endif
 | 
|---|
| [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)
 | 
|---|
 | 152 | ifdef $(target)_2_OUTPUT_DEBUG_DIRS
 | 
|---|
 | 153 |         $$(QUIET)$$(RM) -Rf -- $($(target)_2_OUTPUT_DEBUG_DIRS)
 | 
|---|
 | 154 | endif
 | 
|---|
| [412] | 155 | 
 | 
|---|
| [1496] | 156 | $(cmds)
 | 
|---|
| [380] | 157 | 
 | 
|---|
| [524] | 158 | ifndef 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] | 162 | endif
 | 
|---|
| [380] | 163 | 
 | 
|---|
| [1686] | 164 | $(basename $(notdir $(out))):: $(out)
 | 
|---|
| [719] | 165 | 
 | 
|---|
| [1936] | 166 | endef # 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] | 173 | define 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] | 182 | endef
 | 
|---|
| [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
 | 
|---|
 | 188 | define 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 | 
 | 
|---|
 | 200 | endef
 | 
|---|
 | 201 | 
 | 
|---|
 | 202 | 
 | 
|---|
| [1424] | 203 | ## def_src_handler_*
 | 
|---|
 | 204 | #
 | 
|---|
 | 205 | # @{
 | 
|---|
 | 206 | define def_src_handler_c
 | 
|---|
| [1496] | 207 | local type := C
 | 
|---|
| [1795] | 208 |  $(kb-src-one 2)
 | 
|---|
| [1424] | 209 | endef
 | 
|---|
| [73] | 210 | 
 | 
|---|
| [1424] | 211 | define def_src_handler_cxx
 | 
|---|
| [1496] | 212 | local type := CXX
 | 
|---|
| [1795] | 213 |  $(kb-src-one 2)
 | 
|---|
| [1424] | 214 | endef
 | 
|---|
| [73] | 215 | 
 | 
|---|
| [1424] | 216 | define def_src_handler_objc
 | 
|---|
| [1496] | 217 | local type := OBJC
 | 
|---|
| [1795] | 218 |  $(kb-src-one 2)
 | 
|---|
| [1424] | 219 | endef
 | 
|---|
| [1256] | 220 | 
 | 
|---|
| [2356] | 221 | define def_src_handler_objcxx
 | 
|---|
| [2359] | 222 | local type := OBJCXX
 | 
|---|
| [2356] | 223 |  $(kb-src-one 2)
 | 
|---|
 | 224 | endef
 | 
|---|
 | 225 | 
 | 
|---|
| [1424] | 226 | define def_src_handler_asm
 | 
|---|
| [1496] | 227 | local type := AS
 | 
|---|
| [1795] | 228 |  $(kb-src-one 2)
 | 
|---|
| [1424] | 229 | endef
 | 
|---|
| [353] | 230 | 
 | 
|---|
| [1424] | 231 | define def_src_handler_rc
 | 
|---|
| [1496] | 232 | local type := RC
 | 
|---|
| [1795] | 233 |  $(kb-src-one 2)
 | 
|---|
| [1424] | 234 | endef
 | 
|---|
| [641] | 235 | 
 | 
|---|
| [1424] | 236 | define def_src_handler_obj
 | 
|---|
| [1434] | 237 | ifeq ($(defpath),)
 | 
|---|
| [2080] | 238 |  $(target)_2_OBJS += $(source)
 | 
|---|
 | 239 | else
 | 
|---|
 | 240 |  $(target)_2_OBJS += $(abspathex $(source), $(defpath))
 | 
|---|
 | 241 | endif
 | 
|---|
 | 242 | endef
 | 
|---|
| [1424] | 243 | ## @}
 | 
|---|
| [73] | 244 | 
 | 
|---|
| [1424] | 245 | ## Handle one source.
 | 
|---|
 | 246 | # .
 | 
|---|
 | 247 | define def_src_handler_one
 | 
|---|
| [1496] | 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))
 | 
|---|
| [1424] | 251 | ifneq ($(handler),)
 | 
|---|
| [1625] | 252 |  $(evalvalctx $(handler))
 | 
|---|
| [1424] | 253 | else
 | 
|---|
| [1434] | 254 |  othersrc += $(source)
 | 
|---|
| [1424] | 255 | endif
 | 
|---|
| [2475] | 256 | endef # 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] | 263 | define def_target_sources
 | 
|---|
| [1496] | 264 | local 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] | 286 | endef # 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.
 | 
|---|
 | 293 | define def_link_install_debug_dir_rule
 | 
|---|
| [2535] | 294 | local 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)
 | 
|---|
 | 300 | endef # def_link_install_debug_dir_rule
 | 
|---|
 | 301 | 
 | 
|---|
 | 302 | ##
 | 
|---|
| [2531] | 303 | # Install a debug file.
 | 
|---|
| [2523] | 304 | # @param    debug_file          Src=>Dst file pair.
 | 
|---|
 | 305 | define def_link_install_debug_file_rule
 | 
|---|
| [2535] | 306 | local dst := $(debug_inst_path)/$(debug_inst2)$(word 2, $(subst =>,$(SP),$(debug_file)))
 | 
|---|
| [2531] | 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 $$$$@)
 | 
|---|
| [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)
 | 
|---|
 | 314 | endef # 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.
 | 
|---|
 | 319 | define def_target_install_only_debug
 | 
|---|
 | 320 | if "$(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))
 | 
|---|
 | 332 | else
 | 
|---|
| [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))
 | 
|---|
 | 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 | 
 | 
|---|
| [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] | 350 | define def_target_install_only
 | 
|---|
| [2551] | 351 | if1of ($($(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] | 380 | endif
 | 
|---|
| [219] | 381 | 
 | 
|---|
| [2551] | 382 | ifneq ($($(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)
 | 
|---|
 | 391 | else  # INSTTYPE == none
 | 
|---|
| [1697] | 392 |  $(typevar) += $(out)
 | 
|---|
| [2475] | 393 | endif # 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 | 
 | 
|---|
 | 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
 | 
|---|
| [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)
 | 
|---|
 | 431 | endif
 | 
|---|
 | 432 | 
 | 
|---|
| [2475] | 433 | endef # 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] | 443 | define def_lib
 | 
|---|
| [145] | 444 | # library basics
 | 
|---|
| [222] | 445 | ## @todo prefix
 | 
|---|
| [1504] | 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))
 | 
|---|
| [1496] | 450 | local tool        := $(call _TARGET_TOOL,$(target),AR)
 | 
|---|
| [78] | 451 | ifeq ($(tool),)
 | 
|---|
| [353] | 452 | $(error kBuild: Library target $(target) does not have a tool defined!)
 | 
|---|
| [78] | 453 | endif
 | 
|---|
| [1496] | 454 | local 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] | 463 | local 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] | 466 | local 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] | 474 | local out         := $(outbase)$(suff)
 | 
|---|
| [2434] | 475 | local defpath     := $($(target)_DEFPATH)
 | 
|---|
 | 476 | ifeq ($(defpath),)
 | 
|---|
 | 477 |  local defpath    := $($(target)_PATH)
 | 
|---|
 | 478 | endif
 | 
|---|
| [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.
 | 
|---|
 | 482 | othersrc          :=
 | 
|---|
| [2236] | 483 | $(target)_2_OBJS  :=
 | 
|---|
| [145] | 484 | 
 | 
|---|
| [1672] | 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)
 | 
|---|
| [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] | 499 | local tool        := $(call _TARGET_TOOL,$(target),AR)
 | 
|---|
 | 500 | local 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] | 509 | local outbase     := $(call TARGET_BASE,$(name),$(target))
 | 
|---|
 | 510 | local 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] | 521 | local dirdep      := $(call DIRDEP,$(dir $(out)))
 | 
|---|
| [1702] | 522 | local 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)
 | 
|---|
 | 539 | local 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.
 | 
|---|
 | 558 | ifneq ($(defpath),)
 | 
|---|
| [1496] | 559 |  local deps       := $(abspathex $(deps),$(defpath))
 | 
|---|
 | 560 |  local orderdeps  := $(abspathex $(orderdeps),$(defpath))
 | 
|---|
| [1472] | 561 |  othersrc := $(abspathex $(othersrc),$(defpath))
 | 
|---|
| [725] | 562 | endif
 | 
|---|
 | 563 | 
 | 
|---|
| [859] | 564 | 
 | 
|---|
 | 565 | # Custom pre-link actions.
 | 
|---|
| [2475] | 566 | local pre_cmds  := $(evalcall def_fn_prop_get_first_defined,PRE_CMDS)
 | 
|---|
 | 567 | local post_cmds := $(evalcall def_fn_prop_get_first_defined,POST_CMDS)
 | 
|---|
| [859] | 568 | 
 | 
|---|
| [1424] | 569 | # eliminate this guy?
 | 
|---|
| [2236] | 570 | local objs = $($(target)_2_OBJS)
 | 
|---|
| [1424] | 571 | 
 | 
|---|
| [380] | 572 | # dependency file
 | 
|---|
| [1496] | 573 | local dep := $(out)$(SUFF_DEP)
 | 
|---|
| [524] | 574 | ifndef 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] | 581 | endif
 | 
|---|
| [72] | 582 | 
 | 
|---|
| [380] | 583 | # check that the tool is defined.
 | 
|---|
 | 584 | ifndef 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) )
 | 
|---|
 | 599 | endif
 | 
|---|
 | 600 | 
 | 
|---|
 | 601 | # call the tool
 | 
|---|
| [2523] | 602 | local  cmds := $(TOOL_$(tool)_LINK_LIBRARY_CMDS)
 | 
|---|
| [859] | 603 | ifneq ($(pre_cmds),)
 | 
|---|
| [1496] | 604 |  local cmds := $(TAB)$(pre_cmds)$(NL)$(TAB)$(cmds)
 | 
|---|
| [859] | 605 | endif
 | 
|---|
 | 606 | ifneq ($(post_cmds),)
 | 
|---|
| [2523] | 607 |  local cmds := $(cmds)$(NL)$(TAB)$(post_cmds)
 | 
|---|
| [859] | 608 | endif
 | 
|---|
| [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] | 619 | local 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 | 
 | 
|---|
 | 627 | endef # def_lib
 | 
|---|
| [1936] | 628 | $(eval-opt-var def_lib)
 | 
|---|
| [72] | 629 | 
 | 
|---|
 | 630 | # Process libraries
 | 
|---|
| [859] | 631 | typevar := _LIBS
 | 
|---|
| [776] | 632 | tool_do := LINK_LIBRARY
 | 
|---|
| [380] | 633 | mode := 0644
 | 
|---|
| [2762] | 634 | $(foreach target, $(_ALL_LIBRARIES), $(evalvalctx def_lib))
 | 
|---|
| [72] | 635 | 
 | 
|---|
| [988] | 636 | ifdef KBUILD_PROFILE_SELF
 | 
|---|
| [2008] | 637 |  $(evalcall def_profile_self, done library targets)
 | 
|---|
| [988] | 638 | endif
 | 
|---|
| [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] | 651 | define def_link_common
 | 
|---|
| [353] | 652 | # basics
 | 
|---|
| [1504] | 653 | local bld_type    := $(firstword $($(target)_BLD_TYPE)     $(KBUILD_TYPE))
 | 
|---|
| [1496] | 654 | local bld_trg     := $(firstword $($(target)_BLD_TRG)      $(BUILD_$(bld_trg_base_var)))
 | 
|---|
 | 655 | local bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_$(bld_trg_base_var)_ARCH))
 | 
|---|
 | 656 | local bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU)  $(BUILD_$(bld_trg_base_var)_CPU))
 | 
|---|
| [145] | 657 | 
 | 
|---|
| [1496] | 658 | local tool        := $(call _TARGET_TOOL,$(target),LD)
 | 
|---|
 | 659 | local 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] | 668 | local 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] | 671 | local 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] | 679 | local 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] | 682 | local defpath     := $($(target)_DEFPATH)
 | 
|---|
 | 683 | ifeq ($(defpath),)
 | 
|---|
 | 684 |  local defpath    := $($(target)_PATH)
 | 
|---|
 | 685 | endif
 | 
|---|
| [1496] | 686 | # no local here - must be writable across some foreachs.
 | 
|---|
 | 687 | othersrc          :=
 | 
|---|
| [2236] | 688 | $(target)_2_OBJS  :=
 | 
|---|
| [353] | 689 | 
 | 
|---|
| [1672] | 690 | # Do units pre source callouts.
 | 
|---|
 | 691 | local 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] | 704 | local tool        := $(call _TARGET_TOOL,$(target),LD)
 | 
|---|
 | 705 | local 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] | 714 | local outbase     := $(call TARGET_BASE,$(name),$(target))
 | 
|---|
 | 715 | local 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] | 756 | local 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] | 797 | local 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] | 838 | local dirdep      := $(call DIRDEP,$(dir $(out)))
 | 
|---|
| [1702] | 839 | local 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)
 | 
|---|
 | 856 | local 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.
 | 
|---|
 | 875 | ifneq ($(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] | 881 | endif
 | 
|---|
 | 882 | 
 | 
|---|
| [2523] | 883 | # Debug info.
 | 
|---|
 | 884 | local ld_debug      := $(evalcall def_fn_prop_get_first_defined,LD_DEBUG)
 | 
|---|
 | 885 | local debug_inst    := $(evalcall def_fn_prop_get_first_defined,DEBUG_INST)
 | 
|---|
 | 886 | local debug_stage   := $(evalcall def_fn_prop_get_first_defined,DEBUG_STAGE)
 | 
|---|
 | 887 | local debug_nostage := $(evalcall def_fn_prop_get_first_word,DEBUG_NOSTAGE)
 | 
|---|
 | 888 | 
 | 
|---|
| [2475] | 889 | # Custom pre/post-link actions.
 | 
|---|
| [2523] | 890 | local pre_cmds      := $(evalcall def_fn_prop_get_first_defined,PRE_CMDS)
 | 
|---|
 | 891 | local post_cmds     := $(evalcall def_fn_prop_get_first_defined,POST_CMDS)
 | 
|---|
| [72] | 892 | 
 | 
|---|
| [1424] | 893 | # eliminate this guy?
 | 
|---|
| [2236] | 894 | local objs = $($(target)_2_OBJS)
 | 
|---|
| [1424] | 895 | 
 | 
|---|
| [380] | 896 | # dependency file
 | 
|---|
| [1496] | 897 | local dep := $(outbase)$(SUFF_DEP)
 | 
|---|
| [524] | 898 | ifndef 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] | 905 | endif
 | 
|---|
| [353] | 906 | 
 | 
|---|
| [380] | 907 | # check that the tool is defined.
 | 
|---|
 | 908 | ifndef 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) )
 | 
|---|
 | 923 | endif
 | 
|---|
| [353] | 924 | 
 | 
|---|
| [380] | 925 | # call the tool
 | 
|---|
| [1496] | 926 | local cmds   := $(TOOL_$(tool)_$(tool_do)_CMDS)
 | 
|---|
| [859] | 927 | ifneq ($(pre_cmds),)
 | 
|---|
| [1496] | 928 |  local cmds  := $(TAB)$(pre_cmds)$(NL)$(TAB)$(cmds)
 | 
|---|
| [859] | 929 | endif
 | 
|---|
 | 930 | ifneq ($(post_cmds),)
 | 
|---|
| [1496] | 931 |  local cmds  := $(cmds)$(NL)$(TAB)$(post_cmds)
 | 
|---|
| [859] | 932 | endif
 | 
|---|
| [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] | 936 | if1of ($(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))
 | 
|---|
 | 939 | else
 | 
|---|
 | 940 |  $(target)_2_OUTPUT_DEBUG_FILES :=
 | 
|---|
 | 941 |  $(target)_2_OUTPUT_DEBUG_DIRS  :=
 | 
|---|
 | 942 | endif
 | 
|---|
 | 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
 | 
|---|
 | 950 | local 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] | 960 | endef # def_link_common
 | 
|---|
 | 961 | $(eval-opt-var def_link_common)
 | 
|---|
| [353] | 962 | 
 | 
|---|
 | 963 | 
 | 
|---|
 | 964 | #
 | 
|---|
 | 965 | # BLDPROGS
 | 
|---|
 | 966 | #
 | 
|---|
 | 967 | 
 | 
|---|
 | 968 | # Process build programs.
 | 
|---|
 | 969 | EXT     := EXE
 | 
|---|
 | 970 | EXTPRE  := HOST
 | 
|---|
| [380] | 971 | tool_do := LINK_PROGRAM
 | 
|---|
| [353] | 972 | typevar := _BLDPROGS
 | 
|---|
| [380] | 973 | mode    := 0755
 | 
|---|
| [353] | 974 | bld_trg_base_var := PLATFORM
 | 
|---|
| [2762] | 975 | $(foreach target, $(_ALL_BLDPROGS), $(evalvalctx def_link_common))
 | 
|---|
| [353] | 976 | 
 | 
|---|
| [988] | 977 | ifdef KBUILD_PROFILE_SELF
 | 
|---|
| [2008] | 978 |  $(evalcall def_profile_self, done build program targets)
 | 
|---|
| [988] | 979 | endif
 | 
|---|
| [353] | 980 | 
 | 
|---|
 | 981 | 
 | 
|---|
 | 982 | #
 | 
|---|
 | 983 | # DLLS
 | 
|---|
 | 984 | #
 | 
|---|
 | 985 | 
 | 
|---|
| [189] | 986 | # Process dlls
 | 
|---|
| [353] | 987 | EXT     := DLL
 | 
|---|
 | 988 | EXTPRE  :=
 | 
|---|
| [380] | 989 | tool_do := LINK_DLL
 | 
|---|
| [353] | 990 | typevar := _DLLS
 | 
|---|
| [830] | 991 | mode    := 0644
 | 
|---|
| [353] | 992 | bld_trg_base_var := TARGET
 | 
|---|
| [2762] | 993 | $(foreach target, $(_ALL_DLLS), $(evalvalctx def_link_common))
 | 
|---|
| [74] | 994 | 
 | 
|---|
| [988] | 995 | ifdef KBUILD_PROFILE_SELF
 | 
|---|
| [2008] | 996 |  $(evalcall def_profile_self, done dll targets)
 | 
|---|
| [988] | 997 | endif
 | 
|---|
| [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 | #
 | 
|---|
 | 1006 | EXTPRE  :=
 | 
|---|
 | 1007 | typevar := _IMPORT_LIBS
 | 
|---|
 | 1008 | mode    := 0644
 | 
|---|
 | 1009 | bld_trg_base_var := TARGET
 | 
|---|
| [1504] | 1010 | ifeq ($(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] | 1014 | else
 | 
|---|
| [830] | 1015 |  EXT     := DLL
 | 
|---|
 | 1016 |  tool_do := LINK_DLL
 | 
|---|
| [2762] | 1017 |  $(foreach target, $(_ALL_IMPORT_LIBS), $(evalvalctx def_link_common))
 | 
|---|
| [189] | 1018 | endif
 | 
|---|
| [72] | 1019 | 
 | 
|---|
| [988] | 1020 | ifdef KBUILD_PROFILE_SELF
 | 
|---|
| [2008] | 1021 |  $(evalcall def_profile_self, done import library targets)
 | 
|---|
| [988] | 1022 | endif
 | 
|---|
| [189] | 1023 | 
 | 
|---|
| [988] | 1024 | 
 | 
|---|
| [189] | 1025 | #
 | 
|---|
 | 1026 | # PROGRAMS
 | 
|---|
 | 1027 | #
 | 
|---|
 | 1028 | 
 | 
|---|
| [353] | 1029 | # Process programs
 | 
|---|
 | 1030 | EXT     := EXE
 | 
|---|
 | 1031 | EXTPRE  :=
 | 
|---|
| [380] | 1032 | tool_do := LINK_PROGRAM
 | 
|---|
| [353] | 1033 | typevar := _PROGRAMS
 | 
|---|
| [380] | 1034 | mode    := 0755
 | 
|---|
| [353] | 1035 | bld_trg_base_var := TARGET
 | 
|---|
| [2762] | 1036 | $(foreach target, $(_ALL_PROGRAMS), $(evalvalctx def_link_common))
 | 
|---|
| [130] | 1037 | 
 | 
|---|
| [988] | 1038 | ifdef KBUILD_PROFILE_SELF
 | 
|---|
| [2008] | 1039 |  $(evalcall def_profile_self, done program targets)
 | 
|---|
| [988] | 1040 | endif
 | 
|---|
| [130] | 1041 | 
 | 
|---|
| [189] | 1042 | 
 | 
|---|
| [72] | 1043 | #
 | 
|---|
| [83] | 1044 | # SYSMODS
 | 
|---|
| [72] | 1045 | #
 | 
|---|
 | 1046 | 
 | 
|---|
| [130] | 1047 | # Process sysmods
 | 
|---|
| [353] | 1048 | EXT     := SYS
 | 
|---|
 | 1049 | EXTPRE  :=
 | 
|---|
| [380] | 1050 | tool_do := LINK_SYSMOD
 | 
|---|
| [353] | 1051 | typevar := _SYSMODS
 | 
|---|
| [380] | 1052 | mode    := 0644
 | 
|---|
| [353] | 1053 | bld_trg_base_var := TARGET
 | 
|---|
| [2762] | 1054 | $(foreach target, $(_ALL_SYSMODS), $(evalvalctx def_link_common))
 | 
|---|
| [83] | 1055 | 
 | 
|---|
| [988] | 1056 | ifdef KBUILD_PROFILE_SELF
 | 
|---|
| [2008] | 1057 |  $(evalcall def_profile_self, done sysmod targets)
 | 
|---|
| [988] | 1058 | endif
 | 
|---|
| [83] | 1059 | 
 | 
|---|
| [988] | 1060 | 
 | 
|---|
| [72] | 1061 | #
 | 
|---|
| [2084] | 1062 | # MISCBINS
 | 
|---|
 | 1063 | #
 | 
|---|
 | 1064 | 
 | 
|---|
 | 1065 | # Process MISCBINS
 | 
|---|
 | 1066 | EXT     := BIN
 | 
|---|
 | 1067 | EXTPRE  :=
 | 
|---|
 | 1068 | tool_do := LINK_MISCBIN
 | 
|---|
 | 1069 | typevar := _MISCBINS
 | 
|---|
 | 1070 | mode    := 0644
 | 
|---|
 | 1071 | bld_trg_base_var := TARGET
 | 
|---|
| [2762] | 1072 | $(foreach target, $(_ALL_MISCBINS), $(evalvalctx def_link_common))
 | 
|---|
| [2084] | 1073 | 
 | 
|---|
 | 1074 | ifdef KBUILD_PROFILE_SELF
 | 
|---|
 | 1075 |  $(evalcall def_profile_self, done misc binary targets)
 | 
|---|
 | 1076 | endif
 | 
|---|
 | 1077 | 
 | 
|---|