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