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