source: trunk/kBuild/footer-pass2-compiling-targets.kmk@ 2523

Last change on this file since 2523 was 2523, checked in by bird, 14 years ago

kBuild: debug info installation support, core hacking + mac os x.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 38.0 KB
RevLine 
[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.
40ifndef 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]47else
[730]48 _DEP_COMPILE_CMDS =
[380]49endif
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]55define def_target_source_rule
[2026]56ifndef NO_COMPILE_CMDS_DEPS
57$(obj): .MUST_MAKE = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_CMDS_PREV_),$$(commands $$@),FORCE)
58endif
[1012]59ifdef 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]73else
[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]86ifdef TOOL_$(tool)_COMPILE_$(type)_DONT_PURGE_OUTPUT
[1599]87 $$(QUIET)$$(RM) -f -- $(dep) $(obj) $($(target)_$(source)_OUTPUT_) $($(target)_OUTPUT_MAYBE_)
[1007]88endif
[1012]89endif
[412]90
[380]91$($(target)_$(source)_CMDS_)
92
93ifndef 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]98endif
[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]109endef # 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]114ifndef 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]120else
[730]121 _DEP_LINK_CMDS =
[380]122endif
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.
135define def_link_rule
[2026]136ifndef NO_LINK_CMDS_DEPS
137$(out): .MUST_MAKE = $$(comp-cmds-ex $$($(target)_CMDS_PREV_),$$(commands $$@),FORCE)
138endif
[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)
150ifdef $(target)_2_OUTPUT_DEBUG_DIRS
151 $$(QUIET)$$(RM) -Rf -- $($(target)_2_OUTPUT_DEBUG_DIRS)
152endif
[412]153
[1496]154$(cmds)
[380]155
[524]156ifndef 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]160endif
[380]161
[1686]162$(basename $(notdir $(out))):: $(out)
[719]163
[1936]164endef # 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]171define 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]179endef
[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
185define 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
196endef
197
198
[1424]199## def_src_handler_*
200#
201# @{
202define def_src_handler_c
[1496]203local type := C
[1795]204 $(kb-src-one 2)
[1424]205endef
[73]206
[1424]207define def_src_handler_cxx
[1496]208local type := CXX
[1795]209 $(kb-src-one 2)
[1424]210endef
[73]211
[1424]212define def_src_handler_objc
[1496]213local type := OBJC
[1795]214 $(kb-src-one 2)
[1424]215endef
[1256]216
[2356]217define def_src_handler_objcxx
[2359]218local type := OBJCXX
[2356]219 $(kb-src-one 2)
220endef
221
[1424]222define def_src_handler_asm
[1496]223local type := AS
[1795]224 $(kb-src-one 2)
[1424]225endef
[353]226
[1424]227define def_src_handler_rc
[1496]228local type := RC
[1795]229 $(kb-src-one 2)
[1424]230endef
[641]231
[1424]232define def_src_handler_obj
[1434]233ifeq ($(defpath),)
[2080]234 $(target)_2_OBJS += $(source)
235else
236 $(target)_2_OBJS += $(abspathex $(source), $(defpath))
237endif
238endef
[1424]239## @}
[73]240
[1424]241## Handle one source.
242# .
243define def_src_handler_one
[1496]244local suff := $(suffix $(source))
245local src_handler := $(firstword $(filter $(suff):%, $($(target)_$(source)_SRC_HANDLERS) $($(source)_SRC_HANDLERS) $(target_src_handlers) ))
246local handler := $(patsubst $(suff):%,%,$(src_handler))
[1424]247ifneq ($(handler),)
[1625]248 $(evalvalctx $(handler))
[1424]249else
[1434]250 othersrc += $(source)
[1424]251endif
[2475]252endef # 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]259define def_target_sources
[1496]260local 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]282endef # 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#
295define def_fn_prop_get_first_defined
[2523]296local .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)
306ifeq ($(.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]332endif
[2523]333local .RETURN := $(strip $($(.RETURN)))
[2475]334endef # 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#
345define def_fn_prop_get_first_word
346local .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)
356ifeq ($(.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
382endif
383endef # def_fn_prop_get_first_word
[2475]384
[2523]385##
386# Install a debug directory.
387# @param debug_dir The directory name.
388define def_link_install_debug_dir_rule
389local 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)
394endef # def_link_install_debug_dir_rule
395
396##
397# Install a debug file.
398# @param debug_file Src=>Dst file pair.
399define def_link_install_debug_file_rule
400local 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)
405endef # 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.
410define def_target_install_only_debug
411if "$(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))
421else
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))
425endif
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)))
428endef
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]437define def_target_install_only
438ifneq ($($(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)
475else # INSTTYPE == none
[1697]476 $(typevar) += $(out)
[2475]477endif # 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
485if ( 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)
515endif
516
[2475]517endef # 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]527define def_lib
[145]528# library basics
[222]529## @todo prefix
[1504]530local bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE))
531local bld_trg := $(firstword $($(target)_BLD_TRG) $(KBUILD_TARGET))
532local bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(KBUILD_TARGET_ARCH))
533local bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(KBUILD_TARGET_CPU))
[1496]534local tool := $(call _TARGET_TOOL,$(target),AR)
[78]535ifeq ($(tool),)
[353]536$(error kBuild: Library target $(target) does not have a tool defined!)
[78]537endif
[1496]538local 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]547local 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]550local 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]558local out := $(outbase)$(suff)
[2434]559local defpath := $($(target)_DEFPATH)
560ifeq ($(defpath),)
561 local defpath := $($(target)_PATH)
562endif
[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.
566othersrc :=
[2236]567$(target)_2_OBJS :=
[145]568
[1672]569# Do units pre source callouts.
570local 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]582local tool := $(call _TARGET_TOOL,$(target),AR)
583local 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]592local outbase := $(call TARGET_BASE,$(name),$(target))
593local 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]604local dirdep := $(call DIRDEP,$(dir $(out)))
[1702]605local 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)
622local 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.
641ifneq ($(defpath),)
[1496]642 local deps := $(abspathex $(deps),$(defpath))
643 local orderdeps := $(abspathex $(orderdeps),$(defpath))
[1472]644 othersrc := $(abspathex $(othersrc),$(defpath))
[725]645endif
646
[859]647
648# Custom pre-link actions.
[2475]649local pre_cmds := $(evalcall def_fn_prop_get_first_defined,PRE_CMDS)
650local post_cmds := $(evalcall def_fn_prop_get_first_defined,POST_CMDS)
[859]651
[1424]652# eliminate this guy?
[2236]653local objs = $($(target)_2_OBJS)
[1424]654
[380]655# dependency file
[1496]656local dep := $(out)$(SUFF_DEP)
[524]657ifndef 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]664endif
[72]665
[380]666# check that the tool is defined.
667ifndef 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) )
682endif
683
684# call the tool
[2523]685local cmds := $(TOOL_$(tool)_LINK_LIBRARY_CMDS)
[859]686ifneq ($(pre_cmds),)
[1496]687 local cmds := $(TAB)$(pre_cmds)$(NL)$(TAB)$(cmds)
[859]688endif
689ifneq ($(post_cmds),)
[2523]690 local cmds := $(cmds)$(NL)$(TAB)$(post_cmds)
[859]691endif
[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]701local 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
709endef # def_lib
[1936]710$(eval-opt-var def_lib)
[72]711
712# Process libraries
[859]713typevar := _LIBS
[776]714tool_do := LINK_LIBRARY
[380]715mode := 0644
[1648]716$(foreach target, $(_ALL_LIBRARIES), $(evalval def_lib))
[72]717
[988]718ifdef KBUILD_PROFILE_SELF
[2008]719 $(evalcall def_profile_self, done library targets)
[988]720endif
[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]733define def_link_common
[353]734# basics
[1504]735local bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE))
[1496]736local bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_$(bld_trg_base_var)))
737local bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_$(bld_trg_base_var)_ARCH))
738local bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_$(bld_trg_base_var)_CPU))
[145]739
[1496]740local tool := $(call _TARGET_TOOL,$(target),LD)
741local 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]750local 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]753local 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]761local 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]764local defpath := $($(target)_DEFPATH)
765ifeq ($(defpath),)
766 local defpath := $($(target)_PATH)
767endif
[1496]768# no local here - must be writable across some foreachs.
769othersrc :=
[2236]770$(target)_2_OBJS :=
[353]771
[1672]772# Do units pre source callouts.
773local 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]785local tool := $(call _TARGET_TOOL,$(target),LD)
786local 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]795local outbase := $(call TARGET_BASE,$(name),$(target))
796local 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]837local 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]878local 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]919local dirdep := $(call DIRDEP,$(dir $(out)))
[1702]920local 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)
937local 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.
956ifneq ($(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]962endif
963
[2523]964# Debug info.
965local ld_debug := $(evalcall def_fn_prop_get_first_defined,LD_DEBUG)
966local debug_inst := $(evalcall def_fn_prop_get_first_defined,DEBUG_INST)
967local debug_stage := $(evalcall def_fn_prop_get_first_defined,DEBUG_STAGE)
968local debug_nostage := $(evalcall def_fn_prop_get_first_word,DEBUG_NOSTAGE)
969
[2475]970# Custom pre/post-link actions.
[2523]971local pre_cmds := $(evalcall def_fn_prop_get_first_defined,PRE_CMDS)
972local post_cmds := $(evalcall def_fn_prop_get_first_defined,POST_CMDS)
[72]973
[1424]974# eliminate this guy?
[2236]975local objs = $($(target)_2_OBJS)
[1424]976
[380]977# dependency file
[1496]978local dep := $(outbase)$(SUFF_DEP)
[524]979ifndef 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]986endif
[353]987
[380]988# check that the tool is defined.
989ifndef 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) )
1004endif
[353]1005
[380]1006# call the tool
[1496]1007local cmds := $(TOOL_$(tool)_$(tool_do)_CMDS)
[859]1008ifneq ($(pre_cmds),)
[1496]1009 local cmds := $(TAB)$(pre_cmds)$(NL)$(TAB)$(cmds)
[859]1010endif
1011ifneq ($(post_cmds),)
[1496]1012 local cmds := $(cmds)$(NL)$(TAB)$(post_cmds)
[859]1013endif
[2523]1014$(target)_2_OUTPUT := $(TOOL_$(tool)_$(tool_do)_OUTPUT)
1015$(target)_2_OUTPUT_MAYBE := $(TOOL_$(tool)_$(tool_do)_OUTPUT_MAYBE)
1016if1of ($(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))
1019else
1020 $(target)_2_OUTPUT_DEBUG_FILES :=
1021 $(target)_2_OUTPUT_DEBUG_DIRS :=
1022endif
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
1030local 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]1040endef # def_link_common
1041$(eval-opt-var def_link_common)
[353]1042
1043
1044#
1045# BLDPROGS
1046#
1047
1048# Process build programs.
1049EXT := EXE
1050EXTPRE := HOST
[380]1051tool_do := LINK_PROGRAM
[353]1052typevar := _BLDPROGS
[380]1053mode := 0755
[353]1054bld_trg_base_var := PLATFORM
[2475]1055$(foreach target, $(_ALL_BLDPROGS), $(evalval def_link_common))
[353]1056
[988]1057ifdef KBUILD_PROFILE_SELF
[2008]1058 $(evalcall def_profile_self, done build program targets)
[988]1059endif
[353]1060
1061
1062#
1063# DLLS
1064#
1065
[189]1066# Process dlls
[353]1067EXT := DLL
1068EXTPRE :=
[380]1069tool_do := LINK_DLL
[353]1070typevar := _DLLS
[830]1071mode := 0644
[353]1072bld_trg_base_var := TARGET
[1648]1073$(foreach target, $(_ALL_DLLS), $(evalval def_link_common))
[74]1074
[988]1075ifdef KBUILD_PROFILE_SELF
[2008]1076 $(evalcall def_profile_self, done dll targets)
[988]1077endif
[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#
1086EXTPRE :=
1087typevar := _IMPORT_LIBS
1088mode := 0644
1089bld_trg_base_var := TARGET
[1504]1090ifeq ($(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]1094else
[830]1095 EXT := DLL
1096 tool_do := LINK_DLL
[1648]1097 $(foreach target, $(_ALL_IMPORT_LIBS), $(evalval def_link_common))
[189]1098endif
[72]1099
[988]1100ifdef KBUILD_PROFILE_SELF
[2008]1101 $(evalcall def_profile_self, done import library targets)
[988]1102endif
[189]1103
[988]1104
[189]1105#
1106# PROGRAMS
1107#
1108
[353]1109# Process programs
1110EXT := EXE
1111EXTPRE :=
[380]1112tool_do := LINK_PROGRAM
[353]1113typevar := _PROGRAMS
[380]1114mode := 0755
[353]1115bld_trg_base_var := TARGET
[1648]1116$(foreach target, $(_ALL_PROGRAMS), $(evalval def_link_common))
[130]1117
[988]1118ifdef KBUILD_PROFILE_SELF
[2008]1119 $(evalcall def_profile_self, done program targets)
[988]1120endif
[130]1121
[189]1122
[72]1123#
[83]1124# SYSMODS
[72]1125#
1126
[130]1127# Process sysmods
[353]1128EXT := SYS
1129EXTPRE :=
[380]1130tool_do := LINK_SYSMOD
[353]1131typevar := _SYSMODS
[380]1132mode := 0644
[353]1133bld_trg_base_var := TARGET
[1648]1134$(foreach target, $(_ALL_SYSMODS), $(evalval def_link_common))
[83]1135
[988]1136ifdef KBUILD_PROFILE_SELF
[2008]1137 $(evalcall def_profile_self, done sysmod targets)
[988]1138endif
[83]1139
[988]1140
[72]1141#
[2084]1142# MISCBINS
1143#
1144
1145# Process MISCBINS
1146EXT := BIN
1147EXTPRE :=
1148tool_do := LINK_MISCBIN
1149typevar := _MISCBINS
1150mode := 0644
1151bld_trg_base_var := TARGET
1152$(foreach target, $(_ALL_MISCBINS), $(evalval def_link_common))
1153
1154ifdef KBUILD_PROFILE_SELF
1155 $(evalcall def_profile_self, done misc binary targets)
1156endif
1157
Note: See TracBrowser for help on using the repository browser.