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

Last change on this file since 2775 was 2762, checked in by bird, 10 years ago

Use evalvalctx instead of evalval for most of the target processing to make sure there isn't leakage between tragets via supposedly local variables (which ended up being local at the foreach level instead of the evalval level). Avoid troubles like we had in def_pass1_link_common when PDBs was installed but not the actual binary, we ended up using the $(inst) value from the previous run. (VBoxDrv.sys w/ signing enabled.)

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