1 | # $Id: footer.kmk 414 2006-01-18 16:51:23Z bird $
|
---|
2 | ## @file
|
---|
3 | #
|
---|
4 | # kBuild - File included at top of makefile.
|
---|
5 | #
|
---|
6 | # Copyright (c) 2004-2005 knut st. osmundsen <bird-srcspam@anduin.net>
|
---|
7 | #
|
---|
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 |
|
---|
27 | ifndef __footer_kmk__
|
---|
28 | # start-of-file-content
|
---|
29 |
|
---|
30 | #
|
---|
31 | # Variables.
|
---|
32 | # (Some of these need initialization before including definitions using them.)
|
---|
33 | #
|
---|
34 |
|
---|
35 | # all targets.
|
---|
36 | ALL_TARGETS += \
|
---|
37 | $(BLDPROGS) $(BLDPROGS.$(BUILD_PLATFORM)) \
|
---|
38 | $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)) \
|
---|
39 | $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)) \
|
---|
40 | $(DLLS) $(DLLS.$(BUILD_TARGET)) \
|
---|
41 | $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)) \
|
---|
42 | $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)) \
|
---|
43 | $(INSTALLS) $(INSTALLS.$(BUILD_TARGET)) \
|
---|
44 | $(OTHERS) $(OTHERS.$(BUILD_TARGET))
|
---|
45 |
|
---|
46 | # dependency files.
|
---|
47 | _DEPFILES :=
|
---|
48 |
|
---|
49 | # included dependency files.
|
---|
50 | _DEPFILES_INCLUDED :=
|
---|
51 |
|
---|
52 |
|
---|
53 | # All kind of output files except for _OBJS and _DEPFILES.
|
---|
54 | # Compiling or linking definition outputting other things that $@ and any
|
---|
55 | # required dependency file must add those output files to this variable.
|
---|
56 | _OUT_FILES :=
|
---|
57 |
|
---|
58 | # Files which only requires cleaning up.
|
---|
59 | _CLEAN_FILES :=
|
---|
60 |
|
---|
61 | # all of a type
|
---|
62 | _OBJS :=
|
---|
63 | _BLDPROGS :=
|
---|
64 | _LIBS :=
|
---|
65 | _DLLS :=
|
---|
66 | _PROGRAMS :=
|
---|
67 | _SYSMODS :=
|
---|
68 | _INSTALLS :=
|
---|
69 | _INSTALLS_DIRS :=
|
---|
70 | _OTHERS :=
|
---|
71 | _DIRS := $(PATH_TARGET)/ $(PATH_TARGET)
|
---|
72 | _IMPORT_LIBS :=
|
---|
73 |
|
---|
74 | # misc
|
---|
75 | pass_prev :=
|
---|
76 |
|
---|
77 |
|
---|
78 | #
|
---|
79 | # Basic macros
|
---|
80 | #
|
---|
81 |
|
---|
82 | ## Figure out the tool for a source
|
---|
83 | # @param $target source file
|
---|
84 | # @param $source normalized main target
|
---|
85 | # @param $type tooltype
|
---|
86 | # @param bld_trg build target.
|
---|
87 | _SOURCE_TOOL = $(strip $(firstword \
|
---|
88 | $($(target)_$(source)_$(type)TOOL.$(bld_trg)) \
|
---|
89 | $($(target)_$(source)_$(type)TOOL) \
|
---|
90 | $($(target)_$(source)_TOOL.$(bld_trg)) \
|
---|
91 | $($(target)_$(source)_TOOL) \
|
---|
92 | $($(target)_$(type)TOOL.$(bld_trg)) \
|
---|
93 | $($(target)_$(type)TOOL) \
|
---|
94 | $($(target)_TOOL.$(bld_trg)) \
|
---|
95 | $($(target)_TOOL) \
|
---|
96 | $($(source)_$(type)TOOL.$(bld_trg)) \
|
---|
97 | $($(source)_$(type)TOOL) \
|
---|
98 | $($(source)_TOOL.$(bld_trg)) \
|
---|
99 | $($(source)_TOOL) \
|
---|
100 | $($(type)TOOL.$(bld_trg)) \
|
---|
101 | $($(type)TOOL) \
|
---|
102 | $(TOOL.$(bld_trg)) \
|
---|
103 | $(TOOL) ))
|
---|
104 |
|
---|
105 | ## Figure out the tool for a target.
|
---|
106 | # @param $target normalized target.
|
---|
107 | # @param $source tooltype.
|
---|
108 | # @param bld_trg build target.
|
---|
109 | _TARGET_TOOL = $(strip $(firstword \
|
---|
110 | $($(target)_$(source)TOOL.$(bld_trg)) \
|
---|
111 | $($(target)_$(source)TOOL) \
|
---|
112 | $($(target)_TOOL.$(bld_trg)) \
|
---|
113 | $($(target)_TOOL) \
|
---|
114 | $($(source)TOOL.$(bld_trg)) \
|
---|
115 | $($(source)TOOL) \
|
---|
116 | $(TOOL.$(bld_trg)) \
|
---|
117 | $(TOOL) \
|
---|
118 | ))
|
---|
119 |
|
---|
120 | ## Removes the drive letter from a path (if it has one)
|
---|
121 | # @param $1 the path
|
---|
122 | no-drive=$(word $(words $(subst :, ,$(1))),$(subst :, ,$(1)))
|
---|
123 |
|
---|
124 | ## Removes the root slash from a path (if it has one)
|
---|
125 | # @param $1 the path
|
---|
126 | no-root-slash=$(patsubst /%,%,$(1))
|
---|
127 |
|
---|
128 | ## Figure out where to put object files.
|
---|
129 | # @param $1 source file
|
---|
130 | # @param $2 normalized main target
|
---|
131 | # @remark There are two major hacks here:
|
---|
132 | # 1. Source files in the output directory are translated into a gen/ subdir.
|
---|
133 | # 2. Catch anyone specifying $(PATH_CURRENT)/sourcefile.c.
|
---|
134 | _OBJECT_BASE = $(PATH_TARGET)/$(2)/$(call no-root-slash,$(call no-drive,$(basename \
|
---|
135 | $(patsubst $(PATH_ROOT)/%,%,$(patsubst $(PATH_CURRENT)/%,%,$(patsubst $(PATH_TARGET)/$(2)/%,gen/%,$(1)))))))
|
---|
136 |
|
---|
137 | ## Figure out where to put object files.
|
---|
138 | # @param $1 real target name.
|
---|
139 | # @param $2 normalized main target
|
---|
140 | _TARGET_BASE = $(PATH_TARGET)/$(2)/$(call no-root-slash,$(call no-drive,$(basename $(1))))
|
---|
141 |
|
---|
142 |
|
---|
143 | ## Figure out the actual name of an installed file.
|
---|
144 | # @param $1 The file to install.
|
---|
145 | # @param $2 The target name.
|
---|
146 | # @param $3 The _INST value (can be empty).
|
---|
147 | # @param $4 The default directory to use when $3 is empty.
|
---|
148 | _INSTALL_FILE = $(patsubst %/,%/$(notdir $(1)),$(if $(3),$(PATH_INS)/$(3),$(4)/))
|
---|
149 |
|
---|
150 |
|
---|
151 | #
|
---|
152 | # Check syntax which leads to weird syntax errors.
|
---|
153 | #
|
---|
154 |
|
---|
155 | ## Check
|
---|
156 | # @param $(target) Target name.
|
---|
157 | define def_check_target
|
---|
158 | ifneq ("$($(target)_TEMPLATE)","$(strip $($(target)_TEMPLATE))")
|
---|
159 | $$(error $(target) have an incorrect template name. Remove any tabs!)
|
---|
160 | endif
|
---|
161 | endef
|
---|
162 | $(foreach target, $(ALL_TARGETS),$(eval $(def_check_target)))
|
---|
163 |
|
---|
164 |
|
---|
165 | #
|
---|
166 | # Include templates
|
---|
167 | #
|
---|
168 | _TEMPLATES := $(TEMPLATE)
|
---|
169 | define def_templates
|
---|
170 | ifdef $(target)_TEMPLATE
|
---|
171 | _TEMPLATES += $($(target)_TEMPLATE)
|
---|
172 | endif
|
---|
173 | endef
|
---|
174 | $(foreach target, $(ALL_TARGETS), $(eval $(def_templates)))
|
---|
175 | _TEMPLATES := $(sort $(_TEMPLATES))
|
---|
176 | # $ (warning dbg: _TEMPLATES=$(_TEMPLATES))
|
---|
177 |
|
---|
178 | define def_templates_include
|
---|
179 | ifndef TEMPLATE_$(template)
|
---|
180 | include $(firstword $(foreach path, $(TEMPLATE_PATHS) $(PATH_KBUILD)/templates/, $(wildcard $(path)/$(template).kmk)))
|
---|
181 | endif
|
---|
182 | endef
|
---|
183 | $(foreach template, $(_TEMPLATES), $(eval $(def_templates)))
|
---|
184 |
|
---|
185 |
|
---|
186 | #
|
---|
187 | # Template Inheritance.
|
---|
188 | #
|
---|
189 | define def_template_extends_prop
|
---|
190 | ifndef TEMPLATE_$(template)_$(prop)
|
---|
191 | ifdef TEMPLATE_$(parent)_$(prop)
|
---|
192 | TEMPLATE_$(template)_$(prop) = $$(TEMPLATE_$(parent)_$(prop))
|
---|
193 | endif
|
---|
194 | endif
|
---|
195 | endef
|
---|
196 |
|
---|
197 | define def_template_extends
|
---|
198 | ifdef TEMPLATE_$(template)_EXTENDS
|
---|
199 | parent := $(strip $(TEMPLATE_$(template)_EXTENDS))
|
---|
200 |
|
---|
201 | $(foreach prop, $(PROPS_SINGLE) $(PROPS_ACCUMULATE) $(PROPS_DEFERRED)\
|
---|
202 | $(addsuffix .$(BUILD_TARGET), $(PROPS_SINGLE) $(PROPS_ACCUMULATE) $(PROPS_DEFERRED))\
|
---|
203 | $(addsuffix .$(BUILD_TYPE), $(PROPS_SINGLE) $(PROPS_ACCUMULATE) $(PROPS_DEFERRED))\
|
---|
204 | ,$(eval $(def_template_extends_prop))) # exploits the 2 evaluation, so no value!
|
---|
205 | endif
|
---|
206 | endef
|
---|
207 |
|
---|
208 | # $ (foreach template, $(_TEMPLATES), $(if TEMPLATE_$(template)_EXTENDS, $(eval $(value def_template_extends))))
|
---|
209 | $(foreach template, $(_TEMPLATES), $(eval $(value def_template_extends)))
|
---|
210 |
|
---|
211 |
|
---|
212 | #
|
---|
213 | # Common Inheritance
|
---|
214 | #
|
---|
215 |
|
---|
216 | ## Inherit defaults property
|
---|
217 | # @param $(prop) Property name
|
---|
218 | # @param $(target) Target name.
|
---|
219 | define def_inherit_defaults_one
|
---|
220 | ifndef $(target)_$(prop)
|
---|
221 | ifndef $(target)_$(prop).$(BUILD_TARGET)
|
---|
222 | ifdef $(prop)
|
---|
223 | $$(eval $(target)_$(prop) := $($(prop)))
|
---|
224 | endif
|
---|
225 | ifdef $(prop).$(BUILD_TARGET)
|
---|
226 | $$(eval $(target)_$(prop).$(BUILD_TARGET) := $($(prop).$(BUILD_TARGET)))
|
---|
227 | endif
|
---|
228 | endif
|
---|
229 | endif
|
---|
230 | endef
|
---|
231 |
|
---|
232 | ## Inherit default properties for one target.
|
---|
233 | # A bit tricky this one, but it depends a bit on whether or not TEMPLATE
|
---|
234 | # is inherited from the default properties.
|
---|
235 | # @param $(target) Target name
|
---|
236 | #
|
---|
237 | define def_inherit_defaults
|
---|
238 | ifdef $(target)_TEMPLATE
|
---|
239 | ifeq ($(strip $(TEMPLATE_$($(target)_TEMPLATE)_TOOL) $(TEMPLATE_$($(target)_TEMPLATE)_TOOL.$(BUILD_TARGET))),)
|
---|
240 | $$(foreach prop,TOOL, $$(eval $$(def_inherit_defaults_one)))
|
---|
241 | endif
|
---|
242 | ifeq ($(strip $(TEMPLATE_$($(target)_TEMPLATE)_SDKS) $(TEMPLATE_$($(target)_TEMPLATE)_SDKS.$(BUILD_TARGET))),)
|
---|
243 | $$(foreach prop,SDKS, $$(eval $$(def_inherit_defaults_one)))
|
---|
244 | endif
|
---|
245 | else
|
---|
246 | $$(foreach prop,TEMPLATE TOOL SDKS, $$(eval $$(def_inherit_defaults_one)))
|
---|
247 | endif
|
---|
248 | endef
|
---|
249 | # Inherit default properties.
|
---|
250 | # !!!!!!THIS IS MESSY AND NOT NECESSARY!!!!!!
|
---|
251 | $(foreach target, $(ALL_TARGETS),$(eval $(def_inherit_defaults)))
|
---|
252 |
|
---|
253 |
|
---|
254 | ## Inherit one template property in a non-accumulative manner.
|
---|
255 | # @param $(prop) Property name
|
---|
256 | # @param $(target) Target name
|
---|
257 | # @todo fix the precedence order for some properties.
|
---|
258 | define def_inherit_template_one
|
---|
259 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
|
---|
260 | ifndef $(target)_$(prop)
|
---|
261 | $(target)_$(prop) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
---|
262 | #$ (warning dbgtarget: $(target)_$(prop):='$(value $(target)_$(prop))' TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
---|
263 | endif
|
---|
264 | endif
|
---|
265 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)
|
---|
266 | ifndef $(target)_$(prop).$(BUILD_TARGET)
|
---|
267 | #$ (warning dbgsource: $(target)_$(prop).$(BUILD_TARGET)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET))
|
---|
268 | $(target)_$(prop).$(BUILD_TARGET) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET))
|
---|
269 | endif
|
---|
270 | endif
|
---|
271 | endef
|
---|
272 |
|
---|
273 | ## Inherit one template property in a non-accumulative manner, deferred expansion.
|
---|
274 | # @param 1: $(prop) Property name
|
---|
275 | # @param 2: $(target) Target name
|
---|
276 | # @todo fix the precedence order for some properties.
|
---|
277 | # @remark this define relies on double evaluation
|
---|
278 | define def_inherit_template_one_deferred
|
---|
279 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
|
---|
280 | ifndef $(target)_$(prop)
|
---|
281 | $(target)_$(prop) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
---|
282 | #$ (warning dbgtarget: $(target)_$(prop):='$(value $(target)_$(prop))' TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
---|
283 | endif
|
---|
284 | endif
|
---|
285 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)
|
---|
286 | ifndef $(target)_$(prop).$(BUILD_TARGET)
|
---|
287 | #$ (warning dbgsource: $(target)_$(prop).$(BUILD_TARGET)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET))
|
---|
288 | $(target)_$(prop).$(BUILD_TARGET) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET))
|
---|
289 | endif
|
---|
290 | endif
|
---|
291 | endef
|
---|
292 |
|
---|
293 | ## Inherit one template property.
|
---|
294 | # @param $(prop) Property name
|
---|
295 | # @param $(target) Target name
|
---|
296 | define def_inherit_template_one_accumulate
|
---|
297 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
|
---|
298 | #$ (warning dbgtype: TEMPLATE_$($(target)_TEMPLATE)_$(prop) $(target)_$(prop)=$($(target)_$(prop)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop)))
|
---|
299 | $(target)_$(prop) := $($(target)_$(prop)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
---|
300 | #$ (warning dbgtype: $(target)_$(prop)=$($(target)_$(prop)))
|
---|
301 | endif
|
---|
302 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE)
|
---|
303 | #$ (warning dbg4: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE))
|
---|
304 | $(target)_$(prop).$(BUILD_TYPE) := $($(target)_$(prop).$(BUILD_TYPE)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE))
|
---|
305 | endif
|
---|
306 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)
|
---|
307 | #$ (warning dbg4: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET))
|
---|
308 | $(target)_$(prop).$(BUILD_TARGET) := $($(target)_$(prop).$(BUILD_TARGET)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET))
|
---|
309 | endif
|
---|
310 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_CPU)
|
---|
311 | #$ (warning dbg5: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_CPU))
|
---|
312 | $(target)_$(prop).$(BUILD_TARGET_CPU) := $($(target)_$(prop).$(BUILD_TARGET)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_CPU))
|
---|
313 | endif
|
---|
314 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_ARCH)
|
---|
315 | #$ (warning dbg6: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_ARCH))
|
---|
316 | $(target)_$(prop).$(BUILD_TARGET_ARCH) := $($(target)_$(prop).$(BUILD_TARGET)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_ARCH))
|
---|
317 | endif
|
---|
318 | endef
|
---|
319 |
|
---|
320 | ## Inherit template properties for on target.
|
---|
321 | # @param $(target) Target name.
|
---|
322 | define def_inherit_template
|
---|
323 | $(foreach prop,$(PROPS_SINGLE),$(eval $(value def_inherit_template_one)))
|
---|
324 | $(foreach prop,$(PROPS_DEFERRED),$(eval $(def_inherit_template_one_deferred))) # exploits the 2 evaluation, so no value!
|
---|
325 | $(foreach prop,$(PROPS_ACCUMULATE),$(eval $(value def_inherit_template_one_accumulate)))
|
---|
326 | endef
|
---|
327 |
|
---|
328 | # Inherit template properties
|
---|
329 | $(foreach target, $(ALL_TARGETS),$(eval $(value def_inherit_template)))
|
---|
330 |
|
---|
331 |
|
---|
332 | #
|
---|
333 | # Include tools
|
---|
334 | #
|
---|
335 | _TOOLS := $(TOOL)
|
---|
336 | define def_tools_target_source
|
---|
337 | $(eval _TOOLS += $(foreach prop, $(PROPS_TOOLS), \
|
---|
338 | $($(source)_$(prop).$(BUILD_TARGET)) \
|
---|
339 | $($(target)_$(source)_$(prop).$(BUILD_TARGET)) \
|
---|
340 | $($(source)_$(prop)) \
|
---|
341 | $($(target)_$(source)_$(prop))))
|
---|
342 | endef
|
---|
343 |
|
---|
344 | define def_tools_target
|
---|
345 | $(eval _TOOLS += $(foreach prop, $(PROPS_TOOLS), \
|
---|
346 | $($(target)_$(prop).$(BUILD_TARGET)) \
|
---|
347 | $($(target)_$(prop))))
|
---|
348 | $(foreach source, \
|
---|
349 | $($(target)_SOURCES.$(BUILD_TARGET)) \
|
---|
350 | $($(target)_SOURCES.$(BUILD_TYPE)) \
|
---|
351 | $($(target)_SOURCES) \
|
---|
352 | , $(eval $(value def_tools_target_source)))
|
---|
353 | endef
|
---|
354 |
|
---|
355 | $(foreach target, $(ALL_TARGETS), $(eval $(value def_tools_target)))
|
---|
356 | _TOOLS := $(sort $(_TOOLS))
|
---|
357 |
|
---|
358 | define def_tools_include
|
---|
359 | ifndef TOOL_$(tool)
|
---|
360 | TOOL_$(tool)_KMK_FILE := $(firstword $(foreach path, $(TOOL_PATHS) $(PATH_KBUILD)/tools, $(wildcard $(path)/$(tool).kmk)))
|
---|
361 | ifeq ($(TOOL_$(tool)_KMK_FILE),)
|
---|
362 | $(error kBuild: Cannot find include file for the tool '$(tool)'! Searched: $(TOOL_PATHS) $(PATH_KBUILD)/tools)
|
---|
363 | endif
|
---|
364 | include $(TOOL_$(tool)_KMK_FILE)
|
---|
365 | endif
|
---|
366 | endef
|
---|
367 | $(foreach tool, $(_TOOLS), $(eval $(value def_tools_include)))
|
---|
368 |
|
---|
369 |
|
---|
370 | #
|
---|
371 | # Include SDKs
|
---|
372 | #
|
---|
373 | _SDKS := $(SDKS)
|
---|
374 | define def_sdks_target_source
|
---|
375 | $(foreach sdk, $($(source)_SDKS) $($(source)_SDKS.$(BUILD_TARGET)) $($(source)_SDKS.$(BUILD_TYPE)) \
|
---|
376 | $($(target)_$(source)_SDKS) $($(target)_$(source)_SDKS.$(BUILD_TARGET)) $($(target)_$(source)_SDKS.$(BUILD_TYPE)), \
|
---|
377 | $(eval _SDKS += $(sdk)))
|
---|
378 | endef
|
---|
379 | define def_sdks_target
|
---|
380 | $(foreach sdk, $($(target)_SDKS) $($(target)_SDKS.$(BUILD_TARGET)) $($(target)_SDKS.$(BUILD_TYPE))\
|
---|
381 | , $(eval _SDKS += $(sdk)))
|
---|
382 | $(foreach source, $($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_TYPE))\
|
---|
383 | , $(eval $(def_sdks_target_source)))
|
---|
384 | endef
|
---|
385 | $(foreach target, $(ALL_TARGETS), $(eval $(def_sdks_target)))
|
---|
386 | _SDKS := $(sort $(_SDKS))
|
---|
387 |
|
---|
388 | define def_sdks_include_one
|
---|
389 | ifndef SDK_$(sdk)
|
---|
390 | SDK_$(sdk)_KMK_FILE := $(firstword $(foreach path, $(SDK_PATHS) $(PATH_KBUILD)/sdks, $(wildcard $(path)/$(sdk).kmk)))
|
---|
391 | ifeq ($(SDK_$(sdk)_KMK_FILE),)
|
---|
392 | $(error kBuild: Cannot find include file for the SDK '$(sdk)'! Searched: $(SDK_PATHS) $(PATH_KBUILD)/sdks)
|
---|
393 | endif
|
---|
394 | include $(SDK_$(sdk)_KMK_FILE)
|
---|
395 | endif
|
---|
396 | endef
|
---|
397 | $(foreach sdk, $(_SDKS), $(eval $(value def_sdks_include_one)))
|
---|
398 |
|
---|
399 |
|
---|
400 | #
|
---|
401 | # Object processing.
|
---|
402 | #
|
---|
403 |
|
---|
404 | ## wrapper the compile command dependency check.
|
---|
405 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
406 | _DEP_COMPILE_CMDS = $(if $(subst $(strip $($(target)_$(source)_CMDS_PREV_)),,$(strip $($(target)_$(source)_CMDS_))),FORCE,)
|
---|
407 | else
|
---|
408 | _DEP_COMPILE_CMDS =
|
---|
409 | endif
|
---|
410 |
|
---|
411 | ## Generates the rules for building a specific object, and the '::' aliases
|
---|
412 | # for building a source file.
|
---|
413 | # @param $(obj) The object file.
|
---|
414 | define def_target_source_rule
|
---|
415 | $(obj) $($(target)_$(source)_OUTPUT_): \
|
---|
416 | $($(target)_$(source)_DEPEND_) \
|
---|
417 | $(_DEP_COMPILE_CMDS) \
|
---|
418 | | \
|
---|
419 | $($(target)_$(source)_DEPORD_)
|
---|
420 | $(call MSG_L1,Creating $$@)
|
---|
421 | $(RM) -f $(dep) $(out) $($(target)_$(source)_OUTPUT_)
|
---|
422 | $(custom_pre)
|
---|
423 |
|
---|
424 | $($(target)_$(source)_CMDS_)
|
---|
425 |
|
---|
426 | $(custom_post)
|
---|
427 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
428 | @$(APPEND) "$(dep)"
|
---|
429 | @$(APPEND) "$(dep)" 'define $(target)_$(source)_CMDS_PREV_'
|
---|
430 | @$(APPEND) "$(dep)" '$(subst $(NL),'$(NL)$(TAB)@$(APPEND) "$(dep)" ',$($(target)_$(source)_CMDS_))'
|
---|
431 | @$(APPEND) "$(dep)" 'endef'
|
---|
432 | endif
|
---|
433 |
|
---|
434 | $(basename $(notdir $(obj))).o::
|
---|
435 | + $$(MAKE) -B -f $$(MAKEFILE) $(obj)
|
---|
436 | $(basename $$(notdir $$(obj))).obj::
|
---|
437 | + $$(MAKE) -B -f $$(MAKEFILE) $(obj)
|
---|
438 | endef
|
---|
439 |
|
---|
440 |
|
---|
441 | ## wrapper the link command dependency check.
|
---|
442 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
443 | _DEP_LINK_CMDS = $(if $(subst $(strip $($(target)_CMDS_PREV_)),,$(strip $($(target)_CMDS_))),FORCE,)
|
---|
444 | else
|
---|
445 | _DEP_LINK_CMDS =
|
---|
446 | endif
|
---|
447 |
|
---|
448 | ## Generate the link rule for a target.
|
---|
449 | # @param $(target) The normalized target name.
|
---|
450 | # @param $(dirdep) Directories we depend upon begin created before linking.
|
---|
451 | # @param $(dep) The name of the dependency file.
|
---|
452 | # @param $(out)
|
---|
453 | # @param $($(target)_OUTPUT_) Output files from the link.
|
---|
454 | # @param $($(target)_DEPEND_) Dependencies.
|
---|
455 | # @param $($(target)_DEPORD_) Dependencies which should only affect build order.
|
---|
456 | # @param $($(target)_CMDS_) The link commands.
|
---|
457 | # @param $($(target)_CMDS_PREV_) The link commands from the previous run.
|
---|
458 | define def_link_rule
|
---|
459 | $(out) $($(target)_OUTPUT_): \
|
---|
460 | $($(target)_DEPEND_) \
|
---|
461 | $(_DEP_LINK_CMDS) \
|
---|
462 | | \
|
---|
463 | $($(target)_DEPORD_)
|
---|
464 | $(call MSG_L1,Creating $$@)
|
---|
465 | $(RM) -f $(dep) $($(target)_OUTPUT_)
|
---|
466 | $(custom_pre)
|
---|
467 |
|
---|
468 | $($(target)_CMDS_)
|
---|
469 |
|
---|
470 | $(custom_post)
|
---|
471 | ifndef NO_LINK_CMDS_DEP
|
---|
472 | @$(APPEND) "$(dep)" 'define $(target)_CMDS_PREV_'
|
---|
473 | @$(APPEND) "$(dep)" '$(subst $(NL),'$(NL)$(TAB)@$(APPEND) "$(dep)" ',$($(target)_CMDS_))'
|
---|
474 | @$(APPEND) "$(dep)" 'endef'
|
---|
475 | endif
|
---|
476 |
|
---|
477 | $(basename $(notdir $(out)))::
|
---|
478 | + $$(MAKE) -B -f $$(MAKEFILE) $(out)
|
---|
479 | endef
|
---|
480 |
|
---|
481 |
|
---|
482 | ## Generate the link & lib install rule
|
---|
483 | # @param $(target) Normalized target name.
|
---|
484 | # @param $(out) The build target.
|
---|
485 | # @param $(INSTARGET_$(target)) The installation targets.
|
---|
486 | # @param $(mode) The file mode (optional)
|
---|
487 | define def_link_install_rule
|
---|
488 | $(INSTARGET_$(target)) : $(out) | $(call DIRDEP,$(dir $(INSTARGET_$(target))))
|
---|
489 | $(INSTALL) $$(if $(mode),-m $(mode)) $(out) $$@
|
---|
490 | endef
|
---|
491 |
|
---|
492 |
|
---|
493 |
|
---|
494 | ## Generic macro for processing C, C++ and Assembly sources.
|
---|
495 | # @param $(target) Normalized target name.
|
---|
496 | # @param $(source) Source file name.
|
---|
497 | # @param $(type) Source type. {C,CXX,AS}
|
---|
498 | # @param bld_type Build type.
|
---|
499 | # @param bld_trg Build target.
|
---|
500 | # @param bld_trg_arch Build target arch.
|
---|
501 | # @param bld_trg_cpu Build target cpu.
|
---|
502 | #
|
---|
503 | # @remark I've no clue why I've to $(eval ..) everything in this define. MAKE bug?
|
---|
504 | # @remark I now have a clue. Have to use $$ if not.
|
---|
505 | define def_target_source_c_cpp_asm
|
---|
506 | #$ (warning dbg: def_target_source_c_cpp_asm: source='$(source)' target='$(target)' type='$(type)')
|
---|
507 |
|
---|
508 | tool := $(call _SOURCE_TOOL,$(source),$(target),$(type))
|
---|
509 | outbase := $(call _OBJECT_BASE,$(source),$(target))
|
---|
510 | PATH_$(target)_$(source) := $(patsubst %/,%,$(dir $(outbase)))
|
---|
511 | dirdep := $(call DIRDEP,$(dir $(outbase)))
|
---|
512 | defs :=\
|
---|
513 | $(TOOL_$(tool)_DEFS)\
|
---|
514 | $(TOOL_$(tool)_DEFS.$(bld_type))\
|
---|
515 | $(TOOL_$(tool)_DEFS.$(bld_trg))\
|
---|
516 | $(TOOL_$(tool)_DEFS.$(bld_trg_arch))\
|
---|
517 | $(TOOL_$(tool)_DEFS.$(bld_trg_cpu))\
|
---|
518 | $(TOOL_$(tool)_$(type)DEFS)\
|
---|
519 | $(TOOL_$(tool)_$(type)DEFS.$(bld_type))\
|
---|
520 | $(foreach sdk, $(SDKS.$(bld_trg)) \
|
---|
521 | $(SDKS.$(bld_type)) \
|
---|
522 | $(SDKS),\
|
---|
523 | $(SDK_$(sdk)_DEFS)\
|
---|
524 | $(SDK_$(sdk)_DEFS.$(bld_type))\
|
---|
525 | $(SDK_$(sdk)_DEFS.$(bld_trg))\
|
---|
526 | $(SDK_$(sdk)_DEFS.$(bld_trg_arch))\
|
---|
527 | $(SDK_$(sdk)_DEFS.$(bld_trg_cpu))\
|
---|
528 | $(SDK_$(sdk)_$(type)DEFS)\
|
---|
529 | $(SDK_$(sdk)_$(type)DEFS.$(bld_type))\
|
---|
530 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg))\
|
---|
531 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_arch))\
|
---|
532 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_cpu)))\
|
---|
533 | $(DEFS)\
|
---|
534 | $(DEFS.$(bld_type))\
|
---|
535 | $(DEFS.$(bld_trg))\
|
---|
536 | $(DEFS.$(bld_trg_arch))\
|
---|
537 | $(DEFS.$(bld_trg_cpu))\
|
---|
538 | $($(type)DEFS)\
|
---|
539 | $($(type)DEFS.$(bld_type))\
|
---|
540 | $($(type)DEFS.$(bld_trg))\
|
---|
541 | $($(type)DEFS.$(bld_trg_arch))\
|
---|
542 | $($(type)DEFS.$(bld_trg_cpu))\
|
---|
543 | $(foreach sdk, $($(target)_SDKS.$(bld_trg)) \
|
---|
544 | $($(target)_SDKS.$(bld_type)) \
|
---|
545 | $($(target)_SDKS),\
|
---|
546 | $(SDK_$(sdk)_DEFS)\
|
---|
547 | $(SDK_$(sdk)_DEFS.$(bld_type))\
|
---|
548 | $(SDK_$(sdk)_DEFS.$(bld_trg))\
|
---|
549 | $(SDK_$(sdk)_DEFS.$(bld_trg_arch))\
|
---|
550 | $(SDK_$(sdk)_DEFS.$(bld_trg_cpu))\
|
---|
551 | $(SDK_$(sdk)_$(type)DEFS)\
|
---|
552 | $(SDK_$(sdk)_$(type)DEFS.$(bld_type))\
|
---|
553 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg))\
|
---|
554 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_arch))\
|
---|
555 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_cpu)))\
|
---|
556 | $($(target)_DEFS)\
|
---|
557 | $($(target)_DEFS.$(bld_type))\
|
---|
558 | $($(target)_DEFS.$(bld_trg))\
|
---|
559 | $($(target)_DEFS.$(bld_trg_arch))\
|
---|
560 | $($(target)_DEFS.$(bld_trg_cpu))\
|
---|
561 | $($(target)_$(type)DEFS)\
|
---|
562 | $($(target)_$(type)DEFS.$(bld_type))\
|
---|
563 | $($(target)_$(type)DEFS.$(bld_trg))\
|
---|
564 | $($(target)_$(type)DEFS.$(bld_trg_arch))\
|
---|
565 | $($(target)_$(type)DEFS.$(bld_trg_cpu))\
|
---|
566 | $(foreach sdk, $($(source)_SDKS.$(bld_trg)) \
|
---|
567 | $($(source)_SDKS.$(bld_type)) \
|
---|
568 | $($(source)_SDKS),\
|
---|
569 | $(SDK_$(sdk)_DEFS)\
|
---|
570 | $(SDK_$(sdk)_DEFS.$(bld_type))\
|
---|
571 | $(SDK_$(sdk)_DEFS.$(bld_trg))\
|
---|
572 | $(SDK_$(sdk)_DEFS.$(bld_trg_arch))\
|
---|
573 | $(SDK_$(sdk)_DEFS.$(bld_trg_cpu))\
|
---|
574 | $(SDK_$(sdk)_$(type)DEFS)\
|
---|
575 | $(SDK_$(sdk)_$(type)DEFS.$(bld_type))\
|
---|
576 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg))\
|
---|
577 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_arch))\
|
---|
578 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_cpu)))\
|
---|
579 | $($(source)_DEFS)\
|
---|
580 | $($(source)_DEFS.$(bld_type))\
|
---|
581 | $($(source)_DEFS.$(bld_trg))\
|
---|
582 | $($(source)_DEFS.$(bld_trg_arch))\
|
---|
583 | $($(source)_DEFS.$(bld_trg_cpu))\
|
---|
584 | $($(source)_$(type)DEFS)\
|
---|
585 | $($(source)_$(type)DEFS.$(bld_type))\
|
---|
586 | $($(source)_$(type)DEFS.$(bld_trg))\
|
---|
587 | $($(source)_$(type)DEFS.$(bld_trg_arch))\
|
---|
588 | $($(source)_$(type)DEFS.$(bld_trg_cpu))\
|
---|
589 | $(foreach sdk, $($(target)_$(source)_SDKS.$(bld_trg)) \
|
---|
590 | $($(target)_$(source)_SDKS.$(bld_type)) \
|
---|
591 | $($(target)_$(source)_SDKS),\
|
---|
592 | $(SDK_$(sdk)_DEFS)\
|
---|
593 | $(SDK_$(sdk)_DEFS.$(bld_type))\
|
---|
594 | $(SDK_$(sdk)_DEFS.$(bld_trg))\
|
---|
595 | $(SDK_$(sdk)_DEFS.$(bld_trg_arch))\
|
---|
596 | $(SDK_$(sdk)_DEFS.$(bld_trg_cpu))\
|
---|
597 | $(SDK_$(sdk)_$(type)DEFS)\
|
---|
598 | $(SDK_$(sdk)_$(type)DEFS.$(bld_type))\
|
---|
599 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg))\
|
---|
600 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_arch))\
|
---|
601 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_cpu)))\
|
---|
602 | $($(target)_$(source)_DEFS)\
|
---|
603 | $($(target)_$(source)_DEFS.$(bld_type))\
|
---|
604 | $($(target)_$(source)_DEFS.$(bld_trg))\
|
---|
605 | $($(target)_$(source)_DEFS.$(bld_trg_arch))\
|
---|
606 | $($(target)_$(source)_DEFS.$(bld_trg_cpu))\
|
---|
607 | $($(target)_$(source)_$(type)DEFS)\
|
---|
608 | $($(target)_$(source)_$(type)DEFS.$(bld_type))\
|
---|
609 | $($(target)_$(source)_$(type)DEFS.$(bld_trg))\
|
---|
610 | $($(target)_$(source)_$(type)DEFS.$(bld_trg_arch))\
|
---|
611 | $($(target)_$(source)_$(type)DEFS.$(bld_trg_cpu))
|
---|
612 | incs :=\
|
---|
613 | $($(target)_$(source)_$(type)INCS.$(bld_trg_cpu))\
|
---|
614 | $($(target)_$(source)_$(type)INCS.$(bld_trg_arch))\
|
---|
615 | $($(target)_$(source)_$(type)INCS.$(bld_trg))\
|
---|
616 | $($(target)_$(source)_$(type)INCS.$(bld_type))\
|
---|
617 | $($(target)_$(source)_$(type)INCS)\
|
---|
618 | $($(target)_$(source)_INCS.$(bld_trg_cpu))\
|
---|
619 | $($(target)_$(source)_INCS.$(bld_trg_arch))\
|
---|
620 | $($(target)_$(source)_INCS.$(bld_trg))\
|
---|
621 | $($(target)_$(source)_INCS.$(bld_type))\
|
---|
622 | $($(target)_$(source)_INCS)\
|
---|
623 | $(foreach sdk, $($(target)_$(source)_SDKS.$(bld_trg)) \
|
---|
624 | $($(target)_$(source)_SDKS.$(bld_type)) \
|
---|
625 | $($(target)_$(source)_SDKS),\
|
---|
626 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg_cpu))\
|
---|
627 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg_arch))\
|
---|
628 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg))\
|
---|
629 | $(SDK_$(sdk)_$(type)INCS.$(bld_type))\
|
---|
630 | $(SDK_$(sdk)_$(type)INCS)\
|
---|
631 | $(SDK_$(sdk)_INCS.$(bld_trg_cpu))\
|
---|
632 | $(SDK_$(sdk)_INCS.$(bld_trg_arch))\
|
---|
633 | $(SDK_$(sdk)_INCS.$(bld_trg))\
|
---|
634 | $(SDK_$(sdk)_INCS.$(bld_type))\
|
---|
635 | $(SDK_$(sdk)_INCS))\
|
---|
636 | $($(source)_$(type)INCS.$(bld_trg_cpu))\
|
---|
637 | $($(source)_$(type)INCS.$(bld_trg_arch))\
|
---|
638 | $($(source)_$(type)INCS.$(bld_trg))\
|
---|
639 | $($(source)_$(type)INCS.$(bld_type))\
|
---|
640 | $($(source)_$(type)INCS)\
|
---|
641 | $($(source)_INCS.$(bld_trg_cpu))\
|
---|
642 | $($(source)_INCS.$(bld_trg_arch))\
|
---|
643 | $($(source)_INCS.$(bld_trg))\
|
---|
644 | $($(source)_INCS.$(bld_type))\
|
---|
645 | $($(source)_INCS)\
|
---|
646 | $(foreach sdk, $($(source)_SDKS.$(bld_trg)) \
|
---|
647 | $($(source)_SDKS.$(bld_type)) \
|
---|
648 | $($(source)_SDKS),\
|
---|
649 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg_cpu))\
|
---|
650 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg_arch))\
|
---|
651 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg))\
|
---|
652 | $(SDK_$(sdk)_$(type)INCS.$(bld_type))\
|
---|
653 | $(SDK_$(sdk)_$(type)INCS)\
|
---|
654 | $(SDK_$(sdk)_INCS.$(bld_trg_cpu))\
|
---|
655 | $(SDK_$(sdk)_INCS.$(bld_trg_arch))\
|
---|
656 | $(SDK_$(sdk)_INCS.$(bld_trg))\
|
---|
657 | $(SDK_$(sdk)_INCS.$(bld_type))\
|
---|
658 | $(SDK_$(sdk)_INCS))\
|
---|
659 | $($(target)_$(type)INCS.$(bld_trg_cpu))\
|
---|
660 | $($(target)_$(type)INCS.$(bld_trg_arch))\
|
---|
661 | $($(target)_$(type)INCS.$(bld_trg))\
|
---|
662 | $($(target)_$(type)INCS.$(bld_type))\
|
---|
663 | $($(target)_$(type)INCS)\
|
---|
664 | $($(target)_INCS.$(bld_trg_cpu))\
|
---|
665 | $($(target)_INCS.$(bld_trg_arch))\
|
---|
666 | $($(target)_INCS.$(bld_trg))\
|
---|
667 | $($(target)_INCS.$(bld_type))\
|
---|
668 | $($(target)_INCS)\
|
---|
669 | $(foreach sdk, $($(target)_SDKS.$(bld_trg)) \
|
---|
670 | $($(target)_SDKS.$(bld_type)) \
|
---|
671 | $($(target)_SDKS),\
|
---|
672 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg_cpu))\
|
---|
673 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg_arch))\
|
---|
674 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg))\
|
---|
675 | $(SDK_$(sdk)_$(type)INCS.$(bld_type))\
|
---|
676 | $(SDK_$(sdk)_$(type)INCS)\
|
---|
677 | $(SDK_$(sdk)_INCS.$(bld_trg_cpu))\
|
---|
678 | $(SDK_$(sdk)_INCS.$(bld_trg_arch))\
|
---|
679 | $(SDK_$(sdk)_INCS.$(bld_trg))\
|
---|
680 | $(SDK_$(sdk)_INCS.$(bld_type))\
|
---|
681 | $(SDK_$(sdk)_INCS))\
|
---|
682 | $(INCS.$(bld_trg_cpu))\
|
---|
683 | $(INCS.$(bld_trg_arch))\
|
---|
684 | $(INCS.$(bld_trg))\
|
---|
685 | $(INCS.$(bld_type))\
|
---|
686 | $(INCS)\
|
---|
687 | $(foreach sdk, $(SDKS.$(bld_trg)) \
|
---|
688 | $(SDKS.$(bld_type)) \
|
---|
689 | $(SDKS),\
|
---|
690 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg_cpu))\
|
---|
691 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg_arch))\
|
---|
692 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg))\
|
---|
693 | $(SDK_$(sdk)_$(type)INCS.$(bld_type))\
|
---|
694 | $(SDK_$(sdk)_$(type)INCS)\
|
---|
695 | $(SDK_$(sdk)_INCS.$(bld_trg_cpu))\
|
---|
696 | $(SDK_$(sdk)_INCS.$(bld_trg_arch))\
|
---|
697 | $(SDK_$(sdk)_INCS.$(bld_trg))\
|
---|
698 | $(SDK_$(sdk)_INCS.$(bld_type))\
|
---|
699 | $(SDK_$(sdk)_INCS))\
|
---|
700 | $(TOOL_$(tool)_$(type)INCS.$(bld_trg_cpu))\
|
---|
701 | $(TOOL_$(tool)_$(type)INCS.$(bld_trg_arch))\
|
---|
702 | $(TOOL_$(tool)_$(type)INCS.$(bld_trg))\
|
---|
703 | $(TOOL_$(tool)_$(type)INCS.$(bld_type))\
|
---|
704 | $(TOOL_$(tool)_$(type)INCS)
|
---|
705 | flags :=\
|
---|
706 | $(TOOL_$(tool)_$(type)FLAGS)\
|
---|
707 | $(TOOL_$(tool)_$(type)FLAGS.$(bld_type))\
|
---|
708 | $(TOOL_$(tool)_$(type)FLAGS.$(bld_trg))\
|
---|
709 | $(TOOL_$(tool)_$(type)FLAGS.$(bld_trg_arch))\
|
---|
710 | $(TOOL_$(tool)_$(type)FLAGS.$(bld_trg_cpu))\
|
---|
711 | $($(type)FLAGS)\
|
---|
712 | $($(type)FLAGS.$(bld_type))\
|
---|
713 | $($(type)FLAGS.$(bld_trg))\
|
---|
714 | $($(type)FLAGS.$(bld_trg_arch))\
|
---|
715 | $($(type)FLAGS.$(bld_trg_cpu))\
|
---|
716 | $($(target)_$(type)FLAGS)\
|
---|
717 | $($(target)_$(type)FLAGS.$(bld_type))\
|
---|
718 | $($(target)_$(type)FLAGS.$(bld_trg))\
|
---|
719 | $($(target)_$(type)FLAGS.$(bld_trg_arch))\
|
---|
720 | $($(target)_$(type)FLAGS.$(bld_trg_cpu))\
|
---|
721 | $($(source)_$(type)FLAGS)\
|
---|
722 | $($(source)_$(type)FLAGS.$(bld_type))\
|
---|
723 | $($(source)_$(type)FLAGS.$(bld_trg))\
|
---|
724 | $($(source)_$(type)FLAGS.$(bld_trg_arch))\
|
---|
725 | $($(source)_$(type)FLAGS.$(bld_trg_cpu))\
|
---|
726 | $($(target)_$(source)_$(type)FLAGS)\
|
---|
727 | $($(target)_$(source)_$(type)FLAGS.$(bld_type))\
|
---|
728 | $($(target)_$(source)_$(type)FLAGS.$(bld_trg))\
|
---|
729 | $($(target)_$(source)_$(type)FLAGS.$(bld_trg_arch))\
|
---|
730 | $($(target)_$(source)_$(type)FLAGS.$(bld_trg_cpu))
|
---|
731 | objsuff := $(firstword \
|
---|
732 | $($(target)_$(source)_OBJSUFF.$(bld_trg))\
|
---|
733 | $($(target)_$(source)_OBJSUFF)\
|
---|
734 | $($(source)_OBJSUFF.$(bld_trg))\
|
---|
735 | $($(source)_OBJSUFF)\
|
---|
736 | $($(target)_OBJSUFF.$(bld_trg))\
|
---|
737 | $($(target)_OBJSUFF)\
|
---|
738 | $(TOOL_$(tool)_$(type)OBJSUFF.$(bld_trg))\
|
---|
739 | $(TOOL_$(tool)_$(type)OBJSUFF)\
|
---|
740 | $(SUFF_OBJ))
|
---|
741 | obj := $(outbase)$(objsuff)
|
---|
742 | deps := \
|
---|
743 | $($(target)_$(source)_DEPS)\
|
---|
744 | $($(target)_$(source)_DEPS.$(bld_type))\
|
---|
745 | $($(target)_$(source)_DEPS.$(bld_trg))\
|
---|
746 | $($(target)_$(source)_DEPS.$(bld_trg_arch))\
|
---|
747 | $($(target)_$(source)_DEPS.$(bld_trg_cpu))\
|
---|
748 | $($(source)_DEPS)\
|
---|
749 | $($(source)_DEPS.$(bld_type))\
|
---|
750 | $($(source)_DEPS.$(bld_trg))\
|
---|
751 | $($(source)_DEPS.$(bld_trg_arch))\
|
---|
752 | $($(source)_DEPS.$(bld_trg_cpu))\
|
---|
753 | $($(target)_DEPS)\
|
---|
754 | $($(target)_DEPS.$(bld_type))\
|
---|
755 | $($(target)_DEPS.$(bld_trg_arch))\
|
---|
756 | $($(target)_DEPS.$(bld_trg_cpu))
|
---|
757 |
|
---|
758 | # dependencies
|
---|
759 | dep := $(obj)$(SUFF_DEP)
|
---|
760 | ifndef NO_COMPILE_DEPS
|
---|
761 | _DEPFILES_INCLUDED += $(dep)
|
---|
762 | $(if $(wildcard $(dep)),$(eval include $(dep)))
|
---|
763 | endif
|
---|
764 |
|
---|
765 | #$ (warning dbg: target=$(target) source=$(source) tool=$(tool) obj=$(obj) dep=$(dep) flags=$(flags) defs=$(defs) incs=$(incs) dirdep=$(dirdep) outbase=$(outbase) objsuff=$(objsuff) deps=$(deps))
|
---|
766 | ifndef TOOL_$(tool)_COMPILE_$(type)_CMDS
|
---|
767 | $(warning kBuild: tools: \
|
---|
768 | 1 $($(target)_$(source)_$(type)TOOL.$(bld_trg)) \
|
---|
769 | 2 $($(target)_$(source)_$(type)TOOL) \
|
---|
770 | 3 $($(target)_$(source)_TOOL.$(bld_trg)) \
|
---|
771 | 4 $($(target)_$(source)_TOOL) \
|
---|
772 | 5 $($(target)_$(type)TOOL.$(bld_trg)) \
|
---|
773 | 6 $($(target)_$(type)TOOL) \
|
---|
774 | 7 $($(target)_TOOL.$(bld_trg)) \
|
---|
775 | 8 $($(target)_TOOL) \
|
---|
776 | 9 $($(source)_$(type)TOOL.$(bld_trg)) \
|
---|
777 | 10 $($(source)_$(type)TOOL) \
|
---|
778 | 11 $($(source)_TOOL.$(bld_trg)) \
|
---|
779 | 12 $($(source)_TOOL) \
|
---|
780 | 13 $($(type)TOOL.$(bld_trg)) \
|
---|
781 | 14 $($(type)TOOL) \
|
---|
782 | 15 $(TOOL.$(bld_trg)) \
|
---|
783 | 16 $(TOOL) )
|
---|
784 | $(error kBuild: TOOL_$(tool)_COMPILE_$(type)_CMDS is not defined. source=$(source) target=$(target) )
|
---|
785 | endif
|
---|
786 |
|
---|
787 | # call the tool
|
---|
788 | $(target)_$(source)_CMDS_ := $(TOOL_$(tool)_COMPILE_$(type)_CMDS)
|
---|
789 | $(target)_$(source)_OUTPUT_ := $(TOOL_$(tool)_COMPILE_$(type)_OUTPUT)
|
---|
790 | $(target)_$(source)_DEPEND_ := $(TOOL_$(tool)_COMPILE_$(type)_DEPEND) $(deps) $(source)
|
---|
791 | $(target)_$(source)_DEPORD_ := $(TOOL_$(tool)_COMPILE_$(type)_DEPORD) $(dirdep)
|
---|
792 |
|
---|
793 | # generate the compile rule.
|
---|
794 | $(eval $(def_target_source_rule))
|
---|
795 |
|
---|
796 | _OUT_FILES += $($(target)_$(source)_OUTPUT_)
|
---|
797 | $(target)_OBJS_ += $(obj)
|
---|
798 |
|
---|
799 | endef
|
---|
800 |
|
---|
801 | ## Generic macro for processing all target sources.
|
---|
802 | # @param $(target) Normalized target name.
|
---|
803 | define def_target_sources
|
---|
804 | #$ (warning def_target_sources)
|
---|
805 | # C sources
|
---|
806 | type := C
|
---|
807 | $(foreach source, $(filter %.c, $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_cpu)) $($(target)_SOURCES.$(bld_type)))\
|
---|
808 | ,$(eval $(value def_target_source_c_cpp_asm)) )
|
---|
809 |
|
---|
810 | # C++ sources
|
---|
811 | type := CXX
|
---|
812 | $(foreach source, $(filter %.cpp %.cxx %.xx, $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_cpu)) $($(target)_SOURCES.$(bld_type)))\
|
---|
813 | ,$(eval $(value def_target_source_c_cpp_asm)) )
|
---|
814 |
|
---|
815 | # ASM sources
|
---|
816 | type := AS
|
---|
817 | $(foreach source, $(filter %.asm %.s %.S, $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_cpu)) $($(target)_SOURCES.$(bld_type)))\
|
---|
818 | ,$(eval $(value def_target_source_c_cpp_asm)) )
|
---|
819 |
|
---|
820 | endef
|
---|
821 |
|
---|
822 |
|
---|
823 |
|
---|
824 | ## Generic macro for generating the install rule(s) for a target
|
---|
825 | # and update the globals with default out.
|
---|
826 | #
|
---|
827 | # @param $(target) Normalized target name.
|
---|
828 | # @param $(out) The output file.
|
---|
829 | # @param $(definst) The default _INST value.
|
---|
830 | # @param $(typevar) The name of the variable with all the root targets of its type.
|
---|
831 | # @obsolete
|
---|
832 | define def_target_install_pluss
|
---|
833 | ifndef $(target)_NOINST
|
---|
834 | INSTARGET_$(target) := $(patsubst %/,%/$(notdir $(out)), \
|
---|
835 | $(if $($(target)_INST), $(addprefix $(PATH_INS)/,$($(target)_INST)), $(definst)/))
|
---|
836 |
|
---|
837 | $(eval $(def_link_install_rule))
|
---|
838 |
|
---|
839 | _INSTALLS += $(INSTARGET_$(target))
|
---|
840 |
|
---|
841 | ifdef KBUILD_DO_AUTO_INSTALL
|
---|
842 | $(typevar) += $(INSTARGET_$(target))
|
---|
843 | else
|
---|
844 | $(typevar) += $(out)
|
---|
845 | endif
|
---|
846 | else # _NOINST
|
---|
847 | $(typevar) += $(out)
|
---|
848 | endif
|
---|
849 |
|
---|
850 | _OUT_FILES += $(out)
|
---|
851 | _CLEAN_FILES += $($(target)_CLEAN)
|
---|
852 | _OBJS += $($(target)_OBJS_)
|
---|
853 |
|
---|
854 | endef
|
---|
855 |
|
---|
856 |
|
---|
857 |
|
---|
858 | #
|
---|
859 | # LIBRARIES
|
---|
860 | #
|
---|
861 |
|
---|
862 | ## Library (one).
|
---|
863 | # @param $(target) Normalized library (target) name.
|
---|
864 | define def_lib
|
---|
865 | # library basics
|
---|
866 | ## @todo prefix
|
---|
867 | bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
|
---|
868 | bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))
|
---|
869 | bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_TARGET_ARCH))
|
---|
870 | bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_TARGET_CPU))
|
---|
871 | tool := $(call _TARGET_TOOL,$(target),AR)
|
---|
872 | ifeq ($(tool),)
|
---|
873 | $(error kBuild: Library target $(target) does not have a tool defined!)
|
---|
874 | endif
|
---|
875 | outbase := $(call _TARGET_BASE,$(target),$(target))
|
---|
876 | PATH_$(target) := $(patsubst %/,%,$(dir $(outbase)))
|
---|
877 | suff := $(firstword\
|
---|
878 | $($(target)_LIBSUFF.$(bld_trg))\
|
---|
879 | $($(target)_LIBSUFF)\
|
---|
880 | $(TOOL_$(tool)_ARLIBSUFF.$(bld_trg))\
|
---|
881 | $(TOOL_$(tool)_ARLIBSUFF)\
|
---|
882 | $(SUFF_LIB))
|
---|
883 | out := $(outbase)$(suff)
|
---|
884 | TARGET_$(target) := $(out)
|
---|
885 | $(target)_OBJS_ := $(filter %.o %.obj, \
|
---|
886 | $($(target)_SOURCES) \
|
---|
887 | $($(target)_SOURCES.$(bld_trg)) \
|
---|
888 | $($(target)_SOURCES.$(bld_trg_arch)) \
|
---|
889 | $($(target)_SOURCES.$(bld_trg_cpu)) \
|
---|
890 | $($(target)_SOURCES.$(bld_type)))
|
---|
891 |
|
---|
892 |
|
---|
893 | # source -> object
|
---|
894 | $(eval $(value def_target_sources))
|
---|
895 |
|
---|
896 | # library linking
|
---|
897 | tool := $(call _TARGET_TOOL,$(target),AR)
|
---|
898 | outbase := $(call _TARGET_BASE,$(target),$(target))
|
---|
899 | flags :=\
|
---|
900 | $(TOOL_$(tool)_ARFLAGS)\
|
---|
901 | $(TOOL_$(tool)_ARFLAGS.$(bld_type))\
|
---|
902 | $(ARFLAGS)\
|
---|
903 | $(ARFLAGS.$(bld_type))\
|
---|
904 | $($(target)_ARFLAGS)\
|
---|
905 | $($(target)_ARFLAGS.$(bld_type))
|
---|
906 | othersrc := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm %.o %.obj,\
|
---|
907 | $($(target)_SOURCES) \
|
---|
908 | $($(target)_SOURCES.$(bld_trg)) \
|
---|
909 | $($(target)_SOURCES.$(bld_trg_arch)) \
|
---|
910 | $($(target)_SOURCES.$(bld_trg_cpu)) \
|
---|
911 | $($(target)_SOURCES.$(bld_type)))
|
---|
912 | objs = $($(target)_OBJS_)
|
---|
913 | dirdep := $(call DIRDEP,$(dir $(out)))
|
---|
914 | ## @todo fix dependencies on makefiles an such
|
---|
915 | deps := $($(target)_DEPS)
|
---|
916 |
|
---|
917 | # dependency file
|
---|
918 | dep := $(out)$(SUFF_DEP)
|
---|
919 | ifndef NO_LINK_CMDS_DEP
|
---|
920 | _DEPFILES_INCLUDED += $(dep)
|
---|
921 | $(if $(wildcard $(dep)),$(eval include $(dep)))
|
---|
922 | endif
|
---|
923 |
|
---|
924 | # check that the tool is defined.
|
---|
925 | ifndef TOOL_$(tool)_LINK_LIBRARY_CMDS
|
---|
926 | $(warning kBuild: tools: \
|
---|
927 | 1 $($(target)_$(source)TOOL.$(bld_trg)) \
|
---|
928 | 2 $($(target)_$(source)TOOL) \
|
---|
929 | 3 $($(target)_TOOL.$(bld_trg)) \
|
---|
930 | 4 $($(target)_TOOL) \
|
---|
931 | 5 $($(source)TOOL) \
|
---|
932 | 6 $($(source)TOOL.$(bld_trg)) \
|
---|
933 | 7 $(TOOL.$(bld_trg)) \
|
---|
934 | 8 $(TOOL) )
|
---|
935 | $(error kBuild: TOOL_$(tool)_LINK_LIBRARY_CMDS isn't defined! target=$(target) )
|
---|
936 | endif
|
---|
937 |
|
---|
938 | # call the tool
|
---|
939 | $(target)_CMDS_ := $(TOOL_$(tool)_LINK_LIBRARY_CMDS)
|
---|
940 | $(target)_OUTPUT_ := $(TOOL_$(tool)_LINK_LIBRARY_OUTPUT)
|
---|
941 | $(target)_DEPEND_ := $(TOOL_$(tool)_LINK_LIBRARY_DEPEND) $(deps) $(objs)
|
---|
942 | $(target)_DEPORD_ := $(TOOL_$(tool)_LINK_LIBRARY_DEPORD) $(dirdep)
|
---|
943 |
|
---|
944 | # generate the link rule.
|
---|
945 | $(eval $(def_link_rule))
|
---|
946 |
|
---|
947 | # installing and globals
|
---|
948 | definst := $(PATH_LIB)
|
---|
949 | typevar := _LIBS
|
---|
950 | $(eval $(value def_target_install_pluss))
|
---|
951 | endef
|
---|
952 |
|
---|
953 | # Process libraries
|
---|
954 | mode := 0644
|
---|
955 | $(foreach target, $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)), $(eval $(value def_lib)))
|
---|
956 |
|
---|
957 |
|
---|
958 | #
|
---|
959 | # Link operations.
|
---|
960 | #
|
---|
961 |
|
---|
962 | ##
|
---|
963 | # Link prolog
|
---|
964 | #
|
---|
965 | # @param $(target) Normalized target name.
|
---|
966 | # @param $(EXT) EXE,DLL,SYS.
|
---|
967 | # @param $(definst) The default _INST value.
|
---|
968 | # @param $(typevar) The name of the variable with all the root targets of its type.
|
---|
969 | define def_link_common
|
---|
970 | # basics
|
---|
971 | bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
|
---|
972 | bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_$(bld_trg_base_var)))
|
---|
973 | bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_$(bld_trg_base_var)_ARCH))
|
---|
974 | bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_$(bld_trg_base_var)_CPU))
|
---|
975 |
|
---|
976 | tool := $(call _TARGET_TOOL,$(target),LD)
|
---|
977 | outbase := $(call _TARGET_BASE,$(target),$(target))
|
---|
978 | suff := $(firstword \
|
---|
979 | $($(target)_$(EXT)SUFF) \
|
---|
980 | $($(target)_$(EXT)SUFF) \
|
---|
981 | $(TOOL_$(tool)_LD$(EXT)SUFF) \
|
---|
982 | $($(EXTPRE)SUFF_$(EXT)))
|
---|
983 | out := $(outbase)$(suff)
|
---|
984 | PATH_$(target) := $(patsubst %/,%,$(dir $(outbase)))
|
---|
985 | TARGET_$(target) := $(out)
|
---|
986 | $(target)_OBJS_ := $(filter %.o %.obj, \
|
---|
987 | $($(target)_SOURCES) \
|
---|
988 | $($(target)_SOURCES.$(bld_trg)) \
|
---|
989 | $($(target)_SOURCES.$(bld_trg_arch)) \
|
---|
990 | $($(target)_SOURCES.$(bld_trg_cpu)) \
|
---|
991 | $($(target)_SOURCES.$(bld_type)))
|
---|
992 |
|
---|
993 | # source -> object
|
---|
994 | $(eval $(value def_target_sources))
|
---|
995 |
|
---|
996 | # more library stuff.
|
---|
997 | tool := $(call _TARGET_TOOL,$(target),LD)
|
---|
998 | outbase := $(call _TARGET_BASE,$(target),$(target))
|
---|
999 | flags :=\
|
---|
1000 | $(TOOL_$(tool)_LDFLAGS)\
|
---|
1001 | $(TOOL_$(tool)_LDFLAGS.$(bld_type))\
|
---|
1002 | $(TOOL_$(tool)_LDFLAGS.$(bld_trg))\
|
---|
1003 | $(TOOL_$(tool)_LDFLAGS.$(bld_trg_arch))\
|
---|
1004 | $(TOOL_$(tool)_LDFLAGS.$(bld_trg_cpu))\
|
---|
1005 | $(LDFLAGS)\
|
---|
1006 | $(LDFLAGS.$(bld_type))\
|
---|
1007 | $(LDFLAGS.$(bld_trg))\
|
---|
1008 | $(LDFLAGS.$(bld_trg_arch))\
|
---|
1009 | $(LDFLAGS.$(bld_trg_cpu))\
|
---|
1010 | $($(target)_LDFLAGS)\
|
---|
1011 | $($(target)_LDFLAGS.$(bld_type))\
|
---|
1012 | $($(target)_LDFLAGS.$(bld_trg))\
|
---|
1013 | $($(target)_LDFLAGS.$(bld_trg_arch))\
|
---|
1014 | $($(target)_LDFLAGS.$(bld_trg_cpu))
|
---|
1015 | othersrc := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm %.o %.obj,\
|
---|
1016 | $($(target)_SOURCES)\
|
---|
1017 | $($(target)_SOURCES.$(bld_trg)) \
|
---|
1018 | $($(target)_SOURCES.$(bld_trg_arch)) \
|
---|
1019 | $($(target)_SOURCES.$(bld_trg_cpu)) \
|
---|
1020 | $($(target)_SOURCES.$(bld_type)))
|
---|
1021 | objs = $($(target)_OBJS_)
|
---|
1022 | libs :=\
|
---|
1023 | $($(target)_LIBS.$(bld_trg_cpu))\
|
---|
1024 | $($(target)_LIBS.$(bld_trg_arch))\
|
---|
1025 | $($(target)_LIBS.$(bld_trg))\
|
---|
1026 | $($(target)_LIBS.$(bld_type))\
|
---|
1027 | $($(target)_LIBS)\
|
---|
1028 | $(foreach sdk, $($(target)_SDKS.$(bld_trg)) \
|
---|
1029 | $($(target)_SDKS.$(bld_type)) \
|
---|
1030 | $($(target)_SDKS),\
|
---|
1031 | $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
|
---|
1032 | $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
|
---|
1033 | $(SDK_$(sdk)_LIBS.$(bld_trg))\
|
---|
1034 | $(SDK_$(sdk)_LIBS.$(bld_type))\
|
---|
1035 | $(SDK_$(sdk)_LIBS))\
|
---|
1036 | $(LIBS.$(bld_trg_cpu))\
|
---|
1037 | $(LIBS.$(bld_trg_arch))\
|
---|
1038 | $(LIBS.$(bld_trg))\
|
---|
1039 | $(LIBS.$(bld_type))\
|
---|
1040 | $(LIBS)\
|
---|
1041 | $(foreach sdk, $(SDKS.$(bld_trg)) \
|
---|
1042 | $(SDKS.$(bld_type)) \
|
---|
1043 | $(SDKS),\
|
---|
1044 | $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
|
---|
1045 | $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
|
---|
1046 | $(SDK_$(sdk)_LIBS.$(bld_trg))\
|
---|
1047 | $(SDK_$(sdk)_LIBS.$(bld_type))\
|
---|
1048 | $(SDK_$(sdk)_LIBS))\
|
---|
1049 | $(TOOL_$(tool)_LIBS.$(bld_trg_cpu))\
|
---|
1050 | $(TOOL_$(tool)_LIBS.$(bld_trg_arch))\
|
---|
1051 | $(TOOL_$(tool)_LIBS.$(bld_trg))\
|
---|
1052 | $(TOOL_$(tool)_LIBS.$(bld_type))\
|
---|
1053 | $(TOOL_$(tool)_LIBS)
|
---|
1054 | libpath :=\
|
---|
1055 | $($(target)_LIBPATH.$(bld_trg_cpu))\
|
---|
1056 | $($(target)_LIBPATH.$(bld_trg_arch))\
|
---|
1057 | $($(target)_LIBPATH.$(bld_trg))\
|
---|
1058 | $($(target)_LIBPATH.$(bld_type))\
|
---|
1059 | $($(target)_LIBPATH)\
|
---|
1060 | $(foreach sdk, $($(target)_SDKS.$(bld_trg)) \
|
---|
1061 | $($(target)_SDKS.$(bld_type)) \
|
---|
1062 | $($(target)_SDKS),\
|
---|
1063 | $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
|
---|
1064 | $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
|
---|
1065 | $(SDK_$(sdk)_LIBPATH.$(bld_trg))\
|
---|
1066 | $(SDK_$(sdk)_LIBPATH.$(bld_type))\
|
---|
1067 | $(SDK_$(sdk)_LIBPATH))\
|
---|
1068 | $(LIBPATH.$(bld_trg_cpu))\
|
---|
1069 | $(LIBPATH.$(bld_trg_arch))\
|
---|
1070 | $(LIBPATH.$(bld_trg))\
|
---|
1071 | $(LIBPATH.$(bld_type))\
|
---|
1072 | $(LIBPATH)\
|
---|
1073 | $(foreach sdk, $(SDKS.$(bld_trg)) \
|
---|
1074 | $(SDKS.$(bld_type)) \
|
---|
1075 | $(SDKS),\
|
---|
1076 | $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
|
---|
1077 | $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
|
---|
1078 | $(SDK_$(sdk)_LIBPATH.$(bld_trg))\
|
---|
1079 | $(SDK_$(sdk)_LIBPATH.$(bld_type))\
|
---|
1080 | $(SDK_$(sdk)_LIBPATH))\
|
---|
1081 | $(TOOL_$(tool)_LIBPATH.$(bld_trg_cpu))\
|
---|
1082 | $(TOOL_$(tool)_LIBPATH.$(bld_trg_arch))\
|
---|
1083 | $(TOOL_$(tool)_LIBPATH.$(bld_trg))\
|
---|
1084 | $(TOOL_$(tool)_LIBPATH.$(bld_type))\
|
---|
1085 | $(TOOL_$(tool)_LIBPATH)
|
---|
1086 | dirdep := $(call DIRDEP,$(dir $(out)))
|
---|
1087 | ## @todo fix dependencies
|
---|
1088 | deps := $($(target)_DEPS)
|
---|
1089 |
|
---|
1090 | ## @todo this stuff can't be working.
|
---|
1091 | custom_pre := $(strip $(firstword \
|
---|
1092 | $($(target)_CUSTOM_PRE.$(bld_trg).$(bld_type))\
|
---|
1093 | $($(target)_CUSTOM_PRE.$(bld_trg))\
|
---|
1094 | $($(target)_CUSTOM_PRE.$(bld_type))\
|
---|
1095 | $($(target)_CUSTOM_PRE)\
|
---|
1096 | $(CUSTOM_PRE.$(bld_trg).$(bld_type))\
|
---|
1097 | $(CUSTOM_PRE.$(bld_trg))\
|
---|
1098 | $(CUSTOM_PRE.$(bld_type))\
|
---|
1099 | $(CUSTOM_PRE)\
|
---|
1100 | ))
|
---|
1101 | custom_post := $(strip $(firstword \
|
---|
1102 | $($(target)_CUSTOM_POST.$(bld_trg).$(bld_type))\
|
---|
1103 | $($(target)_CUSTOM_POST.$(bld_trg))\
|
---|
1104 | $($(target)_CUSTOM_POST.$(bld_type))\
|
---|
1105 | $($(target)_CUSTOM_POST)\
|
---|
1106 | $(CUSTOM_POST.$(bld_trg).$(bld_type))\
|
---|
1107 | $(CUSTOM_POST.$(bld_trg))\
|
---|
1108 | $(CUSTOM_POST.$(bld_type))\
|
---|
1109 | $(CUSTOM_POST)\
|
---|
1110 | ))
|
---|
1111 |
|
---|
1112 | # installation targets
|
---|
1113 | ifndef $(target)_NOINST
|
---|
1114 | INSTARGET_$(target) := $(patsubst %/,%/$(notdir $(out)), \
|
---|
1115 | $(if $($(target)_INST), $(addprefix $(PATH_INS)/,$($(target)_INST)), $(definst)/))
|
---|
1116 | ifdef KBUILD_DO_AUTO_INSTALL
|
---|
1117 | $(typevar) += $(INSTARGET_$(target))
|
---|
1118 | else
|
---|
1119 | $(typevar) += $(out)
|
---|
1120 | endif
|
---|
1121 | # generate the install rule
|
---|
1122 | $(eval $(def_link_install_rule))
|
---|
1123 |
|
---|
1124 | else # NOINST
|
---|
1125 | INSTARGET_$(target) :=
|
---|
1126 | $(typevar) += $(out)
|
---|
1127 | endif # NOINST
|
---|
1128 |
|
---|
1129 | # dependency file
|
---|
1130 | dep := $(outbase)$(SUFF_DEP)
|
---|
1131 | ifndef NO_LINK_CMDS_DEP
|
---|
1132 | _DEPFILES_INCLUDED += $(dep)
|
---|
1133 | $(if $(wildcard $(dep)),$(eval include $(dep)))
|
---|
1134 | endif
|
---|
1135 |
|
---|
1136 | # check that the tool is defined.
|
---|
1137 | ifndef TOOL_$(tool)_$(tool_do)_CMDS
|
---|
1138 | $(warning kBuild: tools: \
|
---|
1139 | 1 $($(target)_$(source)TOOL.$(bld_trg)) \
|
---|
1140 | 2 $($(target)_$(source)TOOL) \
|
---|
1141 | 3 $($(target)_TOOL.$(bld_trg)) \
|
---|
1142 | 4 $($(target)_TOOL) \
|
---|
1143 | 5 $($(source)TOOL) \
|
---|
1144 | 6 $($(source)TOOL.$(bld_trg)) \
|
---|
1145 | 7 $(TOOL.$(bld_trg)) \
|
---|
1146 | 8 $(TOOL) )
|
---|
1147 | $(error kBuild: TOOL_$(tool)_$(tool_do)_CMDS isn't defined! target=$(target) )
|
---|
1148 | endif
|
---|
1149 |
|
---|
1150 | # call the tool
|
---|
1151 | $(target)_CMDS_ := $(TOOL_$(tool)_$(tool_do)_CMDS)
|
---|
1152 | $(target)_OUTPUT_ := $(TOOL_$(tool)_$(tool_do)_OUTPUT)
|
---|
1153 | $(target)_DEPEND_ := $(TOOL_$(tool)_$(tool_do)_DEPEND) $(deps) $(objs)
|
---|
1154 | $(target)_DEPORD_ := $(TOOL_$(tool)_$(tool_do)_DEPORD) $(dirdep)
|
---|
1155 |
|
---|
1156 | # generate the link rule.
|
---|
1157 | $(eval $(def_link_rule))
|
---|
1158 |
|
---|
1159 |
|
---|
1160 | # Update globals.
|
---|
1161 | _OBJS += $($(target)_OBJS_)
|
---|
1162 | _OUT_FILES += $($(target)_OUTPUT_) $(out)
|
---|
1163 | _CLEAN_FILES += $($(target)_CLEAN)
|
---|
1164 | _INSTALLS += $(INSTARGET_$(target))
|
---|
1165 |
|
---|
1166 | endef
|
---|
1167 |
|
---|
1168 |
|
---|
1169 | #
|
---|
1170 | # BLDPROGS
|
---|
1171 | #
|
---|
1172 |
|
---|
1173 | ## Build program (one).
|
---|
1174 | # @param $(target) Normalized target (program) name.
|
---|
1175 | define def_bldprog
|
---|
1176 |
|
---|
1177 | # set NOINST if not forced installation.
|
---|
1178 | ifndef $(target)_INST
|
---|
1179 | $(target)_NOINST := 1
|
---|
1180 | endif
|
---|
1181 |
|
---|
1182 | # do the usual stuff.
|
---|
1183 | $(eval $(value def_link_common))
|
---|
1184 |
|
---|
1185 | endef
|
---|
1186 |
|
---|
1187 | # Process build programs.
|
---|
1188 | EXT := EXE
|
---|
1189 | EXTPRE := HOST
|
---|
1190 | tool_do := LINK_PROGRAM
|
---|
1191 | definst := $(PATH_BIN)
|
---|
1192 | typevar := _BLDPROGS
|
---|
1193 | mode := 0755
|
---|
1194 | bld_trg_base_var := PLATFORM
|
---|
1195 | $(foreach target, $(BLDPROGS) $(BLDPROGS.$(BUILD_PLATFORM)), $(eval $(value def_bldprog)))
|
---|
1196 |
|
---|
1197 |
|
---|
1198 |
|
---|
1199 | #
|
---|
1200 | # DLLS
|
---|
1201 | #
|
---|
1202 |
|
---|
1203 | # Process dlls
|
---|
1204 | EXT := DLL
|
---|
1205 | EXTPRE :=
|
---|
1206 | tool_do := LINK_DLL
|
---|
1207 | definst := $(PATH_DLL)
|
---|
1208 | typevar := _DLLS
|
---|
1209 | mode := 0755
|
---|
1210 | bld_trg_base_var := TARGET
|
---|
1211 | $(foreach target, $(DLLS) $(DLLS.$(BUILD_TARGET)), $(eval $(value def_link_common)))
|
---|
1212 |
|
---|
1213 |
|
---|
1214 | #
|
---|
1215 | # Process import libraries.
|
---|
1216 | #
|
---|
1217 | # - On OS/2 and windows these are libraries.
|
---|
1218 | # - On other platforms they are fake DLLs.
|
---|
1219 | ifeq ($(subst win32,os2,$(BUILD_TARGET)),os2)
|
---|
1220 | $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)), $(eval $(value def_lib)))
|
---|
1221 | else
|
---|
1222 | $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)), $(eval $(value def_link_common)))
|
---|
1223 | endif
|
---|
1224 | $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)), \
|
---|
1225 | $(eval _IMPORT_LIBS += $(if $(INSTARGET_$(target)),$(INSTARGET_$(target)), $(TARGET_$(target)))))
|
---|
1226 |
|
---|
1227 |
|
---|
1228 | #
|
---|
1229 | # PROGRAMS
|
---|
1230 | #
|
---|
1231 |
|
---|
1232 | # Process programs
|
---|
1233 | EXT := EXE
|
---|
1234 | EXTPRE :=
|
---|
1235 | tool_do := LINK_PROGRAM
|
---|
1236 | definst := $(PATH_BIN)
|
---|
1237 | typevar := _PROGRAMS
|
---|
1238 | mode := 0755
|
---|
1239 | bld_trg_base_var := TARGET
|
---|
1240 | $(foreach target, $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)), $(eval $(value def_link_common)))
|
---|
1241 |
|
---|
1242 |
|
---|
1243 |
|
---|
1244 | #
|
---|
1245 | # SYSMODS
|
---|
1246 | #
|
---|
1247 |
|
---|
1248 | # Process sysmods
|
---|
1249 | EXT := SYS
|
---|
1250 | EXTPRE :=
|
---|
1251 | tool_do := LINK_SYSMOD
|
---|
1252 | definst := $(PATH_SYS)
|
---|
1253 | typevar := _SYSMODS
|
---|
1254 | mode := 0644
|
---|
1255 | bld_trg_base_var := TARGET
|
---|
1256 | $(foreach target, $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)), $(eval $(value def_link_common)))
|
---|
1257 |
|
---|
1258 |
|
---|
1259 | #
|
---|
1260 | # OTHERS
|
---|
1261 | #
|
---|
1262 | _OTHERS = $(OTHERS) $(OTHERS.$(BUILD_TARGET))
|
---|
1263 |
|
---|
1264 |
|
---|
1265 | #
|
---|
1266 | # INSTALLS
|
---|
1267 | #
|
---|
1268 |
|
---|
1269 | ## generate the install rule
|
---|
1270 | define def_install_src_rule
|
---|
1271 | # the install rule
|
---|
1272 | $(insdst) : $(srcsrc) | $(call DIRDEP,$(dir $(insdst)))
|
---|
1273 | $$(if $$(filter $(INSTALL),$(inscmd)),,$$(RM) -f $$@)
|
---|
1274 | $(inscmd)
|
---|
1275 | endef
|
---|
1276 |
|
---|
1277 | ## install one file
|
---|
1278 | define def_install_src
|
---|
1279 |
|
---|
1280 | # deal with '=>' in the source file name.
|
---|
1281 | srcdst := $(subst =>, ,$(src))
|
---|
1282 | srcsrc := $(firstword $(srcdst))
|
---|
1283 | srcdst := $(word $(words $(srcdst)),$(srcdst))
|
---|
1284 |
|
---|
1285 | # _INSTFUN
|
---|
1286 | ifdef $(srcsrc)_INSTFUN
|
---|
1287 | instfun := $(srcsrc)_INSTFUN
|
---|
1288 | else
|
---|
1289 | ifdef $(target)_INSTFUN
|
---|
1290 | instfun := $(target)_INSTFUN
|
---|
1291 | else
|
---|
1292 | instfun := _INSTALL_FILE
|
---|
1293 | endif
|
---|
1294 | endif
|
---|
1295 |
|
---|
1296 | # _INST
|
---|
1297 | ifdef $(srcsrc)_INST
|
---|
1298 | inst := $(patsubst %/,%,$($(srcsrc)_INST))/$(dir $(srcdst))
|
---|
1299 | else
|
---|
1300 | ifdef $(target)_INST
|
---|
1301 | inst := $(patsubst %/,%,$($(target)_INST))/$(dir $(srcdst))
|
---|
1302 | else
|
---|
1303 | inst := $(dir $(srcdst))
|
---|
1304 | endif
|
---|
1305 | endif
|
---|
1306 |
|
---|
1307 | # calc target
|
---|
1308 | insdst := $(call $(instfun),$(srcdst),$(target),$(inst),$(PATH_INS))
|
---|
1309 | #$(warning instfun=$(instfun) srcdst=$(srcdst) target=$(target) srcdst=$(srcsrc) inst=$(inst) => insdst=$(insdst))
|
---|
1310 |
|
---|
1311 | # mode, uid and gid
|
---|
1312 | mode := $(firstword \
|
---|
1313 | $($(target)_$(srcsrc)_MODE.$(bld_trg)) \
|
---|
1314 | $($(target)_$(srcsrc)_MODE) \
|
---|
1315 | $($(target)_$(srcdst)_MODE.$(bld_trg)) \
|
---|
1316 | $($(target)_$(srcdst)_MODE) \
|
---|
1317 | $($(srcsrc)_MODE.$(bld_trg)) \
|
---|
1318 | $($(srcsrc)_MODE) \
|
---|
1319 | $($(srcdst)_MODE.$(bld_trg)) \
|
---|
1320 | $($(srcdst)_MODE) \
|
---|
1321 | $($(target)_MODE.$(bld_trg)) \
|
---|
1322 | $($(target)_MODE))
|
---|
1323 | uid := $(firstword \
|
---|
1324 | $($(target)_$(srcsrc)_UID.$(bld_trg)) \
|
---|
1325 | $($(target)_$(srcsrc)_UID) \
|
---|
1326 | $($(target)_$(srcdst)_UID.$(bld_trg)) \
|
---|
1327 | $($(target)_$(srcdst)_UID) \
|
---|
1328 | $($(srcsrc)_UID.$(bld_trg)) \
|
---|
1329 | $($(srcsrc)_UID) \
|
---|
1330 | $($(srcdst)_UID.$(bld_trg)) \
|
---|
1331 | $($(srcdst)_UID) \
|
---|
1332 | $($(target)_UID.$(bld_trg)) \
|
---|
1333 | $($(target)_UID))
|
---|
1334 | gid := $(firstword \
|
---|
1335 | $($(target)_$(srcsrc)_GID.$(bld_trg)) \
|
---|
1336 | $($(target)_$(srcsrc)_GID) \
|
---|
1337 | $($(target)_$(srcdst)_GID.$(bld_trg)) \
|
---|
1338 | $($(target)_$(srcdst)_GID) \
|
---|
1339 | $($(srcsrc)_GID.$(bld_trg)) \
|
---|
1340 | $($(srcsrc)_GID) \
|
---|
1341 | $($(srcdst)_GID.$(bld_trg)) \
|
---|
1342 | $($(srcdst)_GID) \
|
---|
1343 | $($(target)_GID.$(bld_trg)) \
|
---|
1344 | $($(target)_GID))
|
---|
1345 |
|
---|
1346 | # create the command
|
---|
1347 | ifdef $(srcsrc)_INSTALLER
|
---|
1348 | inscmd := $(call $(srcsrc)_INSTALLER,$(srcsrc),$(insdst),$(target))
|
---|
1349 | else
|
---|
1350 | ifdef $(target)_INSTALLER
|
---|
1351 | inscmd := $(call $(target)_INSTALLER,$(srcsrc),$(insdst),$(target))
|
---|
1352 | else
|
---|
1353 | inscmd := $$(INSTALL)\
|
---|
1354 | $(if $(uid),-o $(uid))\
|
---|
1355 | $(if $(gid),-g $(gid))\
|
---|
1356 | $(if $(mode),-m $(mode))\
|
---|
1357 | $(srcsrc) $(insdst)
|
---|
1358 | endif
|
---|
1359 | endif
|
---|
1360 |
|
---|
1361 | # generate the rule (need double evaluation here)
|
---|
1362 | $(eval $(def_install_src_rule))
|
---|
1363 |
|
---|
1364 | INSTARGET_$(target) += $(insdst)
|
---|
1365 | endef
|
---|
1366 |
|
---|
1367 |
|
---|
1368 | ## generate the symlink rule
|
---|
1369 | define def_install_symlink_rule
|
---|
1370 | # the install rule
|
---|
1371 | $(insdst) : | $(call DIRDEP,$(dir $(insdst)))
|
---|
1372 | $$(RM) -f $$@
|
---|
1373 | $$(LN_SYMLINK) $(symdst) $(insdst)
|
---|
1374 | endef
|
---|
1375 |
|
---|
1376 | ## create one symlink
|
---|
1377 | define def_install_symlink
|
---|
1378 |
|
---|
1379 | # deal with '=>' in the source file name.
|
---|
1380 | symdst := $(subst =>, ,$(src))
|
---|
1381 | symlnk := $(firstword $(symdst))
|
---|
1382 | symdst := $(word $(words $(symdst)),$(symdst))
|
---|
1383 |
|
---|
1384 | # _INSTFUN
|
---|
1385 | ifdef $(symlnk)_INSTFUN
|
---|
1386 | instfun := $(symlnk)_INSTFUN
|
---|
1387 | else
|
---|
1388 | ifdef $(target)_INSTFUN
|
---|
1389 | instfun := $(target)_INSTFUN
|
---|
1390 | else
|
---|
1391 | instfun := _INSTALL_FILE
|
---|
1392 | endif
|
---|
1393 | endif
|
---|
1394 |
|
---|
1395 | # _INST
|
---|
1396 | ifdef $(symlnk)_INST
|
---|
1397 | inst := $(patsubst %/,%,$($(symlnk)_INST))/$(dir $(symlnk))
|
---|
1398 | else
|
---|
1399 | ifdef $(target)_INST
|
---|
1400 | inst := $(patsubst %/,%,$($(target)_INST))/$(dir $(symlnk))
|
---|
1401 | else
|
---|
1402 | inst := $(dir $(symlnk))
|
---|
1403 | endif
|
---|
1404 | endif
|
---|
1405 |
|
---|
1406 | # calc target
|
---|
1407 | insdst := $(call $(instfun),$(symlnk),$(target),$(inst),$(PATH_INS))
|
---|
1408 | #$(warning symlnk=$(symlnk) symdst=$(symdst) insdst=$(insdst) instfun=$(instfun) inst='$(inst)')
|
---|
1409 |
|
---|
1410 | # generate the rule (need double evaluation here)
|
---|
1411 | $(eval $(def_install_symlink_rule))
|
---|
1412 |
|
---|
1413 | INSTARGET_$(target) += $(insdst)
|
---|
1414 | endef
|
---|
1415 |
|
---|
1416 |
|
---|
1417 | ## generate the install rule
|
---|
1418 | define def_install_directory_rule
|
---|
1419 | # the install rule
|
---|
1420 | $(insdst):
|
---|
1421 | $(INSTALL) -d \
|
---|
1422 | $(if $(uid),-o $(uid))\
|
---|
1423 | $(if $(gid),-g $(gid))\
|
---|
1424 | $(if $(mode),-m $(mode))\
|
---|
1425 | $(insdst)
|
---|
1426 |
|
---|
1427 | .NOTPARALLEL: $(insdst)
|
---|
1428 | endef
|
---|
1429 |
|
---|
1430 |
|
---|
1431 | ## create one directory
|
---|
1432 | define def_install_directory
|
---|
1433 |
|
---|
1434 | # _INST
|
---|
1435 | ifdef $(directory)_INST
|
---|
1436 | inst := $(PATH_INS)/$(patsubst %/,%,$($(directory)_INST))
|
---|
1437 | else
|
---|
1438 | ifdef $(target)_INST
|
---|
1439 | inst := $(PATH_INS)/$(patsubst %/,%,$($(target)_INST))
|
---|
1440 | else
|
---|
1441 | inst := $(PATH_INS)
|
---|
1442 | endif
|
---|
1443 | endif
|
---|
1444 |
|
---|
1445 | mode := $(firstword \
|
---|
1446 | $($(target)_$(directory)_MODE.$(bld_trg)) \
|
---|
1447 | $($(target)_$(directory)_MODE) \
|
---|
1448 | $($(directory)_MODE.$(bld_trg)) \
|
---|
1449 | $($(directory)_MODE) \
|
---|
1450 | $($(target)_MODE.$(bld_trg)) \
|
---|
1451 | $($(target)_MODE))
|
---|
1452 | uid := $(firstword \
|
---|
1453 | $($(target)_$(directory)_UID.$(bld_trg)) \
|
---|
1454 | $($(target)_$(directory)_UID) \
|
---|
1455 | $($(directory)_UID.$(bld_trg)) \
|
---|
1456 | $($(directory)_UID) \
|
---|
1457 | $($(target)_UID.$(bld_trg)) \
|
---|
1458 | $($(target)_UID))
|
---|
1459 | gid := $(firstword \
|
---|
1460 | $($(target)_$(directory)_GID.$(bld_trg)) \
|
---|
1461 | $($(target)_$(directory)_GID) \
|
---|
1462 | $($(directory)_GID.$(bld_trg)) \
|
---|
1463 | $($(directory)_GID) \
|
---|
1464 | $($(target)_GID.$(bld_trg)) \
|
---|
1465 | $($(target)_GID))
|
---|
1466 |
|
---|
1467 | insdst := $(inst)/$(directory)/
|
---|
1468 | #$(warning directory=$(directory) inst=$(inst) insdst=$(insdst) mode=$(mode) gid=$(gid) uid=$(uid))
|
---|
1469 |
|
---|
1470 | # generate the rule (need double evaluation here)
|
---|
1471 | $(eval $(def_install_directory_rule))
|
---|
1472 |
|
---|
1473 | INSTARGET_DIRS_$(target) += $(insdst)
|
---|
1474 | endef
|
---|
1475 |
|
---|
1476 |
|
---|
1477 | ## process one install target.
|
---|
1478 | define def_install
|
---|
1479 | bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
|
---|
1480 | bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))
|
---|
1481 | bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_TARGET_ARCH))
|
---|
1482 | bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_TARGET_CPU))
|
---|
1483 |
|
---|
1484 | INSTARGET_$(target) :=
|
---|
1485 | INSTARGET_DIRS_$(target) :=
|
---|
1486 |
|
---|
1487 | $(foreach directory,$($(target)_DIRS) $($(target)_DIRS.$(bld_trg)) $($(target)_DIRS.$(bld_trg_arch)) $($(target)_DIRS.$(bld_trg_cpu)) $($(target)_DIRS.$(bld_type)), \
|
---|
1488 | $(eval $(value def_install_directory)))
|
---|
1489 |
|
---|
1490 | $(foreach src,$($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_cpu)) $($(target)_SOURCES.$(bld_type)), \
|
---|
1491 | $(eval $(value def_install_src)))
|
---|
1492 |
|
---|
1493 | $(foreach src,$($(target)_SYMLINKS) $($(target)_SYMLINKS.$(bld_trg)) $($(target)_SYMLINKS.$(bld_trg_arch)) $($(target)_SYMLINKS.$(bld_trg_cpu)) $($(target)_SYMLINKS.$(bld_type)), \
|
---|
1494 | $(eval $(value def_install_symlink)))
|
---|
1495 |
|
---|
1496 | _INSTALLS += $(INSTARGET_$(target)) $($(target)_GOALS)
|
---|
1497 | _INSTALLS_DIRS += $(INSTARGET_DIRS_$(target))
|
---|
1498 | endef
|
---|
1499 |
|
---|
1500 | ## process all install targets
|
---|
1501 | $(foreach target, $(INSTALLS) $(INSTALLS.$(BUILD_TARGET)), \
|
---|
1502 | $(eval $(value def_install)))
|
---|
1503 |
|
---|
1504 |
|
---|
1505 | #
|
---|
1506 | # DOCS
|
---|
1507 | #
|
---|
1508 |
|
---|
1509 |
|
---|
1510 | #
|
---|
1511 | # DIRECTORIES
|
---|
1512 | #
|
---|
1513 | _DIR_ALL := $(sort $(addsuffix /,$(patsubst %/,%,$(_DIRS))) $(dir $(_OUT_FILES) $(_OBJS) $(_INSTALLS)))
|
---|
1514 | $(foreach directory,$(_INSTALLS_DIRS), $(eval _DIR_ALL := $(filter-out $(directory),$(_DIR_ALL))))
|
---|
1515 |
|
---|
1516 |
|
---|
1517 | define def_mkdir_rule
|
---|
1518 | $(directory):
|
---|
1519 | $(call MSG_L1,Creating directory $$@)
|
---|
1520 | $(MKDIR) -p $$@
|
---|
1521 | endef
|
---|
1522 |
|
---|
1523 | $(foreach directory,$(_DIR_ALL),$(eval $(def_mkdir_rule)))
|
---|
1524 |
|
---|
1525 |
|
---|
1526 | #
|
---|
1527 | # NOTHING
|
---|
1528 | #
|
---|
1529 | do-nothing:
|
---|
1530 | $(call MSG_L1,Did nothing in $(CURDIR))
|
---|
1531 |
|
---|
1532 |
|
---|
1533 | #
|
---|
1534 | # CLEAN UP
|
---|
1535 | #
|
---|
1536 | do-clean:
|
---|
1537 | $(RM) -f $(_OUT_FILES) $(_OBJS) $(_DEPFILES) $(_DEPFILES_INCLUDED) $(_CLEAN_FILES) $(OTHER_CLEAN)
|
---|
1538 |
|
---|
1539 |
|
---|
1540 | #
|
---|
1541 | # PASSES (including directory and makefile walking)
|
---|
1542 | #
|
---|
1543 |
|
---|
1544 | ## Subdir
|
---|
1545 | # @param $(pass) Lowercase pass name.
|
---|
1546 | # @param $(PASS) Uppercase pass name.
|
---|
1547 | # @param $(subdir) Subdirectory
|
---|
1548 | # @param $(tag) tag to attach to the rule name.
|
---|
1549 | define def_pass_subdir
|
---|
1550 | pass_$(pass)$(tag):: $(dep)
|
---|
1551 | + $(QUIET)$$(MAKE) -C $(subdir) -f $$(notdir $$(firstword $$(wildcard $$(addprefix $(subdir)/,$$(DEFAULT_MAKEFILE))))) pass_$(pass)
|
---|
1552 | endef
|
---|
1553 |
|
---|
1554 | ## Submakefile
|
---|
1555 | # @param $(pass) Lowercase pass name.
|
---|
1556 | # @param $(PASS) Uppercase pass name.
|
---|
1557 | # @param $(makefile) Makefile.
|
---|
1558 | # @param $(tag) tag to attach to the rule name.
|
---|
1559 | define def_pass_makefile
|
---|
1560 | pass_$(pass)$(tag):: $(dep)
|
---|
1561 | + $(QUIET)$$(MAKE) -C $(patsubst %/,%,$(dir $(makefile))) -f $(notdir $(makefile)) pass_$(pass)
|
---|
1562 | endef
|
---|
1563 |
|
---|
1564 | ## Execute a pass.
|
---|
1565 | # @param $(pass) Lowercase pass name.
|
---|
1566 | # @param $(PASS) Uppercase pass name.
|
---|
1567 | define def_pass_old
|
---|
1568 | $(eval SUBDIRS_$(PASS) ?= $(SUBDIRS) $(SUBDIRS.$(BUILD_TARGET)))
|
---|
1569 | $(eval SUBDIRS_AFTER_$(PASS) ?= $(SUBDIRS_AFTER) $(SUBDIRS_AFTER.$(BUILD_TARGET)))
|
---|
1570 | $(eval MAKEFILES_BEFORE_$(PASS) ?= $(MAKEFILES_BEFORE) $(MAKEFILES_BEFORE.$(BUILD_TARGET)))
|
---|
1571 | $(eval MAKEFILES_AFTER_$(PASS) ?= $(MAKEFILES_AFTER) $(MAKEFILES_AFTER.$(BUILD_TARGET)))
|
---|
1572 |
|
---|
1573 | $(eval tag:=_before)
|
---|
1574 | $(eval dep:=)
|
---|
1575 | $(foreach subdir,$(SUBDIRS_$(PASS)) $(SUBDIRS_$(PASS).$(BUILD_TARGET)) ,$(eval $(def_pass_subdir)))
|
---|
1576 | $(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(BUILD_TARGET)),$(eval $(def_pass_makefile)))
|
---|
1577 |
|
---|
1578 | $(eval tag:=_after)
|
---|
1579 | $(eval dep:=pass_$(pass)_doit)
|
---|
1580 | $(foreach subdir,$(SUBDIRS_AFTER_$(PASS)) $(SUBDIRS_AFTER_$(PASS).$(BUILD_TARGET)) ,$(eval $(def_pass_subdir)))
|
---|
1581 | $(foreach makefile,$(MAKEFILES_AFTER_$(PASS)) $(MAKEFILES_AFTER_$(PASS).$(BUILD_TARGET)) ,$(eval $(def_pass_makefile)))
|
---|
1582 |
|
---|
1583 | .NOTPARALLEL: pass_$(pass)_before pass_$(pass)_after
|
---|
1584 | .PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_doit pass_$(pass)_after
|
---|
1585 | pass_$(pass)_doit: $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$(var))
|
---|
1586 | pass_$(pass)_this: pass_$(pass)_before
|
---|
1587 | + $(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)_doit
|
---|
1588 | pass_$(pass)_after:: pass_$(pass)_this
|
---|
1589 | pass_$(pass): pass_$(pass)_after
|
---|
1590 |
|
---|
1591 | endef
|
---|
1592 |
|
---|
1593 | define def_pass
|
---|
1594 | $(eval SUBDIRS_$(PASS) ?= $(SUBDIRS) $(SUBDIRS.$(BUILD_TARGET)))
|
---|
1595 | $(eval SUBDIRS_AFTER_$(PASS) ?= $(SUBDIRS_AFTER) $(SUBDIRS_AFTER.$(BUILD_TARGET)))
|
---|
1596 | $(eval MAKEFILES_BEFORE_$(PASS) ?= $(MAKEFILES_BEFORE) $(MAKEFILES_BEFORE.$(BUILD_TARGET)))
|
---|
1597 | $(eval MAKEFILES_AFTER_$(PASS) ?= $(MAKEFILES_AFTER) $(MAKEFILES_AFTER.$(BUILD_TARGET)))
|
---|
1598 |
|
---|
1599 | $(eval tag:=_before)
|
---|
1600 | $(eval dep:=)
|
---|
1601 | $(foreach subdir,$(SUBDIRS_$(PASS)) $(SUBDIRS_$(PASS).$(BUILD_TARGET)) ,$(eval $(def_pass_subdir)))
|
---|
1602 | $(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(BUILD_TARGET)),$(eval $(def_pass_makefile)))
|
---|
1603 |
|
---|
1604 | $(eval tag:=_after)
|
---|
1605 | $(eval dep:=pass_$(pass)_doit)
|
---|
1606 | $(foreach subdir,$(SUBDIRS_AFTER_$(PASS)) $(SUBDIRS_AFTER_$(PASS).$(BUILD_TARGET)) ,$(eval $(def_pass_subdir)))
|
---|
1607 | $(foreach makefile,$(MAKEFILES_AFTER_$(PASS)) $(MAKEFILES_AFTER_$(PASS).$(BUILD_TARGET)) ,$(eval $(def_pass_makefile)))
|
---|
1608 |
|
---|
1609 | ifdef KBUILD_SAFE_PARALLEL
|
---|
1610 | .NOTPARALLEL: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_this
|
---|
1611 | .PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_this pass_$(pass)_doit
|
---|
1612 | pass_$(pass)_doit: $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$(var))
|
---|
1613 | pass_$(pass)_this: pass_$(pass)_before
|
---|
1614 | + $(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)_doit
|
---|
1615 | pass_$(pass)_after:: pass_$(pass)_this
|
---|
1616 | pass_$(pass): pass_$(pass)_after
|
---|
1617 | else
|
---|
1618 | .NOTPARALLEL: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_doit
|
---|
1619 | .PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_doit
|
---|
1620 | pass_$(pass)_doit: pass_$(pass)_before \
|
---|
1621 | $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var)))
|
---|
1622 | pass_$(pass): \
|
---|
1623 | pass_$(pass)_before \
|
---|
1624 | pass_$(pass)_doit \
|
---|
1625 | pass_$(pass)_after
|
---|
1626 | endif
|
---|
1627 |
|
---|
1628 | #$ (warning pass=$(pass) PASS=$(PASS): $(PASS_$(PASS)_trgs) $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var))))
|
---|
1629 | endef
|
---|
1630 |
|
---|
1631 | # Generate the defined passes.
|
---|
1632 | $(foreach PASS, $(PASSES), \
|
---|
1633 | $(eval pass := $(PASS_$(PASS)_pass)) \
|
---|
1634 | $(eval $(def_pass)))
|
---|
1635 |
|
---|
1636 | ## Pass order
|
---|
1637 | # @param $(pass) Current pass name.
|
---|
1638 | # @param $(prev_pass) The previous pass name.
|
---|
1639 | define def_pass_order
|
---|
1640 | ifdef KBUILD_SAFE_PARALLEL
|
---|
1641 | .NOTPARALLEL: pass_$(pass)_order
|
---|
1642 | .PHONY: pass_$(pass)_order
|
---|
1643 | pass_$(pass)_order: $(pass_prev)
|
---|
1644 | $(call MSG_L1,Pass - $(if $(PASS_$(PASS)),$(PASS_$(PASS)),$(pass)))
|
---|
1645 | + $(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)
|
---|
1646 | else
|
---|
1647 | .NOTPARALLEL: pass_$(pass)_order pass_$(pass)_banner
|
---|
1648 | .PHONY: pass_$(pass)_order pass_$(pass)_banner
|
---|
1649 | pass_$(pass)_banner:
|
---|
1650 | $(call MSG_L1,Pass - $(if $(PASS_$(PASS)),$(PASS_$(PASS)),$(pass)))
|
---|
1651 | pass_$(pass)_order: \
|
---|
1652 | $(pass_prev) \
|
---|
1653 | pass_$(pass)_banner \
|
---|
1654 | pass_$(pass)
|
---|
1655 | endif
|
---|
1656 | $(eval pass_prev := pass_$(pass)_order)
|
---|
1657 | endef
|
---|
1658 |
|
---|
1659 | ## PASS: order
|
---|
1660 | # Use dependencies to ensure correct pass order.
|
---|
1661 | pass_prev :=
|
---|
1662 | $(foreach PASS,$(DEFAULT_PASSES),\
|
---|
1663 | $(eval pass := $(PASS_$(PASS)_pass)) \
|
---|
1664 | $(eval $(def_pass_order)))
|
---|
1665 |
|
---|
1666 |
|
---|
1667 | #
|
---|
1668 | # THE MAIN RULES
|
---|
1669 | #
|
---|
1670 | all_recursive: $(pass_prev)
|
---|
1671 |
|
---|
1672 | rebuild: clean
|
---|
1673 | + $(MAKE) -f $(firstword $(MAKEFILE_LIST)) all_recursive
|
---|
1674 |
|
---|
1675 | # @todo make this a non-default pass!
|
---|
1676 | uninstall:
|
---|
1677 | $(RM) -f $(_INSTALLS)
|
---|
1678 |
|
---|
1679 | install: pass_installs
|
---|
1680 |
|
---|
1681 | # misc shortcuts.
|
---|
1682 | targets: bldprogs libraries dlls programs sysmods others installs
|
---|
1683 | objects: $(_OBJS)
|
---|
1684 | bldprogs: $(_BLDPROGS)
|
---|
1685 | libraries: $(_LIBS) $(_IMPORT_LIBS) $(_OTHER_LIBRARIES)
|
---|
1686 | dlls: $(_DLLS)
|
---|
1687 | programs: $(_PROGRAMS)
|
---|
1688 | sysmods: $(_SYSMODS)
|
---|
1689 | others: $(_OTHERS)
|
---|
1690 | installs: $(_INSTALLS_DIRS) $(_INSTALLS)
|
---|
1691 |
|
---|
1692 |
|
---|
1693 | #
|
---|
1694 | # kBuild debugging stuff.
|
---|
1695 | #
|
---|
1696 | _SPACE := $(subst ., ,.)
|
---|
1697 | _TAB := $(subst ., ,.)
|
---|
1698 | define _NEWLINE
|
---|
1699 |
|
---|
1700 |
|
---|
1701 | endef
|
---|
1702 | NLTAB = $(_NEWLINE)$(TAB)
|
---|
1703 | show_targets:
|
---|
1704 | @$(foreach target, $(ALL_TARGETS),\
|
---|
1705 | @$(ECHO) "target: $(target)" $(NLTAB)\
|
---|
1706 | @$(ECHO) " PATH_$(target)=$(PATH_$(target))" $(NLTAB)\
|
---|
1707 | @$(ECHO) " TARGET_$(target)=$(TARGET_$(target))" $(NLTAB)\
|
---|
1708 | @$(ECHO) " INSTARGET_$(target)=$(INSTARGET_$(target))" $(NLTAB)\
|
---|
1709 | $(foreach prop,$(PROPS_SINGLE) $(PROPS_ACCUMULATE) OBJS_ CLEAN, \
|
---|
1710 | $(eval _tmp:=$(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))) \
|
---|
1711 | $(if $($(target)_$(prop).$(_tmp)),\
|
---|
1712 | @$(ECHO) " $(target)_$(prop).$(_tmp)=$($(target)_$(prop).$(_tmp))" $(NLTAB)) \
|
---|
1713 | $(if $($(target)_$(prop)), $(NLTAB)@$(ECHO) " $(target)_$(prop)=$($(target)_$(prop))" $(NLTAB)) \
|
---|
1714 | )\
|
---|
1715 | $(foreach prop,$(PROPS_DEFERRED), \
|
---|
1716 | $(eval _tmp:=$(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))) \
|
---|
1717 | $(if $(value $(target)_$(prop).$(_tmp)),\
|
---|
1718 | @$(ECHO) ' $(target)_$(prop).$(_tmp)=$(value $(TARGET)_$(prop).$(_tmp))' $(NLTAB)) \
|
---|
1719 | $(if $(value $(target)_$(prop)), $(NLTAB)@$(ECHO) ' $(target)_$(prop)=$(value $(target)_$(prop))' $(NLTAB)) \
|
---|
1720 | ))
|
---|
1721 |
|
---|
1722 |
|
---|
1723 |
|
---|
1724 | #
|
---|
1725 | # Include dependency files.
|
---|
1726 | #
|
---|
1727 | $(foreach dep,$(wildcard $(_DEPFILES)),$(eval include $(dep)))
|
---|
1728 |
|
---|
1729 |
|
---|
1730 | # end-of-file-content
|
---|
1731 | __footer_kmk__ := target
|
---|
1732 | endif # __footer_kmk__
|
---|