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

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

footer.kmk: Split it up into several files.

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