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