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