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
Line 
1# $Id: footer-pass2-compiling-targets.kmk 2523 2011-07-31 23:45:20Z bird $
2## @file
3# kBuild - Footer - Target lists - Pass 2 - Compiling Targets.
4#
5
6#
7# Copyright (c) 2004-2011 knut st. osmundsen <bird-kBuild-spamx@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
136ifndef NO_LINK_CMDS_DEPS
137$(out): .MUST_MAKE = $$(comp-cmds-ex $$($(target)_CMDS_PREV_),$$(commands $$@),FORCE)
138endif
139$(out) \
140+ $($(target)_2_OUTPUT) \
141+ $($(target)_2_OUTPUT_DEBUG_FILES) \
142+ $($(target)_2_OUTPUT_DEBUG_DIRS) \
143+| $($(target)_2_OUTPUT_MAYBE) : \
144 $$$$($(target)_2_DEPEND) \
145 $(value _DEP_LINK_CMDS) \
146 | \
147 $$$$($(target)_2_DEPORD)
148 %$$(call MSG_LINK,$(target),$$@,$(tool_do))
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
153
154$(cmds)
155
156ifndef NO_LINK_CMDS_DEPS
157 %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_CMDS_PREV_'
158 %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
159 %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
160endif
161
162$(basename $(notdir $(out))):: $(out)
163
164endef # def_link_rule
165$(eval-opt-var def_link_rule)
166
167
168## Generate the link & lib install rule
169# Implicit parameters: target, out, $(target)_1_STAGE_TARGET, mode,
170# pre_install_cmds, post_install_cmds
171define def_link_install_rule
172$($(target)_1_INST_TARGET): $(out) | $$$$(dir $$$$@)
173 %$$(call MSG_INST_TRG,$(target),$(out),$$@)
174 $(pre_install_cmds)
175
176 $$(QUIET)$$(INSTALL) $(if $(mode),-m $(mode)) $(if $(uid),-o $(uid)) $(if $(gid),-g $(gid)) -- $(out) $$@
177 $(post_install_cmds)
178
179endef
180
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
186$($(target)_1_STAGE_TARGET): $(out) | $$$$(dir $$$$@)
187 %$$(call MSG_INST_TRG,$(target),$(out),$$@)
188 $(pre_install_cmds)
189
190 $$(QUIET)$$(INSTALL_STAGING) $(if $(mode),-m $(mode)) $(if $(uid),-o $(uid)) $(if $(gid),-g $(gid)) -- $(out) $$@
191 $(post_install_cmds)
192
193
194$(basename $(notdir $(out))):: $($(target)_1_STAGE_TARGET)
195
196endef
197
198
199## def_src_handler_*
200#
201# @{
202define def_src_handler_c
203local type := C
204 $(kb-src-one 2)
205endef
206
207define def_src_handler_cxx
208local type := CXX
209 $(kb-src-one 2)
210endef
211
212define def_src_handler_objc
213local type := OBJC
214 $(kb-src-one 2)
215endef
216
217define def_src_handler_objcxx
218local type := OBJCXX
219 $(kb-src-one 2)
220endef
221
222define def_src_handler_asm
223local type := AS
224 $(kb-src-one 2)
225endef
226
227define def_src_handler_rc
228local type := RC
229 $(kb-src-one 2)
230endef
231
232define def_src_handler_obj
233ifeq ($(defpath),)
234 $(target)_2_OBJS += $(source)
235else
236 $(target)_2_OBJS += $(abspathex $(source), $(defpath))
237endif
238endef
239## @}
240
241## Handle one source.
242# .
243define def_src_handler_one
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))
247ifneq ($(handler),)
248 $(evalvalctx $(handler))
249else
250 othersrc += $(source)
251endif
252endef # def_src_handler_one
253
254## Generic macro for processing all target sources.
255# @param $(target) Normalized target name.
256# @param $(defpath)
257# @param much-more...
258# @returns othersrc, $(target)_2_OBJS, ++
259define def_target_sources
260local target_src_handlers := $($(target)_SRC_HANDLERS) $(KBUILD_SRC_HANDLERS)
261$(foreach source,\
262 $($(target)_SOURCES)\
263 $($(target)_SOURCES.$(bld_trg))\
264 $($(target)_SOURCES.$(bld_trg).$(bld_type))\
265 $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch))\
266 $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch).$(bld_type))\
267 $($(target)_SOURCES.$(bld_trg_arch))\
268 $($(target)_SOURCES.$(bld_trg_cpu))\
269 $($(target)_SOURCES.$(bld_type))\
270 ,$(evalval def_src_handler_one) )
271
272$(foreach source,\
273 $($(target)_GEN_SOURCES_)\
274 $($(target)_GEN_SOURCES_.$(bld_trg))\
275 $($(target)_GEN_SOURCES_.$(bld_trg).$(bld_type))\
276 $($(target)_GEN_SOURCES_.$(bld_trg).$(bld_trg_arch))\
277 $($(target)_GEN_SOURCES_.$(bld_trg).$(bld_trg_arch).$(bld_type))\
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) )
282endef # def_target_sources
283$(eval-opt-var def_target_sources)
284
285
286##
287# Function for getting the first defined propert value.
288#
289# @param 1 The property name.
290# @param 2 The default property name, empty if none.
291# @param 3 What to return if all variables are empty. (optional)
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
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
332endif
333local .RETURN := $(strip $($(.RETURN)))
334endef # def_fn_prop_get_first_defined
335
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
384
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
431## Generic macro for generating the install rule(s) for a target.
432#
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.
436# @param $(target_type_mode) The default file mode implied by the target type.
437define def_target_install_only
438ifneq ($($(target)_1_INSTTYPE),none)
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)) \
446 $($(target)_MODE) \
447 $(target_type_mode) )
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) )
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)
466
467 # Generate the rules
468 ifeq ($($(target)_1_INSTTYPE),both)
469$(eval $(def_link_install_rule))
470 _INSTALLS_FILES += $($(target)_1_INST_TARGET)
471 endif
472$(eval $(def_link_stage_rule))
473 _STAGE_FILES += $($(target)_1_STAGE_TARGET)
474 $(typevar) += $($(target)_1_STAGE_TARGET)
475else # INSTTYPE == none
476 $(typevar) += $(out)
477endif # INSTTYPE == none
478
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
517endef # def_target_install_only
518
519
520
521#
522# LIBRARIES
523#
524
525## Library (one).
526# @param $(target) Normalized library (target) name.
527define def_lib
528# library basics
529## @todo prefix
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))
534local tool := $(call _TARGET_TOOL,$(target),AR)
535ifeq ($(tool),)
536$(error kBuild: Library target $(target) does not have a tool defined!)
537endif
538local name := $(firstword\
539 $($(target)_NAME.$(bld_trg).$(bld_trg_arch).$(bld_type))\
540 $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\
541 $($(target)_NAME.$(bld_trg).$(bld_type))\
542 $($(target)_NAME.$(bld_trg_arch))\
543 $($(target)_NAME.$(bld_trg))\
544 $($(target)_NAME.$(bld_type))\
545 $($(target)_NAME)\
546 $(target))
547local outbase := $(call TARGET_BASE,$(name),$(target))
548$(target)_0_OUTDIR:= $(patsubst %/,%,$(dir $(outbase)))
549$(call KB_FN_ASSIGN_DEPRECATED,PATH_$(target),$($(target)_0_OUTDIR), $(target)_0_OUTDIR)
550local suff := $(firstword\
551 $($(target)_LIBSUFF.$(bld_trg).$(bld_trg_arch))\
552 $($(target)_LIBSUFF.$(bld_trg))\
553 $($(target)_LIBSUFF)\
554 $(TOOL_$(tool)_ARLIBSUFF.$(bld_trg).$(bld_trg_arch))\
555 $(TOOL_$(tool)_ARLIBSUFF.$(bld_trg))\
556 $(TOOL_$(tool)_ARLIBSUFF)\
557 $(SUFF_LIB))
558local out := $(outbase)$(suff)
559local defpath := $($(target)_DEFPATH)
560ifeq ($(defpath),)
561 local defpath := $($(target)_PATH)
562endif
563$(target)_1_TARGET:= $(out)
564$(call KB_FN_ASSIGN_DEPRECATED,TARGET_$(target),$($(target)_1_TARGET), $(target)_1_TARGET)
565# no local here - must be writable across some foreachs.
566othersrc :=
567$(target)_2_OBJS :=
568
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
578# source -> object
579$(evalval def_target_sources)
580
581# library linking
582local tool := $(call _TARGET_TOOL,$(target),AR)
583local name := $(firstword\
584 $($(target)_NAME.$(bld_trg).$(bld_trg_arch).$(bld_type))\
585 $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\
586 $($(target)_NAME.$(bld_trg).$(bld_type))\
587 $($(target)_NAME.$(bld_trg_arch))\
588 $($(target)_NAME.$(bld_trg))\
589 $($(target)_NAME.$(bld_type))\
590 $($(target)_NAME)\
591 $(target))
592local outbase := $(call TARGET_BASE,$(name),$(target))
593local flags :=\
594 $(TOOL_$(tool)_ARFLAGS)\
595 $(TOOL_$(tool)_ARFLAGS.$(bld_type))\
596 $(ARFLAGS)\
597 $(ARFLAGS.$(bld_type))\
598 $($(target)_ARFLAGS)\
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))
604local dirdep := $(call DIRDEP,$(dir $(out)))
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)
639
640# Adjust paths if we got a default path.
641ifneq ($(defpath),)
642 local deps := $(abspathex $(deps),$(defpath))
643 local orderdeps := $(abspathex $(orderdeps),$(defpath))
644 othersrc := $(abspathex $(othersrc),$(defpath))
645endif
646
647
648# Custom pre-link actions.
649local pre_cmds := $(evalcall def_fn_prop_get_first_defined,PRE_CMDS)
650local post_cmds := $(evalcall def_fn_prop_get_first_defined,POST_CMDS)
651
652# eliminate this guy?
653local objs = $($(target)_2_OBJS)
654
655# dependency file
656local dep := $(out)$(SUFF_DEP)
657ifndef NO_LINK_CMDS_DEPS
658 _DEPFILES_INCLUDED += $(dep)
659 ifdef KB_HAVE_INCLUDEDEP_QUEUE
660 includedep-queue $(dep)
661 else
662 includedep $(dep)
663 endif
664endif
665
666# check that the tool is defined.
667ifndef TOOL_$(tool)_LINK_LIBRARY_CMDS
668$(warning kBuild: tools: \
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) )
681$(error kBuild: TOOL_$(tool)_LINK_LIBRARY_CMDS isn't defined! target=$(target) )
682endif
683
684# call the tool
685local cmds := $(TOOL_$(tool)_LINK_LIBRARY_CMDS)
686ifneq ($(pre_cmds),)
687 local cmds := $(TAB)$(pre_cmds)$(NL)$(TAB)$(cmds)
688endif
689ifneq ($(post_cmds),)
690 local cmds := $(cmds)$(NL)$(TAB)$(post_cmds)
691endif
692$(target)_2_OUTPUT := $(TOOL_$(tool)_LINK_LIBRARY_OUTPUT)
693$(target)_2_OUTPUT_MAYBE := $(TOOL_$(tool)_LINK_LIBRARY_OUTPUT_MAYBE)
694$(target)_2_DEPEND := $(TOOL_$(tool)_LINK_LIBRARY_DEPEND) $(deps) $($(target)_2_OBJS)
695$(target)_2_DEPORD := $(TOOL_$(tool)_LINK_LIBRARY_DEPORD) $(dirdep) $(orderdeps)
696
697# generate the link rule.
698$(eval $(def_link_rule))
699
700# installing and globals.
701local target_type_mode := a+r,u+w
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
710$(eval-opt-var def_lib)
711
712# Process libraries
713typevar := _LIBS
714tool_do := LINK_LIBRARY
715mode := 0644
716$(foreach target, $(_ALL_LIBRARIES), $(evalval def_lib))
717
718ifdef KBUILD_PROFILE_SELF
719 $(evalcall def_profile_self, done library targets)
720endif
721
722
723#
724# Link operations.
725#
726
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.
733define def_link_common
734# basics
735local bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE))
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))
739
740local tool := $(call _TARGET_TOOL,$(target),LD)
741local name := $(firstword\
742 $($(target)_NAME.$(bld_trg).$(bld_trg_arch).$(bld_type))\
743 $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\
744 $($(target)_NAME.$(bld_trg).$(bld_type))\
745 $($(target)_NAME.$(bld_trg_arch))\
746 $($(target)_NAME.$(bld_trg))\
747 $($(target)_NAME.$(bld_type))\
748 $($(target)_NAME)\
749 $(target))
750local outbase := $(call TARGET_BASE,$(name),$(target))
751$(target)_0_OUTDIR:= $(patsubst %/,%,$(dir $(outbase)))
752$(call KB_FN_ASSIGN_DEPRECATED,PATH_$(target),$($(target)_0_OUTDIR), $(target)_0_OUTDIR)
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)) )
761local out := $(outbase)$(suff)
762$(target)_1_TARGET:= $(out)
763$(call KB_FN_ASSIGN_DEPRECATED,TARGET_$(target),$($(target)_1_TARGET), $(target)_1_TARGET)
764local defpath := $($(target)_DEFPATH)
765ifeq ($(defpath),)
766 local defpath := $($(target)_PATH)
767endif
768# no local here - must be writable across some foreachs.
769othersrc :=
770$(target)_2_OBJS :=
771
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
781# source -> object
782$(evalval def_target_sources)
783
784# more link stuff.
785local tool := $(call _TARGET_TOOL,$(target),LD)
786local name := $(firstword\
787 $($(target)_NAME.$(bld_trg).$(bld_trg_arch).$(bld_type))\
788 $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\
789 $($(target)_NAME.$(bld_trg).$(bld_type))\
790 $($(target)_NAME.$(bld_trg_arch))\
791 $($(target)_NAME.$(bld_trg))\
792 $($(target)_NAME.$(bld_type))\
793 $($(target)_NAME)\
794 $(target))
795local outbase := $(call TARGET_BASE,$(name),$(target))
796local flags :=\
797 $(TOOL_$(tool)_LDFLAGS)\
798 $(TOOL_$(tool)_LDFLAGS.$(bld_type))\
799 $(TOOL_$(tool)_LDFLAGS.$(bld_trg))\
800 $(TOOL_$(tool)_LDFLAGS.$(bld_trg_arch))\
801 $(TOOL_$(tool)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\
802 $(TOOL_$(tool)_LDFLAGS.$(bld_trg_cpu))\
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)))\
814 $(LDFLAGS)\
815 $(LDFLAGS.$(bld_type))\
816 $(LDFLAGS.$(bld_trg))\
817 $(LDFLAGS.$(bld_trg_arch))\
818 $(LDFLAGS.$(bld_trg).$(bld_trg_arch))\
819 $(LDFLAGS.$(bld_trg_cpu))\
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)))\
831 $($(target)_LDFLAGS)\
832 $($(target)_LDFLAGS.$(bld_type))\
833 $($(target)_LDFLAGS.$(bld_trg))\
834 $($(target)_LDFLAGS.$(bld_trg_arch))\
835 $($(target)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\
836 $($(target)_LDFLAGS.$(bld_trg_cpu))
837local libs :=\
838 $($(target)_LIBS.$(bld_trg_cpu))\
839 $($(target)_LIBS.$(bld_trg).$(bld_trg_arch))\
840 $($(target)_LIBS.$(bld_trg_arch))\
841 $($(target)_LIBS.$(bld_trg))\
842 $($(target)_LIBS.$(bld_type))\
843 $($(target)_LIBS)\
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),\
849 $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
850 $(SDK_$(sdk)_LIBS.$(bld_trg).$(bld_trg_arch))\
851 $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
852 $(SDK_$(sdk)_LIBS.$(bld_trg))\
853 $(SDK_$(sdk)_LIBS.$(bld_type))\
854 $(SDK_$(sdk)_LIBS))\
855 $(LIBS.$(bld_trg_cpu))\
856 $(LIBS.$(bld_trg).$(bld_trg_arch))\
857 $(LIBS.$(bld_trg_arch))\
858 $(LIBS.$(bld_trg))\
859 $(LIBS.$(bld_type))\
860 $(LIBS)\
861 $(foreach sdk, $(SDKS.$(bld_trg).$(bld_trg_arch)) \
862 $(SDKS.$(bld_trg_arch)) \
863 $(SDKS.$(bld_trg)) \
864 $(SDKS.$(bld_type)) \
865 $(SDKS),\
866 $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
867 $(SDK_$(sdk)_LIBS.$(bld_trg).$(bld_trg_arch))\
868 $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
869 $(SDK_$(sdk)_LIBS.$(bld_trg))\
870 $(SDK_$(sdk)_LIBS.$(bld_type))\
871 $(SDK_$(sdk)_LIBS))\
872 $(TOOL_$(tool)_LIBS.$(bld_trg_cpu))\
873 $(TOOL_$(tool)_LIBS.$(bld_trg).$(bld_trg_arch))\
874 $(TOOL_$(tool)_LIBS.$(bld_trg_arch))\
875 $(TOOL_$(tool)_LIBS.$(bld_trg))\
876 $(TOOL_$(tool)_LIBS.$(bld_type))\
877 $(TOOL_$(tool)_LIBS)
878local libpath :=\
879 $($(target)_LIBPATH.$(bld_trg_cpu))\
880 $($(target)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
881 $($(target)_LIBPATH.$(bld_trg_arch))\
882 $($(target)_LIBPATH.$(bld_trg))\
883 $($(target)_LIBPATH.$(bld_type))\
884 $($(target)_LIBPATH)\
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),\
890 $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
891 $(SDK_$(sdk)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
892 $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
893 $(SDK_$(sdk)_LIBPATH.$(bld_trg))\
894 $(SDK_$(sdk)_LIBPATH.$(bld_type))\
895 $(SDK_$(sdk)_LIBPATH))\
896 $(LIBPATH.$(bld_trg_cpu))\
897 $(LIBPATH.$(bld_trg).$(bld_trg_arch))\
898 $(LIBPATH.$(bld_trg_arch))\
899 $(LIBPATH.$(bld_trg))\
900 $(LIBPATH.$(bld_type))\
901 $(LIBPATH)\
902 $(foreach sdk, $(SDKS.$(bld_trg).$(bld_trg_arch)) \
903 $(SDKS.$(bld_trg_arch)) \
904 $(SDKS.$(bld_trg)) \
905 $(SDKS.$(bld_type)) \
906 $(SDKS),\
907 $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
908 $(SDK_$(sdk)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
909 $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
910 $(SDK_$(sdk)_LIBPATH.$(bld_trg))\
911 $(SDK_$(sdk)_LIBPATH.$(bld_type))\
912 $(SDK_$(sdk)_LIBPATH))\
913 $(TOOL_$(tool)_LIBPATH.$(bld_trg_cpu))\
914 $(TOOL_$(tool)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
915 $(TOOL_$(tool)_LIBPATH.$(bld_trg_arch))\
916 $(TOOL_$(tool)_LIBPATH.$(bld_trg))\
917 $(TOOL_$(tool)_LIBPATH.$(bld_type))\
918 $(TOOL_$(tool)_LIBPATH)
919local dirdep := $(call DIRDEP,$(dir $(out)))
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)
954
955# Adjust paths if we got a default path.
956ifneq ($(defpath),)
957 local libpath := $(abspathex $(libpath),$(defpath))
958 local deps := $(abspathex $(deps),$(defpath))
959 local orderdeps := $(abspathex $(orderdeps),$(defpath))
960 othersrc := $(abspathex $(othersrc),$(defpath))
961 # libs are not subject to this because of the the -l<lib> stuff. Use $(<target>_DEFPATH)/lib if relative to current dir!
962endif
963
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
970# Custom pre/post-link actions.
971local pre_cmds := $(evalcall def_fn_prop_get_first_defined,PRE_CMDS)
972local post_cmds := $(evalcall def_fn_prop_get_first_defined,POST_CMDS)
973
974# eliminate this guy?
975local objs = $($(target)_2_OBJS)
976
977# dependency file
978local dep := $(outbase)$(SUFF_DEP)
979ifndef NO_LINK_CMDS_DEPS
980 _DEPFILES_INCLUDED += $(dep)
981 ifdef KB_HAVE_INCLUDEDEP_QUEUE
982 includedep-queue $(dep)
983 else
984 includedep $(dep)
985 endif
986endif
987
988# check that the tool is defined.
989ifndef TOOL_$(tool)_$(tool_do)_CMDS
990$(warning kBuild: tools: \
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) )
1003$(error kBuild: TOOL_$(tool)_$(tool_do)_CMDS isn't defined! target=$(target) )
1004endif
1005
1006# call the tool
1007local cmds := $(TOOL_$(tool)_$(tool_do)_CMDS)
1008ifneq ($(pre_cmds),)
1009 local cmds := $(TAB)$(pre_cmds)$(NL)$(TAB)$(cmds)
1010endif
1011ifneq ($(post_cmds),)
1012 local cmds := $(cmds)$(NL)$(TAB)$(post_cmds)
1013endif
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)
1025
1026# generate the link rule.
1027$(eval $(def_link_rule))
1028
1029# installation targets
1030local target_type_mode :=
1031$(evalval def_target_install_only)
1032
1033# Update globals.
1034_OBJS += $($(target)_2_OBJS)
1035_OUT_FILES += $($(target)_2_OUTPUT) $($(target)_2_OUTPUT_MAYBE) $(out)
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))
1038_INSTALLS_FILES += $(INSTARGET_$(target))
1039
1040endef # def_link_common
1041$(eval-opt-var def_link_common)
1042
1043
1044#
1045# BLDPROGS
1046#
1047
1048# Process build programs.
1049EXT := EXE
1050EXTPRE := HOST
1051tool_do := LINK_PROGRAM
1052typevar := _BLDPROGS
1053mode := 0755
1054bld_trg_base_var := PLATFORM
1055$(foreach target, $(_ALL_BLDPROGS), $(evalval def_link_common))
1056
1057ifdef KBUILD_PROFILE_SELF
1058 $(evalcall def_profile_self, done build program targets)
1059endif
1060
1061
1062#
1063# DLLS
1064#
1065
1066# Process dlls
1067EXT := DLL
1068EXTPRE :=
1069tool_do := LINK_DLL
1070typevar := _DLLS
1071mode := 0644
1072bld_trg_base_var := TARGET
1073$(foreach target, $(_ALL_DLLS), $(evalval def_link_common))
1074
1075ifdef KBUILD_PROFILE_SELF
1076 $(evalcall def_profile_self, done dll targets)
1077endif
1078
1079
1080#
1081# IMPORT LIBRARIES
1082#
1083# - On OS/2 and windows these are libraries.
1084# - On other platforms they are fake DLLs.
1085#
1086EXTPRE :=
1087typevar := _IMPORT_LIBS
1088mode := 0644
1089bld_trg_base_var := TARGET
1090ifeq ($(filter-out nt os2 win win64 win32,$(KBUILD_TARGET)),)
1091 EXT := LIB
1092 tool_do := LINK_LIBRARY
1093 $(foreach target, $(_ALL_IMPORT_LIBS), $(evalval def_lib))
1094else
1095 EXT := DLL
1096 tool_do := LINK_DLL
1097 $(foreach target, $(_ALL_IMPORT_LIBS), $(evalval def_link_common))
1098endif
1099
1100ifdef KBUILD_PROFILE_SELF
1101 $(evalcall def_profile_self, done import library targets)
1102endif
1103
1104
1105#
1106# PROGRAMS
1107#
1108
1109# Process programs
1110EXT := EXE
1111EXTPRE :=
1112tool_do := LINK_PROGRAM
1113typevar := _PROGRAMS
1114mode := 0755
1115bld_trg_base_var := TARGET
1116$(foreach target, $(_ALL_PROGRAMS), $(evalval def_link_common))
1117
1118ifdef KBUILD_PROFILE_SELF
1119 $(evalcall def_profile_self, done program targets)
1120endif
1121
1122
1123#
1124# SYSMODS
1125#
1126
1127# Process sysmods
1128EXT := SYS
1129EXTPRE :=
1130tool_do := LINK_SYSMOD
1131typevar := _SYSMODS
1132mode := 0644
1133bld_trg_base_var := TARGET
1134$(foreach target, $(_ALL_SYSMODS), $(evalval def_link_common))
1135
1136ifdef KBUILD_PROFILE_SELF
1137 $(evalcall def_profile_self, done sysmod targets)
1138endif
1139
1140
1141#
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.