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