1 | # $Id: footer.kmk 689 2006-12-08 08:12:03Z bird $
|
---|
2 | ## @file
|
---|
3 | #
|
---|
4 | # kBuild - File included at top of makefile.
|
---|
5 | #
|
---|
6 | # Copyright (c) 2004-2006 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 | # Make sure that the core variables we defined in recursive expansion mode
|
---|
32 | # up in header.kmk get expanded before we really start using them. The kBuild
|
---|
33 | # functions added to kmk to speed stuff up assumes that the variables are
|
---|
34 | # expanded here.
|
---|
35 | #
|
---|
36 | PATH_OBJ := $(PATH_OBJ)
|
---|
37 | PATH_TARGET := $(PATH_TARGET)
|
---|
38 | PATH_INS := $(PATH_INS)
|
---|
39 | PATH_BIN := $(PATH_BIN)
|
---|
40 | PATH_DLL := $(PATH_DLL)
|
---|
41 | PATH_SYS := $(PATH_SYS)
|
---|
42 | PATH_LIB := $(PATH_LIB)
|
---|
43 | PATH_DOC := $(PATH_DOC)
|
---|
44 |
|
---|
45 | #
|
---|
46 | # Variables.
|
---|
47 | # (Some of these need initialization before including definitions using them.)
|
---|
48 | #
|
---|
49 |
|
---|
50 | # all targets.
|
---|
51 | ALL_TARGETS += \
|
---|
52 | $(FETCHES) $(FETCHES.$(BUILD_TARGET)) $(FETCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
53 | $(PATCHES) $(PATCHES.$(BUILD_TARGET)) $(PATCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
54 | $(BLDPROGS) $(BLDPROGS.$(BUILD_PLATFORM)) $(BLDPROGS.$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)) \
|
---|
55 | $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)) $(LIBRARIES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
56 | $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)) $(IMPORT_LIBS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
57 | $(DLLS) $(DLLS.$(BUILD_TARGET)) $(DLLS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
58 | $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)) $(PROGRAMS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
59 | $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)) $(SYSMODS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
60 | $(INSTALLS) $(INSTALLS.$(BUILD_TARGET)) $(INSTALLS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
61 | $(OTHERS) $(OTHERS.$(BUILD_TARGET)) $(OTHERS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH))
|
---|
62 |
|
---|
63 | # all $(BUILD_TARGET) targets.
|
---|
64 | _ALL_BUILD_TARGET_TARGETS += \
|
---|
65 | $(FETCHES) $(FETCHES.$(BUILD_TARGET)) $(FETCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
66 | $(PATCHES) $(PATCHES.$(BUILD_TARGET)) $(PATCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
67 | $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)) $(LIBRARIES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
68 | $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)) $(IMPORT_LIBS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
69 | $(DLLS) $(DLLS.$(BUILD_TARGET)) $(DLLS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
70 | $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)) $(PROGRAMS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
71 | $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)) $(SYSMODS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
72 | $(INSTALLS) $(INSTALLS.$(BUILD_TARGET)) $(INSTALLS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
73 | $(OTHERS) $(OTHERS.$(BUILD_TARGET)) $(OTHERS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH))
|
---|
74 |
|
---|
75 | # all $(BUILD_TARGET) targets.
|
---|
76 | _ALL_BUILD_PLATFORM_TARGETS += \
|
---|
77 | $(BLDPROGS) $(BLDPROGS.$(BUILD_PLATFORM)) $(BLDPROGS.$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH))
|
---|
78 |
|
---|
79 | # all targets making use of srcname.
|
---|
80 | _ALL_SRCNAME_TARGETS += \
|
---|
81 | $(FETCHES) $(FETCHES.$(BUILD_TARGET)) $(FETCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
82 | $(PATCHES) $(PATCHES.$(BUILD_TARGET)) $(PATCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH))
|
---|
83 |
|
---|
84 | # dependency files.
|
---|
85 | _DEPFILES :=
|
---|
86 |
|
---|
87 | # included dependency files.
|
---|
88 | _DEPFILES_INCLUDED :=
|
---|
89 |
|
---|
90 |
|
---|
91 | # All kind of output files except for _OBJS and _DEPFILES.
|
---|
92 | # Compiling or linking definition outputting other things that $@ and any
|
---|
93 | # required dependency file must add those output files to this variable.
|
---|
94 | _OUT_FILES :=
|
---|
95 |
|
---|
96 | # Files which only requires cleaning up.
|
---|
97 | _CLEAN_FILES :=
|
---|
98 |
|
---|
99 | # all of a type
|
---|
100 | _OBJS :=
|
---|
101 | _FETCHES :=
|
---|
102 | _DOWNLOADS:=
|
---|
103 | _UNPACKS :=
|
---|
104 | _PATCHES :=
|
---|
105 | _UNFETCHES:=
|
---|
106 | _BLDPROGS :=
|
---|
107 | _LIBS :=
|
---|
108 | _DLLS :=
|
---|
109 | _PROGRAMS :=
|
---|
110 | _SYSMODS :=
|
---|
111 | _INSTALLS :=
|
---|
112 | _INSTALLS_DIRS :=
|
---|
113 | _OTHERS :=
|
---|
114 | _PACKING :=
|
---|
115 | _DIRS := $(PATH_TARGET)/ $(PATH_TARGET)
|
---|
116 | _IMPORT_LIBS :=
|
---|
117 |
|
---|
118 | # misc
|
---|
119 | pass_prev :=
|
---|
120 |
|
---|
121 |
|
---|
122 | #
|
---|
123 | # Basic macros
|
---|
124 | #
|
---|
125 |
|
---|
126 | ## Figure out the tool for a source
|
---|
127 | # @param target source file
|
---|
128 | # @param source normalized main target
|
---|
129 | # @param type tooltype
|
---|
130 | # @param bld_trg build target.
|
---|
131 | # @param bld_trg_arch build target architecture.
|
---|
132 | # @remark Obsoleted by kBuild helpers in kmk. Only required for gmake compatbility.
|
---|
133 | _SOURCE_TOOL = $(strip $(firstword \
|
---|
134 | $($(target)_$(source)_$(type)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
135 | $($(target)_$(source)_$(type)TOOL.$(bld_trg)) \
|
---|
136 | $($(target)_$(source)_$(type)TOOL) \
|
---|
137 | $($(target)_$(source)_TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
138 | $($(target)_$(source)_TOOL.$(bld_trg)) \
|
---|
139 | $($(target)_$(source)_TOOL) \
|
---|
140 | $($(source)_$(type)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
141 | $($(source)_$(type)TOOL.$(bld_trg)) \
|
---|
142 | $($(source)_$(type)TOOL) \
|
---|
143 | $($(source)_TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
144 | $($(source)_TOOL.$(bld_trg)) \
|
---|
145 | $($(source)_TOOL) \
|
---|
146 | $($(target)_$(type)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
147 | $($(target)_$(type)TOOL.$(bld_trg)) \
|
---|
148 | $($(target)_$(type)TOOL) \
|
---|
149 | $($(target)_TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
150 | $($(target)_TOOL.$(bld_trg)) \
|
---|
151 | $($(target)_TOOL) \
|
---|
152 | $($(type)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
153 | $($(type)TOOL.$(bld_trg)) \
|
---|
154 | $($(type)TOOL) \
|
---|
155 | $(TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
156 | $(TOOL.$(bld_trg)) \
|
---|
157 | $(TOOL) ))
|
---|
158 |
|
---|
159 | ## Figure out the tool for a target.
|
---|
160 | # @param target normalized target.
|
---|
161 | # @param source tooltype.
|
---|
162 | # @param bld_trg build target.
|
---|
163 | # @param bld_trg_arch build target architecture.
|
---|
164 | _TARGET_TOOL = $(strip $(firstword \
|
---|
165 | $($(target)_$(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
166 | $($(target)_$(source)TOOL.$(bld_trg)) \
|
---|
167 | $($(target)_$(source)TOOL) \
|
---|
168 | $($(target)_TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
169 | $($(target)_TOOL.$(bld_trg)) \
|
---|
170 | $($(target)_TOOL) \
|
---|
171 | $($(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
172 | $($(source)TOOL.$(bld_trg)) \
|
---|
173 | $($(source)TOOL) \
|
---|
174 | $(TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
175 | $(TOOL.$(bld_trg)) \
|
---|
176 | $(TOOL) \
|
---|
177 | ))
|
---|
178 |
|
---|
179 | ## Removes the drive letter from a path (if it has one)
|
---|
180 | # @param $1 the path
|
---|
181 | no-drive=$(word $(words $(subst :, ,$(1))),$(subst :, ,$(1)))
|
---|
182 |
|
---|
183 | ## Removes the root slash from a path (if it has one)
|
---|
184 | # @param $1 the path
|
---|
185 | no-root-slash=$(patsubst /%,%,$(1))
|
---|
186 |
|
---|
187 | ## Figure out where to put object files.
|
---|
188 | # @param $1 source file
|
---|
189 | # @param $2 normalized main target
|
---|
190 | # @remark There are two major hacks here:
|
---|
191 | # 1. Source files in the output directory are translated into a gen/ subdir.
|
---|
192 | # 2. Catch anyone specifying $(PATH_SUB_CURRENT)/sourcefile.c.
|
---|
193 | # @remark obsoleted by kBuild helpers in kmk. Only required for gmake compatbility.
|
---|
194 | _OBJECT_BASE = $(PATH_TARGET)/$(2)/$(call no-root-slash,$(call no-drive,$(basename \
|
---|
195 | $(patsubst $(PATH_ROOT)/%,%,$(patsubst $(PATH_SUB_CURRENT)/%,%,$(patsubst $(PATH_TARGET)/$(2)/%,gen/%,$(1)))))))
|
---|
196 |
|
---|
197 | ## Figure out where to put object files.
|
---|
198 | # @param $1 real target name.
|
---|
199 | # @param $2 normalized main target
|
---|
200 | _TARGET_BASE = $(PATH_TARGET)/$(2)/$(call no-root-slash,$(call no-drive,$(basename $(1))))
|
---|
201 |
|
---|
202 |
|
---|
203 | ## Figure out the actual name of an installed file.
|
---|
204 | # @param $1 The file to install.
|
---|
205 | # @param $2 The target name.
|
---|
206 | # @param $3 The _INST value (can be empty).
|
---|
207 | # @param $4 The default directory to use when $3 is empty.
|
---|
208 | _INSTALL_FILE = $(patsubst %/,%/$(notdir $(1)),$(if $(3),$(PATH_INS)/$(3),$(4)/))
|
---|
209 |
|
---|
210 |
|
---|
211 | #
|
---|
212 | # Check syntax which leads to weird syntax errors.
|
---|
213 | #
|
---|
214 |
|
---|
215 | ## Check
|
---|
216 | # @param $(target) Target name.
|
---|
217 | define def_check_target
|
---|
218 | ifneq ("$($(target)_TEMPLATE)","$(strip $($(target)_TEMPLATE))")
|
---|
219 | $$(error $(target) have an incorrect template name. Remove any tabs!)
|
---|
220 | endif
|
---|
221 | endef
|
---|
222 | $(foreach target, $(ALL_TARGETS),$(eval $(def_check_target)))
|
---|
223 |
|
---|
224 |
|
---|
225 | #
|
---|
226 | # Include templates
|
---|
227 | #
|
---|
228 | _TEMPLATES := $(TEMPLATE)
|
---|
229 | define def_templates
|
---|
230 | ifdef $(target)_TEMPLATE
|
---|
231 | _TEMPLATES += $($(target)_TEMPLATE)
|
---|
232 | endif
|
---|
233 | endef
|
---|
234 | $(foreach target, $(ALL_TARGETS), $(eval $(def_templates)))
|
---|
235 | _TEMPLATES := $(sort $(_TEMPLATES))
|
---|
236 | # $ (warning dbg: _TEMPLATES=$(_TEMPLATES))
|
---|
237 |
|
---|
238 | define def_templates_include
|
---|
239 | ifndef TEMPLATE_$(template)
|
---|
240 | include $(firstword $(foreach path, $(TEMPLATE_PATHS) $(PATH_KBUILD)/templates/, $(wildcard $(path)/$(template).kmk)))
|
---|
241 | endif
|
---|
242 | endef
|
---|
243 | $(foreach template, $(_TEMPLATES), $(eval $(def_templates)))
|
---|
244 |
|
---|
245 |
|
---|
246 | #
|
---|
247 | # Template Inheritance.
|
---|
248 | #
|
---|
249 | define def_template_extends_prop
|
---|
250 | ifndef TEMPLATE_$(template)_$(prop)
|
---|
251 | ifdef TEMPLATE_$(parent)_$(prop)
|
---|
252 | TEMPLATE_$(template)_$(prop) = $$(TEMPLATE_$(parent)_$(prop))
|
---|
253 | endif
|
---|
254 | endif
|
---|
255 | endef
|
---|
256 |
|
---|
257 |
|
---|
258 | define def_template_extends
|
---|
259 | ifdef TEMPLATE_$(template)_EXTENDS
|
---|
260 | ifndef TEMPLATE_$(template)_EXTENDS_STATUS_
|
---|
261 | TEMPLATE_$(template)_EXTENDS_STATUS_ := 0
|
---|
262 | parent := $(strip $(TEMPLATE_$(template)_EXTENDS))
|
---|
263 |
|
---|
264 | # recursivly process the parent if it's inherting from somebody too.
|
---|
265 | ifdef TEMPLATE_$(parent)_EXTENDS
|
---|
266 | ifneq ($(TEMPLATE_$(parent)_EXTENDS_STATUS_),42)
|
---|
267 | # foreach will create 'template' in a new variable context hiding our current variable.
|
---|
268 | $(foreach template, $(parent), $(eval $(value def_template_extends)))
|
---|
269 | parent := $(strip $(TEMPLATE_$(template)_EXTENDS))
|
---|
270 | endif
|
---|
271 | endif
|
---|
272 |
|
---|
273 | # inherit properties.
|
---|
274 | $(foreach prop, $(PROPS_SINGLE) $(PROPS_ACCUMULATE_R) $(PROPS_ACCUMULATE_L) $(PROPS_DEFERRED)\
|
---|
275 | $(addsuffix .$(BUILD_TARGET), $(PROPS_SINGLE) $(PROPS_ACCUMULATE_L) $(PROPS_ACCUMULATE_R) $(PROPS_DEFERRED))\
|
---|
276 | $(addsuffix .$(BUILD_TARGET).$(BUILD_TARGET_ARCH), $(PROPS_SINGLE) $(PROPS_ACCUMULATE_L) $(PROPS_ACCUMULATE_R) $(PROPS_DEFERRED))\
|
---|
277 | $(addsuffix .$(BUILD_TARGET_ARCH), $(PROPS_SINGLE) $(PROPS_ACCUMULATE_L) $(PROPS_ACCUMULATE_R) $(PROPS_DEFERRED))\
|
---|
278 | $(addsuffix .$(BUILD_TARGET_CPU), $(PROPS_SINGLE) $(PROPS_ACCUMULATE_L) $(PROPS_ACCUMULATE_R) $(PROPS_DEFERRED))\
|
---|
279 | $(addsuffix .$(BUILD_TYPE), $(PROPS_SINGLE) $(PROPS_ACCUMULATE_L) $(PROPS_ACCUMULATE_R) $(PROPS_DEFERRED))\
|
---|
280 | ,$(eval $(def_template_extends_prop))) # exploits the 2 evaluation, so no value!
|
---|
281 |
|
---|
282 | TEMPLATE_$(template)_EXTENDS_STATUS_ := 42
|
---|
283 | else
|
---|
284 | # protect against inheritance loops.
|
---|
285 | ifneq ($(TEMPLATE_$(template)_EXTENDS_STATUS_),42)
|
---|
286 | $(error kBuild: inheritance loop! template=$(template))
|
---|
287 | endif
|
---|
288 | endif
|
---|
289 | endif
|
---|
290 | endef
|
---|
291 |
|
---|
292 | # $ (foreach template, $(_TEMPLATES), $(if TEMPLATE_$(template)_EXTENDS, $(eval $(value def_template_extends))))
|
---|
293 | $(foreach template, $(_TEMPLATES), $(eval $(value def_template_extends)))
|
---|
294 |
|
---|
295 |
|
---|
296 | #
|
---|
297 | # Common Inheritance
|
---|
298 | #
|
---|
299 |
|
---|
300 | ## Inherit one template property in a non-accumulative manner.
|
---|
301 | # @param $(prop) Property name
|
---|
302 | # @param $(target) Target name
|
---|
303 | # @todo fix the precedence order for some properties.
|
---|
304 | define def_inherit_template_one
|
---|
305 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
|
---|
306 | ifndef $(target)_$(prop)
|
---|
307 | $(target)_$(prop) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
---|
308 | #$ (warning dbgtarget: $(target)_$(prop):='$(value $(target)_$(prop))' TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
---|
309 | endif
|
---|
310 | endif
|
---|
311 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)
|
---|
312 | ifndef $(target)_$(prop).$(bld_trg)
|
---|
313 | #$ (warning dbgsource: $(target)_$(prop).$(bld_trg)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
---|
314 | $(target)_$(prop).$(bld_trg) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
---|
315 | endif
|
---|
316 | endif
|
---|
317 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch)
|
---|
318 | ifndef $(target)_$(prop).$(bld_trg).$(bld_trg_arch)
|
---|
319 | #$ (warning dbgsource: $(target)_$(prop).$(bld_trg).$(bld_trg_arch)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch))
|
---|
320 | $(target)_$(prop).$(bld_trg).$(bld_trg_arch) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch))
|
---|
321 | endif
|
---|
322 | endif
|
---|
323 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)
|
---|
324 | ifndef $(target)_$(prop).$(bld_trg_arch)
|
---|
325 | #$ (warning dbgsource: $(target)_$(prop).$(bld_trg_arch)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
|
---|
326 | $(target)_$(prop).$(bld_trg_arch) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
|
---|
327 | endif
|
---|
328 | endif
|
---|
329 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)
|
---|
330 | ifndef $(target)_$(prop).$(bld_trg_cpu)
|
---|
331 | #$ (warning dbgsource: $(target)_$(prop).$(bld_trg_cpu)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
|
---|
332 | $(target)_$(prop).$(bld_trg_cpu) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
|
---|
333 | endif
|
---|
334 | endif
|
---|
335 | endef
|
---|
336 |
|
---|
337 | ## Inherit one template property in a non-accumulative manner, deferred expansion.
|
---|
338 | # @param 1: $(prop) Property name
|
---|
339 | # @param 2: $(target) Target name
|
---|
340 | # @todo fix the precedence order for some properties.
|
---|
341 | # @remark this define relies on double evaluation
|
---|
342 | define def_inherit_template_one_deferred
|
---|
343 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
|
---|
344 | ifndef $(target)_$(prop)
|
---|
345 | $(target)_$(prop) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
---|
346 | #$ (warning dbgtarget: $(target)_$(prop):='$(value $(target)_$(prop))' TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
---|
347 | endif
|
---|
348 | endif
|
---|
349 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)
|
---|
350 | ifndef $(target)_$(prop).$(bld_trg)
|
---|
351 | #$ (warning dbgsource: $(target)_$(prop).$(bld_trg)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
---|
352 | $(target)_$(prop).$(bld_trg) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
---|
353 | endif
|
---|
354 | endif
|
---|
355 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch)
|
---|
356 | ifndef $(target)_$(prop).$(bld_trg).$(bld_trg_arch)
|
---|
357 | #$ (warning dbgsource: $(target)_$(prop).$(bld_trg).$(bld_trg_arch)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch))
|
---|
358 | $(target)_$(prop).$(bld_trg).$(bld_trg_arch) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch))
|
---|
359 | endif
|
---|
360 | endif
|
---|
361 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)
|
---|
362 | ifndef $(target)_$(prop).$(bld_trg_arch)
|
---|
363 | #$ (warning dbgsource: $(target)_$(prop).$(bld_trg_arch)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
|
---|
364 | $(target)_$(prop).$(bld_trg_arch) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
|
---|
365 | endif
|
---|
366 | endif
|
---|
367 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)
|
---|
368 | ifndef $(target)_$(prop).$(bld_trg_cpu)
|
---|
369 | #$ (warning dbgsource: $(target)_$(prop).$(bld_trg_cpu)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
|
---|
370 | $(target)_$(prop).$(bld_trg_cpu) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
|
---|
371 | endif
|
---|
372 | endif
|
---|
373 | endef
|
---|
374 |
|
---|
375 | ## Inherit one acculumlative template property where the 'most significant' items are at the left end.
|
---|
376 | # @param $(prop) Property name
|
---|
377 | # @param $(target) Target name
|
---|
378 | define def_inherit_template_one_accumulate_l
|
---|
379 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
|
---|
380 | #$ (warning dbgtype: TEMPLATE_$($(target)_TEMPLATE)_$(prop) $(target)_$(prop)=$($(target)_$(prop)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop)))
|
---|
381 | $(target)_$(prop) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
---|
382 | #$ (warning dbgtype: $(target)_$(prop)=$($(target)_$(prop)))
|
---|
383 | endif
|
---|
384 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE)
|
---|
385 | #$ (warning dbg4: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE))
|
---|
386 | $(target)_$(prop).$(BUILD_TYPE) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE))
|
---|
387 | endif
|
---|
388 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)
|
---|
389 | #$ (warning dbg5: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
---|
390 | $(target)_$(prop).$(bld_trg) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
---|
391 | endif
|
---|
392 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch)
|
---|
393 | #$ (warning dbg4: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch))
|
---|
394 | $(target)_$(prop).$(bld_trg).$(bld_trg_arch) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch))
|
---|
395 | endif
|
---|
396 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)
|
---|
397 | #$ (warning dbg5: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
|
---|
398 | $(target)_$(prop).$(bld_trg_cpu) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
|
---|
399 | endif
|
---|
400 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)
|
---|
401 | #$ (warning dbg6: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
|
---|
402 | $(target)_$(prop).$(bld_trg_arch) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
|
---|
403 | endif
|
---|
404 | endef
|
---|
405 |
|
---|
406 | ## Inherit one acculumlative template property where the 'most significant' items are at the right end.
|
---|
407 | # First pass, $(value) referenced.
|
---|
408 | # @param $(prop) Property name
|
---|
409 | # @param $(target) Target name
|
---|
410 | define def_inherit_template_one_accumulate_r1
|
---|
411 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
|
---|
412 | $(eval _$(target)_$(prop)_R = $(value $(target)_$(prop)))
|
---|
413 | endif
|
---|
414 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE)
|
---|
415 | $(eval _$(target)_$(prop).$(BUILD_TYPE)_R = $(value $(target)_$(prop).$(BUILD_TYPE)))
|
---|
416 | endif
|
---|
417 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)
|
---|
418 | $(eval _$(target)_$(prop).$(bld_trg)_R = $(value $(target)_$(prop).$(bld_trg)))
|
---|
419 | endif
|
---|
420 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch)
|
---|
421 | $(eval _$(target)_$(prop).$(bld_trg).$(bld_trg_arch)_R = $(value $(target)_$(prop).$(bld_trg).$(bld_trg_arch)))
|
---|
422 | endif
|
---|
423 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)
|
---|
424 | $(eval _$(target)_$(prop).$(bld_trg_cpu)_R = $(value $(target)_$(prop).$(bld_trg_cpu)))
|
---|
425 | endif
|
---|
426 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)
|
---|
427 | $(eval _$(target)_$(prop).$(bld_trg_arch)_R = $(value $(target)_$(prop).$(bld_trg_arch)))
|
---|
428 | endif
|
---|
429 | endef
|
---|
430 |
|
---|
431 | ## Inherit one template property the other way around.
|
---|
432 | # Second pass, not $(value) referenced.
|
---|
433 | # @param $(prop) Property name
|
---|
434 | # @param $(target) Target name
|
---|
435 | define def_inherit_template_one_accumulate_r2
|
---|
436 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
|
---|
437 | $(target)_$(prop) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop)) $$(_$(target)_$(prop)_R)
|
---|
438 | endif
|
---|
439 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE)
|
---|
440 | $(target)_$(prop).$(BUILD_TYPE) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE)) $$(_$(target)_$(prop).$(BUILD_TYPE)_R)
|
---|
441 | endif
|
---|
442 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)
|
---|
443 | $(target)_$(prop).$(bld_trg) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)) $$(_$(target)_$(prop).$(bld_trg)_R)
|
---|
444 | endif
|
---|
445 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch)
|
---|
446 | $(target)_$(prop).$(bld_trg).$(bld_trg_arch) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch)) $$(_$(target)_$(prop).$(bld_trg).$(bld_trg_arch)_R)
|
---|
447 | endif
|
---|
448 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)
|
---|
449 | $(target)_$(prop).$(bld_trg_cpu) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)) $$(_$(target)_$(prop).$(bld_trg_cpu)_R)
|
---|
450 | endif
|
---|
451 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)
|
---|
452 | $(target)_$(prop).$(bld_trg_arch) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)) $$(_$(target)_$(prop).$(bld_trg_arch)_R)
|
---|
453 | endif
|
---|
454 | endef
|
---|
455 |
|
---|
456 |
|
---|
457 | ## Inherit template properties for on target.
|
---|
458 | # @param $(target) Target name.
|
---|
459 | define def_inherit_template
|
---|
460 | # Inherit any default template.
|
---|
461 | ifdef TEMPLATE
|
---|
462 | ifeq ($($(target)_TEMPLATE),)
|
---|
463 | $(eval $(target)_TEMPLATE:=$(TEMPLATE))
|
---|
464 | endif
|
---|
465 | endif
|
---|
466 | # Expand the template if specified.
|
---|
467 | ifneq ($($(target)_TEMPLATE),)
|
---|
468 | $(foreach prop,$(PROPS_SINGLE),$(eval $(value def_inherit_template_one)))
|
---|
469 | $(foreach prop,$(PROPS_DEFERRED),$(eval $(def_inherit_template_one_deferred))) # exploits the 2 evaluation, so no value!
|
---|
470 | $(foreach prop,$(PROPS_ACCUMULATE_L),$(eval $(def_inherit_template_one_accumulate_l))) # += works fine (better) without value.
|
---|
471 | $(foreach prop,$(PROPS_ACCUMULATE_R),\
|
---|
472 | $(eval $(value def_inherit_template_one_accumulate_r1))\
|
---|
473 | $(eval $(def_inherit_template_one_accumulate_r2))\
|
---|
474 | ) # This is a hack! (but it appears to work)
|
---|
475 | endif
|
---|
476 | endef
|
---|
477 |
|
---|
478 | # Inherit template properties
|
---|
479 | bld_trg := $(BUILD_TARGET)
|
---|
480 | bld_trg_arch := $(BUILD_TARGET_ARCH)
|
---|
481 | bld_trg_cpu := $(BUILD_TARGET_CPU)
|
---|
482 | $(foreach target, $(_ALL_BUILD_TARGET_TARGETS),$(eval $(value def_inherit_template)))
|
---|
483 |
|
---|
484 | bld_trg := $(BUILD_PLATFORM)
|
---|
485 | bld_trg_arch := $(BUILD_PLATFORM_ARCH)
|
---|
486 | bld_trg_cpu := $(BUILD_PLATFORM_CPU)
|
---|
487 | $(foreach target, $(_ALL_BUILD_PLATFORM_TARGETS),$(eval $(value def_inherit_template)))
|
---|
488 |
|
---|
489 |
|
---|
490 | #
|
---|
491 | # Include tools & sdks
|
---|
492 | #
|
---|
493 | _TOOLS := $(TOOL.$(BUILD_TARGET)) $(TOOL.$(BUILD_TARGET_ARCH)) $(TOOL.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
494 | $(TOOL.$(BUILD_PLATFORM)) $(TOOL.$(BUILD_PLATFORM_ARCH)) $(TOOL.$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)) \
|
---|
495 | $(TOOL)
|
---|
496 | _SDKS := $(SDKS.$(BUILD_TARGET)) $(SDKS.$(BUILD_TARGET_ARCH)) $(SDKS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
497 | $(SDKS.$(BUILD_PLATFORM)) $(SDKS.$(BUILD_PLATFORM_ARCH)) $(SDKS.$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)) \
|
---|
498 | $(SDKS.$(BUILD_TYPE)) \
|
---|
499 | $(SDKS)
|
---|
500 | define def_tools_sdks_target_source
|
---|
501 | $(eval _TOOLS += $(foreach prop, $(PROPS_TOOLS), \
|
---|
502 | $($(source)_$(prop).$(_bld_trg)) \
|
---|
503 | $($(target)_$(source)_$(prop).$(_bld_trg)) \
|
---|
504 | $($(source)_$(prop).$(_bld_trg).$(_bld_trg_arch)) \
|
---|
505 | $($(target)_$(source)_$(prop).$(_bld_trg).$(_bld_trg_arch)) \
|
---|
506 | $($(source)_$(prop).$(_bld_trg_arch)) \
|
---|
507 | $($(target)_$(source)_$(prop).$(_bld_trg_arch)) \
|
---|
508 | $($(source)_$(prop)) \
|
---|
509 | $($(target)_$(source)_$(prop))))
|
---|
510 | $(eval _SDKS += \
|
---|
511 | $($(source)_SDKS.$(_bld_trg)) \
|
---|
512 | $($(target)_$(source)_SDKS.$(_bld_trg)) \
|
---|
513 | $($(source)_SDKS.$(_bld_trg).$(_bld_trg_arch)) \
|
---|
514 | $($(target)_$(source)_SDKS.$(_bld_trg).$(_bld_trg_arch)) \
|
---|
515 | $($(source)_SDKS.$(_bld_trg_arch)) \
|
---|
516 | $($(target)_$(source)_SDKS.$(_bld_trg_arch)) \
|
---|
517 | $($(source)_SDKS.$(BUILD_TYPE)) \
|
---|
518 | $($(target)_$(source)_SDKS.$(BUILD_TYPE)) \
|
---|
519 | $($(source)_SDKS) \
|
---|
520 | $($(target)_$(source)_SDKS))
|
---|
521 | endef
|
---|
522 |
|
---|
523 | define def_tools_sdks_target
|
---|
524 | _bld_trg := $(firstword $($(target)_BLD_TRG) $(bld_trg))
|
---|
525 | _bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(bld_trg_arch))
|
---|
526 | _bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(bld_trg_cpu))
|
---|
527 |
|
---|
528 | $(eval _TOOLS += $(foreach prop, $(PROPS_TOOLS), \
|
---|
529 | $($(target)_$(prop).$(_bld_trg)) \
|
---|
530 | $($(target)_$(prop).$(_bld_trg_arch)) \
|
---|
531 | $($(target)_$(prop).$(_bld_trg).$(_bld_trg_arch)) \
|
---|
532 | $($(target)_$(prop))))
|
---|
533 | $(eval _SDKS += \
|
---|
534 | $($(target)_SDKS.$(_bld_trg)) \
|
---|
535 | $($(target)_SDKS.$(_bld_trg_arch)) \
|
---|
536 | $($(target)_SDKS.$(_bld_trg).$(_bld_trg_arch)) \
|
---|
537 | $($(target)_SDKS))
|
---|
538 | $(foreach source, \
|
---|
539 | $($(target)_SOURCES.$(_bld_trg)) \
|
---|
540 | $($(target)_SOURCES.$(_bld_trg_arch)) \
|
---|
541 | $($(target)_SOURCES.$(_bld_trg).$(_bld_trg_arch)) \
|
---|
542 | $($(target)_SOURCES.$(_bld_trg_cpu)) \
|
---|
543 | $($(target)_SOURCES.$(BUILD_TYPE)) \
|
---|
544 | $($(target)_SOURCES) \
|
---|
545 | , $(eval $(value def_tools_sdks_target_source)))
|
---|
546 | endef
|
---|
547 |
|
---|
548 | define def_tools_srcname_target
|
---|
549 | _bld_trg := $(firstword $($(target)_BLD_TRG) $(bld_trg))
|
---|
550 | _bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(bld_trg_arch))
|
---|
551 | _bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(bld_trg_cpu))
|
---|
552 |
|
---|
553 | $(foreach source, $(notdir\
|
---|
554 | $($(target)_SOURCES.$(_bld_trg)) \
|
---|
555 | $($(target)_SOURCES.$(_bld_trg_arch)) \
|
---|
556 | $($(target)_SOURCES.$(_bld_trg).$(_bld_trg_arch)) \
|
---|
557 | $($(target)_SOURCES.$(_bld_trg_cpu)) \
|
---|
558 | $($(target)_SOURCES.$(BUILD_TYPE)) \
|
---|
559 | $($(target)_SOURCES) \
|
---|
560 | ), $(eval $(value def_tools_sdks_target_source)))
|
---|
561 | endef
|
---|
562 |
|
---|
563 | bld_trg := $(BUILD_TARGET)
|
---|
564 | bld_trg_arch := $(BUILD_TARGET_ARCH)
|
---|
565 | bld_trg_cpu := $(BUILD_TARGET_CPU)
|
---|
566 | $(foreach target, $(_ALL_BUILD_TARGET_TARGETS), $(eval $(value def_tools_sdks_target)))
|
---|
567 | $(foreach target, $(_ALL_SRCNAME_TARGETS), $(eval $(value def_tools_srcname_target)))
|
---|
568 |
|
---|
569 | bld_trg := $(BUILD_PLATFORM)
|
---|
570 | bld_trg_arch := $(BUILD_PLATFORM_ARCH)
|
---|
571 | bld_trg_cpu := $(BUILD_PLATFORM_CPU)
|
---|
572 | $(foreach target, $(_ALL_BUILD_PLATFORM_TARGETS), $(eval $(value def_tools_sdks_target)))
|
---|
573 |
|
---|
574 |
|
---|
575 | # include TOOLS
|
---|
576 | define def_tools_include
|
---|
577 | ifndef TOOL_$(tool)
|
---|
578 | TOOL_$(tool)_KMK_FILE := $(firstword $(foreach path, $(TOOL_PATHS) $(PATH_KBUILD)/tools, $(wildcard $(path)/$(tool).kmk)))
|
---|
579 | ifeq ($(TOOL_$(tool)_KMK_FILE),)
|
---|
580 | $(error kBuild: Cannot find include file for the tool '$(tool)'! Searched: $(TOOL_PATHS) $(PATH_KBUILD)/tools)
|
---|
581 | endif
|
---|
582 | include $(TOOL_$(tool)_KMK_FILE)
|
---|
583 | endif
|
---|
584 | endef
|
---|
585 |
|
---|
586 | _TOOLS := $(sort $(_TOOLS))
|
---|
587 | $(foreach tool, $(_TOOLS), $(eval $(value def_tools_include)))
|
---|
588 |
|
---|
589 |
|
---|
590 | # include SDKS
|
---|
591 | define def_sdks_include_one
|
---|
592 | ifndef SDK_$(sdk)
|
---|
593 | SDK_$(sdk)_KMK_FILE := $(firstword $(foreach path, $(SDK_PATHS) $(PATH_KBUILD)/sdks, $(wildcard $(path)/$(sdk).kmk)))
|
---|
594 | ifeq ($(SDK_$(sdk)_KMK_FILE),)
|
---|
595 | $(error kBuild: Cannot find include file for the SDK '$(sdk)'! Searched: $(SDK_PATHS) $(PATH_KBUILD)/sdks)
|
---|
596 | endif
|
---|
597 | include $(SDK_$(sdk)_KMK_FILE)
|
---|
598 | endif
|
---|
599 | endef
|
---|
600 |
|
---|
601 | _SDKS := $(sort $(_SDKS))
|
---|
602 | $(foreach sdk, $(_SDKS), $(eval $(value def_sdks_include_one)))
|
---|
603 |
|
---|
604 |
|
---|
605 |
|
---|
606 | ## @page pg_fetches Fetching Tools, Sources and Similar.
|
---|
607 | #
|
---|
608 | # The targets listed in the the FETCHES target list have the following attributes:
|
---|
609 | # SOURCES
|
---|
610 | # INST
|
---|
611 | # FETCHTOOL
|
---|
612 | # FETCHFLAGS
|
---|
613 | # FETCHDIR
|
---|
614 | # UNPACKTOOL
|
---|
615 | # UNPACKFLAGS
|
---|
616 | #
|
---|
617 | # As usual the target name is an alias for 'creating' the target. Other
|
---|
618 | # aliases are:
|
---|
619 | # pass_fetches
|
---|
620 | # fetch
|
---|
621 | # unfetch
|
---|
622 | # download
|
---|
623 | # unpack
|
---|
624 | #
|
---|
625 | # @remark
|
---|
626 | #
|
---|
627 | # This is a little bit complex because we must guarantee that if a source file
|
---|
628 | # changes only sligtly we must refetch it and to a proper unpacking of it. It
|
---|
629 | # is also a desire that fetched archives and unpacked files can be deleted to
|
---|
630 | # save space.
|
---|
631 | #
|
---|
632 | # Thus, we must be able to cleanup what we've unpacked should any of the
|
---|
633 | # sources be removed. We do this by maintaining a file listing the files
|
---|
634 | # and directories that was unpacked. This operation is named 'unfetch'.
|
---|
635 | #
|
---|
636 | # We make use of the SIZE and MD5 attributes for each of the sources to
|
---|
637 | # create a digest that is stored in the primary target file. Subsequent
|
---|
638 | # runswill compare their digest with it to decide if a refetch is required.
|
---|
639 | # When a refetch is found necessary, an 'unfetch' is performed first to
|
---|
640 | # clean out old files and directores. Note even changes in source order
|
---|
641 | # will cause a refetch due to the way the digest is constructed and
|
---|
642 | # evaluated.
|
---|
643 | #
|
---|
644 | # By not depending directly on the archives (nor on any unpacked files)
|
---|
645 | # but on a goal made up from the archive name, size and md5, we allow
|
---|
646 | # the user to delete the archives. Naturally, this means we'll have to
|
---|
647 | # check and fetch missing archives before attempting to unpack them.
|
---|
648 | #
|
---|
649 | # @remark
|
---|
650 | #
|
---|
651 | # This feature will *NOT* work correctly with vanilla GNU make becuase
|
---|
652 | # it makes use of includedep to avoid too many unnecessary files.
|
---|
653 | #
|
---|
654 | # @todo
|
---|
655 | # 1. Port md5sum or some equivalent tool and include it in kBuild.
|
---|
656 | # 2. Download corruption / continuation.
|
---|
657 | # 3. It's quite possible that there is one too many indirect dependency now...
|
---|
658 | #
|
---|
659 |
|
---|
660 | ## @todo move this!
|
---|
661 | MD5SUM := md5sum
|
---|
662 |
|
---|
663 | ## generates the fetch rule
|
---|
664 | define def_fetch_src_fetch_rule
|
---|
665 | # Indirect goal for downloading something.
|
---|
666 | .PRECIOUS: $(out)
|
---|
667 | $(out) $($(target)_$(srcname)_FETCH_OUTPUT_): | $($(target)_$(srcname)_FETCH_DEPORD_)
|
---|
668 | @$$(ECHO) Downloading $(source)...
|
---|
669 | ## @todo do fancy stuff like download continuation.
|
---|
670 | $$(RM) -f $(out) $(out).md5
|
---|
671 | $($(target)_$(srcname)_FETCH_CMDS_)
|
---|
672 | @$(if $(md5),$$(APPEND) $(out).md5 "$(md5) *$(out)")
|
---|
673 | $(if $(md5),$$(MD5SUM) -c $(out).md5)
|
---|
674 |
|
---|
675 |
|
---|
676 |
|
---|
677 | # Intermediate goal for making sure the md5 and size matches. it will (re) fetch the archive if necessary.
|
---|
678 | $(out).checked_$(md5)_$(size): $($(target)_$(srcname)_FETCH_DEPEND_) | $($(target)_$(srcname)_FETCH_DEPORD_)
|
---|
679 | @$$(ECHO) Checking $(out) ($(source))...
|
---|
680 | $$(RM) -f $$@ $(out).md5
|
---|
681 | @# creates the .md5 we pass to md5sum.
|
---|
682 | @$(if $(md5),$$(APPEND) $(out).md5 "$(md5) *$(out)")
|
---|
683 | @# (re)fetch the file if it doesn't exist or if it doesn't matches the md5.
|
---|
684 | ## @todo do fancy stuff like download continuation.
|
---|
685 | ( test -f $(out) && $(if $(md5),$$(MD5SUM) -c $(out).md5, true) ) \
|
---|
686 | || ( $$(RM_EXT) -f $(out) \
|
---|
687 | && $$(MAKE) $(out) -f $(MAKEFILE) )
|
---|
688 | @$$(APPEND) $$@
|
---|
689 |
|
---|
690 | _TARGET_$(target)_FETCHED += $(out) $(out).checked_$(md5)_$(size)
|
---|
691 |
|
---|
692 | # Just a little precaution.
|
---|
693 | .NOTPARALLEL: $(out) $(out).checked_$(md5)_$(size)
|
---|
694 |
|
---|
695 | endef
|
---|
696 |
|
---|
697 | ## generates the unpack rule
|
---|
698 | define def_fetch_src_unpack_rule
|
---|
699 | # This is the unpack rule. it has an order-only dependency on the download check.
|
---|
700 | $(out) $($(target)_$(srcname)_UNPACK_OUTPUT_): $($(target)_$(srcname)_UNPACK_DEPEND_) \
|
---|
701 | | $($(target)_$(srcname)_UNPACK_DEPORD_) $(archive).checked_$(md5)_$(size)
|
---|
702 | @$$(ECHO) Unpacking $(source) into $(inst)...
|
---|
703 | $$(RM) -f $(out)
|
---|
704 | @# if the source archive doesn't exist fetch it (can have been deleted to save space).
|
---|
705 | test -f $(archive) \
|
---|
706 | || ( $$(RM_EXT) -f $(archive).checked_$(md5)_$(size) \
|
---|
707 | && $$(MAKE) $(archive).checked_$(md5)_$(size) -f $(MAKEFILE) )
|
---|
708 | $($(target)_$(srcname)_UNPACK_CMDS_)
|
---|
709 | @$$(APPEND) $(out) $(notdir $(archive).checked_$(md5)_$(size))
|
---|
710 | @$$(APPEND) $(out) $(notdir $(out))
|
---|
711 |
|
---|
712 | $(eval _TARGET_$(target)_UNPACKED += $(out))
|
---|
713 | _TARGET_$(target)_DIGEST := $(_TARGET_$(target)_DIGEST)-$(srcname)_$(md5)_$(size)
|
---|
714 |
|
---|
715 | .NOTPARALLEL: $(out)
|
---|
716 |
|
---|
717 | endef
|
---|
718 |
|
---|
719 | ## Processes a fetch source
|
---|
720 | #
|
---|
721 | define def_fetch_src
|
---|
722 | #$ (warning dbg: def_fetch_src: source='$(source)' target='$(target)')
|
---|
723 |
|
---|
724 | # common
|
---|
725 | srcname := $(notdir $(source))
|
---|
726 | inst := $(firstword \
|
---|
727 | $($(target)_$(source)_INST)\
|
---|
728 | $($(target)_$(srcname)_INST)\
|
---|
729 | $($(source)_INST)\
|
---|
730 | $($(srcname)_INST)\
|
---|
731 | $($(target)_INST)\
|
---|
732 | )
|
---|
733 | ifneq ($(patsubst %/,ok,$(inst)),ok)
|
---|
734 | $(error kBuild: Bad or missing INST property for source '$(source)' in target '$(target)': $(inst))
|
---|
735 | endif
|
---|
736 | INSTARGET_$(target)_$(srcname) := $(inst)
|
---|
737 | fetchdir := $(firstword \
|
---|
738 | $($(target)_$(source)_FETCHDIR)\
|
---|
739 | $($(target)_$(srcname)_FETCHDIR)\
|
---|
740 | $($(source)_FETCHDIR)\
|
---|
741 | $($(srcname)_FETCHDIR)\
|
---|
742 | $($(target)_FETCHDIR)\
|
---|
743 | $(FETCHDIR)\
|
---|
744 | $(PATH_TARGET)\
|
---|
745 | )
|
---|
746 | deps := \
|
---|
747 | $($(target)_$(source)_DEPS)\
|
---|
748 | $($(target)_$(srcname)_DEPS)\
|
---|
749 | $($(source)_DEPS)\
|
---|
750 | $($(srcname)_DEPS)\
|
---|
751 | $($(target)_DEPS)
|
---|
752 | md5 := $(firstword \
|
---|
753 | $($(target)_$(source)_MD5)\
|
---|
754 | $($(target)_$(srcname)_MD5)\
|
---|
755 | $($(source)_MD5)\
|
---|
756 | $($(srcname)_MD5)\
|
---|
757 | $($(target)_MD5)\
|
---|
758 | )
|
---|
759 | size := $(firstword \
|
---|
760 | $($(target)_$(source)_SIZE)\
|
---|
761 | $($(target)_$(srcname)_SIZE)\
|
---|
762 | $($(source)_SIZE)\
|
---|
763 | $($(srcname)_SIZE)\
|
---|
764 | $($(target)_SIZE)\
|
---|
765 | )
|
---|
766 | dep := # not legal for fetch and unpack tools
|
---|
767 |
|
---|
768 |
|
---|
769 | #
|
---|
770 | # The fetching.
|
---|
771 | #
|
---|
772 | out := $(fetchdir)/$(srcname)
|
---|
773 | archive := $(out)
|
---|
774 | TARGET_$(target)_$(srcname) := $(out)
|
---|
775 | dirdep := $(call DIRDEP,$(fetchdir))
|
---|
776 | tool := $(firstword \
|
---|
777 | $($(target)_$(source)_FETCHTOOL)\
|
---|
778 | $($(target)_$(srcname)_FETCHTOOL)\
|
---|
779 | $($(target)_$(source)_TOOL)\
|
---|
780 | $($(target)_$(srcname)_TOOL)\
|
---|
781 | $($(source)_FETCHTOOL)\
|
---|
782 | $($(srcname)_FETCHTOOL)\
|
---|
783 | $($(source)_TOOL)\
|
---|
784 | $($(srcname)_TOOL)\
|
---|
785 | $($(target)_FETCHTOOL)\
|
---|
786 | $($(target)_TOOL)\
|
---|
787 | )
|
---|
788 | flags :=\
|
---|
789 | $(TOOL_$(tool)_FETCHFLAGS)\
|
---|
790 | $(FETCHFLAGS)\
|
---|
791 | $($(target)_FETCHFLAGS)\
|
---|
792 | $($(srcname)_FETCHFLAGS)\
|
---|
793 | $($(source)_FETCHFLAGS)\
|
---|
794 | $($(target)_$(srcname)_FETCHFLAGS)\
|
---|
795 | $($(target)_$(source)_FETCHFLAGS)
|
---|
796 |
|
---|
797 | #$ (warning dbg: target=$(target) source=$(source) $(srcname)=$(srcname) tool=$(tool) out=$(out) flags=$(flags) dirdep=$(dirdep) fetchdir=$(fetchdir) md5=$(md5) size=$(size))
|
---|
798 |
|
---|
799 | ifndef TOOL_$(tool)_FETCH_CMDS
|
---|
800 | $(warning kBuild: tools: \
|
---|
801 | 1 $($(target)_$(source)_FETCHTOOL)\
|
---|
802 | 2 $($(target)_$(srcname)_FETCHTOOL)\
|
---|
803 | 3 $($(target)_$(source)_TOOL)\
|
---|
804 | 4 $($(target)_$(srcname)_TOOL)\
|
---|
805 | 5 $($(source)_FETCHTOOL)\
|
---|
806 | 6 $($(srcname)_FETCHTOOL)\
|
---|
807 | 7 $($(source)_TOOL)\
|
---|
808 | 8 $($(srcname)_TOOL)\
|
---|
809 | 9 $($(target)_FETCHTOOL)\
|
---|
810 | 10 $($(target)_TOOL) )
|
---|
811 | $(error kBuild: TOOL_$(tool)_FETCH_CMDS is not defined. source=$(source) target=$(target) )
|
---|
812 | endif
|
---|
813 |
|
---|
814 | # call the tool
|
---|
815 | $(target)_$(srcname)_FETCH_CMDS_ := $(TOOL_$(tool)_FETCH_CMDS)
|
---|
816 | $(target)_$(srcname)_FETCH_OUTPUT_ := $(TOOL_$(tool)_FETCH_OUTPUT)
|
---|
817 | $(target)_$(srcname)_FETCH_DEPEND_ := $(TOOL_$(tool)_FETCH_DEPEND) $(deps)
|
---|
818 | $(target)_$(srcname)_FETCH_DEPORD_ := $(TOOL_$(tool)_FETCH_DEPORD) $(dirdep)
|
---|
819 |
|
---|
820 | # generate the fetch rule.
|
---|
821 | $(eval $(def_fetch_src_fetch_rule))
|
---|
822 |
|
---|
823 |
|
---|
824 | #
|
---|
825 | # The unpacking / installing.
|
---|
826 | #
|
---|
827 | out := $(inst)_kBuild_$(target)_$(srcname)_unpacked.lst
|
---|
828 | dirdep := $(call DIRDEP,$(inst))
|
---|
829 | tool := $(firstword \
|
---|
830 | $($(target)_$(source)_UNPACKTOOL)\
|
---|
831 | $($(target)_$(srcname)_UNPACKTOOL)\
|
---|
832 | $($(target)_$(source)_TOOL)\
|
---|
833 | $($(target)_$(srcname)_TOOL)\
|
---|
834 | $($(source)_UNPACKTOOL)\
|
---|
835 | $($(srcname)_UNPACKTOOL)\
|
---|
836 | $($(source)_TOOL)\
|
---|
837 | $($(srcname)_TOOL)\
|
---|
838 | $($(target)_UNPACKTOOL)\
|
---|
839 | $($(target)_TOOL) \
|
---|
840 | )
|
---|
841 | ifeq ($(tool),)
|
---|
842 | tool := $(toupper $(subst .,,$(suffix $(subst tar.,TAR,$(srcname)))))
|
---|
843 | $(eval $(value def_tools_include))
|
---|
844 | endif
|
---|
845 | flags :=\
|
---|
846 | $(TOOL_$(tool)_UNPACKFLAGS)\
|
---|
847 | $(UNPACKFLAGS)\
|
---|
848 | $($(target)_UNPACKFLAGS)\
|
---|
849 | $($(srcname)_UNPACKFLAGS)\
|
---|
850 | $($(source)_UNPACKFLAGS)\
|
---|
851 | $($(target)_$(srcname)_UNPACKFLAGS)\
|
---|
852 | $($(target)_$(source)_UNPACKFLAGS)
|
---|
853 |
|
---|
854 | #$ (warning dbg: target=$(target) source=$(source) $(srcname)=$(srcname) tool=$(tool) out=$(out) flags=$(flags) dirdep=$(dirdep) inst=$(inst) md5=$(md5) size=$(size))
|
---|
855 | ifndef TOOL_$(tool)_UNPACK_CMDS
|
---|
856 | $(warning kBuild: tools: \
|
---|
857 | 1 $($(target)_$(source)_UNPACKTOOL)\
|
---|
858 | 2 $($(target)_$(srcname)_UNPACKTOOL)\
|
---|
859 | 3 $($(target)_$(source)_TOOL)\
|
---|
860 | 4 $($(target)_$(srcname)_TOOL)\
|
---|
861 | 5 $($(source)_UNPACKTOOL)\
|
---|
862 | 6 $($(srcname)_UNPACKTOOL)\
|
---|
863 | 7 $($(source)_TOOL)\
|
---|
864 | 8 $($(srcname)_TOOL)\
|
---|
865 | 9 $($(target)_UNPACKTOOL)\
|
---|
866 | 10 $($(target)_TOOL) \
|
---|
867 | 11 $(toupper $(subst tar.,TAR,$(ext $(srcname)))) \
|
---|
868 | )
|
---|
869 | $(error kBuild: TOOL_$(tool)_UNPACK_CMDS is not defined. source=$(source) target=$(target) )
|
---|
870 | endif
|
---|
871 |
|
---|
872 | # call the tool
|
---|
873 | $(target)_$(srcname)_UNPACK_CMDS_ := $(TOOL_$(tool)_UNPACK_CMDS)
|
---|
874 | $(target)_$(srcname)_UNPACK_OUTPUT_ := $(TOOL_$(tool)_UNPACK_OUTPUT)
|
---|
875 | $(target)_$(srcname)_UNPACK_DEPEND_ := $(TOOL_$(tool)_UNPACK_DEPEND) $(deps)
|
---|
876 | $(target)_$(srcname)_UNPACK_DEPORD_ := $(TOOL_$(tool)_UNPACK_DEPORD) $(dirdep)
|
---|
877 |
|
---|
878 | # generate the fetch rule.
|
---|
879 | $(eval $(def_fetch_src_unpack_rule))
|
---|
880 |
|
---|
881 | _DIRS += $(inst) $(fetchdir)
|
---|
882 |
|
---|
883 | endef
|
---|
884 |
|
---|
885 |
|
---|
886 | ##
|
---|
887 | # Define the target level rules for a fetch.
|
---|
888 | # @param target
|
---|
889 | # @param out
|
---|
890 | # @param inst
|
---|
891 | # @param _TARGET_$(target)_UNPACKED
|
---|
892 | # @param _TARGET_$(target)_DIGEST
|
---|
893 | # @param bld_trg
|
---|
894 | # @param bld_trg_arch
|
---|
895 | define def_fetch_rules
|
---|
896 |
|
---|
897 | $(out).lst: $(_TARGET_$(target)_UNPACKED) | $(call DIRDEP,$(inst))
|
---|
898 | @$$(ECHO) Successfully fetched $(target)
|
---|
899 | $$(RM) -f $$@ $$@.tmp
|
---|
900 | @$$(APPEND) $$@.tmp "$(notdir $(out))"
|
---|
901 | $(if $(_TARGET_$(target)_UNPACKED),$$(CAT_EXT) $(_TARGET_$(target)_UNPACKED) >> $$@.tmp)
|
---|
902 | $$(MV) -f $$@.tmp $$@
|
---|
903 |
|
---|
904 | $(out)_unfetched:
|
---|
905 | @$$(ECHO) Unfetching $(target)...
|
---|
906 | $$(RM) -f $$(addprefix $(inst),$$(shell $$(CAT_EXT) $(out).lst 2> /dev/null | $$(SED) -e '/\/$$$$/d'))
|
---|
907 | $$(RMDIR) -p --ignore-fail-on-non-empty --ignore-fail-on-not-exist $$(dir $$@) \
|
---|
908 | $$(addprefix $(inst),$$(sort $$(dir $$(shell $$(CAT_EXT) $(out).lst 2> /dev/null))))
|
---|
909 | $$(RM) -f $(out).lst $(out)
|
---|
910 | -/cygwin/bin/sleep 30
|
---|
911 | $$(RMDIR) -p --ignore-fail-on-non-empty --ignore-fail-on-not-exist $$(dir $$@)
|
---|
912 |
|
---|
913 | $(out): $(comp-vars _TARGET_$(target)_DIGEST_PREV,_TARGET_$(target)_DIGEST,FORCE) | $(call DIRDEP,$(inst))
|
---|
914 | @$$(RM) -f $$@
|
---|
915 | @$$(ECHO) $$(if $$(wildcard $(out).lst),Re-fetching,Fetching) $(target)...
|
---|
916 | $$(if $$(wildcard $(out).lst),$$(MAKE) -f $(MAKEFILE) $(out)_unfetched)
|
---|
917 | $$(MAKE) -f $(MAKEFILE) $(out).lst
|
---|
918 | @$$(APPEND) $$@ "_TARGET_$(target)_DIGEST_PREV := $(_TARGET_$(target)_DIGEST)"
|
---|
919 |
|
---|
920 | $(target):: $(out)
|
---|
921 | $(target)_unfetch:: $(out)_unfetched
|
---|
922 |
|
---|
923 | .NOTPARALLEL: $(out).lst $(out)_unfetched $(out)
|
---|
924 |
|
---|
925 | endef
|
---|
926 |
|
---|
927 |
|
---|
928 | ##
|
---|
929 | # Deal with one fetch target.
|
---|
930 | # @param target
|
---|
931 | # @param bld_trg
|
---|
932 | # @param bld_trg_arch
|
---|
933 | define def_fetch
|
---|
934 |
|
---|
935 | # common
|
---|
936 | INSTARGET_$(target) := $($(target)_INST)
|
---|
937 | ifneq ($(patsubst %/,ok,$(INSTARGET_$(target))),ok)
|
---|
938 | $(error kBuild: Bad or missing INST property for target '$(target)'. \
|
---|
939 | $(target)_INST='$($(target)_INST)' ($(origin $(target)_INST)))
|
---|
940 | endif
|
---|
941 | _TARGET_$(target)_FETCHED :=
|
---|
942 | _TARGET_$(target)_UNPACKED :=
|
---|
943 | _TARGET_$(target)_DIGEST :=
|
---|
944 |
|
---|
945 | # The 'sources'.
|
---|
946 | #$ (warning dbg fetch: target=$(target) sources=$($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TYPE)) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_TARGET_ARCH)) $($(target)_SOURCES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)))
|
---|
947 | $(foreach source,$($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TYPE)) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_TARGET_ARCH)) $($(target)_SOURCES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)),\
|
---|
948 | $(eval $(value def_fetch_src)))
|
---|
949 |
|
---|
950 | # The target.
|
---|
951 | inst := $(INSTARGET_$(target))
|
---|
952 | out := $(inst)_kBuild_fetch_$(target)
|
---|
953 |
|
---|
954 | $(eval includedep $(out))
|
---|
955 | $(eval $(def_fetch_rules))
|
---|
956 |
|
---|
957 | _FETCHES += $(out)
|
---|
958 | _DOWNLOADS += $(_TARGET_$(target)_FETCHED)
|
---|
959 | _UNPACKS += $(_TARGET_$(target)_UNPACKED)
|
---|
960 | _UNFETCHES += $(out)_unfetched
|
---|
961 | _DIRS += $(inst)
|
---|
962 |
|
---|
963 | endef
|
---|
964 |
|
---|
965 | # Walk the FETCH target lists.
|
---|
966 | bld_trg := $(BUILD_TARGET)
|
---|
967 | bld_trg_arch := $(BUILD_TARGET_ARCH)
|
---|
968 | $(foreach target, $(FETCHES) $(FETCHES.$(BUILD_TARGET)) $(FETCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
|
---|
969 | $(eval $(value def_fetch)))
|
---|
970 |
|
---|
971 | # some aliases.
|
---|
972 | download: $(_DOWNLOADS)
|
---|
973 | unpack: $(_UNPACKS)
|
---|
974 | fetch: $(_FETCHES)
|
---|
975 | unfetch: $(_UNFETCHES)
|
---|
976 |
|
---|
977 |
|
---|
978 |
|
---|
979 | ##
|
---|
980 | ## Patching.
|
---|
981 | ##
|
---|
982 | ##
|
---|
983 | #define def_patch_src
|
---|
984 | #
|
---|
985 | #endef
|
---|
986 | #
|
---|
987 | #
|
---|
988 | ## Deal with one patch target.
|
---|
989 | #define def_patch
|
---|
990 | #
|
---|
991 | #$(foreach source,$($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TYPE)) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_TARGET_ARCH)) $($(target)_SOURCES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)),\
|
---|
992 | # $(eval $(value def_patch_src)))
|
---|
993 | #
|
---|
994 | #_PATCHES +=
|
---|
995 | #endef
|
---|
996 | #
|
---|
997 | #$(foreach target, $(PATCHES) $(PATCHES.$(BUILD_TARGET)) $(PATCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
|
---|
998 | # $(eval $(value def_patch)))
|
---|
999 | #
|
---|
1000 |
|
---|
1001 |
|
---|
1002 | #
|
---|
1003 | # Object processing.
|
---|
1004 | #
|
---|
1005 |
|
---|
1006 | ## wrapper the compile command dependency check.
|
---|
1007 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
1008 | ifneq ($(filter comp-vars,$(KMK_FEATURES)),)
|
---|
1009 | _DEP_COMPILE_CMDS = $(comp-vars $(target)_$(source)_CMDS_PREV_,$(target)_$(source)_CMDS_,FORCE)
|
---|
1010 | else
|
---|
1011 | _DEP_COMPILE_CMDS = $(if $(subst $(strip $($(target)_$(source)_CMDS_PREV_)),,$(strip $($(target)_$(source)_CMDS_))),FORCE,)
|
---|
1012 | endif
|
---|
1013 | else
|
---|
1014 | _DEP_COMPILE_CMDS =
|
---|
1015 | endif
|
---|
1016 |
|
---|
1017 | ## Generates the rules for building a specific object, and the '::' aliases
|
---|
1018 | # for building a source file.
|
---|
1019 | # @param $(obj) The object file.
|
---|
1020 | define def_target_source_rule
|
---|
1021 | $(obj) $($(target)_$(source)_OUTPUT_): \
|
---|
1022 | $($(target)_$(source)_DEPEND_) \
|
---|
1023 | $(_DEP_COMPILE_CMDS) \
|
---|
1024 | | \
|
---|
1025 | $($(target)_$(source)_DEPORD_)
|
---|
1026 | $(call MSG_L1,Creating $$@)
|
---|
1027 | $(RM) -f $(dep) $(obj) $($(target)_$(source)_OUTPUT_)
|
---|
1028 | $(custom_pre)
|
---|
1029 |
|
---|
1030 | $($(target)_$(source)_CMDS_)
|
---|
1031 |
|
---|
1032 | $(custom_post)
|
---|
1033 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
1034 | @$(APPEND) "$(dep)"
|
---|
1035 | @$(APPEND) "$(dep)" 'define $(target)_$(source)_CMDS_PREV_'
|
---|
1036 | @$(APPEND) "$(dep)" '$(subst $(NL),'$(NL)$(TAB)@$(APPEND) "$(dep)" ',$($(target)_$(source)_CMDS_))'
|
---|
1037 | @$(APPEND) "$(dep)" 'endef'
|
---|
1038 | endif
|
---|
1039 |
|
---|
1040 | $(basename $(notdir $(obj))).o::
|
---|
1041 | + $$(MAKE) -f $$(MAKEFILE) $(obj)
|
---|
1042 | $(basename $(notdir $(obj))).obj::
|
---|
1043 | + $$(MAKE) -f $$(MAKEFILE) $(obj)
|
---|
1044 | endef
|
---|
1045 |
|
---|
1046 |
|
---|
1047 | ## wrapper the link command dependency check.
|
---|
1048 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
1049 | ifneq ($(filter comp-vars,$(KMK_FEATURES)),)
|
---|
1050 | _DEP_LINK_CMDS = $(comp-vars $(target)_CMDS_PREV_,$(target)_CMDS_,FORCE)
|
---|
1051 | else
|
---|
1052 | _DEP_LINK_CMDS = $(if $(subst $(strip $($(target)_CMDS_PREV_)),,$(strip $($(target)_CMDS_))),FORCE,)
|
---|
1053 | endif
|
---|
1054 | else
|
---|
1055 | _DEP_LINK_CMDS =
|
---|
1056 | endif
|
---|
1057 |
|
---|
1058 | ## Generate the link rule for a target.
|
---|
1059 | # @param $(target) The normalized target name.
|
---|
1060 | # @param $(dirdep) Directories we depend upon begin created before linking.
|
---|
1061 | # @param $(dep) The name of the dependency file.
|
---|
1062 | # @param $(out)
|
---|
1063 | # @param $($(target)_OUTPUT_) Output files from the link.
|
---|
1064 | # @param $($(target)_DEPEND_) Dependencies.
|
---|
1065 | # @param $($(target)_DEPORD_) Dependencies which should only affect build order.
|
---|
1066 | # @param $($(target)_CMDS_) The link commands.
|
---|
1067 | # @param $($(target)_CMDS_PREV_) The link commands from the previous run.
|
---|
1068 | define def_link_rule
|
---|
1069 | $(out) $($(target)_OUTPUT_): \
|
---|
1070 | $($(target)_DEPEND_) \
|
---|
1071 | $(_DEP_LINK_CMDS) \
|
---|
1072 | | \
|
---|
1073 | $($(target)_DEPORD_)
|
---|
1074 | $(call MSG_L1,Creating $$@)
|
---|
1075 | $(RM) -f $(dep) $(out) $($(target)_OUTPUT_)
|
---|
1076 | $(custom_pre)
|
---|
1077 |
|
---|
1078 | $($(target)_CMDS_)
|
---|
1079 |
|
---|
1080 | $(custom_post)
|
---|
1081 | ifndef NO_LINK_CMDS_DEPS
|
---|
1082 | @$(APPEND) "$(dep)" 'define $(target)_CMDS_PREV_'
|
---|
1083 | @$(APPEND) "$(dep)" '$(subst $(NL),'$(NL)$(TAB)@$(APPEND) "$(dep)" ',$($(target)_CMDS_))'
|
---|
1084 | @$(APPEND) "$(dep)" 'endef'
|
---|
1085 | endif
|
---|
1086 |
|
---|
1087 | $(basename $(notdir $(out)))::
|
---|
1088 | + $$(MAKE) -f $$(MAKEFILE) $(out)
|
---|
1089 | endef
|
---|
1090 |
|
---|
1091 |
|
---|
1092 | ## Generate the link & lib install rule
|
---|
1093 | # @param $(target) Normalized target name.
|
---|
1094 | # @param $(out) The build target.
|
---|
1095 | # @param $(INSTARGET_$(target)) The installation targets.
|
---|
1096 | # @param $(mode) The file mode (optional)
|
---|
1097 | define def_link_install_rule
|
---|
1098 | $(INSTARGET_$(target)) : $(out) | $(call DIRDEP,$(dir $(INSTARGET_$(target))))
|
---|
1099 | $(INSTALL) $$(if $(mode),-m $(mode)) $(out) $$@
|
---|
1100 | endef
|
---|
1101 |
|
---|
1102 |
|
---|
1103 |
|
---|
1104 | ## Generic macro for processing C, C++ and Assembly sources.
|
---|
1105 | # @param $(target) Normalized target name.
|
---|
1106 | # @param $(source) Source file name.
|
---|
1107 | # @param $(type) Source type. {C,CXX,AS}
|
---|
1108 | # @param bld_type Build type.
|
---|
1109 | # @param bld_trg Build target.
|
---|
1110 | # @param bld_trg_arch Build target arch.
|
---|
1111 | # @param bld_trg_cpu Build target cpu.
|
---|
1112 | # @remark obsoleted by kBuild helpers in kmk. Only required for limited gmake compatbility.
|
---|
1113 | #
|
---|
1114 | define def_target_source_c_cpp_asm_rc_old
|
---|
1115 | #$ (warning dbg: def_target_source_c_cpp_asm_rc_old: source='$(source)' target='$(target)' type='$(type)')
|
---|
1116 |
|
---|
1117 | tool := $(call _SOURCE_TOOL,$(source),$(target),$(type))
|
---|
1118 | outbase := $(call _OBJECT_BASE,$(source),$(target))
|
---|
1119 | PATH_$(target)_$(source) := $(patsubst %/,%,$(dir $(outbase)))
|
---|
1120 | dirdep := $(call DIRDEP,$(dir $(outbase)))
|
---|
1121 | defs :=\
|
---|
1122 | $(TOOL_$(tool)_DEFS)\
|
---|
1123 | $(TOOL_$(tool)_DEFS.$(bld_type))\
|
---|
1124 | $(TOOL_$(tool)_DEFS.$(bld_trg))\
|
---|
1125 | $(TOOL_$(tool)_DEFS.$(bld_trg_arch))\
|
---|
1126 | $(TOOL_$(tool)_DEFS.$(bld_trg).$(bld_trg_arch))\
|
---|
1127 | $(TOOL_$(tool)_DEFS.$(bld_trg_cpu))\
|
---|
1128 | $(TOOL_$(tool)_$(type)DEFS)\
|
---|
1129 | $(TOOL_$(tool)_$(type)DEFS.$(bld_type))\
|
---|
1130 | $(foreach sdk, $(SDKS.$(bld_trg).$(bld_trg_arch)) \
|
---|
1131 | $(SDKS.$(bld_trg_arch)) \
|
---|
1132 | $(SDKS.$(bld_trg)) \
|
---|
1133 | $(SDKS.$(bld_type)) \
|
---|
1134 | $(SDKS),\
|
---|
1135 | $(SDK_$(sdk)_DEFS)\
|
---|
1136 | $(SDK_$(sdk)_DEFS.$(bld_type))\
|
---|
1137 | $(SDK_$(sdk)_DEFS.$(bld_trg))\
|
---|
1138 | $(SDK_$(sdk)_DEFS.$(bld_trg_arch))\
|
---|
1139 | $(SDK_$(sdk)_DEFS.$(bld_trg).$(bld_trg_arch))\
|
---|
1140 | $(SDK_$(sdk)_DEFS.$(bld_trg_cpu))\
|
---|
1141 | $(SDK_$(sdk)_$(type)DEFS)\
|
---|
1142 | $(SDK_$(sdk)_$(type)DEFS.$(bld_type))\
|
---|
1143 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg))\
|
---|
1144 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_arch))\
|
---|
1145 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg).$(bld_trg_arch))\
|
---|
1146 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_cpu)))\
|
---|
1147 | $(DEFS)\
|
---|
1148 | $(DEFS.$(bld_type))\
|
---|
1149 | $(DEFS.$(bld_trg))\
|
---|
1150 | $(DEFS.$(bld_trg_arch))\
|
---|
1151 | $(DEFS.$(bld_trg).$(bld_trg_arch))\
|
---|
1152 | $(DEFS.$(bld_trg_cpu))\
|
---|
1153 | $($(type)DEFS)\
|
---|
1154 | $($(type)DEFS.$(bld_type))\
|
---|
1155 | $($(type)DEFS.$(bld_trg))\
|
---|
1156 | $($(type)DEFS.$(bld_trg_arch))\
|
---|
1157 | $($(type)DEFS.$(bld_trg).$(bld_trg_arch))\
|
---|
1158 | $($(type)DEFS.$(bld_trg_cpu))\
|
---|
1159 | $(foreach sdk, $($(target)_SDKS.$(bld_trg).$(bld_trg_arch)) \
|
---|
1160 | $($(target)_SDKS.$(bld_trg_arch)) \
|
---|
1161 | $($(target)_SDKS.$(bld_trg)) \
|
---|
1162 | $($(target)_SDKS.$(bld_type)) \
|
---|
1163 | $($(target)_SDKS),\
|
---|
1164 | $(SDK_$(sdk)_DEFS)\
|
---|
1165 | $(SDK_$(sdk)_DEFS.$(bld_type))\
|
---|
1166 | $(SDK_$(sdk)_DEFS.$(bld_trg))\
|
---|
1167 | $(SDK_$(sdk)_DEFS.$(bld_trg_arch))\
|
---|
1168 | $(SDK_$(sdk)_DEFS.$(bld_trg).$(bld_trg_arch))\
|
---|
1169 | $(SDK_$(sdk)_DEFS.$(bld_trg_cpu))\
|
---|
1170 | $(SDK_$(sdk)_$(type)DEFS)\
|
---|
1171 | $(SDK_$(sdk)_$(type)DEFS.$(bld_type))\
|
---|
1172 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg))\
|
---|
1173 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_arch))\
|
---|
1174 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg).$(bld_trg_arch))\
|
---|
1175 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_cpu)))\
|
---|
1176 | $($(target)_DEFS)\
|
---|
1177 | $($(target)_DEFS.$(bld_type))\
|
---|
1178 | $($(target)_DEFS.$(bld_trg))\
|
---|
1179 | $($(target)_DEFS.$(bld_trg_arch))\
|
---|
1180 | $($(target)_DEFS.$(bld_trg).$(bld_trg_arch))\
|
---|
1181 | $($(target)_DEFS.$(bld_trg_cpu))\
|
---|
1182 | $($(target)_$(type)DEFS)\
|
---|
1183 | $($(target)_$(type)DEFS.$(bld_type))\
|
---|
1184 | $($(target)_$(type)DEFS.$(bld_trg))\
|
---|
1185 | $($(target)_$(type)DEFS.$(bld_trg_arch))\
|
---|
1186 | $($(target)_$(type)DEFS.$(bld_trg).$(bld_trg_arch))\
|
---|
1187 | $($(target)_$(type)DEFS.$(bld_trg_cpu))\
|
---|
1188 | $(foreach sdk, $($(source)_SDKS.$(bld_trg).$(bld_trg_arch)) \
|
---|
1189 | $($(source)_SDKS.$(bld_trg_arch)) \
|
---|
1190 | $($(source)_SDKS.$(bld_trg)) \
|
---|
1191 | $($(source)_SDKS.$(bld_type)) \
|
---|
1192 | $($(source)_SDKS),\
|
---|
1193 | $(SDK_$(sdk)_DEFS)\
|
---|
1194 | $(SDK_$(sdk)_DEFS.$(bld_type))\
|
---|
1195 | $(SDK_$(sdk)_DEFS.$(bld_trg))\
|
---|
1196 | $(SDK_$(sdk)_DEFS.$(bld_trg_arch))\
|
---|
1197 | $(SDK_$(sdk)_DEFS.$(bld_trg).$(bld_trg_arch))\
|
---|
1198 | $(SDK_$(sdk)_DEFS.$(bld_trg_cpu))\
|
---|
1199 | $(SDK_$(sdk)_$(type)DEFS)\
|
---|
1200 | $(SDK_$(sdk)_$(type)DEFS.$(bld_type))\
|
---|
1201 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg))\
|
---|
1202 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_arch))\
|
---|
1203 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg).$(bld_trg_arch))\
|
---|
1204 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_cpu)))\
|
---|
1205 | $($(source)_DEFS)\
|
---|
1206 | $($(source)_DEFS.$(bld_type))\
|
---|
1207 | $($(source)_DEFS.$(bld_trg))\
|
---|
1208 | $($(source)_DEFS.$(bld_trg_arch))\
|
---|
1209 | $($(source)_DEFS.$(bld_trg).$(bld_trg_arch))\
|
---|
1210 | $($(source)_DEFS.$(bld_trg_cpu))\
|
---|
1211 | $($(source)_$(type)DEFS)\
|
---|
1212 | $($(source)_$(type)DEFS.$(bld_type))\
|
---|
1213 | $($(source)_$(type)DEFS.$(bld_trg))\
|
---|
1214 | $($(source)_$(type)DEFS.$(bld_trg_arch))\
|
---|
1215 | $($(source)_$(type)DEFS.$(bld_trg).$(bld_trg_arch))\
|
---|
1216 | $($(source)_$(type)DEFS.$(bld_trg_cpu))\
|
---|
1217 | $(foreach sdk, $($(target)_$(source)_SDKS.$(bld_trg).$(bld_trg_arch)) \
|
---|
1218 | $($(target)_$(source)_SDKS.$(bld_trg_arch)) \
|
---|
1219 | $($(target)_$(source)_SDKS.$(bld_trg)) \
|
---|
1220 | $($(target)_$(source)_SDKS.$(bld_type)) \
|
---|
1221 | $($(target)_$(source)_SDKS),\
|
---|
1222 | $(SDK_$(sdk)_DEFS)\
|
---|
1223 | $(SDK_$(sdk)_DEFS.$(bld_type))\
|
---|
1224 | $(SDK_$(sdk)_DEFS.$(bld_trg))\
|
---|
1225 | $(SDK_$(sdk)_DEFS.$(bld_trg_arch))\
|
---|
1226 | $(SDK_$(sdk)_DEFS.$(bld_trg).$(bld_trg_arch))\
|
---|
1227 | $(SDK_$(sdk)_DEFS.$(bld_trg_cpu))\
|
---|
1228 | $(SDK_$(sdk)_$(type)DEFS)\
|
---|
1229 | $(SDK_$(sdk)_$(type)DEFS.$(bld_type))\
|
---|
1230 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg))\
|
---|
1231 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_arch))\
|
---|
1232 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg).$(bld_trg_arch))\
|
---|
1233 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_cpu)))\
|
---|
1234 | $($(target)_$(source)_DEFS)\
|
---|
1235 | $($(target)_$(source)_DEFS.$(bld_type))\
|
---|
1236 | $($(target)_$(source)_DEFS.$(bld_trg))\
|
---|
1237 | $($(target)_$(source)_DEFS.$(bld_trg_arch))\
|
---|
1238 | $($(target)_$(source)_DEFS.$(bld_trg).$(bld_trg_arch))\
|
---|
1239 | $($(target)_$(source)_DEFS.$(bld_trg_cpu))\
|
---|
1240 | $($(target)_$(source)_$(type)DEFS)\
|
---|
1241 | $($(target)_$(source)_$(type)DEFS.$(bld_type))\
|
---|
1242 | $($(target)_$(source)_$(type)DEFS.$(bld_trg))\
|
---|
1243 | $($(target)_$(source)_$(type)DEFS.$(bld_trg_arch))\
|
---|
1244 | $($(target)_$(source)_$(type)DEFS.$(bld_trg).$(bld_trg_arch))\
|
---|
1245 | $($(target)_$(source)_$(type)DEFS.$(bld_trg_cpu))
|
---|
1246 | incs :=\
|
---|
1247 | $($(target)_$(source)_$(type)INCS.$(bld_trg_cpu))\
|
---|
1248 | $($(target)_$(source)_$(type)INCS.$(bld_trg).$(bld_trg_arch))\
|
---|
1249 | $($(target)_$(source)_$(type)INCS.$(bld_trg_arch))\
|
---|
1250 | $($(target)_$(source)_$(type)INCS.$(bld_trg))\
|
---|
1251 | $($(target)_$(source)_$(type)INCS.$(bld_type))\
|
---|
1252 | $($(target)_$(source)_$(type)INCS)\
|
---|
1253 | $($(target)_$(source)_INCS.$(bld_trg_cpu))\
|
---|
1254 | $($(target)_$(source)_INCS.$(bld_trg).$(bld_trg_arch))\
|
---|
1255 | $($(target)_$(source)_INCS.$(bld_trg_arch))\
|
---|
1256 | $($(target)_$(source)_INCS.$(bld_trg))\
|
---|
1257 | $($(target)_$(source)_INCS.$(bld_type))\
|
---|
1258 | $($(target)_$(source)_INCS)\
|
---|
1259 | $(foreach sdk, $($(target)_$(source)_SDKS.$(bld_trg).$(bld_trg_arch)) \
|
---|
1260 | $($(target)_$(source)_SDKS.$(bld_trg_arch)) \
|
---|
1261 | $($(target)_$(source)_SDKS.$(bld_trg)) \
|
---|
1262 | $($(target)_$(source)_SDKS.$(bld_type)) \
|
---|
1263 | $($(target)_$(source)_SDKS),\
|
---|
1264 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg_cpu))\
|
---|
1265 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg).$(bld_trg_arch))\
|
---|
1266 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg_arch))\
|
---|
1267 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg))\
|
---|
1268 | $(SDK_$(sdk)_$(type)INCS.$(bld_type))\
|
---|
1269 | $(SDK_$(sdk)_$(type)INCS)\
|
---|
1270 | $(SDK_$(sdk)_INCS.$(bld_trg_cpu))\
|
---|
1271 | $(SDK_$(sdk)_INCS.$(bld_trg).$(bld_trg_arch))\
|
---|
1272 | $(SDK_$(sdk)_INCS.$(bld_trg_arch))\
|
---|
1273 | $(SDK_$(sdk)_INCS.$(bld_trg))\
|
---|
1274 | $(SDK_$(sdk)_INCS.$(bld_type))\
|
---|
1275 | $(SDK_$(sdk)_INCS))\
|
---|
1276 | $($(source)_$(type)INCS.$(bld_trg_cpu))\
|
---|
1277 | $($(source)_$(type)INCS.$(bld_trg).$(bld_trg_arch))\
|
---|
1278 | $($(source)_$(type)INCS.$(bld_trg_arch))\
|
---|
1279 | $($(source)_$(type)INCS.$(bld_trg))\
|
---|
1280 | $($(source)_$(type)INCS.$(bld_type))\
|
---|
1281 | $($(source)_$(type)INCS)\
|
---|
1282 | $($(source)_INCS.$(bld_trg_cpu))\
|
---|
1283 | $($(source)_INCS.$(bld_trg).$(bld_trg_arch))\
|
---|
1284 | $($(source)_INCS.$(bld_trg_arch))\
|
---|
1285 | $($(source)_INCS.$(bld_trg))\
|
---|
1286 | $($(source)_INCS.$(bld_type))\
|
---|
1287 | $($(source)_INCS)\
|
---|
1288 | $(foreach sdk, $($(source)_SDKS.$(bld_trg).$(bld_trg_arch)) \
|
---|
1289 | $($(source)_SDKS.$(bld_trg_arch)) \
|
---|
1290 | $($(source)_SDKS.$(bld_trg)) \
|
---|
1291 | $($(source)_SDKS.$(bld_type)) \
|
---|
1292 | $($(source)_SDKS),\
|
---|
1293 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg_cpu))\
|
---|
1294 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg).$(bld_trg_arch))\
|
---|
1295 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg_arch))\
|
---|
1296 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg))\
|
---|
1297 | $(SDK_$(sdk)_$(type)INCS.$(bld_type))\
|
---|
1298 | $(SDK_$(sdk)_$(type)INCS)\
|
---|
1299 | $(SDK_$(sdk)_INCS.$(bld_trg_cpu))\
|
---|
1300 | $(SDK_$(sdk)_INCS.$(bld_trg).$(bld_trg_arch))\
|
---|
1301 | $(SDK_$(sdk)_INCS.$(bld_trg_arch))\
|
---|
1302 | $(SDK_$(sdk)_INCS.$(bld_trg))\
|
---|
1303 | $(SDK_$(sdk)_INCS.$(bld_type))\
|
---|
1304 | $(SDK_$(sdk)_INCS))\
|
---|
1305 | $($(target)_$(type)INCS.$(bld_trg_cpu))\
|
---|
1306 | $($(target)_$(type)INCS.$(bld_trg).$(bld_trg_arch))\
|
---|
1307 | $($(target)_$(type)INCS.$(bld_trg_arch))\
|
---|
1308 | $($(target)_$(type)INCS.$(bld_trg))\
|
---|
1309 | $($(target)_$(type)INCS.$(bld_type))\
|
---|
1310 | $($(target)_$(type)INCS)\
|
---|
1311 | $($(target)_INCS.$(bld_trg_cpu))\
|
---|
1312 | $($(target)_INCS.$(bld_trg).$(bld_trg_arch))\
|
---|
1313 | $($(target)_INCS.$(bld_trg_arch))\
|
---|
1314 | $($(target)_INCS.$(bld_trg))\
|
---|
1315 | $($(target)_INCS.$(bld_type))\
|
---|
1316 | $($(target)_INCS)\
|
---|
1317 | $(foreach sdk, $($(target)_SDKS.$(bld_trg).$(bld_trg_arch)) \
|
---|
1318 | $($(target)_SDKS.$(bld_trg_arch)) \
|
---|
1319 | $($(target)_SDKS.$(bld_trg)) \
|
---|
1320 | $($(target)_SDKS.$(bld_type)) \
|
---|
1321 | $($(target)_SDKS),\
|
---|
1322 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg_cpu))\
|
---|
1323 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg).$(bld_trg_arch))\
|
---|
1324 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg_arch))\
|
---|
1325 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg))\
|
---|
1326 | $(SDK_$(sdk)_$(type)INCS.$(bld_type))\
|
---|
1327 | $(SDK_$(sdk)_$(type)INCS)\
|
---|
1328 | $(SDK_$(sdk)_INCS.$(bld_trg_cpu))\
|
---|
1329 | $(SDK_$(sdk)_INCS.$(bld_trg).$(bld_trg_arch))\
|
---|
1330 | $(SDK_$(sdk)_INCS.$(bld_trg_arch))\
|
---|
1331 | $(SDK_$(sdk)_INCS.$(bld_trg))\
|
---|
1332 | $(SDK_$(sdk)_INCS.$(bld_type))\
|
---|
1333 | $(SDK_$(sdk)_INCS))\
|
---|
1334 | $(INCS.$(bld_trg_cpu))\
|
---|
1335 | $(INCS.$(bld_trg).$(bld_trg_arch))\
|
---|
1336 | $(INCS.$(bld_trg_arch))\
|
---|
1337 | $(INCS.$(bld_trg))\
|
---|
1338 | $(INCS.$(bld_type))\
|
---|
1339 | $(INCS)\
|
---|
1340 | $(foreach sdk, $(SDKS.$(bld_trg).$(bld_trg_arch)) \
|
---|
1341 | $(SDKS.$(bld_trg_arch)) \
|
---|
1342 | $(SDKS.$(bld_trg)) \
|
---|
1343 | $(SDKS.$(bld_type)) \
|
---|
1344 | $(SDKS),\
|
---|
1345 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg_cpu))\
|
---|
1346 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg).$(bld_trg_arch))\
|
---|
1347 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg_arch))\
|
---|
1348 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg))\
|
---|
1349 | $(SDK_$(sdk)_$(type)INCS.$(bld_type))\
|
---|
1350 | $(SDK_$(sdk)_$(type)INCS)\
|
---|
1351 | $(SDK_$(sdk)_INCS.$(bld_trg_cpu))\
|
---|
1352 | $(SDK_$(sdk)_INCS.$(bld_trg).$(bld_trg_arch))\
|
---|
1353 | $(SDK_$(sdk)_INCS.$(bld_trg_arch))\
|
---|
1354 | $(SDK_$(sdk)_INCS.$(bld_trg))\
|
---|
1355 | $(SDK_$(sdk)_INCS.$(bld_type))\
|
---|
1356 | $(SDK_$(sdk)_INCS))\
|
---|
1357 | $(TOOL_$(tool)_$(type)INCS.$(bld_trg_cpu))\
|
---|
1358 | $(TOOL_$(tool)_$(type)INCS.$(bld_trg).$(bld_trg_arch))\
|
---|
1359 | $(TOOL_$(tool)_$(type)INCS.$(bld_trg_arch))\
|
---|
1360 | $(TOOL_$(tool)_$(type)INCS.$(bld_trg))\
|
---|
1361 | $(TOOL_$(tool)_$(type)INCS.$(bld_type))\
|
---|
1362 | $(TOOL_$(tool)_$(type)INCS)
|
---|
1363 | flags :=\
|
---|
1364 | $(TOOL_$(tool)_$(type)FLAGS)\
|
---|
1365 | $(TOOL_$(tool)_$(type)FLAGS.$(bld_type))\
|
---|
1366 | $(TOOL_$(tool)_$(type)FLAGS.$(bld_trg))\
|
---|
1367 | $(TOOL_$(tool)_$(type)FLAGS.$(bld_trg_arch))\
|
---|
1368 | $(TOOL_$(tool)_$(type)FLAGS.$(bld_trg).$(bld_trg_arch))\
|
---|
1369 | $(TOOL_$(tool)_$(type)FLAGS.$(bld_trg_cpu))\
|
---|
1370 | $($(type)FLAGS)\
|
---|
1371 | $($(type)FLAGS.$(bld_type))\
|
---|
1372 | $($(type)FLAGS.$(bld_trg))\
|
---|
1373 | $($(type)FLAGS.$(bld_trg_arch))\
|
---|
1374 | $($(type)FLAGS.$(bld_trg).$(bld_trg_arch))\
|
---|
1375 | $($(type)FLAGS.$(bld_trg_cpu))\
|
---|
1376 | $($(target)_$(type)FLAGS)\
|
---|
1377 | $($(target)_$(type)FLAGS.$(bld_type))\
|
---|
1378 | $($(target)_$(type)FLAGS.$(bld_trg))\
|
---|
1379 | $($(target)_$(type)FLAGS.$(bld_trg_arch))\
|
---|
1380 | $($(target)_$(type)FLAGS.$(bld_trg).$(bld_trg_arch))\
|
---|
1381 | $($(target)_$(type)FLAGS.$(bld_trg_cpu))\
|
---|
1382 | $($(source)_$(type)FLAGS)\
|
---|
1383 | $($(source)_$(type)FLAGS.$(bld_type))\
|
---|
1384 | $($(source)_$(type)FLAGS.$(bld_trg))\
|
---|
1385 | $($(source)_$(type)FLAGS.$(bld_trg_arch))\
|
---|
1386 | $($(source)_$(type)FLAGS.$(bld_trg).$(bld_trg_arch))\
|
---|
1387 | $($(source)_$(type)FLAGS.$(bld_trg_cpu))\
|
---|
1388 | $($(target)_$(source)_$(type)FLAGS)\
|
---|
1389 | $($(target)_$(source)_$(type)FLAGS.$(bld_type))\
|
---|
1390 | $($(target)_$(source)_$(type)FLAGS.$(bld_trg))\
|
---|
1391 | $($(target)_$(source)_$(type)FLAGS.$(bld_trg_arch))\
|
---|
1392 | $($(target)_$(source)_$(type)FLAGS.$(bld_trg).$(bld_trg_arch))\
|
---|
1393 | $($(target)_$(source)_$(type)FLAGS.$(bld_trg_cpu))
|
---|
1394 | # this isn't 100% in sync with kBuild, but it doesn't matter as it's only for gmake now.
|
---|
1395 | objsuff := $(firstword \
|
---|
1396 | $($(target)_$(source)_OBJSUFF.$(bld_trg).$(bld_trg_arch))\
|
---|
1397 | $($(target)_$(source)_OBJSUFF.$(bld_trg))\
|
---|
1398 | $($(target)_$(source)_OBJSUFF)\
|
---|
1399 | $($(source)_OBJSUFF.$(bld_trg).$(bld_trg_arch))\
|
---|
1400 | $($(source)_OBJSUFF.$(bld_trg))\
|
---|
1401 | $($(source)_OBJSUFF)\
|
---|
1402 | $($(target)_OBJSUFF.$(bld_trg).$(bld_trg_arch))\
|
---|
1403 | $($(target)_OBJSUFF.$(bld_trg))\
|
---|
1404 | $($(target)_OBJSUFF)\
|
---|
1405 | $(TOOL_$(tool)_$(type)OBJSUFF.$(bld_trg).$(bld_trg_arch))\
|
---|
1406 | $(TOOL_$(tool)_$(type)OBJSUFF.$(bld_trg))\
|
---|
1407 | $(TOOL_$(tool)_$(type)OBJSUFF)\
|
---|
1408 | $(SUFF_OBJ))
|
---|
1409 | obj := $(outbase)$(objsuff)
|
---|
1410 | deps := \
|
---|
1411 | $($(target)_$(source)_DEPS)\
|
---|
1412 | $($(target)_$(source)_DEPS.$(bld_type))\
|
---|
1413 | $($(target)_$(source)_DEPS.$(bld_trg))\
|
---|
1414 | $($(target)_$(source)_DEPS.$(bld_trg_arch))\
|
---|
1415 | $($(target)_$(source)_DEPS.$(bld_trg).$(bld_trg_arch))\
|
---|
1416 | $($(target)_$(source)_DEPS.$(bld_trg_cpu))\
|
---|
1417 | $($(source)_DEPS)\
|
---|
1418 | $($(source)_DEPS.$(bld_type))\
|
---|
1419 | $($(source)_DEPS.$(bld_trg))\
|
---|
1420 | $($(source)_DEPS.$(bld_trg_arch))\
|
---|
1421 | $($(source)_DEPS.$(bld_trg).$(bld_trg_arch))\
|
---|
1422 | $($(source)_DEPS.$(bld_trg_cpu))\
|
---|
1423 | $($(target)_DEPS)\
|
---|
1424 | $($(target)_DEPS.$(bld_type))\
|
---|
1425 | $($(target)_DEPS.$(bld_trg))\
|
---|
1426 | $($(target)_DEPS.$(bld_trg_arch))\
|
---|
1427 | $($(target)_DEPS.$(bld_trg).$(bld_trg_arch))\
|
---|
1428 | $($(target)_DEPS.$(bld_trg_cpu))
|
---|
1429 |
|
---|
1430 | # dependencies
|
---|
1431 | dep := $(obj)$(SUFF_DEP)
|
---|
1432 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
1433 | _DEPFILES_INCLUDED += $(dep)
|
---|
1434 | $(if $(wildcard $(dep)),$(eval include $(dep)))
|
---|
1435 | endif
|
---|
1436 |
|
---|
1437 | #$ (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))
|
---|
1438 | ifndef TOOL_$(tool)_COMPILE_$(type)_CMDS
|
---|
1439 | $(warning kBuild: tools: \
|
---|
1440 | 1 $($(target)_$(source)_$(type)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
1441 | 2 $($(target)_$(source)_$(type)TOOL.$(bld_trg)) \
|
---|
1442 | 3 $($(target)_$(source)_$(type)TOOL) \
|
---|
1443 | 4 $($(target)_$(source)_TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
1444 | 5 $($(target)_$(source)_TOOL.$(bld_trg)) \
|
---|
1445 | 6 $($(target)_$(source)_TOOL) \
|
---|
1446 | 7 $($(target)_$(type)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
1447 | 8 $($(target)_$(type)TOOL.$(bld_trg)) \
|
---|
1448 | 9 $($(target)_$(type)TOOL) \
|
---|
1449 | 10 $($(target)_TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
1450 | 11 $($(target)_TOOL.$(bld_trg)) \
|
---|
1451 | 12 $($(target)_TOOL) \
|
---|
1452 | 13 $($(source)_$(type)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
1453 | 14 $($(source)_$(type)TOOL.$(bld_trg)) \
|
---|
1454 | 15 $($(source)_$(type)TOOL) \
|
---|
1455 | 16 $($(source)_TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
1456 | 17 $($(source)_TOOL.$(bld_trg)) \
|
---|
1457 | 18 $($(source)_TOOL) \
|
---|
1458 | 19 $($(type)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
1459 | 20 $($(type)TOOL.$(bld_trg)) \
|
---|
1460 | 21 $($(type)TOOL) \
|
---|
1461 | 22 $(TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
1462 | 23 $(TOOL.$(bld_trg)) \
|
---|
1463 | 24 $(TOOL) )
|
---|
1464 | $(error kBuild: TOOL_$(tool)_COMPILE_$(type)_CMDS is not defined. source=$(source) target=$(target) )
|
---|
1465 | endif
|
---|
1466 |
|
---|
1467 | # call the tool
|
---|
1468 | $(target)_$(source)_CMDS_ := $(TOOL_$(tool)_COMPILE_$(type)_CMDS)
|
---|
1469 | $(target)_$(source)_OUTPUT_ := $(TOOL_$(tool)_COMPILE_$(type)_OUTPUT)
|
---|
1470 | $(target)_$(source)_DEPEND_ := $(TOOL_$(tool)_COMPILE_$(type)_DEPEND) $(deps) $(source)
|
---|
1471 | $(target)_$(source)_DEPORD_ := $(TOOL_$(tool)_COMPILE_$(type)_DEPORD) $(dirdep)
|
---|
1472 |
|
---|
1473 | # generate the compile rule.
|
---|
1474 | $(eval $(def_target_source_rule))
|
---|
1475 |
|
---|
1476 | _OUT_FILES += $($(target)_$(source)_OUTPUT_)
|
---|
1477 | $(target)_OBJS_ += $(obj)
|
---|
1478 |
|
---|
1479 | endef
|
---|
1480 |
|
---|
1481 | ## Generic macro for processing C, C++ and Assembly sources.
|
---|
1482 | # @param $(target) Normalized target name.
|
---|
1483 | # @param $(source) Source file name.
|
---|
1484 | # @param $(type) Source type. {C,CXX,AS}
|
---|
1485 | # @param bld_type Build type.
|
---|
1486 | # @param bld_trg Build target.
|
---|
1487 | # @param bld_trg_arch Build target arch.
|
---|
1488 | # @param bld_trg_cpu Build target cpu.
|
---|
1489 | #
|
---|
1490 | #$ (warning dbg: def_target_source_c_cpp_asm: source='$(source)' target='$(target)' type='$(type)')
|
---|
1491 | def_target_source_c_cpp_asm_rc_new = $(kb-src-one x)
|
---|
1492 |
|
---|
1493 | ifneq ($(filter kb-src-one,$(KMK_FEATURES)),)
|
---|
1494 | def_target_source_c_cpp_asm_rc_var = def_target_source_c_cpp_asm_rc_new
|
---|
1495 | else
|
---|
1496 | def_target_source_c_cpp_asm_rc_var = def_target_source_c_cpp_asm_rc_old
|
---|
1497 | endif
|
---|
1498 |
|
---|
1499 | ## Generic macro for processing all target sources.
|
---|
1500 | # @param $(target) Normalized target name.
|
---|
1501 | define def_target_sources
|
---|
1502 | #$ (warning def_target_sources)
|
---|
1503 | # C sources
|
---|
1504 | type := C
|
---|
1505 | $(foreach source, $(filter %.c , $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_cpu)) $($(target)_SOURCES.$(bld_type)))\
|
---|
1506 | ,$(eval $(value $(def_target_source_c_cpp_asm_rc_var))) )
|
---|
1507 |
|
---|
1508 | # C++ sources
|
---|
1509 | type := CXX
|
---|
1510 | $(foreach source, $(filter %.cpp %.cxx %.xx, $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_cpu)) $($(target)_SOURCES.$(bld_type)))\
|
---|
1511 | ,$(eval $(value $(def_target_source_c_cpp_asm_rc_var))) )
|
---|
1512 |
|
---|
1513 | # ASM sources
|
---|
1514 | type := AS
|
---|
1515 | $(foreach source, $(filter %.asm %.s %.S , $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_cpu)) $($(target)_SOURCES.$(bld_type)))\
|
---|
1516 | ,$(eval $(value $(def_target_source_c_cpp_asm_rc_var))) )
|
---|
1517 |
|
---|
1518 | # Resource sources
|
---|
1519 | type := RC
|
---|
1520 | $(foreach source, $(filter %.rc , $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_cpu)) $($(target)_SOURCES.$(bld_type)))\
|
---|
1521 | ,$(eval $(value $(def_target_source_c_cpp_asm_rc_var))) )
|
---|
1522 |
|
---|
1523 | endef
|
---|
1524 |
|
---|
1525 |
|
---|
1526 |
|
---|
1527 | ## Generic macro for generating the install rule(s) for a target
|
---|
1528 | # and update the globals with default out.
|
---|
1529 | #
|
---|
1530 | # @param $(target) Normalized target name.
|
---|
1531 | # @param $(out) The output file.
|
---|
1532 | # @param $(definst) The default _INST value.
|
---|
1533 | # @param $(typevar) The name of the variable with all the root targets of its type.
|
---|
1534 | # @obsolete
|
---|
1535 | define def_target_install_pluss
|
---|
1536 | ifndef $(target)_NOINST
|
---|
1537 | INSTARGET_$(target) := $(patsubst %/,%/$(notdir $(out)), \
|
---|
1538 | $(if $($(target)_INST), $(addprefix $(PATH_INS)/,$($(target)_INST)), $(definst)/))
|
---|
1539 |
|
---|
1540 | $(eval $(def_link_install_rule))
|
---|
1541 |
|
---|
1542 | _INSTALLS += $(INSTARGET_$(target))
|
---|
1543 |
|
---|
1544 | ifdef KBUILD_DO_AUTO_INSTALL
|
---|
1545 | $(typevar) += $(INSTARGET_$(target))
|
---|
1546 | else
|
---|
1547 | $(typevar) += $(out)
|
---|
1548 | endif
|
---|
1549 | else # _NOINST
|
---|
1550 | $(typevar) += $(out)
|
---|
1551 | endif
|
---|
1552 |
|
---|
1553 | _OUT_FILES += $($(target)_OUTPUT_)
|
---|
1554 | _CLEAN_FILES += $($(target)_CLEAN)
|
---|
1555 | _OBJS += $($(target)_OBJS_)
|
---|
1556 |
|
---|
1557 | endef
|
---|
1558 |
|
---|
1559 |
|
---|
1560 |
|
---|
1561 | #
|
---|
1562 | # LIBRARIES
|
---|
1563 | #
|
---|
1564 |
|
---|
1565 | ## Library (one).
|
---|
1566 | # @param $(target) Normalized library (target) name.
|
---|
1567 | define def_lib
|
---|
1568 | # library basics
|
---|
1569 | ## @todo prefix
|
---|
1570 | bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
|
---|
1571 | bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))
|
---|
1572 | bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_TARGET_ARCH))
|
---|
1573 | bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_TARGET_CPU))
|
---|
1574 | tool := $(call _TARGET_TOOL,$(target),AR)
|
---|
1575 | ifeq ($(tool),)
|
---|
1576 | $(error kBuild: Library target $(target) does not have a tool defined!)
|
---|
1577 | endif
|
---|
1578 | outbase := $(call _TARGET_BASE,$(target),$(target))
|
---|
1579 | PATH_$(target) := $(patsubst %/,%,$(dir $(outbase)))
|
---|
1580 | suff := $(firstword\
|
---|
1581 | $($(target)_LIBSUFF.$(bld_trg).$(bld_trg_arch))\
|
---|
1582 | $($(target)_LIBSUFF.$(bld_trg))\
|
---|
1583 | $($(target)_LIBSUFF)\
|
---|
1584 | $(TOOL_$(tool)_ARLIBSUFF.$(bld_trg).$(bld_trg_arch))\
|
---|
1585 | $(TOOL_$(tool)_ARLIBSUFF.$(bld_trg))\
|
---|
1586 | $(TOOL_$(tool)_ARLIBSUFF)\
|
---|
1587 | $(SUFF_LIB))
|
---|
1588 | out := $(outbase)$(suff)
|
---|
1589 | TARGET_$(target) := $(out)
|
---|
1590 | $(target)_OBJS_ :=
|
---|
1591 |
|
---|
1592 | # source -> object
|
---|
1593 | $(eval $(value def_target_sources))
|
---|
1594 |
|
---|
1595 | # library linking
|
---|
1596 | tool := $(call _TARGET_TOOL,$(target),AR)
|
---|
1597 | outbase := $(call _TARGET_BASE,$(target),$(target))
|
---|
1598 | flags :=\
|
---|
1599 | $(TOOL_$(tool)_ARFLAGS)\
|
---|
1600 | $(TOOL_$(tool)_ARFLAGS.$(bld_type))\
|
---|
1601 | $(ARFLAGS)\
|
---|
1602 | $(ARFLAGS.$(bld_type))\
|
---|
1603 | $($(target)_ARFLAGS)\
|
---|
1604 | $($(target)_ARFLAGS.$(bld_type)) \
|
---|
1605 | $($(target)_ARFLAGS.$(bld_trg)) \
|
---|
1606 | $($(target)_ARFLAGS.$(bld_trg_arch)) \
|
---|
1607 | $($(target)_ARFLAGS.$(bld_trg).$(bld_trg_arch)) \
|
---|
1608 | $($(target)_ARFLAGS.$(bld_trg_cpu))
|
---|
1609 | othersrc := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm %.o %.obj,\
|
---|
1610 | $($(target)_SOURCES) \
|
---|
1611 | $($(target)_SOURCES.$(bld_trg)) \
|
---|
1612 | $($(target)_SOURCES.$(bld_trg_arch)) \
|
---|
1613 | $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) \
|
---|
1614 | $($(target)_SOURCES.$(bld_trg_cpu)) \
|
---|
1615 | $($(target)_SOURCES.$(bld_type)))
|
---|
1616 | objs = $(filter %.o %.obj, \
|
---|
1617 | $($(target)_SOURCES) \
|
---|
1618 | $($(target)_SOURCES.$(bld_trg)) \
|
---|
1619 | $($(target)_SOURCES.$(bld_trg_arch)) \
|
---|
1620 | $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) \
|
---|
1621 | $($(target)_SOURCES.$(bld_trg_cpu)) \
|
---|
1622 | $($(target)_SOURCES.$(bld_type))) \
|
---|
1623 | $($(target)_OBJS_)
|
---|
1624 | dirdep := $(call DIRDEP,$(dir $(out)))
|
---|
1625 | ## @todo fix dependencies on makefiles an such
|
---|
1626 | deps := $($(target)_DEPS)
|
---|
1627 |
|
---|
1628 | # dependency file
|
---|
1629 | dep := $(out)$(SUFF_DEP)
|
---|
1630 | ifndef NO_LINK_CMDS_DEPS
|
---|
1631 | _DEPFILES_INCLUDED += $(dep)
|
---|
1632 | $(if $(wildcard $(dep)),$(eval include $(dep)))
|
---|
1633 | endif
|
---|
1634 |
|
---|
1635 | # check that the tool is defined.
|
---|
1636 | ifndef TOOL_$(tool)_LINK_LIBRARY_CMDS
|
---|
1637 | $(warning kBuild: tools: \
|
---|
1638 | 1 $($(target)_$(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
1639 | 2 $($(target)_$(source)TOOL.$(bld_trg)) \
|
---|
1640 | 3 $($(target)_$(source)TOOL) \
|
---|
1641 | 4 $($(target)_TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
1642 | 5 $($(target)_TOOL.$(bld_trg)) \
|
---|
1643 | 6 $($(target)_TOOL) \
|
---|
1644 | 7 $($(source)TOOL) \
|
---|
1645 | 8 $($(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
1646 | 9 $($(source)TOOL.$(bld_trg)) \
|
---|
1647 | 10 $(TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
1648 | 11 $(TOOL.$(bld_trg)) \
|
---|
1649 | 12 $(TOOL) )
|
---|
1650 | $(error kBuild: TOOL_$(tool)_LINK_LIBRARY_CMDS isn't defined! target=$(target) )
|
---|
1651 | endif
|
---|
1652 |
|
---|
1653 | # call the tool
|
---|
1654 | $(target)_CMDS_ := $(TOOL_$(tool)_LINK_LIBRARY_CMDS)
|
---|
1655 | $(target)_OUTPUT_ := $(TOOL_$(tool)_LINK_LIBRARY_OUTPUT)
|
---|
1656 | $(target)_DEPEND_ := $(TOOL_$(tool)_LINK_LIBRARY_DEPEND) $(deps) $(objs)
|
---|
1657 | $(target)_DEPORD_ := $(TOOL_$(tool)_LINK_LIBRARY_DEPORD) $(dirdep)
|
---|
1658 |
|
---|
1659 | # generate the link rule.
|
---|
1660 | $(eval $(def_link_rule))
|
---|
1661 |
|
---|
1662 | # installing and globals
|
---|
1663 | definst := $(PATH_LIB)
|
---|
1664 | typevar := _LIBS
|
---|
1665 | $(eval $(value def_target_install_pluss))
|
---|
1666 | endef
|
---|
1667 |
|
---|
1668 | # Process libraries
|
---|
1669 | mode := 0644
|
---|
1670 | $(foreach target, $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)) $(LIBRARIES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), $(eval $(value def_lib)))
|
---|
1671 |
|
---|
1672 |
|
---|
1673 | #
|
---|
1674 | # Link operations.
|
---|
1675 | #
|
---|
1676 |
|
---|
1677 | ##
|
---|
1678 | # Link prolog
|
---|
1679 | #
|
---|
1680 | # @param $(target) Normalized target name.
|
---|
1681 | # @param $(EXT) EXE,DLL,SYS.
|
---|
1682 | # @param $(definst) The default _INST value.
|
---|
1683 | # @param $(typevar) The name of the variable with all the root targets of its type.
|
---|
1684 | define def_link_common
|
---|
1685 | # basics
|
---|
1686 | bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
|
---|
1687 | bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_$(bld_trg_base_var)))
|
---|
1688 | bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_$(bld_trg_base_var)_ARCH))
|
---|
1689 | bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_$(bld_trg_base_var)_CPU))
|
---|
1690 |
|
---|
1691 | tool := $(call _TARGET_TOOL,$(target),LD)
|
---|
1692 | outbase := $(call _TARGET_BASE,$(target),$(target))
|
---|
1693 | suff := $(firstword \
|
---|
1694 | $($(target)_$(EXT)SUFF) \
|
---|
1695 | $($(target)_$(EXT)SUFF) \
|
---|
1696 | $(TOOL_$(tool)_LD$(EXT)SUFF) \
|
---|
1697 | $($(EXTPRE)SUFF_$(EXT)))
|
---|
1698 | out := $(outbase)$(suff)
|
---|
1699 | PATH_$(target) := $(patsubst %/,%,$(dir $(outbase)))
|
---|
1700 | TARGET_$(target) := $(out)
|
---|
1701 | $(target)_OBJS_ :=
|
---|
1702 |
|
---|
1703 | # source -> object
|
---|
1704 | $(eval $(value def_target_sources))
|
---|
1705 |
|
---|
1706 | # more library stuff.
|
---|
1707 | tool := $(call _TARGET_TOOL,$(target),LD)
|
---|
1708 | outbase := $(call _TARGET_BASE,$(target),$(target))
|
---|
1709 | flags :=\
|
---|
1710 | $(TOOL_$(tool)_LDFLAGS)\
|
---|
1711 | $(TOOL_$(tool)_LDFLAGS.$(bld_type))\
|
---|
1712 | $(TOOL_$(tool)_LDFLAGS.$(bld_trg))\
|
---|
1713 | $(TOOL_$(tool)_LDFLAGS.$(bld_trg_arch))\
|
---|
1714 | $(TOOL_$(tool)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\
|
---|
1715 | $(TOOL_$(tool)_LDFLAGS.$(bld_trg_cpu))\
|
---|
1716 | $(LDFLAGS)\
|
---|
1717 | $(LDFLAGS.$(bld_type))\
|
---|
1718 | $(LDFLAGS.$(bld_trg))\
|
---|
1719 | $(LDFLAGS.$(bld_trg_arch))\
|
---|
1720 | $(LDFLAGS.$(bld_trg).$(bld_trg_arch))\
|
---|
1721 | $(LDFLAGS.$(bld_trg_cpu))\
|
---|
1722 | $($(target)_LDFLAGS)\
|
---|
1723 | $($(target)_LDFLAGS.$(bld_type))\
|
---|
1724 | $($(target)_LDFLAGS.$(bld_trg))\
|
---|
1725 | $($(target)_LDFLAGS.$(bld_trg_arch))\
|
---|
1726 | $($(target)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\
|
---|
1727 | $($(target)_LDFLAGS.$(bld_trg_cpu))
|
---|
1728 | othersrc := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm %.o %.obj,\
|
---|
1729 | $($(target)_SOURCES)\
|
---|
1730 | $($(target)_SOURCES.$(bld_trg)) \
|
---|
1731 | $($(target)_SOURCES.$(bld_trg_arch)) \
|
---|
1732 | $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) \
|
---|
1733 | $($(target)_SOURCES.$(bld_trg_cpu)) \
|
---|
1734 | $($(target)_SOURCES.$(bld_type)))
|
---|
1735 | objs = $(filter %.o %.obj, \
|
---|
1736 | $($(target)_SOURCES) \
|
---|
1737 | $($(target)_SOURCES.$(bld_trg)) \
|
---|
1738 | $($(target)_SOURCES.$(bld_trg_arch)) \
|
---|
1739 | $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) \
|
---|
1740 | $($(target)_SOURCES.$(bld_trg_cpu)) \
|
---|
1741 | $($(target)_SOURCES.$(bld_type))) \
|
---|
1742 | $($(target)_OBJS_)
|
---|
1743 | libs :=\
|
---|
1744 | $($(target)_LIBS.$(bld_trg_cpu))\
|
---|
1745 | $($(target)_LIBS.$(bld_trg).$(bld_trg_arch))\
|
---|
1746 | $($(target)_LIBS.$(bld_trg_arch))\
|
---|
1747 | $($(target)_LIBS.$(bld_trg))\
|
---|
1748 | $($(target)_LIBS.$(bld_type))\
|
---|
1749 | $($(target)_LIBS)\
|
---|
1750 | $(foreach sdk, $($(target)_SDKS.$(bld_trg).$(bld_trg_arch)) \
|
---|
1751 | $($(target)_SDKS.$(bld_trg_arch)) \
|
---|
1752 | $($(target)_SDKS.$(bld_trg)) \
|
---|
1753 | $($(target)_SDKS.$(bld_type)) \
|
---|
1754 | $($(target)_SDKS),\
|
---|
1755 | $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
|
---|
1756 | $(SDK_$(sdk)_LIBS.$(bld_trg).$(bld_trg_arch))\
|
---|
1757 | $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
|
---|
1758 | $(SDK_$(sdk)_LIBS.$(bld_trg))\
|
---|
1759 | $(SDK_$(sdk)_LIBS.$(bld_type))\
|
---|
1760 | $(SDK_$(sdk)_LIBS))\
|
---|
1761 | $(LIBS.$(bld_trg_cpu))\
|
---|
1762 | $(LIBS.$(bld_trg).$(bld_trg_arch))\
|
---|
1763 | $(LIBS.$(bld_trg_arch))\
|
---|
1764 | $(LIBS.$(bld_trg))\
|
---|
1765 | $(LIBS.$(bld_type))\
|
---|
1766 | $(LIBS)\
|
---|
1767 | $(foreach sdk, $(SDKS.$(bld_trg).$(bld_trg_arch)) \
|
---|
1768 | $(SDKS.$(bld_trg_arch)) \
|
---|
1769 | $(SDKS.$(bld_trg)) \
|
---|
1770 | $(SDKS.$(bld_type)) \
|
---|
1771 | $(SDKS),\
|
---|
1772 | $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
|
---|
1773 | $(SDK_$(sdk)_LIBS.$(bld_trg).$(bld_trg_arch))\
|
---|
1774 | $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
|
---|
1775 | $(SDK_$(sdk)_LIBS.$(bld_trg))\
|
---|
1776 | $(SDK_$(sdk)_LIBS.$(bld_type))\
|
---|
1777 | $(SDK_$(sdk)_LIBS))\
|
---|
1778 | $(TOOL_$(tool)_LIBS.$(bld_trg_cpu))\
|
---|
1779 | $(TOOL_$(tool)_LIBS.$(bld_trg).$(bld_trg_arch))\
|
---|
1780 | $(TOOL_$(tool)_LIBS.$(bld_trg_arch))\
|
---|
1781 | $(TOOL_$(tool)_LIBS.$(bld_trg))\
|
---|
1782 | $(TOOL_$(tool)_LIBS.$(bld_type))\
|
---|
1783 | $(TOOL_$(tool)_LIBS)
|
---|
1784 | libpath :=\
|
---|
1785 | $($(target)_LIBPATH.$(bld_trg_cpu))\
|
---|
1786 | $($(target)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
|
---|
1787 | $($(target)_LIBPATH.$(bld_trg_arch))\
|
---|
1788 | $($(target)_LIBPATH.$(bld_trg))\
|
---|
1789 | $($(target)_LIBPATH.$(bld_type))\
|
---|
1790 | $($(target)_LIBPATH)\
|
---|
1791 | $(foreach sdk, $($(target)_SDKS.$(bld_trg).$(bld_trg_arch)) \
|
---|
1792 | $($(target)_SDKS.$(bld_trg_arch)) \
|
---|
1793 | $($(target)_SDKS.$(bld_trg)) \
|
---|
1794 | $($(target)_SDKS.$(bld_type)) \
|
---|
1795 | $($(target)_SDKS),\
|
---|
1796 | $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
|
---|
1797 | $(SDK_$(sdk)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
|
---|
1798 | $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
|
---|
1799 | $(SDK_$(sdk)_LIBPATH.$(bld_trg))\
|
---|
1800 | $(SDK_$(sdk)_LIBPATH.$(bld_type))\
|
---|
1801 | $(SDK_$(sdk)_LIBPATH))\
|
---|
1802 | $(LIBPATH.$(bld_trg_cpu))\
|
---|
1803 | $(LIBPATH.$(bld_trg).$(bld_trg_arch))\
|
---|
1804 | $(LIBPATH.$(bld_trg_arch))\
|
---|
1805 | $(LIBPATH.$(bld_trg))\
|
---|
1806 | $(LIBPATH.$(bld_type))\
|
---|
1807 | $(LIBPATH)\
|
---|
1808 | $(foreach sdk, $(SDKS.$(bld_trg).$(bld_trg_arch)) \
|
---|
1809 | $(SDKS.$(bld_trg_arch)) \
|
---|
1810 | $(SDKS.$(bld_trg)) \
|
---|
1811 | $(SDKS.$(bld_type)) \
|
---|
1812 | $(SDKS),\
|
---|
1813 | $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
|
---|
1814 | $(SDK_$(sdk)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
|
---|
1815 | $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
|
---|
1816 | $(SDK_$(sdk)_LIBPATH.$(bld_trg))\
|
---|
1817 | $(SDK_$(sdk)_LIBPATH.$(bld_type))\
|
---|
1818 | $(SDK_$(sdk)_LIBPATH))\
|
---|
1819 | $(TOOL_$(tool)_LIBPATH.$(bld_trg_cpu))\
|
---|
1820 | $(TOOL_$(tool)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
|
---|
1821 | $(TOOL_$(tool)_LIBPATH.$(bld_trg_arch))\
|
---|
1822 | $(TOOL_$(tool)_LIBPATH.$(bld_trg))\
|
---|
1823 | $(TOOL_$(tool)_LIBPATH.$(bld_type))\
|
---|
1824 | $(TOOL_$(tool)_LIBPATH)
|
---|
1825 | dirdep := $(call DIRDEP,$(dir $(out)))
|
---|
1826 | ## @todo fix dependencies
|
---|
1827 | deps := $($(target)_DEPS)
|
---|
1828 |
|
---|
1829 | ## @todo this stuff can't be working.
|
---|
1830 | custom_pre := $(strip $(firstword \
|
---|
1831 | $($(target)_CUSTOM_PRE.$(bld_trg).$(bld_trg_arch))\
|
---|
1832 | $($(target)_CUSTOM_PRE.$(bld_trg).$(bld_type))\
|
---|
1833 | $($(target)_CUSTOM_PRE.$(bld_trg))\
|
---|
1834 | $($(target)_CUSTOM_PRE.$(bld_type))\
|
---|
1835 | $($(target)_CUSTOM_PRE)\
|
---|
1836 | $(CUSTOM_PRE.$(bld_trg).$(bld_trg_arch))\
|
---|
1837 | $(CUSTOM_PRE.$(bld_trg).$(bld_type))\
|
---|
1838 | $(CUSTOM_PRE.$(bld_trg))\
|
---|
1839 | $(CUSTOM_PRE.$(bld_type))\
|
---|
1840 | $(CUSTOM_PRE)\
|
---|
1841 | ))
|
---|
1842 | custom_post := $(strip $(firstword \
|
---|
1843 | $($(target)_CUSTOM_POST.$(bld_trg).$(bld_trg_arch))\
|
---|
1844 | $($(target)_CUSTOM_POST.$(bld_trg).$(bld_type))\
|
---|
1845 | $($(target)_CUSTOM_POST.$(bld_trg))\
|
---|
1846 | $($(target)_CUSTOM_POST.$(bld_type))\
|
---|
1847 | $($(target)_CUSTOM_POST)\
|
---|
1848 | $(CUSTOM_POST.$(bld_trg).$(bld_trg_arch))\
|
---|
1849 | $(CUSTOM_POST.$(bld_trg).$(bld_type))\
|
---|
1850 | $(CUSTOM_POST.$(bld_trg))\
|
---|
1851 | $(CUSTOM_POST.$(bld_type))\
|
---|
1852 | $(CUSTOM_POST)\
|
---|
1853 | ))
|
---|
1854 |
|
---|
1855 | # installation targets
|
---|
1856 | ifndef $(target)_NOINST
|
---|
1857 | INSTARGET_$(target) := $(patsubst %/,%/$(notdir $(out)), \
|
---|
1858 | $(if $($(target)_INST), $(addprefix $(PATH_INS)/,$($(target)_INST)), $(definst)/))
|
---|
1859 | ifdef KBUILD_DO_AUTO_INSTALL
|
---|
1860 | $(typevar) += $(INSTARGET_$(target))
|
---|
1861 | else
|
---|
1862 | $(typevar) += $(out)
|
---|
1863 | endif
|
---|
1864 | # generate the install rule
|
---|
1865 | $(eval $(def_link_install_rule))
|
---|
1866 |
|
---|
1867 | else # NOINST
|
---|
1868 | INSTARGET_$(target) :=
|
---|
1869 | $(typevar) += $(out)
|
---|
1870 | endif # NOINST
|
---|
1871 |
|
---|
1872 | # dependency file
|
---|
1873 | dep := $(outbase)$(SUFF_DEP)
|
---|
1874 | ifndef NO_LINK_CMDS_DEPS
|
---|
1875 | _DEPFILES_INCLUDED += $(dep)
|
---|
1876 | $(if $(wildcard $(dep)),$(eval include $(dep)))
|
---|
1877 | endif
|
---|
1878 |
|
---|
1879 | # check that the tool is defined.
|
---|
1880 | ifndef TOOL_$(tool)_$(tool_do)_CMDS
|
---|
1881 | $(warning kBuild: tools: \
|
---|
1882 | 1 $($(target)_$(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
1883 | 2 $($(target)_$(source)TOOL.$(bld_trg)) \
|
---|
1884 | 3 $($(target)_$(source)TOOL) \
|
---|
1885 | 4 $($(target)_TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
1886 | 5 $($(target)_TOOL.$(bld_trg)) \
|
---|
1887 | 6 $($(target)_TOOL) \
|
---|
1888 | 7 $($(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
1889 | 8 $($(source)TOOL.$(bld_trg)) \
|
---|
1890 | 9 $($(source)TOOL) \
|
---|
1891 | 10 $(TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
1892 | 11 $(TOOL.$(bld_trg)) \
|
---|
1893 | 12 $(TOOL) )
|
---|
1894 | $(error kBuild: TOOL_$(tool)_$(tool_do)_CMDS isn't defined! target=$(target) )
|
---|
1895 | endif
|
---|
1896 |
|
---|
1897 | # call the tool
|
---|
1898 | $(target)_CMDS_ := $(TOOL_$(tool)_$(tool_do)_CMDS)
|
---|
1899 | $(target)_OUTPUT_ := $(TOOL_$(tool)_$(tool_do)_OUTPUT)
|
---|
1900 | $(target)_DEPEND_ := $(TOOL_$(tool)_$(tool_do)_DEPEND) $(deps) $(objs)
|
---|
1901 | $(target)_DEPORD_ := $(TOOL_$(tool)_$(tool_do)_DEPORD) $(dirdep)
|
---|
1902 |
|
---|
1903 | # generate the link rule.
|
---|
1904 | $(eval $(def_link_rule))
|
---|
1905 |
|
---|
1906 |
|
---|
1907 | # Update globals.
|
---|
1908 | _OBJS += $($(target)_OBJS_)
|
---|
1909 | _OUT_FILES += $($(target)_OUTPUT_) $(out)
|
---|
1910 | _CLEAN_FILES += $($(target)_CLEAN)
|
---|
1911 | _INSTALLS += $(INSTARGET_$(target))
|
---|
1912 |
|
---|
1913 | endef
|
---|
1914 |
|
---|
1915 |
|
---|
1916 | #
|
---|
1917 | # BLDPROGS
|
---|
1918 | #
|
---|
1919 |
|
---|
1920 | ## Build program (one).
|
---|
1921 | # @param $(target) Normalized target (program) name.
|
---|
1922 | define def_bldprog
|
---|
1923 |
|
---|
1924 | # set NOINST if not forced installation.
|
---|
1925 | ifndef $(target)_INST
|
---|
1926 | $(target)_NOINST := 1
|
---|
1927 | endif
|
---|
1928 |
|
---|
1929 | # do the usual stuff.
|
---|
1930 | $(eval $(value def_link_common))
|
---|
1931 |
|
---|
1932 | endef
|
---|
1933 |
|
---|
1934 | # Process build programs.
|
---|
1935 | EXT := EXE
|
---|
1936 | EXTPRE := HOST
|
---|
1937 | tool_do := LINK_PROGRAM
|
---|
1938 | definst := $(PATH_BIN)
|
---|
1939 | typevar := _BLDPROGS
|
---|
1940 | mode := 0755
|
---|
1941 | bld_trg_base_var := PLATFORM
|
---|
1942 | $(foreach target, $(BLDPROGS) $(BLDPROGS.$(BUILD_PLATFORM)) $(BLDPROGS.$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)), $(eval $(value def_bldprog)))
|
---|
1943 |
|
---|
1944 |
|
---|
1945 |
|
---|
1946 | #
|
---|
1947 | # DLLS
|
---|
1948 | #
|
---|
1949 |
|
---|
1950 | # Process dlls
|
---|
1951 | EXT := DLL
|
---|
1952 | EXTPRE :=
|
---|
1953 | tool_do := LINK_DLL
|
---|
1954 | definst := $(PATH_DLL)
|
---|
1955 | typevar := _DLLS
|
---|
1956 | mode := 0755
|
---|
1957 | bld_trg_base_var := TARGET
|
---|
1958 | $(foreach target, $(DLLS) $(DLLS.$(BUILD_TARGET)) $(DLLS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), $(eval $(value def_link_common)))
|
---|
1959 |
|
---|
1960 |
|
---|
1961 | #
|
---|
1962 | # Process import libraries.
|
---|
1963 | #
|
---|
1964 | # - On OS/2 and windows these are libraries.
|
---|
1965 | # - On other platforms they are fake DLLs.
|
---|
1966 | ifeq ($(filter-out nt os2 win win64 win32,$(BUILD_TARGET)),)
|
---|
1967 | $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)) $(IMPORT_LIBS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), $(eval $(value def_lib)))
|
---|
1968 | else
|
---|
1969 | $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)) $(IMPORT_LIBS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), $(eval $(value def_link_common)))
|
---|
1970 | endif
|
---|
1971 | $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)) $(IMPORT_LIBS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
|
---|
1972 | $(eval _IMPORT_LIBS += $(if $(INSTARGET_$(target)),$(INSTARGET_$(target)), $(TARGET_$(target)))))
|
---|
1973 |
|
---|
1974 |
|
---|
1975 | #
|
---|
1976 | # PROGRAMS
|
---|
1977 | #
|
---|
1978 |
|
---|
1979 | # Process programs
|
---|
1980 | EXT := EXE
|
---|
1981 | EXTPRE :=
|
---|
1982 | tool_do := LINK_PROGRAM
|
---|
1983 | definst := $(PATH_BIN)
|
---|
1984 | typevar := _PROGRAMS
|
---|
1985 | mode := 0755
|
---|
1986 | bld_trg_base_var := TARGET
|
---|
1987 | $(foreach target, $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)) $(PROGRAMS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), $(eval $(value def_link_common)))
|
---|
1988 |
|
---|
1989 |
|
---|
1990 |
|
---|
1991 | #
|
---|
1992 | # SYSMODS
|
---|
1993 | #
|
---|
1994 |
|
---|
1995 | # Process sysmods
|
---|
1996 | EXT := SYS
|
---|
1997 | EXTPRE :=
|
---|
1998 | tool_do := LINK_SYSMOD
|
---|
1999 | definst := $(PATH_SYS)
|
---|
2000 | typevar := _SYSMODS
|
---|
2001 | mode := 0644
|
---|
2002 | bld_trg_base_var := TARGET
|
---|
2003 | $(foreach target, $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)) $(SYSMODS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), $(eval $(value def_link_common)))
|
---|
2004 |
|
---|
2005 |
|
---|
2006 | #
|
---|
2007 | # OTHERS
|
---|
2008 | #
|
---|
2009 | _OTHERS = $(OTHERS) $(OTHERS.$(BUILD_TARGET)) $(OTHERS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH))
|
---|
2010 |
|
---|
2011 |
|
---|
2012 | #
|
---|
2013 | # INSTALLS
|
---|
2014 | #
|
---|
2015 |
|
---|
2016 | ## generate the install rule
|
---|
2017 | define def_install_src_rule
|
---|
2018 | # the install rule
|
---|
2019 | $(insdst) : $(srcsrc) | $(call DIRDEP,$(dir $(insdst)))
|
---|
2020 | $$(if $$(filter $(INSTALL),$(inscmd)),,$$(RM) -f $$@)
|
---|
2021 | $(inscmd)
|
---|
2022 | endef
|
---|
2023 |
|
---|
2024 | ## install one file
|
---|
2025 | define def_install_src
|
---|
2026 |
|
---|
2027 | # deal with '=>' in the source file name.
|
---|
2028 | srcdst := $(subst =>, ,$(src))
|
---|
2029 | srcsrc := $(firstword $(srcdst))
|
---|
2030 | srcdstdir := $(dir $(word 2,$(srcdst)))
|
---|
2031 | srcdst := $(word $(words $(srcdst)),$(srcdst))
|
---|
2032 |
|
---|
2033 | # _INSTFUN
|
---|
2034 | ifdef $(srcsrc)_INSTFUN
|
---|
2035 | instfun := $(srcsrc)_INSTFUN
|
---|
2036 | else
|
---|
2037 | ifdef $(target)_INSTFUN
|
---|
2038 | instfun := $(target)_INSTFUN
|
---|
2039 | else
|
---|
2040 | instfun := _INSTALL_FILE
|
---|
2041 | endif
|
---|
2042 | endif
|
---|
2043 |
|
---|
2044 | # _INST
|
---|
2045 | ifdef $(srcsrc)_INST
|
---|
2046 | inst := $(patsubst %/,%,$($(srcsrc)_INST))/$(dir $(srcdstdir))
|
---|
2047 | else
|
---|
2048 | ifdef $(target)_INST
|
---|
2049 | inst := $(patsubst %/,%,$($(target)_INST))/$(dir $(srcdstdir))
|
---|
2050 | else
|
---|
2051 | inst := $(dir $(srcdstdir))
|
---|
2052 | endif
|
---|
2053 | endif
|
---|
2054 |
|
---|
2055 | # calc target
|
---|
2056 | insdst := $(call $(instfun),$(srcdst),$(target),$(inst),$(PATH_INS))
|
---|
2057 | #$(warning instfun=$(instfun) srcdst=$(srcdst) target=$(target) inst=$(inst) => insdst=$(insdst))
|
---|
2058 |
|
---|
2059 | # mode, uid and gid
|
---|
2060 | mode := $(firstword \
|
---|
2061 | $($(target)_$(srcsrc)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
2062 | $($(target)_$(srcsrc)_MODE.$(bld_trg)) \
|
---|
2063 | $($(target)_$(srcsrc)_MODE) \
|
---|
2064 | $($(target)_$(srcdst)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
2065 | $($(target)_$(srcdst)_MODE.$(bld_trg)) \
|
---|
2066 | $($(target)_$(srcdst)_MODE) \
|
---|
2067 | $($(srcsrc)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
2068 | $($(srcsrc)_MODE.$(bld_trg)) \
|
---|
2069 | $($(srcsrc)_MODE) \
|
---|
2070 | $($(srcdst)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
2071 | $($(srcdst)_MODE.$(bld_trg)) \
|
---|
2072 | $($(srcdst)_MODE) \
|
---|
2073 | $($(target)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
2074 | $($(target)_MODE.$(bld_trg)) \
|
---|
2075 | $($(target)_MODE))
|
---|
2076 | uid := $(firstword \
|
---|
2077 | $($(target)_$(srcsrc)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
2078 | $($(target)_$(srcsrc)_UID.$(bld_trg)) \
|
---|
2079 | $($(target)_$(srcsrc)_UID) \
|
---|
2080 | $($(target)_$(srcdst)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
2081 | $($(target)_$(srcdst)_UID.$(bld_trg)) \
|
---|
2082 | $($(target)_$(srcdst)_UID) \
|
---|
2083 | $($(srcsrc)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
2084 | $($(srcsrc)_UID.$(bld_trg)) \
|
---|
2085 | $($(srcsrc)_UID) \
|
---|
2086 | $($(srcdst)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
2087 | $($(srcdst)_UID.$(bld_trg)) \
|
---|
2088 | $($(srcdst)_UID) \
|
---|
2089 | $($(target)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
2090 | $($(target)_UID.$(bld_trg)) \
|
---|
2091 | $($(target)_UID))
|
---|
2092 | gid := $(firstword \
|
---|
2093 | $($(target)_$(srcsrc)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
2094 | $($(target)_$(srcsrc)_GID.$(bld_trg)) \
|
---|
2095 | $($(target)_$(srcsrc)_GID) \
|
---|
2096 | $($(target)_$(srcdst)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
2097 | $($(target)_$(srcdst)_GID.$(bld_trg)) \
|
---|
2098 | $($(target)_$(srcdst)_GID) \
|
---|
2099 | $($(srcsrc)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
2100 | $($(srcsrc)_GID.$(bld_trg)) \
|
---|
2101 | $($(srcsrc)_GID) \
|
---|
2102 | $($(srcdst)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
2103 | $($(srcdst)_GID.$(bld_trg)) \
|
---|
2104 | $($(srcdst)_GID) \
|
---|
2105 | $($(target)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
2106 | $($(target)_GID.$(bld_trg)) \
|
---|
2107 | $($(target)_GID))
|
---|
2108 |
|
---|
2109 | # create the command
|
---|
2110 | ifdef $(srcsrc)_INSTALLER
|
---|
2111 | inscmd := $(call $(srcsrc)_INSTALLER,$(srcsrc),$(insdst),$(target))
|
---|
2112 | else
|
---|
2113 | ifdef $(target)_INSTALLER
|
---|
2114 | inscmd := $(call $(target)_INSTALLER,$(srcsrc),$(insdst),$(target))
|
---|
2115 | else
|
---|
2116 | inscmd := $$(INSTALL)\
|
---|
2117 | $(if $(uid),-o $(uid))\
|
---|
2118 | $(if $(gid),-g $(gid))\
|
---|
2119 | $(if $(mode),-m $(mode))\
|
---|
2120 | $(srcsrc) $(insdst)
|
---|
2121 | endif
|
---|
2122 | endif
|
---|
2123 |
|
---|
2124 | # generate the rule (need double evaluation here)
|
---|
2125 | $(eval $(def_install_src_rule))
|
---|
2126 |
|
---|
2127 | INSTARGET_$(target) += $(insdst)
|
---|
2128 | endef
|
---|
2129 |
|
---|
2130 |
|
---|
2131 | ## generate the symlink rule
|
---|
2132 | define def_install_symlink_rule
|
---|
2133 | # the install rule
|
---|
2134 | $(insdst) : | $(call DIRDEP,$(dir $(insdst)))
|
---|
2135 | $$(RM) -f $$@
|
---|
2136 | $$(LN_SYMLINK) $(symdst) $(insdst)
|
---|
2137 | endef
|
---|
2138 |
|
---|
2139 | ## create one symlink
|
---|
2140 | define def_install_symlink
|
---|
2141 |
|
---|
2142 | # deal with '=>' in the source file name.
|
---|
2143 | symdst := $(subst =>, ,$(src))
|
---|
2144 | symlnk := $(firstword $(symdst))
|
---|
2145 | symdst := $(word $(words $(symdst)),$(symdst))
|
---|
2146 |
|
---|
2147 | # _INSTFUN
|
---|
2148 | ifdef $(symlnk)_INSTFUN
|
---|
2149 | instfun := $(symlnk)_INSTFUN
|
---|
2150 | else
|
---|
2151 | ifdef $(target)_INSTFUN
|
---|
2152 | instfun := $(target)_INSTFUN
|
---|
2153 | else
|
---|
2154 | instfun := _INSTALL_FILE
|
---|
2155 | endif
|
---|
2156 | endif
|
---|
2157 |
|
---|
2158 | # _INST
|
---|
2159 | ifdef $(symlnk)_INST
|
---|
2160 | inst := $(patsubst %/,%,$($(symlnk)_INST))/$(dir $(symlnk))
|
---|
2161 | else
|
---|
2162 | ifdef $(target)_INST
|
---|
2163 | inst := $(patsubst %/,%,$($(target)_INST))/$(dir $(symlnk))
|
---|
2164 | else
|
---|
2165 | inst := $(dir $(symlnk))
|
---|
2166 | endif
|
---|
2167 | endif
|
---|
2168 |
|
---|
2169 | # calc target
|
---|
2170 | insdst := $(call $(instfun),$(symlnk),$(target),$(inst),$(PATH_INS))
|
---|
2171 | #$(warning symlnk=$(symlnk) symdst=$(symdst) insdst=$(insdst) instfun=$(instfun) inst='$(inst)')
|
---|
2172 |
|
---|
2173 | # generate the rule (need double evaluation here)
|
---|
2174 | $(eval $(def_install_symlink_rule))
|
---|
2175 |
|
---|
2176 | INSTARGET_$(target) += $(insdst)
|
---|
2177 | endef
|
---|
2178 |
|
---|
2179 |
|
---|
2180 | ## generate the install rule
|
---|
2181 | define def_install_directory_rule
|
---|
2182 | # the install rule
|
---|
2183 | $(insdst):
|
---|
2184 | $(INSTALL) -d \
|
---|
2185 | $(if $(uid),-o $(uid))\
|
---|
2186 | $(if $(gid),-g $(gid))\
|
---|
2187 | $(if $(mode),-m $(mode))\
|
---|
2188 | $(insdst)
|
---|
2189 |
|
---|
2190 | .NOTPARALLEL: $(insdst)
|
---|
2191 | endef
|
---|
2192 |
|
---|
2193 |
|
---|
2194 | ## create one directory
|
---|
2195 | define def_install_directory
|
---|
2196 |
|
---|
2197 | # _INST
|
---|
2198 | ifdef $(directory)_INST
|
---|
2199 | inst := $(PATH_INS)/$(patsubst %/,%,$($(directory)_INST))
|
---|
2200 | else
|
---|
2201 | ifdef $(target)_INST
|
---|
2202 | inst := $(PATH_INS)/$(patsubst %/,%,$($(target)_INST))
|
---|
2203 | else
|
---|
2204 | inst := $(PATH_INS)
|
---|
2205 | endif
|
---|
2206 | endif
|
---|
2207 |
|
---|
2208 | mode := $(firstword \
|
---|
2209 | $($(target)_$(directory)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
2210 | $($(target)_$(directory)_MODE.$(bld_trg)) \
|
---|
2211 | $($(target)_$(directory)_MODE) \
|
---|
2212 | $($(directory)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
2213 | $($(directory)_MODE.$(bld_trg)) \
|
---|
2214 | $($(directory)_MODE) \
|
---|
2215 | $($(target)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
2216 | $($(target)_MODE.$(bld_trg)) \
|
---|
2217 | $($(target)_MODE))
|
---|
2218 | uid := $(firstword \
|
---|
2219 | $($(target)_$(directory)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
2220 | $($(target)_$(directory)_UID.$(bld_trg)) \
|
---|
2221 | $($(target)_$(directory)_UID) \
|
---|
2222 | $($(directory)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
2223 | $($(directory)_UID.$(bld_trg)) \
|
---|
2224 | $($(directory)_UID) \
|
---|
2225 | $($(target)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
2226 | $($(target)_UID.$(bld_trg)) \
|
---|
2227 | $($(target)_UID))
|
---|
2228 | gid := $(firstword \
|
---|
2229 | $($(target)_$(directory)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
2230 | $($(target)_$(directory)_GID.$(bld_trg)) \
|
---|
2231 | $($(target)_$(directory)_GID) \
|
---|
2232 | $($(directory)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
2233 | $($(directory)_GID.$(bld_trg)) \
|
---|
2234 | $($(directory)_GID) \
|
---|
2235 | $($(target)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
2236 | $($(target)_GID.$(bld_trg)) \
|
---|
2237 | $($(target)_GID))
|
---|
2238 |
|
---|
2239 | insdst := $(inst)/$(directory)/
|
---|
2240 | #$(warning directory=$(directory) inst=$(inst) insdst=$(insdst) mode=$(mode) gid=$(gid) uid=$(uid))
|
---|
2241 |
|
---|
2242 | # generate the rule (need double evaluation here)
|
---|
2243 | $(eval $(def_install_directory_rule))
|
---|
2244 |
|
---|
2245 | INSTARGET_DIRS_$(target) += $(insdst)
|
---|
2246 | endef
|
---|
2247 |
|
---|
2248 |
|
---|
2249 | ## process one install target.
|
---|
2250 | define def_install
|
---|
2251 | bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
|
---|
2252 | bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))
|
---|
2253 | bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_TARGET_ARCH))
|
---|
2254 | bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_TARGET_CPU))
|
---|
2255 |
|
---|
2256 | INSTARGET_$(target) :=
|
---|
2257 | INSTARGET_DIRS_$(target) :=
|
---|
2258 |
|
---|
2259 | $(foreach directory,$($(target)_DIRS) $($(target)_DIRS.$(bld_trg)) $($(target)_DIRS.$(bld_trg).$(bld_trg_arch)) $($(target)_DIRS.$(bld_trg_arch)) $($(target)_DIRS.$(bld_trg_cpu)) $($(target)_DIRS.$(bld_type)), \
|
---|
2260 | $(eval $(value def_install_directory)))
|
---|
2261 |
|
---|
2262 | $(foreach src,$($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_cpu)) $($(target)_SOURCES.$(bld_type)), \
|
---|
2263 | $(eval $(value def_install_src)))
|
---|
2264 |
|
---|
2265 | $(foreach src,$($(target)_SYMLINKS) $($(target)_SYMLINKS.$(bld_trg)) $($(target)_SYMLINKS.$(bld_trg).$(bld_trg_arch)) $($(target)_SYMLINKS.$(bld_trg_arch)) $($(target)_SYMLINKS.$(bld_trg_cpu)) $($(target)_SYMLINKS.$(bld_type)), \
|
---|
2266 | $(eval $(value def_install_symlink)))
|
---|
2267 |
|
---|
2268 | _INSTALLS += $(INSTARGET_$(target)) $($(target)_GOALS)
|
---|
2269 | _INSTALLS_DIRS += $(INSTARGET_DIRS_$(target))
|
---|
2270 | endef
|
---|
2271 |
|
---|
2272 | ## process all install targets
|
---|
2273 | $(foreach target, $(INSTALLS) $(INSTALLS.$(BUILD_TARGET)) $(INSTALLS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
|
---|
2274 | $(eval $(value def_install)))
|
---|
2275 |
|
---|
2276 |
|
---|
2277 | #
|
---|
2278 | # PACKING
|
---|
2279 | #
|
---|
2280 | _PACKING += $(PACKING) $(PACKING.$(BUILD_TARGET)) $(PACKING.$(BUILD_TARGET).$(BUILD_TARGET_ARCH))
|
---|
2281 |
|
---|
2282 |
|
---|
2283 | #
|
---|
2284 | # DOCS
|
---|
2285 | #
|
---|
2286 |
|
---|
2287 |
|
---|
2288 | #
|
---|
2289 | # DIRECTORIES
|
---|
2290 | #
|
---|
2291 | _DIR_ALL := $(sort $(addsuffix /,$(patsubst %/,%,$(_DIRS))) $(dir $(_OUT_FILES) $(_OBJS) $(_INSTALLS)))
|
---|
2292 | $(foreach directory,$(_INSTALLS_DIRS), $(eval _DIR_ALL := $(filter-out $(directory),$(_DIR_ALL))))
|
---|
2293 |
|
---|
2294 |
|
---|
2295 | define def_mkdir_rule
|
---|
2296 | $(directory):
|
---|
2297 | $(call MSG_L1,Creating directory $$@)
|
---|
2298 | $(MKDIR) -p $$@
|
---|
2299 | endef
|
---|
2300 |
|
---|
2301 | $(foreach directory,$(_DIR_ALL),$(eval $(def_mkdir_rule)))
|
---|
2302 |
|
---|
2303 |
|
---|
2304 | #
|
---|
2305 | # NOTHING
|
---|
2306 | #
|
---|
2307 | do-nothing:
|
---|
2308 | $(call MSG_L1,Did nothing in $(CURDIR))
|
---|
2309 |
|
---|
2310 |
|
---|
2311 | #
|
---|
2312 | # CLEAN UP
|
---|
2313 | #
|
---|
2314 | do-clean:
|
---|
2315 | $(RM) -f $(_OUT_FILES) $(_OBJS) $(_DEPFILES) $(_DEPFILES_INCLUDED) $(_CLEAN_FILES) $(OTHER_CLEAN)
|
---|
2316 |
|
---|
2317 |
|
---|
2318 | #
|
---|
2319 | # PASSES (including directory and makefile walking)
|
---|
2320 | #
|
---|
2321 |
|
---|
2322 | ## Subdir
|
---|
2323 | # @param $(pass) Lowercase pass name.
|
---|
2324 | # @param $(PASS) Uppercase pass name.
|
---|
2325 | # @param $(subdir) Subdirectory
|
---|
2326 | # @param $(tag) tag to attach to the rule name.
|
---|
2327 | define def_pass_subdir
|
---|
2328 | pass_$(pass)$(tag):: $(dep)
|
---|
2329 | + $(QUIET)$$(MAKE) -C $(subdir) -f $$(notdir $$(firstword $$(wildcard $$(addprefix $(subdir)/,$$(DEFAULT_MAKEFILE))))) pass_$(pass)
|
---|
2330 | endef
|
---|
2331 |
|
---|
2332 | ## Submakefile
|
---|
2333 | # @param $(pass) Lowercase pass name.
|
---|
2334 | # @param $(PASS) Uppercase pass name.
|
---|
2335 | # @param $(makefile) Makefile.
|
---|
2336 | # @param $(tag) tag to attach to the rule name.
|
---|
2337 | define def_pass_makefile
|
---|
2338 | pass_$(pass)$(tag):: $(dep)
|
---|
2339 | + $(QUIET)$$(MAKE) -C $(patsubst %/,%,$(dir $(makefile))) -f $(notdir $(makefile)) pass_$(pass)
|
---|
2340 | endef
|
---|
2341 |
|
---|
2342 | ## Execute a pass.
|
---|
2343 | # @param $(pass) Lowercase pass name.
|
---|
2344 | # @param $(PASS) Uppercase pass name.
|
---|
2345 | define def_pass_old
|
---|
2346 | $(eval SUBDIRS_$(PASS) ?= $(SUBDIRS) $(SUBDIRS.$(BUILD_TARGET)) $(SUBDIRS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
|
---|
2347 | $(eval SUBDIRS_AFTER_$(PASS) ?= $(SUBDIRS_AFTER) $(SUBDIRS_AFTER.$(BUILD_TARGET)) $(SUBDIRS_AFTER.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
|
---|
2348 | $(eval MAKEFILES_BEFORE_$(PASS) ?= $(MAKEFILES_BEFORE) $(MAKEFILES_BEFORE.$(BUILD_TARGET)) $(MAKEFILES_BEFORE.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
|
---|
2349 | $(eval MAKEFILES_AFTER_$(PASS) ?= $(MAKEFILES_AFTER) $(MAKEFILES_AFTER.$(BUILD_TARGET)) $(MAKEFILES_AFTER.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
|
---|
2350 |
|
---|
2351 | $(eval tag:=_before)
|
---|
2352 | $(eval dep:=)
|
---|
2353 | $(foreach subdir,$(SUBDIRS_$(PASS)) $(SUBDIRS_$(PASS).$(BUILD_TARGET)) $(SUBDIRS_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir)))
|
---|
2354 | $(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(BUILD_TARGET)) $(MAKEFILES_BEFORE_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)),$(eval $(def_pass_makefile)))
|
---|
2355 |
|
---|
2356 | $(eval tag:=_after)
|
---|
2357 | $(eval dep:=pass_$(pass)_doit)
|
---|
2358 | $(foreach subdir,$(SUBDIRS_AFTER_$(PASS)) $(SUBDIRS_AFTER_$(PASS).$(BUILD_TARGET)) $(SUBDIRS_AFTER_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir)))
|
---|
2359 | $(foreach makefile,$(MAKEFILES_AFTER_$(PASS)) $(MAKEFILES_AFTER_$(PASS).$(BUILD_TARGET)) $(MAKEFILES_AFTER_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) ,$(eval $(def_pass_makefile)))
|
---|
2360 |
|
---|
2361 | .NOTPARALLEL: pass_$(pass)_before pass_$(pass)_after
|
---|
2362 | .PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_doit pass_$(pass)_after
|
---|
2363 | pass_$(pass)_doit: $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$(var))
|
---|
2364 | pass_$(pass)_this: pass_$(pass)_before
|
---|
2365 | + $(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)_doit
|
---|
2366 | pass_$(pass)_after:: pass_$(pass)_this
|
---|
2367 | pass_$(pass): pass_$(pass)_after
|
---|
2368 |
|
---|
2369 | endef
|
---|
2370 |
|
---|
2371 | define def_pass
|
---|
2372 | $(eval SUBDIRS_$(PASS) ?= $(SUBDIRS) $(SUBDIRS.$(BUILD_TARGET)) $(SUBDIRS.$(BUILD_TARGET.$(BUILD_TARGET_ARCH))) )
|
---|
2373 | $(eval SUBDIRS_AFTER_$(PASS) ?= $(SUBDIRS_AFTER) $(SUBDIRS_AFTER.$(BUILD_TARGET)) $(SUBDIRS_AFTER.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
|
---|
2374 | $(eval MAKEFILES_BEFORE_$(PASS) ?= $(MAKEFILES_BEFORE) $(MAKEFILES_BEFORE.$(BUILD_TARGET)) $(MAKEFILES_BEFORE.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
|
---|
2375 | $(eval MAKEFILES_AFTER_$(PASS) ?= $(MAKEFILES_AFTER) $(MAKEFILES_AFTER.$(BUILD_TARGET)) $(MAKEFILES_AFTER.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
|
---|
2376 |
|
---|
2377 | $(eval tag:=_before)
|
---|
2378 | $(eval dep:=)
|
---|
2379 | $(foreach subdir,$(SUBDIRS_$(PASS)) $(SUBDIRS_$(PASS).$(BUILD_TARGET)) $(SUBDIRS_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir)))
|
---|
2380 | $(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(BUILD_TARGET)) $(MAKEFILES_BEFORE_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)),$(eval $(def_pass_makefile)))
|
---|
2381 |
|
---|
2382 | $(eval tag:=_after)
|
---|
2383 | $(eval dep:=pass_$(pass)_doit)
|
---|
2384 | $(foreach subdir,$(SUBDIRS_AFTER_$(PASS)) $(SUBDIRS_AFTER_$(PASS).$(BUILD_TARGET)) $(SUBDIRS_AFTER_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir)))
|
---|
2385 | $(foreach makefile,$(MAKEFILES_AFTER_$(PASS)) $(MAKEFILES_AFTER_$(PASS).$(BUILD_TARGET)) $(MAKEFILES_AFTER_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) ,$(eval $(def_pass_makefile)))
|
---|
2386 |
|
---|
2387 | ifdef KBUILD_SAFE_PARALLEL
|
---|
2388 | .NOTPARALLEL: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_this
|
---|
2389 | .PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_this pass_$(pass)_doit
|
---|
2390 | pass_$(pass)_doit: $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$(var))
|
---|
2391 | pass_$(pass)_this: pass_$(pass)_before
|
---|
2392 | + $(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)_doit
|
---|
2393 | pass_$(pass)_after:: pass_$(pass)_this
|
---|
2394 | pass_$(pass): pass_$(pass)_after
|
---|
2395 | else
|
---|
2396 | .NOTPARALLEL: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_doit
|
---|
2397 | .PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_doit
|
---|
2398 | pass_$(pass)_doit: pass_$(pass)_before \
|
---|
2399 | $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var)))
|
---|
2400 | pass_$(pass): \
|
---|
2401 | pass_$(pass)_before \
|
---|
2402 | pass_$(pass)_doit \
|
---|
2403 | pass_$(pass)_after
|
---|
2404 | endif
|
---|
2405 |
|
---|
2406 | #$ (warning pass=$(pass) PASS=$(PASS): $(PASS_$(PASS)_trgs) $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var))))
|
---|
2407 | endef
|
---|
2408 |
|
---|
2409 | # Generate the defined passes.
|
---|
2410 | $(foreach PASS, $(PASSES), \
|
---|
2411 | $(eval pass := $(PASS_$(PASS)_pass)) \
|
---|
2412 | $(eval $(def_pass)))
|
---|
2413 |
|
---|
2414 | ## Pass order
|
---|
2415 | # @param $(pass) Current pass name.
|
---|
2416 | # @param $(prev_pass) The previous pass name.
|
---|
2417 | define def_pass_order
|
---|
2418 | ifdef KBUILD_SAFE_PARALLEL
|
---|
2419 | .NOTPARALLEL: pass_$(pass)_order
|
---|
2420 | .PHONY: pass_$(pass)_order
|
---|
2421 | pass_$(pass)_order: $(pass_prev)
|
---|
2422 | $(call MSG_L1,Pass - $(if $(PASS_$(PASS)),$(PASS_$(PASS)),$(pass)))
|
---|
2423 | + $(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)
|
---|
2424 | else
|
---|
2425 | .NOTPARALLEL: pass_$(pass)_order pass_$(pass)_banner
|
---|
2426 | .PHONY: pass_$(pass)_order pass_$(pass)_banner
|
---|
2427 | pass_$(pass)_banner:
|
---|
2428 | $(call MSG_L1,Pass - $(if $(PASS_$(PASS)),$(PASS_$(PASS)),$(pass)))
|
---|
2429 | pass_$(pass)_order: \
|
---|
2430 | $(pass_prev) \
|
---|
2431 | pass_$(pass)_banner \
|
---|
2432 | pass_$(pass)
|
---|
2433 | endif
|
---|
2434 | $(eval pass_prev := pass_$(pass)_order)
|
---|
2435 | endef
|
---|
2436 |
|
---|
2437 | ## PASS: order
|
---|
2438 | # Use dependencies to ensure correct pass order.
|
---|
2439 | pass_prev :=
|
---|
2440 | $(foreach PASS,$(DEFAULT_PASSES),\
|
---|
2441 | $(eval pass := $(PASS_$(PASS)_pass)) \
|
---|
2442 | $(eval $(def_pass_order)))
|
---|
2443 |
|
---|
2444 |
|
---|
2445 | #
|
---|
2446 | # THE MAIN RULES
|
---|
2447 | #
|
---|
2448 | all_recursive: $(pass_prev)
|
---|
2449 |
|
---|
2450 | rebuild: clean
|
---|
2451 | + $(MAKE) -f $(firstword $(MAKEFILE_LIST)) all_recursive
|
---|
2452 |
|
---|
2453 | # @todo make this a non-default pass!
|
---|
2454 | uninstall:
|
---|
2455 | $(RM) -f $(_INSTALLS)
|
---|
2456 |
|
---|
2457 | install: pass_installs
|
---|
2458 |
|
---|
2459 | # misc shortcuts.
|
---|
2460 | targets: bldprogs libraries dlls programs sysmods others installs
|
---|
2461 | objects: $(_OBJS)
|
---|
2462 | bldprogs: $(_BLDPROGS)
|
---|
2463 | libraries: $(_LIBS) $(_IMPORT_LIBS) $(_OTHER_LIBRARIES)
|
---|
2464 | dlls: $(_DLLS)
|
---|
2465 | programs: $(_PROGRAMS)
|
---|
2466 | sysmods: $(_SYSMODS)
|
---|
2467 | others: $(_OTHERS)
|
---|
2468 | installs: $(_INSTALLS_DIRS) $(_INSTALLS)
|
---|
2469 |
|
---|
2470 |
|
---|
2471 | #
|
---|
2472 | # kBuild debugging stuff.
|
---|
2473 | #
|
---|
2474 | _SPACE := $(subst ., ,.)
|
---|
2475 | _TAB := $(subst ., ,.)
|
---|
2476 | define _NEWLINE
|
---|
2477 |
|
---|
2478 |
|
---|
2479 | endef
|
---|
2480 | NLTAB = $(_NEWLINE)$(TAB)
|
---|
2481 | show_targets:
|
---|
2482 | @$(foreach target, $(ALL_TARGETS),\
|
---|
2483 | @$(ECHO) "target: $(target)" $(NLTAB)\
|
---|
2484 | @$(ECHO) " PATH_$(target)=$(PATH_$(target))" $(NLTAB)\
|
---|
2485 | @$(ECHO) " TARGET_$(target)=$(TARGET_$(target))" $(NLTAB)\
|
---|
2486 | @$(ECHO) " INSTARGET_$(target)=$(INSTARGET_$(target))" $(NLTAB)\
|
---|
2487 | $(foreach prop,$(PROPS_SINGLE) $(PROPS_ACCUMULATE_L) $(PROPS_ACCUMULATE_R) OBJS_ CLEAN, \
|
---|
2488 | $(eval _tmp:=$(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))) \
|
---|
2489 | $(if $($(target)_$(prop).$(_tmp)),\
|
---|
2490 | @$(ECHO) " $(target)_$(prop).$(_tmp)=$($(target)_$(prop).$(_tmp))" $(NLTAB)) \
|
---|
2491 | $(if $($(target)_$(prop)), $(NLTAB)@$(ECHO) " $(target)_$(prop)=$($(target)_$(prop))" $(NLTAB)) \
|
---|
2492 | )\
|
---|
2493 | $(foreach prop,$(PROPS_DEFERRED), \
|
---|
2494 | $(eval _tmp:=$(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))) \
|
---|
2495 | $(if $(value $(target)_$(prop).$(_tmp)),\
|
---|
2496 | @$(ECHO) ' $(target)_$(prop).$(_tmp)=$(value $(TARGET)_$(prop).$(_tmp))' $(NLTAB)) \
|
---|
2497 | $(if $(value $(target)_$(prop)), $(NLTAB)@$(ECHO) ' $(target)_$(prop)=$(value $(target)_$(prop))' $(NLTAB)) \
|
---|
2498 | ))
|
---|
2499 |
|
---|
2500 |
|
---|
2501 |
|
---|
2502 | #
|
---|
2503 | # Include dependency files.
|
---|
2504 | #
|
---|
2505 | $(foreach dep,$(wildcard $(_DEPFILES)),$(eval include $(dep)))
|
---|
2506 |
|
---|
2507 |
|
---|
2508 | # end-of-file-content
|
---|
2509 | __footer_kmk__ := target
|
---|
2510 | endif # __footer_kmk__
|
---|
2511 |
|
---|