1 | # $Id: footer.kmk 1427 2008-03-21 08:06:49Z bird $
|
---|
2 | ## @file
|
---|
3 | #
|
---|
4 | # kBuild - File included at top of makefile.
|
---|
5 | #
|
---|
6 | # Copyright (c) 2004-2007 knut st. osmundsen <bird-kBuild-spam@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 | ifdef KBUILD_PROFILE_SELF
|
---|
30 | _KBUILD_TS_FOOTER_START := $(nanots )
|
---|
31 | $(info prof: $(int-sub $(_KBUILD_TS_FOOTER_START), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_FOOTER_START), $(_KBUILD_TS_PREV)) - start of footer.kmk)
|
---|
32 | _KBUILD_TS_PREV := $(_KBUILD_TS_FOOTER_START)
|
---|
33 | endif
|
---|
34 |
|
---|
35 | #
|
---|
36 | # Variables.
|
---|
37 | # (Some of these need initialization before including definitions using them.)
|
---|
38 | #
|
---|
39 |
|
---|
40 | # All targets of each types.
|
---|
41 | _ALL_BLDPROGS := $(BLDPROGS) $(BLDPROGS.$(BUILD_PLATFORM)) $(BLDPROGS.$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)) $(BLDPROGS.$(BUILD_PLATFORM_ARCH)) $(BLDPROGS.$(BUILD_PLATFORM_CPU)) $(BLDPROGS.$(BUILD_TYPE))
|
---|
42 | _ALL_LIBRARIES := $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)) $(LIBRARIES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) $(LIBRARIES.$(BUILD_TARGET_ARCH)) $(LIBRARIES.$(BUILD_TARGET_CPU)) $(LIBRARIES.$(BUILD_TYPE))
|
---|
43 | _ALL_IMPORT_LIBS := $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)) $(IMPORT_LIBS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) $(IMPORT_LIBS.$(BUILD_TARGET_ARCH)) $(IMPORT_LIBS.$(BUILD_TARGET_CPU)) $(IMPORT_LIBS.$(BUILD_TYPE))
|
---|
44 | _ALL_DLLS := $(DLLS) $(DLLS.$(BUILD_TARGET)) $(DLLS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) $(DLLS.$(BUILD_TARGET_ARCH)) $(DLLS.$(BUILD_TARGET_CPU)) $(DLLS.$(BUILD_TYPE))
|
---|
45 | _ALL_PROGRAMS := $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)) $(PROGRAMS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) $(PROGRAMS.$(BUILD_TARGET_ARCH)) $(PROGRAMS.$(BUILD_TARGET_CPU)) $(PROGRAMS.$(BUILD_TYPE))
|
---|
46 | _ALL_SYSMODS := $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)) $(SYSMODS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) $(SYSMODS.$(BUILD_TARGET_ARCH)) $(SYSMODS.$(BUILD_TARGET_CPU)) $(SYSMODS.$(BUILD_TYPE))
|
---|
47 | _ALL_OTHERS := $(OTHERS) $(OTHERS.$(BUILD_TARGET)) $(OTHERS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) $(OTHERS.$(BUILD_TARGET_ARCH)) $(OTHERS.$(BUILD_TARGET_CPU)) $(OTHERS.$(BUILD_TYPE))
|
---|
48 | _ALL_INSTALLS := $(INSTALLS) $(INSTALLS.$(BUILD_TARGET)) $(INSTALLS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) $(INSTALLS.$(BUILD_TARGET_ARCH)) $(INSTALLS.$(BUILD_TARGET_CPU)) $(INSTALLS.$(BUILD_TYPE))
|
---|
49 | _ALL_FETCHES := $(FETCHES) $(FETCHES.$(BUILD_TARGET)) $(FETCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) $(FETCHES.$(BUILD_TARGET_ARCH)) $(FETCHES.$(BUILD_TARGET_CPU)) $(FETCHES.$(BUILD_TYPE))
|
---|
50 | _ALL_PATCHES := $(PATCHES) $(PATCHES.$(BUILD_TARGET)) $(PATCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) $(PATCHES.$(BUILD_TARGET_ARCH)) $(PATCHES.$(BUILD_TARGET_CPU)) $(PATCHES.$(BUILD_TYPE))
|
---|
51 |
|
---|
52 | # all targets.
|
---|
53 | _ALL_TARGETS = \
|
---|
54 | $(_ALL_FETCHES) \
|
---|
55 | $(_ALL_PATCHES) \
|
---|
56 | $(_ALL_BLDPROGS) \
|
---|
57 | $(_ALL_LIBRARIES) \
|
---|
58 | $(_ALL_IMPORT_LIBS) \
|
---|
59 | $(_ALL_DLLS) \
|
---|
60 | $(_ALL_PROGRAMS) \
|
---|
61 | $(_ALL_SYSMODS) \
|
---|
62 | $(_ALL_INSTALLS) \
|
---|
63 | $(_ALL_OTHERS)
|
---|
64 |
|
---|
65 | # all $(BUILD_TARGET) targets.
|
---|
66 | _ALL_BUILD_TARGET_TARGETS = \
|
---|
67 | $(_ALL_FETCHES) \
|
---|
68 | $(_ALL_PATCHES) \
|
---|
69 | $(_ALL_LIBRARIES) \
|
---|
70 | $(_ALL_IMPORT_LIBS) \
|
---|
71 | $(_ALL_DLLS) \
|
---|
72 | $(_ALL_PROGRAMS) \
|
---|
73 | $(_ALL_SYSMODS) \
|
---|
74 | $(_ALL_INSTALLS) \
|
---|
75 | $(_ALL_OTHERS)
|
---|
76 |
|
---|
77 | # all $(BUILD_PLATFORM) targets.
|
---|
78 | _ALL_BUILD_PLATFORM_TARGETS = \
|
---|
79 | $(_ALL_BLDPROGS)
|
---|
80 |
|
---|
81 | # all targets making use of srcname.
|
---|
82 | _ALL_SRCNAME_TARGETS = \
|
---|
83 | $(_ALL_FETCHES) \
|
---|
84 | $(_ALL_PATCHES)
|
---|
85 |
|
---|
86 | # dependency files.
|
---|
87 | _DEPFILES :=
|
---|
88 |
|
---|
89 | # included dependency files.
|
---|
90 | _DEPFILES_INCLUDED :=
|
---|
91 |
|
---|
92 |
|
---|
93 | # All kind of output files except for _OBJS and _DEPFILES.
|
---|
94 | # Compiling or linking definition outputting other things that $@ and any
|
---|
95 | # required dependency file must add those output files to this variable.
|
---|
96 | _OUT_FILES :=
|
---|
97 |
|
---|
98 | # Files which only requires cleaning up.
|
---|
99 | _CLEAN_FILES :=
|
---|
100 |
|
---|
101 | # all of a type
|
---|
102 | _OBJS :=
|
---|
103 | _FETCHES :=
|
---|
104 | _DOWNLOADS:=
|
---|
105 | _UNPACKS :=
|
---|
106 | _PATCHES :=
|
---|
107 | _UNFETCHES:=
|
---|
108 | _BLDPROGS :=
|
---|
109 | _LIBS :=
|
---|
110 | _DLLS :=
|
---|
111 | _PROGRAMS :=
|
---|
112 | _SYSMODS :=
|
---|
113 | _INSTALLS :=
|
---|
114 | _INSTALLS_FILES :=
|
---|
115 | _INSTALLS_DIRS :=
|
---|
116 | _OTHERS :=
|
---|
117 | _PACKING :=
|
---|
118 | _DIRS := $(PATH_TARGET)/ $(PATH_TARGET) $(BLDDIRS)
|
---|
119 | _IMPORT_LIBS :=
|
---|
120 |
|
---|
121 | # misc
|
---|
122 | pass_prev :=
|
---|
123 |
|
---|
124 |
|
---|
125 |
|
---|
126 | #
|
---|
127 | # Footer macros
|
---|
128 | #
|
---|
129 |
|
---|
130 | ## Figure out the tool for a target.
|
---|
131 | # @param $1 normalized target.
|
---|
132 | # @param $2 tooltype.
|
---|
133 | # @param bld_trg build target.
|
---|
134 | # @param bld_trg_arch build target architecture.
|
---|
135 | _TARGET_TOOL = $(strip $(firstword \
|
---|
136 | $($(1)_$(2)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
137 | $($(1)_$(2)TOOL.$(bld_trg)) \
|
---|
138 | $($(1)_$(2)TOOL) \
|
---|
139 | $($(1)_TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
140 | $($(1)_TOOL.$(bld_trg)) \
|
---|
141 | $($(1)_TOOL) \
|
---|
142 | $($(2)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
143 | $($(2)TOOL.$(bld_trg)) \
|
---|
144 | $($(2)TOOL) \
|
---|
145 | $(TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
146 | $(TOOL.$(bld_trg)) \
|
---|
147 | $(TOOL) \
|
---|
148 | ))
|
---|
149 |
|
---|
150 | ## Figure out the actual name of an installed file.
|
---|
151 | # @param $1 The file to install.
|
---|
152 | # @param $2 The target name.
|
---|
153 | # @param $3 The _INST value (can be empty).
|
---|
154 | # @param $4 The default directory to use when $3 is empty.
|
---|
155 | _INSTALL_FILE = $(patsubst %/,%/$(notdir $(1)),$(if $(3),$(PATH_INS)/$(3),$(4)/))
|
---|
156 |
|
---|
157 |
|
---|
158 |
|
---|
159 | ## Inherit one keyword in a non-accumulative manner.
|
---|
160 | # @param $(trg) Target object.
|
---|
161 | # @param $(prop) The property.
|
---|
162 | # @param $(src_key) Source keyword.
|
---|
163 | # @param $(trg_key) Target keyword.
|
---|
164 | define def_inherit_one_keyword
|
---|
165 | ifdef $(trg)_$(prop).$(src_key)
|
---|
166 | ifndef $(trg)_$(prop).$(trg_key)
|
---|
167 | $(trg)_$(prop).$(trg_key) = $($(trg)_$(prop).$(src_key))
|
---|
168 | endif
|
---|
169 | endif
|
---|
170 | endef
|
---|
171 |
|
---|
172 |
|
---|
173 | # EXPAND_BY = overriding
|
---|
174 |
|
---|
175 | ## Inherit one keyword in a non-accumulative manner.
|
---|
176 | # @param $(trg) Target object.
|
---|
177 | # @param $(prop) The property.
|
---|
178 | # @param $(src_key) Source keyword.
|
---|
179 | # @param $(trg_key) Target keyword.
|
---|
180 | define def_inherit_one_keyword_overriding_now_l
|
---|
181 | ifdef $(trg)_$(prop).$(src_key)
|
---|
182 | ifndef $(trg)_$(prop).$(trg_key)
|
---|
183 | $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(src_key))
|
---|
184 | endif
|
---|
185 | endif
|
---|
186 | endef
|
---|
187 |
|
---|
188 | ## @copydoc def_inherit_one_overriding_now_l
|
---|
189 | define def_inherit_one_keyword_overriding_now_r
|
---|
190 | ifdef $(trg)_$(prop).$(src_key)
|
---|
191 | ifndef $(trg)_$(prop).$(trg_key)
|
---|
192 | $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(src_key))
|
---|
193 | endif
|
---|
194 | endif
|
---|
195 | endef
|
---|
196 |
|
---|
197 | ## Inherit one keyword in a non-accumulative manner, deferred expansion.
|
---|
198 | # @param $(trg) Target object.
|
---|
199 | # @param $(prop) The property.
|
---|
200 | # @param $(src_key) Source keyword.
|
---|
201 | # @param $(trg_key) Target keyword.
|
---|
202 | # @remark This define relies on double evaluation
|
---|
203 | define def_inherit_one_keyword_overriding_deferred
|
---|
204 | ifdef $(trg)_$(prop).$(src_key)
|
---|
205 | ifndef $(trg)_$(prop).$(trg_key)
|
---|
206 | $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key))
|
---|
207 | endif
|
---|
208 | endif
|
---|
209 | endef
|
---|
210 |
|
---|
211 | ## @copydoc def_inherit_one_overriding_deferred
|
---|
212 | define def_inherit_one_keyword_overriding_deferred_l
|
---|
213 | ifdef $(trg)_$(prop).$(src_key)
|
---|
214 | ifndef $(trg)_$(prop).$(trg_key)
|
---|
215 | $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key))
|
---|
216 | endif
|
---|
217 | endif
|
---|
218 | endef
|
---|
219 |
|
---|
220 | ## @copydoc def_inherit_one_overriding_deferred
|
---|
221 | define def_inherit_one_keyword_overriding_deferred_r
|
---|
222 | ifdef $(trg)_$(prop).$(src_key)
|
---|
223 | ifndef $(trg)_$(prop).$(trg_key)
|
---|
224 | $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key))
|
---|
225 | endif
|
---|
226 | endif
|
---|
227 | endef
|
---|
228 |
|
---|
229 |
|
---|
230 | # EXPAND_BY = prepending
|
---|
231 |
|
---|
232 | ## Inherit one keyword in a prepending manner.
|
---|
233 | # @param $(trg) Target object.
|
---|
234 | # @param $(prop) The property.
|
---|
235 | # @param $(src_key) Source keyword.
|
---|
236 | # @param $(trg_key) Target keyword.
|
---|
237 | define def_inherit_one_keyword_prepending_now_l
|
---|
238 | ifdef $(trg)_$(prop).$(src_key)
|
---|
239 | $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(src_key)) $($(trg)_$(prop).$(trg_key))
|
---|
240 | endif
|
---|
241 | endef
|
---|
242 |
|
---|
243 | ## @copydoc def_inherit_one_prepending_now_l
|
---|
244 | define def_inherit_one_keyword_prepending_now_r
|
---|
245 | ifdef $(trg)_$(prop).$(src_key)
|
---|
246 | $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(trg_key)) $($(trg)_$(prop).$(src_key))
|
---|
247 | endif
|
---|
248 | endef
|
---|
249 |
|
---|
250 | ## Inherit one keyword in a non-accumulative manner, deferred expansion.
|
---|
251 | # @param $(trg) Target object.
|
---|
252 | # @param $(prop) The property.
|
---|
253 | # @param $(src_key) Source keyword.
|
---|
254 | # @param $(trg_key) Target keyword.
|
---|
255 | # @remark This define relies on double evaluation
|
---|
256 | define def_inherit_one_keyword_prepending_deferred
|
---|
257 | ifdef $(trg)_$(prop).$(src_key)
|
---|
258 | ifndef $(trg)_$(prop).$(trg_key)
|
---|
259 | $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key))
|
---|
260 | endif
|
---|
261 | endif
|
---|
262 | endef
|
---|
263 |
|
---|
264 | ## Inherit one keyword in a prepending manner, deferred expansion.
|
---|
265 | # @param $(trg) Target object.
|
---|
266 | # @param $(prop) The property.
|
---|
267 | # @param $(src_key) Source keyword.
|
---|
268 | # @param $(trg_key) Target keyword.
|
---|
269 | define def_inherit_one_keyword_prepending_deferred_l
|
---|
270 | ifdef $(trg)_$(prop).$(src_key)
|
---|
271 | $(trg)_$(prop).$(trg_key) <= $$($(trg)_$(prop).$(src_key))
|
---|
272 | endif
|
---|
273 | endef
|
---|
274 |
|
---|
275 | ## @copydoc def_inherit_one_prepending_deferred_l
|
---|
276 | define def_inherit_one_keyword_prepending_deferred_r
|
---|
277 | ifdef $(trg)_$(prop).$(src_key)
|
---|
278 | $(trg)_$(prop).$(trg_key) += $$($(trg)_$(prop).$(src_key))
|
---|
279 | endif
|
---|
280 | endef
|
---|
281 |
|
---|
282 |
|
---|
283 | # EXPAND_BY = appending
|
---|
284 |
|
---|
285 | ## Inherit one keyword in an appending manner.
|
---|
286 | # @param $(trg) Target object.
|
---|
287 | # @param $(prop) The property.
|
---|
288 | # @param $(src_key) Source keyword.
|
---|
289 | # @param $(trg_key) Target keyword.
|
---|
290 | define def_inherit_one_keyword_appending_now_l
|
---|
291 | ifdef $(trg)_$(prop).$(src_key)
|
---|
292 | $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(trg_key)) $($(trg)_$(prop).$(src_key))
|
---|
293 | endif
|
---|
294 | endef
|
---|
295 |
|
---|
296 | ## @copydoc def_inherit_one_appending_now_l
|
---|
297 | define def_inherit_one_keyword_appending_now_r
|
---|
298 | ifdef $(trg)_$(prop).$(src_key)
|
---|
299 | $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(src_key)) $($(trg)_$(prop).$(trg_key))
|
---|
300 | endif
|
---|
301 | endef
|
---|
302 |
|
---|
303 | ## Inherit one keyword in a non-accumulative manner, deferred expansion.
|
---|
304 | # @param $(trg) Target object.
|
---|
305 | # @param $(prop) The property.
|
---|
306 | # @param $(src_key) Source keyword.
|
---|
307 | # @param $(trg_key) Target keyword.
|
---|
308 | # @remark This define relies on double evaluation
|
---|
309 | define def_inherit_one_keyword_appending_deferred
|
---|
310 | ifdef $(trg)_$(prop).$(src_key)
|
---|
311 | ifndef $(trg)_$(prop).$(trg_key)
|
---|
312 | $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key))
|
---|
313 | endif
|
---|
314 | endif
|
---|
315 | endef
|
---|
316 |
|
---|
317 | ## Inherit one keyword in an appending manner, deferred expansion.
|
---|
318 | # @param $(trg) Target object.
|
---|
319 | # @param $(prop) The property.
|
---|
320 | # @param $(src_key) Source keyword.
|
---|
321 | # @param $(trg_key) Target keyword.
|
---|
322 | define def_inherit_one_keyword_appending_deferred_l
|
---|
323 | ifdef $(trg)_$(prop).$(src_key)
|
---|
324 | $(trg)_$(prop).$(trg_key) += $$($(trg)_$(prop).$(src_key))
|
---|
325 | endif
|
---|
326 | endef
|
---|
327 |
|
---|
328 | ## @copydoc def_inherit_one_appending_deferred_l
|
---|
329 | define def_inherit_one_keyword_appending_deferred_r
|
---|
330 | ifdef $(trg)_$(prop).$(src_key)
|
---|
331 | $(trg)_$(prop).$(trg_key) <= $$($(trg)_$(prop).$(src_key))
|
---|
332 | endif
|
---|
333 | endef
|
---|
334 |
|
---|
335 |
|
---|
336 | ## Worker fro def_inherit that deals with one keyword that makes
|
---|
337 | # use of inheritance.
|
---|
338 | # @param prefix_keyword key_prefix:keyword. The cool join/split game as usual.
|
---|
339 | # @param trg Object to consider for inheriting.
|
---|
340 | # @param properties List of the properties with straight expansion.
|
---|
341 | # @param properties_now_l List of the properties with immediate expansion, accumulating on the left side.
|
---|
342 | # @param properties_now_r List of the properties with immediate expansion, accumulating on the right side.
|
---|
343 | # @param properties_deferred List of the properties with deferred expansion (e.g. function), non-accumulative .
|
---|
344 | # @param properties_deferred_l List of the properties with deferred expansion (e.g. function), accumulating on the left side.
|
---|
345 | # @param properties_deferred_r List of the properties with deferred expansion (e.g. function), accumulating on the right side.
|
---|
346 | define def_inherit_keyword
|
---|
347 | prefix := $(word 1,$(subst :, ,$(prefix_keyword)))
|
---|
348 | trg_key := $(word 2,$(subst :, ,$(prefix_keyword)))
|
---|
349 | src_key := $($(prefix)_$(trg_key)_EXTENDS)
|
---|
350 | by := $($(prefix)_$(trg_key)_EXTENDS_BY)
|
---|
351 |
|
---|
352 | # Inherit the properties.
|
---|
353 | $(foreach prop, $(properties), $(eval $(def_inherit_one_keyword)))
|
---|
354 | $(foreach prop, $(properties_now_l), $(eval $(def_inherit_one_keyword_$(by)_now_l)))
|
---|
355 | $(foreach prop, $(properties_now_r), $(eval $(def_inherit_one_keyword_$(by)_now_r)))
|
---|
356 | $(foreach prop, $(properties_deferred), $(eval $(def_inherit_one_keyword_$(by)_deferred)))
|
---|
357 | $(foreach prop, $(properties_deferred_l), $(eval $(def_inherit_one_keyword_$(by)_deferred_l)))
|
---|
358 | $(foreach prop, $(properties_deferred_r), $(eval $(def_inherit_one_keyword_$(by)_deferred_r)))
|
---|
359 |
|
---|
360 | endef # def_inherit_keyword
|
---|
361 |
|
---|
362 |
|
---|
363 | ## Inherit one template property in a non-accumulative manner.
|
---|
364 | # @param $(prop) Property name
|
---|
365 | # @param $(src) Source (parent) object.
|
---|
366 | # @param $(trg) Target (child) object.
|
---|
367 | define def_inherit_one
|
---|
368 | ifdef $(src)_$(prop)
|
---|
369 | ifndef $(trg)_$(prop)
|
---|
370 | $(trg)_$(prop) = $($(src)_$(prop))
|
---|
371 | endif
|
---|
372 | endif
|
---|
373 | endef
|
---|
374 |
|
---|
375 |
|
---|
376 | # EXPAND_BY = overriding
|
---|
377 |
|
---|
378 | ## Inherit one template property in a non-accumulative manner.
|
---|
379 | # @param $(prop) Property name
|
---|
380 | # @param $(src) Source (parent) object.
|
---|
381 | # @param $(trg) Target (child) object.
|
---|
382 | define def_inherit_one_overriding_now_l
|
---|
383 | ifdef $(src)_$(prop)
|
---|
384 | ifndef $(trg)_$(prop)
|
---|
385 | $(trg)_$(prop) := $($(src)_$(prop))
|
---|
386 | endif
|
---|
387 | endif
|
---|
388 | endef
|
---|
389 |
|
---|
390 | ## @copydoc def_inherit_one_overriding_now_l
|
---|
391 | define def_inherit_one_overriding_now_r
|
---|
392 | ifdef $(src)_$(prop)
|
---|
393 | ifndef $(trg)_$(prop)
|
---|
394 | $(trg)_$(prop) := $($(src)_$(prop))
|
---|
395 | endif
|
---|
396 | endif
|
---|
397 | endef
|
---|
398 |
|
---|
399 | ## Inherit one template property in a non-accumulative manner, deferred expansion.
|
---|
400 | # @param $(prop) Property name
|
---|
401 | # @param $(src) Source
|
---|
402 | # @param $(trg) Target
|
---|
403 | # @remark This define relies on double evaluation
|
---|
404 | define def_inherit_one_overriding_deferred
|
---|
405 | ifdef $(src)_$(prop)
|
---|
406 | ifndef $(trg)_$(prop)
|
---|
407 | $(trg)_$(prop) = $$($(src)_$(prop))
|
---|
408 | endif
|
---|
409 | endif
|
---|
410 | endef
|
---|
411 |
|
---|
412 | ## @copydoc def_inherit_one_overriding_deferred
|
---|
413 | define def_inherit_one_overriding_deferred_l
|
---|
414 | ifdef $(src)_$(prop)
|
---|
415 | ifndef $(trg)_$(prop)
|
---|
416 | $(trg)_$(prop) = $$($(src)_$(prop))
|
---|
417 | endif
|
---|
418 | endif
|
---|
419 | endef
|
---|
420 |
|
---|
421 | ## @copydoc def_inherit_one_overriding_deferred
|
---|
422 | define def_inherit_one_overriding_deferred_r
|
---|
423 | ifdef $(src)_$(prop)
|
---|
424 | ifndef $(trg)_$(prop)
|
---|
425 | $(trg)_$(prop) = $$($(src)_$(prop))
|
---|
426 | endif
|
---|
427 | endif
|
---|
428 | endef
|
---|
429 |
|
---|
430 |
|
---|
431 | # EXPAND_BY = prepending
|
---|
432 |
|
---|
433 | ## Inherit one template property in a prepending manner.
|
---|
434 | # @param $(prop) Property name
|
---|
435 | # @param $(src) Source (parent) object.
|
---|
436 | # @param $(trg) Target (child) object.
|
---|
437 | define def_inherit_one_prepending_now_l
|
---|
438 | ifdef $(src)_$(prop)
|
---|
439 | $(trg)_$(prop) := $($(src)_$(prop)) $($(trg)_$(prop))
|
---|
440 | endif
|
---|
441 | endef
|
---|
442 |
|
---|
443 | ## @copydoc def_inherit_one_prepending_now_l
|
---|
444 | define def_inherit_one_prepending_now_r
|
---|
445 | ifdef $(src)_$(prop)
|
---|
446 | $(trg)_$(prop) := $($(trg)_$(prop)) $($(src)_$(prop))
|
---|
447 | endif
|
---|
448 | endef
|
---|
449 |
|
---|
450 | ## Inherit one template property in a non-accumulative manner, deferred expansion.
|
---|
451 | # @param $(prop) Property name
|
---|
452 | # @param $(src) Source
|
---|
453 | # @param $(trg) Target
|
---|
454 | # @remark This define relies on double evaluation
|
---|
455 | define def_inherit_one_prepending_deferred
|
---|
456 | ifdef $(src)_$(prop)
|
---|
457 | ifndef $(trg)_$(prop)
|
---|
458 | $(trg)_$(prop) = $$($(src)_$(prop))
|
---|
459 | endif
|
---|
460 | endif
|
---|
461 | endef
|
---|
462 |
|
---|
463 | ## Inherit one template property in a prepending manner, deferred expansion.
|
---|
464 | # @param $(prop) Property name
|
---|
465 | # @param $(src) Source (parent) object.
|
---|
466 | # @param $(trg) Target (child) object.
|
---|
467 | define def_inherit_one_prepending_deferred_l
|
---|
468 | ifdef $(src)_$(prop)
|
---|
469 | $(trg)_$(prop) <= $$($(src)_$(prop))
|
---|
470 | endif
|
---|
471 | endef
|
---|
472 |
|
---|
473 | ## @copydoc def_inherit_one_prepending_deferred_l
|
---|
474 | define def_inherit_one_prepending_deferred_r
|
---|
475 | ifdef $(src)_$(prop)
|
---|
476 | $(trg)_$(prop) += $$($(src)_$(prop))
|
---|
477 | endif
|
---|
478 | endef
|
---|
479 |
|
---|
480 |
|
---|
481 | # EXPAND_BY = appending
|
---|
482 |
|
---|
483 | ## Inherit one template property in an appending manner.
|
---|
484 | # @param $(prop) Property name
|
---|
485 | # @param $(src) Source (parent) object.
|
---|
486 | # @param $(trg) Target (child) object.
|
---|
487 | define def_inherit_one_appending_now_l
|
---|
488 | ifdef $(src)_$(prop)
|
---|
489 | $(trg)_$(prop) := $($(trg)_$(prop)) $($(src)_$(prop))
|
---|
490 | endif
|
---|
491 | endef
|
---|
492 |
|
---|
493 | ## @copydoc def_inherit_one_appending_now_l
|
---|
494 | define def_inherit_one_appending_now_r
|
---|
495 | ifdef $(src)_$(prop)
|
---|
496 | $(trg)_$(prop) := $($(src)_$(prop)) $($(trg)_$(prop))
|
---|
497 | endif
|
---|
498 | endef
|
---|
499 |
|
---|
500 | ## Inherit one template property in a non-accumulative manner, deferred expansion.
|
---|
501 | # @param $(prop) Property name
|
---|
502 | # @param $(src) Source
|
---|
503 | # @param $(trg) Target
|
---|
504 | # @remark This define relies on double evaluation
|
---|
505 | define def_inherit_one_appending_deferred
|
---|
506 | ifdef $(src)_$(prop)
|
---|
507 | ifndef $(trg)_$(prop)
|
---|
508 | $(trg)_$(prop) = $$($(src)_$(prop))
|
---|
509 | endif
|
---|
510 | endif
|
---|
511 | endef
|
---|
512 |
|
---|
513 | ## Inherit one template property in an appending manner, deferred expansion.
|
---|
514 | # @param $(prop) Property name
|
---|
515 | # @param $(src) Source (parent) object.
|
---|
516 | # @param $(trg) Target (child) object.
|
---|
517 | define def_inherit_one_appending_deferred_l
|
---|
518 | ifdef $(src)_$(prop)
|
---|
519 | $(trg)_$(prop) += $$($(src)_$(prop))
|
---|
520 | endif
|
---|
521 | endef
|
---|
522 |
|
---|
523 | ## @copydoc def_inherit_one_appending_deferred_l
|
---|
524 | define def_inherit_one_appending_deferred_r
|
---|
525 | ifdef $(src)_$(prop)
|
---|
526 | $(trg)_$(prop) <= $$($(src)_$(prop))
|
---|
527 | endif
|
---|
528 | endef
|
---|
529 |
|
---|
530 |
|
---|
531 | ## combines the specified properties $(1) with the $(_KEYWORDS) list.
|
---|
532 | _INHERIT_JOIN_KEYWORDS = $(1) $(foreach keyword,$(_KEYWORDS), $(addsuffix .$(keyword), $(1)))
|
---|
533 |
|
---|
534 |
|
---|
535 | ## Generic inheritance for use with targets templates and tools.
|
---|
536 | # @param trg Object to consider for inheriting.
|
---|
537 | # @param src_prefix What to prefix the value found in EXTENDS with to get the object.
|
---|
538 | # @param load_function Load function for stuff that needs
|
---|
539 | # @param properties List of the properties with straight expansion.
|
---|
540 | # @param properties_now_l List of the properties with immediate expansion, accumulating on the left side.
|
---|
541 | # @param properties_now_r List of the properties with immediate expansion, accumulating on the right side.
|
---|
542 | # @param properties_deferred List of the properties with deferred expansion (e.g. function), non-accumulative .
|
---|
543 | # @param properties_deferred_l List of the properties with deferred expansion (e.g. function), accumulating on the left side.
|
---|
544 | # @param properties_deferred_r List of the properties with deferred expansion (e.g. function), accumulating on the right side.
|
---|
545 | define def_inherit
|
---|
546 |
|
---|
547 | # Load it.
|
---|
548 | ifneq ($(load_function),)
|
---|
549 | loading := $(trg)
|
---|
550 | $(eval $(value $(load_function)))
|
---|
551 | endif
|
---|
552 |
|
---|
553 | src := $(strip $($(trg)_EXTENDS))
|
---|
554 | ifneq ($(src),)
|
---|
555 | ifndef $(trg)_EXTENDS_STATUS_
|
---|
556 | $(trg)_EXTENDS_STATUS_ := 0
|
---|
557 |
|
---|
558 | # Load the source.
|
---|
559 | ifneq ($(load_function),)
|
---|
560 | loading := $(src)
|
---|
561 | $(eval $(value $(load_function)))
|
---|
562 | endif
|
---|
563 |
|
---|
564 | # less typing.
|
---|
565 | src := $(src_prefix)$(src)
|
---|
566 |
|
---|
567 | # Recursivly process the parent (src) if it's inherting from somebody too.
|
---|
568 | ifdef $(src)_EXTENDS
|
---|
569 | ifneq ($($(src)_EXTENDS_STATUS_),42)
|
---|
570 | # 'foreach' will create 'trg' in a new variable context hiding
|
---|
571 | # out current variable. 'src' OTOH will be overwritten.
|
---|
572 | #$ (warning def_inherit: recursing into $(src) from $(trg))
|
---|
573 | $(foreach trg, $(src), $(eval $(value def_inherit)))
|
---|
574 | src := $(src_prefix)$(strip $($(trg)_EXTENDS))
|
---|
575 | endif
|
---|
576 | endif
|
---|
577 |
|
---|
578 | # Get & check EXTENDS_BY.
|
---|
579 | by = $(strip $($(trg)_EXTENDS_BY))
|
---|
580 | ifeq ($(by),)
|
---|
581 | by = overriding
|
---|
582 | else ifn1of ($(by), overriding appending prepending)
|
---|
583 | $(error kBuild: Invalid EXTENDS_BY value '$(by)' on '$(trg)'!)
|
---|
584 | endif
|
---|
585 |
|
---|
586 | # Inherit the properties.
|
---|
587 | $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties)), $(eval $(def_inherit_one)))
|
---|
588 | $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties_now_l)), $(eval $(def_inherit_one_$(by)_now_l)))
|
---|
589 | $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties_now_r)), $(eval $(def_inherit_one_$(by)_now_r)))
|
---|
590 | $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties_deferred)), $(eval $(def_inherit_one_$(by)_deferred)))
|
---|
591 | $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties_deferred_l)), $(eval $(def_inherit_one_$(by)_deferred_l)))
|
---|
592 | $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties_deferred_r)), $(eval $(def_inherit_one_$(by)_deferred_r)))
|
---|
593 |
|
---|
594 | # Mark the target as done.
|
---|
595 | $(trg)_EXTENDS_STATUS_ := 42
|
---|
596 | else
|
---|
597 | # Check for inheritance loops.
|
---|
598 | ifneq ($($(trg)_EXTENDS_STATUS_),42)
|
---|
599 | $(error kBuild: Target inheritance loop! target=$(trg) $(trg)_EXTENDS_STATUS_=$($(trg)_EXTENDS_STATUS_))
|
---|
600 | endif
|
---|
601 | endif
|
---|
602 | endif
|
---|
603 |
|
---|
604 | # Keyword inheritance.
|
---|
605 | $(foreach prefix_keyword, $(join $(_KEYWORDS_PREFIX), $(addprefix :,$(_KEYWORDS_EXTENDS))), $(eval $(value def_inherit_keyword)))
|
---|
606 |
|
---|
607 | endef # def_inherit
|
---|
608 |
|
---|
609 |
|
---|
610 | #
|
---|
611 | # Determin all the templates that is being used and make
|
---|
612 | # sure they are present before we try collect keywords.
|
---|
613 | #
|
---|
614 | _TEMPLATES := $(TEMPLATE)
|
---|
615 | define def_templates
|
---|
616 | ifdef $(target)_TEMPLATE
|
---|
617 | ifneq ("$($(target)_TEMPLATE)","$(strip $($(target)_TEMPLATE))")
|
---|
618 | $$(error kBuild: The template name of target '$(target)' contains tabs ($($(target)_TEMPLATE))). Please remove them)
|
---|
619 | endif
|
---|
620 | _TEMPLATES += $($(target)_TEMPLATE)
|
---|
621 | endif
|
---|
622 | endef # def_templates
|
---|
623 | $(foreach target, $(_ALL_TARGETS), $(eval $(def_templates)))
|
---|
624 | _TEMPLATES := $(sort $(_TEMPLATES))
|
---|
625 |
|
---|
626 | ## Template load function.
|
---|
627 | # @param loading The template name. This is prefixed.
|
---|
628 | define def_templates_load_function
|
---|
629 | loading := $(patsubst TEMPLATE_%,%,$(loading))
|
---|
630 | ifndef TEMPLATE_$(loading)
|
---|
631 | TEMPLATE_$(loading)_KMK_FILE := $(firstword $(foreach path, $(KBUILD_TEMPLATE_PATHS) $(PATH_KBUILD)/templates $(KBUILD_DEFAULT_PATHS), $(wildcard $(path)/$(loading).kmk)))
|
---|
632 | ifneq ($(TEMPLATE_$(loading)_KMK_FILE),)
|
---|
633 | $(error kBuild: Cannot find include file for the template '$(loading)'! Searched: $(KBUILD_TEMPLATE_PATHS) $(PATH_KBUILD)/templates $(KBUILD_DEFAULT_PATHS))
|
---|
634 | endif
|
---|
635 | include $(TEMPLATE_$(loading)_KMK_FILE)
|
---|
636 | ifndef TEMPLATE_$(loading)
|
---|
637 | $(warning kBuild: TEMPLATE_$(loading) was not defined by $(TEMPLATE_$(loading)_KMK_FILE)!)
|
---|
638 | endif
|
---|
639 | endif
|
---|
640 | endef # def_templates_include
|
---|
641 | $(foreach loading, $(addprefix TEMPLATE_,$(_TEMPLATES)), $(eval $(value def_templates_include)))
|
---|
642 |
|
---|
643 |
|
---|
644 | #
|
---|
645 | # Determin the keywords required for correct inherting and setup keyword inheritance.
|
---|
646 | #
|
---|
647 | # This means walking all the lists of immediate template and targets and
|
---|
648 | # pick up all the BLD_T* keywords. Since templates that are referenced
|
---|
649 | # indirectly in the inheritance hierarchy, the result from this exercise
|
---|
650 | # might not be 100% accurate... :-/
|
---|
651 | #
|
---|
652 | _BLD_TYPES := $(BUILD_TYPE)
|
---|
653 | _BLD_TARGETS := $(BUILD_TARGET) $(BUILD_PLATFORMS)
|
---|
654 | _BLD_ARCHES := $(BUILD_TARGET_ARCH) $(BUILD_PLATFORM_ARCH)
|
---|
655 | _BLD_CPUS := $(BUILD_TARGET_CPU) $(BUILD_PLATFORM_CPU)
|
---|
656 |
|
---|
657 | define def_collect_bld_xyz
|
---|
658 | ifdef $(src)_BLD_TYPE
|
---|
659 | ifn1of ($($(src)_BLD_TYPE), $(KBUILD_BLD_TYPES))
|
---|
660 | $(error kBuild: $(src)_BLD_TYPE=$($(src)_BLD_TYPE) not in KBUILD_BLD_TYPES={$(KBUILD_BLD_TYPES)}!)
|
---|
661 | endif
|
---|
662 | _BLD_TYPES += $($(src)_BLD_TYPE)
|
---|
663 | endif
|
---|
664 | ifdef $(src)_BLD_TRG
|
---|
665 | ifn1of ($($(src)_BLD_TRG), $(KBUILD_OSES))
|
---|
666 | $(error kBuild: $(src)_BLD_TRG=$($(src)_BLD_TRG) not in KBUILD_OSES={$(KBUILD_OSES)}!)
|
---|
667 | endif
|
---|
668 | _BLD_TARGETS += $($(src)_BLD_TRG)
|
---|
669 | endif
|
---|
670 | ifdef $(src)_BLD_TRG_ARCH
|
---|
671 | ifn1of ($($(src)_BLD_TRG_ARCH), $(KBUILD_ARCHES))
|
---|
672 | $(error kBuild: $(src)_BLD_TRG_ARCH=$($(src)_BLD_TRG_ARCH) not in KBUILD_ARCHES={$(KBUILD_ARCHES)}!)
|
---|
673 | endif
|
---|
674 | _BLD_ARCHES += $($(src)_BLD_TRG_ARCH)
|
---|
675 | endif
|
---|
676 | ifdef $(src)_BLD_TRG_CPU
|
---|
677 | if1of ($($(src)_BLD_CPU), $(KBUILD_ARCHES) $(KBUILD_OSES) $(KBUILD_BLD_TYPES))
|
---|
678 | $(error kBuild: $(src)_BLD_TRG_CPU=$($(src)_BLD_TRG_CPU) found in KBUILD_ARCHES, KBUILD_OSES or KBUILD_BLD_TYPES!)
|
---|
679 | endif
|
---|
680 | _BLD_CPUS += $($(src)_BLD_TRG_CPU)
|
---|
681 | endif
|
---|
682 | endef # def_collect_bld_xyz
|
---|
683 | $(foreach src, $(addprefix TEMPLATE_, $(_TEMPLATES)) $(_ALL_TARGETS) \
|
---|
684 | ,$(eval $(value def_collect_bld_xyz)))
|
---|
685 |
|
---|
686 | # Drop duplicate values.
|
---|
687 | # WARNING! These list might not include keywords only involved in inheritance.
|
---|
688 | _BLD_TYPES := $(sort $(_BLD_TYPES))
|
---|
689 | _BLD_TARGETS := $(sort $(_BLD_TARGETS))
|
---|
690 | _BLD_ARCHES := $(sort $(_BLD_ARCHES))
|
---|
691 | _BLD_CPUS := $(sort $(_BLD_CPUS))
|
---|
692 |
|
---|
693 | ## Look for keywords which extends others and order them.
|
---|
694 | # @param keyword
|
---|
695 | # @param prefix
|
---|
696 | # @param valid
|
---|
697 | define def_keyword_ordering
|
---|
698 | # Check for EXTENDS, fix and validate it if found.
|
---|
699 | src := $(strip $($(prefix)_$(keyword)_EXTENDS))
|
---|
700 | ifneq ($(src),)
|
---|
701 | ifndef $(prefix)_$(keyword)_EXTENDS_STATUS_
|
---|
702 | ifn1of ($(src), $(valid))
|
---|
703 | $(error kBuild: $(keyword) tries to extend unknown keyword '$(src)'! (known = $(valid)))
|
---|
704 | endif
|
---|
705 |
|
---|
706 | # Recursivly process the parent (src).
|
---|
707 | ifneq ($($(prefix)_$(src)_EXTENDS_STATUS_),42)
|
---|
708 | $(prefix)_$(keyword)_EXTENDS_STATUS_ := 0
|
---|
709 | # 'foreach' will create 'keyword' in a new variable context hiding
|
---|
710 | # out current variable. 'src' OTOH will be overwritten.
|
---|
711 | $(foreach keyword, $(src), $(eval $(value def_keyword_ordering)))
|
---|
712 | src := $(strip $($(prefix)_$(keyword)_EXTENDS))
|
---|
713 | endif
|
---|
714 |
|
---|
715 | # Check and strip EXTENDS_BY.
|
---|
716 | by = $(strip $($(prefix)_$(keyword)_EXTENDS_BY))
|
---|
717 | ifeq ($(by),)
|
---|
718 | by = overriding
|
---|
719 | else ifn1of ($(by), overriding appending prepending)
|
---|
720 | $(error kBuild: Invalid EXTENDS_BY value '$(by)' on '$(keyword)'!)
|
---|
721 | endif
|
---|
722 |
|
---|
723 | # Update the attributes with stripped
|
---|
724 | $(prefix)_$(keyword)_EXTENDS_BY := $(by)
|
---|
725 | $(prefix)_$(keyword)_EXTENDS := $(src)
|
---|
726 |
|
---|
727 | # Add it to the list and mark it as done.
|
---|
728 | _KEYWORDS_EXTENDS += $(keyword)
|
---|
729 | _KEYWORDS_PREFIX += $(prefix)
|
---|
730 | $(prefix)_$(keyword)_EXTENDS_STATUS_ := 42
|
---|
731 | else
|
---|
732 | # Check for inheritance loops.
|
---|
733 | ifneq ($($(trg)_EXTENDS_STATUS_),42)
|
---|
734 | $(error kBuild: Keyword inheritance loop! keyword=$(keyword) $(prefix)_$(keyword)_EXTENDS_STATUS_=$($(prefix)_$(keyword)_EXTENDS_STATUS_))
|
---|
735 | endif
|
---|
736 | endif
|
---|
737 | else
|
---|
738 | # Add it to the ordered list and mark it as done.
|
---|
739 | _KEYWORDS_ORDERED += $(keyword)
|
---|
740 | $(prefix)_$(src)_EXTENDS_STATUS_ := 42
|
---|
741 | endif
|
---|
742 | endef # def_keyword_ordering
|
---|
743 |
|
---|
744 | # Look for keywords which extends others and their parents, and from this
|
---|
745 | # construct two lists.
|
---|
746 | _KEYWORDS_ORDERED :=
|
---|
747 | _KEYWORDS_EXTENDS :=
|
---|
748 | _KEYWORDS_PREFIX :=
|
---|
749 |
|
---|
750 | prefix := BLD_TYPE
|
---|
751 | valid := $(KBUILD_BLD_TYPES)
|
---|
752 | $(foreach keyword, $(_BLD_TYPES) , $(eval $(value def_keyword_ordering)))
|
---|
753 |
|
---|
754 | prefix := BLD_TRG
|
---|
755 | valid := $(KBUILD_OSES)
|
---|
756 | $(foreach keyword, $(_BLD_TARGETS), $(eval $(value def_keyword_ordering)))
|
---|
757 |
|
---|
758 | prefix := BLD_ARCH
|
---|
759 | valid := $(KBUILD_ARCHES)
|
---|
760 | $(foreach keyword, $(_BLD_ARCHES) , $(eval $(value def_keyword_ordering)))
|
---|
761 |
|
---|
762 | prefix := BLD_CPU
|
---|
763 | valid := $(KBUILD_CPUS)
|
---|
764 | $(foreach keyword, $(_BLD_CPUS) , $(eval $(value def_keyword_ordering)))
|
---|
765 |
|
---|
766 | ## @todo Inherit bld_trg.bld_arch for too?
|
---|
767 |
|
---|
768 | # Construct all the possible keywords.
|
---|
769 | _KEYWORDS := $(_KEYWORDS_ORDERED) $(_KEYWORDS_EXTENDS) \
|
---|
770 | $(foreach bld_trg,$(_BLD_TARGETS),$(addprefix $(bld_trg).,$(_BLD_ARCHES)))
|
---|
771 |
|
---|
772 | ifdef KBUILD_PROFILE_SELF
|
---|
773 | _KBUILD_TS_NOW := $(nanots )
|
---|
774 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done keywords)
|
---|
775 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
776 | endif
|
---|
777 |
|
---|
778 |
|
---|
779 | #
|
---|
780 | # Target inheritance.
|
---|
781 | #
|
---|
782 | # This has to be done on a per target list basis as to avoid adding
|
---|
783 | # incorrect properties that will wast memory, time, and may confuse
|
---|
784 | # later strictness checks. This also has to be done *before* templates
|
---|
785 | # are applied to the targets. Since we're doing that part rather
|
---|
786 | # early on, the target inheritance feature is a bit restricted at
|
---|
787 | # the moment. However, this will be addressed in a little(?) while.
|
---|
788 | #
|
---|
789 |
|
---|
790 | src_prefix :=
|
---|
791 | load_function :=
|
---|
792 | properties_deferred_l :=
|
---|
793 | properties_deferred_r :=
|
---|
794 |
|
---|
795 | # Fetches.
|
---|
796 | properties := $(PROPS_FETCHES_SINGLE)
|
---|
797 | properties_now_l := $(PROPS_FETCHES_ACCUMULATE_L)
|
---|
798 | properties_now_r := $(PROPS_FETCHES_ACCUMULATE_R)
|
---|
799 | properties_deferred := $(PROPS_FETCHES_DEFERRED)
|
---|
800 | $(foreach trg, $(_ALL_FETCHES),$(eval $(value def_inherit)))
|
---|
801 |
|
---|
802 | ## Patches. - not implemented yet.
|
---|
803 | #properties := $(PROPS_PATCHES_SINGLE)
|
---|
804 | #properties_now_l := $(PROPS_PATCHES_ACCUMULATE_L)
|
---|
805 | #properties_now_r := $(PROPS_PATCHES_ACCUMULATE_R)
|
---|
806 | #properties_deferred := $(PROPS_PATCHES_DEFERRED)
|
---|
807 | #$(foreach trg, $(_ALL_PATCHES),$(eval $(value def_inherit)))
|
---|
808 |
|
---|
809 | # Programs and build programs.
|
---|
810 | properties := $(PROPS_PROGRAMS_SINGLE)
|
---|
811 | properties_now_l := $(PROPS_PROGRAMS_ACCUMULATE_L)
|
---|
812 | properties_now_r := $(PROPS_PROGRAMS_ACCUMULATE_R)
|
---|
813 | properties_deferred := $(PROPS_PROGRAMS_DEFERRED)
|
---|
814 | $(foreach trg, $(_ALL_BLDPROGS) $(_ALL_PROGRAMS),$(eval $(value def_inherit)))
|
---|
815 |
|
---|
816 | # Libraries and import libraries.
|
---|
817 | properties := $(PROPS_LIBRARIES_SINGLE)
|
---|
818 | properties_now_l := $(PROPS_LIBRARIES_ACCUMULATE_L)
|
---|
819 | properties_now_r := $(PROPS_LIBRARIES_ACCUMULATE_R)
|
---|
820 | properties_deferred := $(PROPS_LIBRARIES_DEFERRED)
|
---|
821 | if1of ($(BUILD_TARGET), nt os2 win)
|
---|
822 | $(foreach trg, $(_ALL_LIBRARIES) $(_ALL_IMPORT_LIBS),$(eval $(value def_inherit)))
|
---|
823 | else
|
---|
824 | $(foreach trg, $(_ALL_LIBRARIES),$(eval $(value def_inherit)))
|
---|
825 | endif
|
---|
826 |
|
---|
827 | # DLLs.
|
---|
828 | properties := $(PROPS_DLLS_SINGLE)
|
---|
829 | properties_now_l := $(PROPS_DLLS_ACCUMULATE_L)
|
---|
830 | properties_now_r := $(PROPS_DLLS_ACCUMULATE_R)
|
---|
831 | properties_deferred := $(PROPS_DLLS_DEFERRED)
|
---|
832 | if1of ($(BUILD_TARGET), nt os2 win)
|
---|
833 | $(foreach trg, $(_ALL_DLLS),$(eval $(value def_inherit)))
|
---|
834 | else
|
---|
835 | $(foreach trg, $(_ALL_DLLS) $(_ALL_IMPORT_LIBS),$(eval $(value def_inherit)))
|
---|
836 | endif
|
---|
837 |
|
---|
838 | # System modules.
|
---|
839 | properties := $(PROPS_SYSMODS_SINGLE)
|
---|
840 | properties_now_l := $(PROPS_SYSMODS_ACCUMULATE_L)
|
---|
841 | properties_now_r := $(PROPS_SYSMODS_ACCUMULATE_R)
|
---|
842 | properties_deferred := $(PROPS_SYSMODS_DEFERRED)
|
---|
843 | $(foreach trg, $(_ALL_SYSMODS),$(eval $(value def_inherit)))
|
---|
844 |
|
---|
845 | # Installs.
|
---|
846 | properties := $(PROPS_INSTALLS_SINGLE)
|
---|
847 | properties_now_l := $(PROPS_INSTALLS_ACCUMULATE_L)
|
---|
848 | properties_now_r := $(PROPS_INSTALLS_ACCUMULATE_R)
|
---|
849 | properties_deferred := $(PROPS_INSTALLS_DEFERRED)
|
---|
850 | $(foreach trg, $(_ALL_INSTALLS),$(eval $(value def_inherit)))
|
---|
851 |
|
---|
852 | ifdef KBUILD_PROFILE_SELF
|
---|
853 | _KBUILD_TS_NOW := $(nanots )
|
---|
854 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done target inheritance)
|
---|
855 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
856 | endif
|
---|
857 |
|
---|
858 |
|
---|
859 | #
|
---|
860 | # Template Inheritance.
|
---|
861 | #
|
---|
862 | # This is much the same as with target inheritance, except we cannot
|
---|
863 | # restrict the properties involved since we haven't got a clue which
|
---|
864 | # target platforms/archs are using them. But, we can drop the instance
|
---|
865 | # expansion we're doing for targets since there won't be any more
|
---|
866 | # changes to either the source nor the target templates beyond this
|
---|
867 | # exercise.
|
---|
868 | #
|
---|
869 |
|
---|
870 | src_prefix := TEMPLATE_
|
---|
871 | load_function := def_templates_load_function
|
---|
872 | properties :=
|
---|
873 | properties_now_l :=
|
---|
874 | properties_now_r :=
|
---|
875 | properties_deferred := $(PROPS_SINGLE) $(PROPS_DEFERRED)
|
---|
876 | properties_deferred_l := $(PROPS_ACCUMULATE_L)
|
---|
877 | properties_deferred_r := $(PROPS_ACCUMULATE_R)
|
---|
878 | $(foreach trg, $(addprefix TEMPLATE_,$(_TEMPLATES)),$(eval $(value def_inherit)))
|
---|
879 |
|
---|
880 | # done inheriting.
|
---|
881 | src_prefix :=
|
---|
882 | load_function :=
|
---|
883 | properties :=
|
---|
884 | properties_now_l :=
|
---|
885 | properties_now_r :=
|
---|
886 | properties_deferred :=
|
---|
887 | properties_deferred_l :=
|
---|
888 | properties_deferred_r :=
|
---|
889 |
|
---|
890 | ifdef KBUILD_PROFILE_SELF
|
---|
891 | _KBUILD_TS_NOW := $(nanots )
|
---|
892 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done template inheritance)
|
---|
893 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
894 | endif
|
---|
895 |
|
---|
896 |
|
---|
897 |
|
---|
898 |
|
---|
899 | #
|
---|
900 | # Template/Target Expansion.
|
---|
901 | #
|
---|
902 | # Extend all targets with the values from the template. Doing this up front
|
---|
903 | # allows more generic code and less mess down in the pass 2 target handling.
|
---|
904 | # However it does eat a good deal of memory.
|
---|
905 | #
|
---|
906 |
|
---|
907 | ## Inherit one template property in a non-accumulative manner.
|
---|
908 | # @param $(prop) Property name
|
---|
909 | # @param $(target) Target name
|
---|
910 | # @todo fix the precedence order for some properties.
|
---|
911 | define def_inherit_template_one
|
---|
912 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
|
---|
913 | ifndef $(target)_$(prop)
|
---|
914 | $(target)_$(prop) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
---|
915 | #$ (warning dbgtarget: $(target)_$(prop):='$(value $(target)_$(prop))' TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
---|
916 | endif
|
---|
917 | endif
|
---|
918 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)
|
---|
919 | ifndef $(target)_$(prop).$(bld_trg)
|
---|
920 | #$ (warning dbgsource: $(target)_$(prop).$(bld_trg)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
---|
921 | $(target)_$(prop).$(bld_trg) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
---|
922 | endif
|
---|
923 | endif
|
---|
924 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch)
|
---|
925 | ifndef $(target)_$(prop).$(bld_trg).$(bld_trg_arch)
|
---|
926 | #$ (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))
|
---|
927 | $(target)_$(prop).$(bld_trg).$(bld_trg_arch) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch))
|
---|
928 | endif
|
---|
929 | endif
|
---|
930 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)
|
---|
931 | ifndef $(target)_$(prop).$(bld_trg_arch)
|
---|
932 | #$ (warning dbgsource: $(target)_$(prop).$(bld_trg_arch)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
|
---|
933 | $(target)_$(prop).$(bld_trg_arch) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
|
---|
934 | endif
|
---|
935 | endif
|
---|
936 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)
|
---|
937 | ifndef $(target)_$(prop).$(bld_trg_cpu)
|
---|
938 | #$ (warning dbgsource: $(target)_$(prop).$(bld_trg_cpu)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
|
---|
939 | $(target)_$(prop).$(bld_trg_cpu) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
|
---|
940 | endif
|
---|
941 | endif
|
---|
942 | endef
|
---|
943 |
|
---|
944 | ## Inherit one template property in a non-accumulative manner, deferred expansion.
|
---|
945 | # @param 1: $(prop) Property name
|
---|
946 | # @param 2: $(target) Target name
|
---|
947 | # @todo fix the precedence order for some properties.
|
---|
948 | # @remark this define relies on double evaluation
|
---|
949 | define def_inherit_template_one_deferred
|
---|
950 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
|
---|
951 | ifndef $(target)_$(prop)
|
---|
952 | $(target)_$(prop) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
---|
953 | #$ (warning dbgtarget: $(target)_$(prop):='$(value $(target)_$(prop))' TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
---|
954 | endif
|
---|
955 | endif
|
---|
956 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)
|
---|
957 | ifndef $(target)_$(prop).$(bld_trg)
|
---|
958 | #$ (warning dbgsource: $(target)_$(prop).$(bld_trg)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
---|
959 | $(target)_$(prop).$(bld_trg) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
---|
960 | endif
|
---|
961 | endif
|
---|
962 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch)
|
---|
963 | ifndef $(target)_$(prop).$(bld_trg).$(bld_trg_arch)
|
---|
964 | #$ (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))
|
---|
965 | $(target)_$(prop).$(bld_trg).$(bld_trg_arch) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch))
|
---|
966 | endif
|
---|
967 | endif
|
---|
968 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)
|
---|
969 | ifndef $(target)_$(prop).$(bld_trg_arch)
|
---|
970 | #$ (warning dbgsource: $(target)_$(prop).$(bld_trg_arch)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
|
---|
971 | $(target)_$(prop).$(bld_trg_arch) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
|
---|
972 | endif
|
---|
973 | endif
|
---|
974 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)
|
---|
975 | ifndef $(target)_$(prop).$(bld_trg_cpu)
|
---|
976 | #$ (warning dbgsource: $(target)_$(prop).$(bld_trg_cpu)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
|
---|
977 | $(target)_$(prop).$(bld_trg_cpu) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
|
---|
978 | endif
|
---|
979 | endif
|
---|
980 | endef
|
---|
981 |
|
---|
982 | ## Inherit one acculumlative template property where the 'most significant' items are at the left end.
|
---|
983 | # @param $(prop) Property name
|
---|
984 | # @param $(target) Target name
|
---|
985 | define def_inherit_template_one_accumulate_l
|
---|
986 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
|
---|
987 | #$ (warning dbgtype: TEMPLATE_$($(target)_TEMPLATE)_$(prop) $(target)_$(prop)=$($(target)_$(prop)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop)))
|
---|
988 | $(target)_$(prop) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
---|
989 | #$ (warning dbgtype: $(target)_$(prop)=$($(target)_$(prop)))
|
---|
990 | endif
|
---|
991 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE)
|
---|
992 | #$ (warning dbg4: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE))
|
---|
993 | $(target)_$(prop).$(BUILD_TYPE) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE))
|
---|
994 | endif
|
---|
995 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)
|
---|
996 | #$ (warning dbg5: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
---|
997 | $(target)_$(prop).$(bld_trg) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
---|
998 | endif
|
---|
999 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch)
|
---|
1000 | #$ (warning dbg4: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch))
|
---|
1001 | $(target)_$(prop).$(bld_trg).$(bld_trg_arch) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch))
|
---|
1002 | endif
|
---|
1003 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)
|
---|
1004 | #$ (warning dbg5: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
|
---|
1005 | $(target)_$(prop).$(bld_trg_cpu) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
|
---|
1006 | endif
|
---|
1007 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)
|
---|
1008 | #$ (warning dbg6: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
|
---|
1009 | $(target)_$(prop).$(bld_trg_arch) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
|
---|
1010 | endif
|
---|
1011 | endef
|
---|
1012 |
|
---|
1013 | ## Inherit one acculumlative template property where the 'most significant' items are at the right end.
|
---|
1014 | # @param $(prop) Property name
|
---|
1015 | # @param $(target) Target name
|
---|
1016 | define def_inherit_template_one_accumulate_r
|
---|
1017 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
|
---|
1018 | #$ (warning dbgtype: TEMPLATE_$($(target)_TEMPLATE)_$(prop) $(target)_$(prop)=$($(target)_$(prop)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop)))
|
---|
1019 | $(target)_$(prop) <=$$(TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
---|
1020 | #$ (warning dbgtype: $(target)_$(prop)=$($(target)_$(prop)))
|
---|
1021 | endif
|
---|
1022 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE)
|
---|
1023 | #$ (warning dbg4: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE))
|
---|
1024 | $(target)_$(prop).$(BUILD_TYPE) <=$$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE))
|
---|
1025 | endif
|
---|
1026 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)
|
---|
1027 | #$ (warning dbg5: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
---|
1028 | $(target)_$(prop).$(bld_trg) <=$$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
---|
1029 | endif
|
---|
1030 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch)
|
---|
1031 | #$ (warning dbg4: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch))
|
---|
1032 | $(target)_$(prop).$(bld_trg).$(bld_trg_arch) <=$$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch))
|
---|
1033 | endif
|
---|
1034 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)
|
---|
1035 | #$ (warning dbg5: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
|
---|
1036 | $(target)_$(prop).$(bld_trg_cpu) <=$$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
|
---|
1037 | endif
|
---|
1038 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)
|
---|
1039 | #$ (warning dbg6: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
|
---|
1040 | $(target)_$(prop).$(bld_trg_arch) <=$$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
|
---|
1041 | endif
|
---|
1042 | endef
|
---|
1043 |
|
---|
1044 |
|
---|
1045 | ## Inherit template properties for on target.
|
---|
1046 | # @param $(target) Target name.
|
---|
1047 | define def_inherit_template
|
---|
1048 | # sanity check.
|
---|
1049 | ifdef _$(target)_ALREADY_PROCESSED
|
---|
1050 | $(error kBuild: The target $(target) appears more than once in the target lists! Please correct the makefile(s))
|
---|
1051 | endif
|
---|
1052 | _$(target)_ALREADY_PROCESSED := 1
|
---|
1053 |
|
---|
1054 | # Inherit any default template.
|
---|
1055 | ifdef TEMPLATE
|
---|
1056 | ifeq ($($(target)_TEMPLATE),)
|
---|
1057 | $(eval $(target)_TEMPLATE:=$(TEMPLATE))
|
---|
1058 | endif
|
---|
1059 | endif
|
---|
1060 | # Expand the template if specified.
|
---|
1061 | ifneq ($($(target)_TEMPLATE),)
|
---|
1062 | $(foreach prop,$(PROPS_SINGLE),$(eval $(value def_inherit_template_one)))
|
---|
1063 | $(foreach prop,$(PROPS_DEFERRED),$(eval $(def_inherit_template_one_deferred))) # exploits the 2 evaluation, so no value!
|
---|
1064 | $(foreach prop,$(PROPS_ACCUMULATE_L),$(eval $(def_inherit_template_one_accumulate_l))) # += works fine without value
|
---|
1065 | $(foreach prop,$(PROPS_ACCUMULATE_R),$(eval $(def_inherit_template_one_accumulate_r))) # use <= (kmk addition)
|
---|
1066 | endif
|
---|
1067 | endef
|
---|
1068 |
|
---|
1069 | # Inherit template properties
|
---|
1070 | bld_trg := $(BUILD_TARGET)
|
---|
1071 | bld_trg_arch := $(BUILD_TARGET_ARCH)
|
---|
1072 | bld_trg_cpu := $(BUILD_TARGET_CPU)
|
---|
1073 | $(foreach target, $(_ALL_BUILD_TARGET_TARGETS),$(eval $(value def_inherit_template)))
|
---|
1074 |
|
---|
1075 | bld_trg := $(BUILD_PLATFORM)
|
---|
1076 | bld_trg_arch := $(BUILD_PLATFORM_ARCH)
|
---|
1077 | bld_trg_cpu := $(BUILD_PLATFORM_CPU)
|
---|
1078 | $(foreach target, $(_ALL_BUILD_PLATFORM_TARGETS),$(eval $(value def_inherit_template)))
|
---|
1079 |
|
---|
1080 | ifdef KBUILD_PROFILE_SELF
|
---|
1081 | _KBUILD_TS_NOW := $(nanots )
|
---|
1082 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done template/target expansion)
|
---|
1083 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
1084 | endif
|
---|
1085 |
|
---|
1086 |
|
---|
1087 | #
|
---|
1088 | # Include tools & sdks
|
---|
1089 | #
|
---|
1090 | # The first part of this exercise is to figure out which TOOLS and SDKS
|
---|
1091 | # that should be included.
|
---|
1092 | #
|
---|
1093 | _TOOLS := $(TOOL.$(BUILD_TARGET)) $(TOOL.$(BUILD_TARGET_ARCH)) $(TOOL.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
1094 | $(TOOL.$(BUILD_PLATFORM)) $(TOOL.$(BUILD_PLATFORM_ARCH)) $(TOOL.$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)) \
|
---|
1095 | $(TOOL)
|
---|
1096 | _SDKS := $(SDKS.$(BUILD_TARGET)) $(SDKS.$(BUILD_TARGET_ARCH)) $(SDKS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
1097 | $(SDKS.$(BUILD_PLATFORM)) $(SDKS.$(BUILD_PLATFORM_ARCH)) $(SDKS.$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)) \
|
---|
1098 | $(SDKS.$(BUILD_TYPE)) \
|
---|
1099 | $(SDKS)
|
---|
1100 | define def_tools_sdks_target_source
|
---|
1101 | $(eval _TOOLS += $(foreach prop, $(PROPS_TOOLS), \
|
---|
1102 | $($(source)_$(prop).$(_bld_trg)) \
|
---|
1103 | $($(target)_$(source)_$(prop).$(_bld_trg)) \
|
---|
1104 | $($(source)_$(prop).$(_bld_trg).$(_bld_trg_arch)) \
|
---|
1105 | $($(target)_$(source)_$(prop).$(_bld_trg).$(_bld_trg_arch)) \
|
---|
1106 | $($(source)_$(prop).$(_bld_trg_arch)) \
|
---|
1107 | $($(target)_$(source)_$(prop).$(_bld_trg_arch)) \
|
---|
1108 | $($(source)_$(prop)) \
|
---|
1109 | $($(target)_$(source)_$(prop))))
|
---|
1110 | $(eval _SDKS += \
|
---|
1111 | $($(source)_SDKS.$(_bld_trg)) \
|
---|
1112 | $($(target)_$(source)_SDKS.$(_bld_trg)) \
|
---|
1113 | $($(source)_SDKS.$(_bld_trg).$(_bld_trg_arch)) \
|
---|
1114 | $($(target)_$(source)_SDKS.$(_bld_trg).$(_bld_trg_arch)) \
|
---|
1115 | $($(source)_SDKS.$(_bld_trg_arch)) \
|
---|
1116 | $($(target)_$(source)_SDKS.$(_bld_trg_arch)) \
|
---|
1117 | $($(source)_SDKS.$(BUILD_TYPE)) \
|
---|
1118 | $($(target)_$(source)_SDKS.$(BUILD_TYPE)) \
|
---|
1119 | $($(source)_SDKS) \
|
---|
1120 | $($(target)_$(source)_SDKS))
|
---|
1121 | endef # def_tools_sdks_target_source
|
---|
1122 |
|
---|
1123 | define def_tools_sdks_target
|
---|
1124 | _bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
|
---|
1125 | _bld_trg := $(firstword $($(target)_BLD_TRG) $(bld_trg))
|
---|
1126 | _bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(bld_trg_arch))
|
---|
1127 | _bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(bld_trg_cpu))
|
---|
1128 |
|
---|
1129 | $(eval _TOOLS += $(foreach prop, $(PROPS_TOOLS), \
|
---|
1130 | $($(target)_$(prop).$(_bld_trg)) \
|
---|
1131 | $($(target)_$(prop).$(_bld_trg_arch)) \
|
---|
1132 | $($(target)_$(prop).$(_bld_trg).$(_bld_trg_arch)) \
|
---|
1133 | $($(target)_$(prop))))
|
---|
1134 | $(eval _SDKS += \
|
---|
1135 | $($(target)_SDKS.$(_bld_trg)) \
|
---|
1136 | $($(target)_SDKS.$(_bld_trg_arch)) \
|
---|
1137 | $($(target)_SDKS.$(_bld_trg).$(_bld_trg_arch)) \
|
---|
1138 | $($(target)_SDKS))
|
---|
1139 | $(foreach source, \
|
---|
1140 | $($(target)_SOURCES.$(_bld_trg)) \
|
---|
1141 | $($(target)_SOURCES.$(_bld_trg_arch)) \
|
---|
1142 | $($(target)_SOURCES.$(_bld_trg).$(_bld_trg_arch)) \
|
---|
1143 | $($(target)_SOURCES.$(_bld_trg_cpu)) \
|
---|
1144 | $($(target)_SOURCES.$(_bld_type)) \
|
---|
1145 | $($(target)_SOURCES) \
|
---|
1146 | , $(eval $(value def_tools_sdks_target_source)))
|
---|
1147 | endef # def_tools_sdks_target
|
---|
1148 |
|
---|
1149 | define def_tools_srcname_target
|
---|
1150 | _bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
|
---|
1151 | _bld_trg := $(firstword $($(target)_BLD_TRG) $(bld_trg))
|
---|
1152 | _bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(bld_trg_arch))
|
---|
1153 | _bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(bld_trg_cpu))
|
---|
1154 |
|
---|
1155 | $(foreach source, $(notdir\
|
---|
1156 | $($(target)_SOURCES.$(_bld_trg)) \
|
---|
1157 | $($(target)_SOURCES.$(_bld_trg_arch)) \
|
---|
1158 | $($(target)_SOURCES.$(_bld_trg).$(_bld_trg_arch)) \
|
---|
1159 | $($(target)_SOURCES.$(_bld_trg_cpu)) \
|
---|
1160 | $($(target)_SOURCES.$(_bld_type)) \
|
---|
1161 | $($(target)_SOURCES) \
|
---|
1162 | ), $(eval $(value def_tools_sdks_target_source)))
|
---|
1163 | endef # def_tools_srcname_target
|
---|
1164 |
|
---|
1165 | bld_trg := $(BUILD_TARGET)
|
---|
1166 | bld_trg_arch := $(BUILD_TARGET_ARCH)
|
---|
1167 | bld_trg_cpu := $(BUILD_TARGET_CPU)
|
---|
1168 | $(foreach target, $(_ALL_BUILD_TARGET_TARGETS), $(eval $(value def_tools_sdks_target)))
|
---|
1169 | $(foreach target, $(_ALL_SRCNAME_TARGETS), $(eval $(value def_tools_srcname_target)))
|
---|
1170 |
|
---|
1171 | bld_trg := $(BUILD_PLATFORM)
|
---|
1172 | bld_trg_arch := $(BUILD_PLATFORM_ARCH)
|
---|
1173 | bld_trg_cpu := $(BUILD_PLATFORM_CPU)
|
---|
1174 | $(foreach target, $(_ALL_BUILD_PLATFORM_TARGETS), $(eval $(value def_tools_sdks_target)))
|
---|
1175 |
|
---|
1176 | _TOOLS := $(sort $(_TOOLS))
|
---|
1177 | _SDKS := $(sort $(_SDKS))
|
---|
1178 |
|
---|
1179 | ## Tool load function.
|
---|
1180 | # @param loading The tool name
|
---|
1181 | define def_tools_load_function
|
---|
1182 | ifndef TOOL_$(loading)
|
---|
1183 | TOOL_$(loading)_KMK_FILE := $(firstword $(foreach path, $(KBUILD_TOOL_PATHS) $(PATH_KBUILD)/tools $(KBUILD_DEFAULT_PATHS), $(wildcard $(path)/$(loading).kmk)))
|
---|
1184 | ifeq ($(TOOL_$(loading)_KMK_FILE),)
|
---|
1185 | $(error kBuild: Cannot find include file for the tool '$(loading)'! Searched: $(KBUILD_TOOL_PATHS) $(PATH_KBUILD)/tools $(KBUILD_DEFAULT_PATHS))
|
---|
1186 | endif
|
---|
1187 | include $(TOOL_$(loading)_KMK_FILE)
|
---|
1188 | ifndef TOOL_$(loading)
|
---|
1189 | $(warning kBuild: TOOL_$(loading) was not defined by $(TOOL_$(loading)_KMK_FILE)!)
|
---|
1190 | endif
|
---|
1191 | endif
|
---|
1192 | endef # def_tools_include
|
---|
1193 |
|
---|
1194 | ## SDK load function.
|
---|
1195 | # @param loading The tool name
|
---|
1196 | define def_sdk_load_function
|
---|
1197 | ifndef SDK_$(loading)
|
---|
1198 | SDK_$(loading)_KMK_FILE := $(firstword $(foreach path, $(KBUILD_SDK_PATHS) $(PATH_KBUILD)/sdks $(KBUILD_DEFAULT_PATHS), $(wildcard $(path)/$(loading).kmk)))
|
---|
1199 | ifeq ($(SDK_$(loading)_KMK_FILE),)
|
---|
1200 | $(error kBuild: Cannot find include file for the SDK '$(loading)'! Searched: $(KBUILD_SDK_PATHS) $(PATH_KBUILD)/sdks $(KBUILD_DEFAULT_PATHS))
|
---|
1201 | endif
|
---|
1202 | include $(SDK_$(loading)_KMK_FILE)
|
---|
1203 | ifndef SDK_$(loading)
|
---|
1204 | $(warning kBuild: SDK_$(loading) was not defined by $(SDK_$(loading)_KMK_FILE)!)
|
---|
1205 | endif
|
---|
1206 | endif
|
---|
1207 | endef # def_sdk_load_function
|
---|
1208 |
|
---|
1209 |
|
---|
1210 | properties :=
|
---|
1211 | properties_now_l :=
|
---|
1212 | properties_now_r :=
|
---|
1213 | properties_deferred := $(PROPS_SINGLE) $(PROPS_DEFERRED)
|
---|
1214 | properties_deferred_l := $(PROPS_ACCUMULATE_L)
|
---|
1215 | properties_deferred_r := $(PROPS_ACCUMULATE_R)
|
---|
1216 |
|
---|
1217 | src_prefix := TOOL_
|
---|
1218 | load_function := def_tools_load_function
|
---|
1219 | $(foreach trg, $(_TOOLS), $(eval $(value def_inherit)))
|
---|
1220 |
|
---|
1221 | src_prefix := SDK_
|
---|
1222 | load_function := def_sdk_load_function
|
---|
1223 | $(foreach trg, $(_SDKS) , $(eval $(value def_inherit)))
|
---|
1224 |
|
---|
1225 | # done inheriting.
|
---|
1226 | src_prefix :=
|
---|
1227 | load_function :=
|
---|
1228 | properties :=
|
---|
1229 | properties_now_l :=
|
---|
1230 | properties_now_r :=
|
---|
1231 | properties_deferred :=
|
---|
1232 | properties_deferred_l :=
|
---|
1233 | properties_deferred_r :=
|
---|
1234 |
|
---|
1235 |
|
---|
1236 | ifdef KBUILD_PROFILE_SELF
|
---|
1237 | _KBUILD_TS_NOW := $(nanots )
|
---|
1238 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done tools and sdks)
|
---|
1239 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
1240 | endif
|
---|
1241 |
|
---|
1242 |
|
---|
1243 |
|
---|
1244 | #
|
---|
1245 | #
|
---|
1246 | # Target lists - Pass 1
|
---|
1247 | #
|
---|
1248 | # This pass is for defining variables that might be referenced in
|
---|
1249 | # properties of other targets.
|
---|
1250 | #
|
---|
1251 | #
|
---|
1252 |
|
---|
1253 | # Don't do anything for fetch targets (yet).
|
---|
1254 |
|
---|
1255 | ##
|
---|
1256 | # Link prolog for Pass 1.
|
---|
1257 | #
|
---|
1258 | # @param $(target) Normalized target name.
|
---|
1259 | # @param $(EXT) EXE,DLL,SYS,LIB.
|
---|
1260 | # @param $(EXTPRE) HOST or nothing.
|
---|
1261 | # @param $(definst) The default _INST value.
|
---|
1262 | # @param $(tool_prefix) LD or AR.
|
---|
1263 | # @param $(bld_trg_base_var) TARGET or PLATFORM.
|
---|
1264 | define def_pass1_link_common
|
---|
1265 |
|
---|
1266 | bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
|
---|
1267 | bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_$(bld_trg_base_var)))
|
---|
1268 | bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_$(bld_trg_base_var)_ARCH))
|
---|
1269 | bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_$(bld_trg_base_var)_CPU))
|
---|
1270 |
|
---|
1271 | tool := $(call _TARGET_TOOL,$(target),$(tool_prefix))
|
---|
1272 | name := $(firstword\
|
---|
1273 | $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\
|
---|
1274 | $($(target)_NAME.$(bld_trg_arch))\
|
---|
1275 | $($(target)_NAME.$(bld_trg))\
|
---|
1276 | $($(target)_NAME.$(bld_type))\
|
---|
1277 | $($(target)_NAME)\
|
---|
1278 | $(target))
|
---|
1279 | outbase := $(call TARGET_BASE,$(name),$(target))
|
---|
1280 | ifndef PATH_$(target)
|
---|
1281 | PATH_$(target) := $(patsubst %/,%,$(dir $(outbase)))
|
---|
1282 | else ifneq ($(PATH_$(target)),$(patsubst %/,%,$(dir $(outbase))))
|
---|
1283 | $(error kBuild internal error: PATH_$(target)=$(PATH_$(target)) expected $(patsubst %/,%,$(dir $(outbase))))
|
---|
1284 | endif
|
---|
1285 | ifeq ($(tool_prefix),AR) ## @todo fix this mess!
|
---|
1286 | suff := $(firstword\
|
---|
1287 | $($(target)_$(EXT)SUFF.$(bld_trg).$(bld_trg_arch))\
|
---|
1288 | $($(target)_$(EXT)SUFF.$(bld_trg))\
|
---|
1289 | $($(target)_$(EXT)SUFF)\
|
---|
1290 | $(TOOL_$(tool)_$(tool_prefix)$(EXT)SUFF.$(bld_trg).$(bld_trg_arch))\
|
---|
1291 | $(TOOL_$(tool)_$(tool_prefix)$(EXT)SUFF.$(bld_trg))\
|
---|
1292 | $(TOOL_$(tool)_$(tool_prefix)$(EXT)SUFF)\
|
---|
1293 | $(SUFF_LIB))
|
---|
1294 | else
|
---|
1295 | suff := $(firstword \
|
---|
1296 | $($(target)_$(EXT)SUFF) \
|
---|
1297 | $($(target)_$(EXT)SUFF) \
|
---|
1298 | $(TOOL_$(tool)_$(tool_prefix)$(EXT)SUFF) \
|
---|
1299 | $($(EXTPRE)SUFF_$(EXT)))
|
---|
1300 | endif
|
---|
1301 | out := $(outbase)$(suff)
|
---|
1302 |
|
---|
1303 | # TARGET_*
|
---|
1304 | TARGET_$(target) := $(out)
|
---|
1305 |
|
---|
1306 | # INSTARGET_*
|
---|
1307 | ifndef $(target)_NOINST
|
---|
1308 | INSTARGET_$(target) := $(patsubst %/,%/$(notdir $(out)), \
|
---|
1309 | $(if $($(target)_INST), $(addprefix $(PATH_INS)/,$($(target)_INST)), $(definst)/))
|
---|
1310 |
|
---|
1311 | else # NOINST
|
---|
1312 | INSTARGET_$(target) :=
|
---|
1313 | endif # NOINST
|
---|
1314 |
|
---|
1315 | endef
|
---|
1316 |
|
---|
1317 |
|
---|
1318 | #
|
---|
1319 | # BLDPROGS (Pass 1)
|
---|
1320 | #
|
---|
1321 | define def_pass1_bldprog
|
---|
1322 | # set NOINST if not forced installation before doing the usual stuff.
|
---|
1323 | ifndef $(target)_INST
|
---|
1324 | $(target)_NOINST := 1
|
---|
1325 | endif
|
---|
1326 | $(eval $(value def_pass1_link_common))
|
---|
1327 | endef
|
---|
1328 |
|
---|
1329 | EXT := EXE
|
---|
1330 | EXTPRE := HOST
|
---|
1331 | definst := $(PATH_BIN)
|
---|
1332 | tool_prefix := LD
|
---|
1333 | bld_trg_base_var := PLATFORM
|
---|
1334 | $(foreach target, $(BLDPROGS) $(BLDPROGS.$(BUILD_PLATFORM)) $(BLDPROGS.$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)), \
|
---|
1335 | $(eval $(value def_pass1_bldprog)))
|
---|
1336 |
|
---|
1337 |
|
---|
1338 | #
|
---|
1339 | # LIBRARIES (Pass 1)
|
---|
1340 | #
|
---|
1341 | EXT := LIB
|
---|
1342 | EXTPRE :=
|
---|
1343 | definst := $(PATH_LIB)
|
---|
1344 | tool_prefix := AR
|
---|
1345 | bld_trg_base_var := TARGET
|
---|
1346 | $(foreach target, $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)) $(LIBRARIES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
|
---|
1347 | $(eval $(value def_pass1_link_common)))
|
---|
1348 |
|
---|
1349 |
|
---|
1350 | #
|
---|
1351 | # DLLS (Pass 1)
|
---|
1352 | #
|
---|
1353 | EXT := DLL
|
---|
1354 | EXTPRE :=
|
---|
1355 | definst := $(PATH_DLL)
|
---|
1356 | tool_prefix := LD
|
---|
1357 | bld_trg_base_var := TARGET
|
---|
1358 | $(foreach target, $(DLLS) $(DLLS.$(BUILD_TARGET)) $(DLLS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
|
---|
1359 | $(eval $(value def_pass1_link_common)))
|
---|
1360 |
|
---|
1361 |
|
---|
1362 | #
|
---|
1363 | # IMPORT LIBRARIES (Pass 1)
|
---|
1364 | #
|
---|
1365 | # - On OS/2 and windows these are libraries.
|
---|
1366 | # - On other platforms they are fake DLLs.
|
---|
1367 | #
|
---|
1368 | if1of ($(BUILD_TARGET), nt os2 win win64 win32)
|
---|
1369 | EXT := LIB
|
---|
1370 | EXTPRE :=
|
---|
1371 | definst := $(PATH_LIB)
|
---|
1372 | tool_prefix := AR
|
---|
1373 | bld_trg_base_var := TARGET
|
---|
1374 | $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)) $(IMPORT_LIBS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
|
---|
1375 | $(eval $(value def_pass1_link_common)))
|
---|
1376 | else
|
---|
1377 | EXT := DLL
|
---|
1378 | EXTPRE :=
|
---|
1379 | definst := $(PATH_DLL)
|
---|
1380 | tool_prefix := LD
|
---|
1381 | bld_trg_base_var := TARGET
|
---|
1382 | $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)) $(IMPORT_LIBS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
|
---|
1383 | $(eval $(value def_pass1_link_common)))
|
---|
1384 | endif
|
---|
1385 |
|
---|
1386 |
|
---|
1387 | #
|
---|
1388 | # PROGRAMS (Pass 1)
|
---|
1389 | #
|
---|
1390 | EXT := EXE
|
---|
1391 | EXTPRE :=
|
---|
1392 | definst := $(PATH_BIN)
|
---|
1393 | tool_prefix := LD
|
---|
1394 | bld_trg_base_var := TARGET
|
---|
1395 | $(foreach target, $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)) $(PROGRAMS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
|
---|
1396 | $(eval $(value def_pass1_link_common)))
|
---|
1397 |
|
---|
1398 |
|
---|
1399 | #
|
---|
1400 | # SYSMODS (Pass 1)
|
---|
1401 | #
|
---|
1402 | EXT := SYS
|
---|
1403 | EXTPRE :=
|
---|
1404 | definst := $(PATH_SYS)
|
---|
1405 | tool_prefix := LD
|
---|
1406 | bld_trg_base_var := TARGET
|
---|
1407 | $(foreach target, $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)) $(SYSMODS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
|
---|
1408 | $(eval $(value def_pass1_link_common)))
|
---|
1409 |
|
---|
1410 |
|
---|
1411 | #
|
---|
1412 | # INSTALLS (Pass 1)
|
---|
1413 | # Note! INSTARGET_* for INSTALLS aren't available until later.
|
---|
1414 | #
|
---|
1415 | define def_pass1_install
|
---|
1416 | bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
|
---|
1417 | bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))
|
---|
1418 | bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_TARGET_ARCH))
|
---|
1419 | bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_TARGET_CPU))
|
---|
1420 | # TARGET_*
|
---|
1421 | TARGET_$(target) := $(PATH_TARGET)/$(target).ins
|
---|
1422 | # INSTARGET_ later.
|
---|
1423 | endef
|
---|
1424 | $(foreach target, $(INSTALLS) $(INSTALLS.$(BUILD_TARGET)) $(INSTALLS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
|
---|
1425 | $(eval $(value def_pass1_install)))
|
---|
1426 |
|
---|
1427 | ifdef KBUILD_PROFILE_SELF
|
---|
1428 | _KBUILD_TS_NOW := $(nanots )
|
---|
1429 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done pass 1)
|
---|
1430 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
1431 | endif
|
---|
1432 |
|
---|
1433 |
|
---|
1434 |
|
---|
1435 |
|
---|
1436 | #
|
---|
1437 | #
|
---|
1438 | # Target lists - Pass 2
|
---|
1439 | #
|
---|
1440 | #
|
---|
1441 |
|
---|
1442 |
|
---|
1443 | ## @page pg_fetches Fetching Tools, Sources and Similar.
|
---|
1444 | #
|
---|
1445 | # The targets listed in the the FETCHES target list have the following attributes:
|
---|
1446 | # SOURCES
|
---|
1447 | # INST
|
---|
1448 | # FETCHTOOL
|
---|
1449 | # FETCHFLAGS
|
---|
1450 | # FETCHDIR
|
---|
1451 | # UNPACKTOOL
|
---|
1452 | # UNPACKFLAGS
|
---|
1453 | #
|
---|
1454 | # As usual the target name is an alias for 'creating' the target. Other
|
---|
1455 | # aliases are:
|
---|
1456 | # pass_fetches
|
---|
1457 | # fetch
|
---|
1458 | # unfetch
|
---|
1459 | # download
|
---|
1460 | # unpack
|
---|
1461 | #
|
---|
1462 | # @remark
|
---|
1463 | #
|
---|
1464 | # This is a little bit complex because we must guarantee that if a source file
|
---|
1465 | # changes only sligtly we must refetch it and to a proper unpacking of it. It
|
---|
1466 | # is also a desire that fetched archives and unpacked files can be deleted to
|
---|
1467 | # save space.
|
---|
1468 | #
|
---|
1469 | # Thus, we must be able to cleanup what we've unpacked should any of the
|
---|
1470 | # sources be removed. We do this by maintaining a file listing the files
|
---|
1471 | # and directories that was unpacked. This operation is named 'unfetch'.
|
---|
1472 | #
|
---|
1473 | # We make use of the SIZE and MD5 attributes for each of the sources to
|
---|
1474 | # create a digest that is stored in the primary target file. Subsequent
|
---|
1475 | # runswill compare their digest with it to decide if a refetch is required.
|
---|
1476 | # When a refetch is found necessary, an 'unfetch' is performed first to
|
---|
1477 | # clean out old files and directores. Note even changes in source order
|
---|
1478 | # will cause a refetch due to the way the digest is constructed and
|
---|
1479 | # evaluated.
|
---|
1480 | #
|
---|
1481 | # By not depending directly on the archives (nor on any unpacked files)
|
---|
1482 | # but on a goal made up from the archive name, size and md5, we allow
|
---|
1483 | # the user to delete the archives. Naturally, this means we'll have to
|
---|
1484 | # check and fetch missing archives before attempting to unpack them.
|
---|
1485 | #
|
---|
1486 | # @remark
|
---|
1487 | #
|
---|
1488 | # This feature will *NOT* work correctly with vanilla GNU make becuase
|
---|
1489 | # it makes use of includedep to avoid too many unnecessary files.
|
---|
1490 | #
|
---|
1491 | # @todo
|
---|
1492 | # 1. Download corruption / continuation.
|
---|
1493 | # 2. It's quite possible that there is one too many indirect dependency now...
|
---|
1494 | #
|
---|
1495 |
|
---|
1496 | ## generates the fetch rule
|
---|
1497 | define def_fetch_src_fetch_rule
|
---|
1498 | # Indirect goal for downloading something.
|
---|
1499 | .PRECIOUS: $(out)
|
---|
1500 | $(out) + $($(target)_$(srcname)_FETCH_OUTPUT_) +| $($(target)_$(srcname)_FETCH_OUTPUT_MAYBE_) : \
|
---|
1501 | | $($(target)_$(srcname)_FETCH_DEPORD_)
|
---|
1502 | $$(call MSG_FETCH_DL,$(target),$(source),$(out))
|
---|
1503 | @## @todo do fancy stuff like download continuation.
|
---|
1504 | $$(QUIET)$$(RM) -f $(out)
|
---|
1505 | $($(target)_$(srcname)_FETCH_CMDS_)
|
---|
1506 | $$(QUIET)$(if $(md5),$$(MD5SUM_EXT) -b -C $(md5) $(out))
|
---|
1507 |
|
---|
1508 |
|
---|
1509 |
|
---|
1510 | # Intermediate goal for making sure the md5 and size matches. it will (re) fetch the archive if necessary.
|
---|
1511 | $(out).checked_$(md5)_$(size): $($(target)_$(srcname)_FETCH_DEPEND_) | $($(target)_$(srcname)_FETCH_DEPORD_)
|
---|
1512 | $$(call MSG_FETCH_CHK,$(target),$(source),$(out))
|
---|
1513 | $$(QUIET)$$(RM) -f $$@
|
---|
1514 | @# (re)fetch the file if it doesn't exist or if it doesn't matches the md5.
|
---|
1515 | @## @todo do fancy stuff like download continuation.
|
---|
1516 | $$(QUIET)( test -f $(out) && $(if $(md5),$$(MD5SUM_EXT) -b -C $(md5) $(out), true) ) \
|
---|
1517 | || ( $$(RM_EXT) -f $(out) \
|
---|
1518 | && $$(MAKE) $(out) -f $(MAKEFILE) --no-print-directory )
|
---|
1519 | $$(QUIET2)$$(APPEND) $$@
|
---|
1520 |
|
---|
1521 | _TARGET_$(target)_FETCHED += $(out) $(out).checked_$(md5)_$(size)
|
---|
1522 |
|
---|
1523 | # Just a little precaution.
|
---|
1524 | .NOTPARALLEL: $(out) $(out).checked_$(md5)_$(size)
|
---|
1525 |
|
---|
1526 | endef
|
---|
1527 |
|
---|
1528 | ## generates the unpack rule
|
---|
1529 | define def_fetch_src_unpack_rule
|
---|
1530 | # This is the unpack rule. it has an order-only dependency on the download check.
|
---|
1531 | $(out) + $($(target)_$(srcname)_UNPACK_OUTPUT_) +| $($(target)_$(srcname)_UNPACK_OUTPUT_MAYBE_) : \
|
---|
1532 | $($(target)_$(srcname)_UNPACK_DEPEND_) \
|
---|
1533 | | $($(target)_$(srcname)_UNPACK_DEPORD_) $(archive).checked_$(md5)_$(size)
|
---|
1534 | $$(call MSG_FETCH_UP,$(target),$(archive),$(inst))
|
---|
1535 | $$(QUIET)$$(RM) -f $(out)
|
---|
1536 | @# if the source archive doesn't exist fetch it (can have been deleted to save space).
|
---|
1537 | $$(QUIET)test -f $(archive) \
|
---|
1538 | || ( $$(RM_EXT) -f $(archive).checked_$(md5)_$(size) \
|
---|
1539 | && $$(MAKE) $(archive).checked_$(md5)_$(size) -f $(MAKEFILE) --no-print-directory )
|
---|
1540 | $($(target)_$(srcname)_UNPACK_CMDS_)
|
---|
1541 | $$(QUIET2)$$(APPEND) $(out) $(notdir $(archive).checked_$(md5)_$(size))
|
---|
1542 | $$(QUIET2)$$(APPEND) $(out) $(notdir $(out))
|
---|
1543 |
|
---|
1544 | $(eval _TARGET_$(target)_UNPACKED += $(out))
|
---|
1545 | _TARGET_$(target)_DIGEST := $(_TARGET_$(target)_DIGEST)-$(srcname)_$(md5)_$(size)
|
---|
1546 |
|
---|
1547 | .NOTPARALLEL: $(out)
|
---|
1548 |
|
---|
1549 | endef
|
---|
1550 |
|
---|
1551 | ## Processes a fetch source
|
---|
1552 | #
|
---|
1553 | define def_fetch_src
|
---|
1554 | #$ (warning dbg: def_fetch_src: source='$(source)' target='$(target)')
|
---|
1555 |
|
---|
1556 | # common
|
---|
1557 | srcname := $(notdir $(source))
|
---|
1558 | inst := $(firstword \
|
---|
1559 | $($(target)_$(source)_INST)\
|
---|
1560 | $($(target)_$(srcname)_INST)\
|
---|
1561 | $($(source)_INST)\
|
---|
1562 | $($(srcname)_INST)\
|
---|
1563 | $($(target)_INST)\
|
---|
1564 | )
|
---|
1565 | ifneq ($(patsubst %/,ok,$(inst)),ok)
|
---|
1566 | $(error kBuild: Bad or missing INST property for source '$(source)' in target '$(target)': $(inst))
|
---|
1567 | endif
|
---|
1568 | INSTARGET_$(target)_$(srcname) := $(inst)
|
---|
1569 | fetchdir := $(firstword \
|
---|
1570 | $($(target)_$(source)_FETCHDIR)\
|
---|
1571 | $($(target)_$(srcname)_FETCHDIR)\
|
---|
1572 | $($(source)_FETCHDIR)\
|
---|
1573 | $($(srcname)_FETCHDIR)\
|
---|
1574 | $($(target)_FETCHDIR)\
|
---|
1575 | $(FETCHDIR)\
|
---|
1576 | $(PATH_TARGET)\
|
---|
1577 | )
|
---|
1578 | deps := \
|
---|
1579 | $($(target)_$(source)_DEPS)\
|
---|
1580 | $($(target)_$(srcname)_DEPS)\
|
---|
1581 | $($(source)_DEPS)\
|
---|
1582 | $($(srcname)_DEPS)\
|
---|
1583 | $($(target)_DEPS)
|
---|
1584 | orderdeps := \
|
---|
1585 | $($(target)_$(source)_ORDERDEPS)\
|
---|
1586 | $($(target)_$(srcname)_ORDERDEPS)\
|
---|
1587 | $($(source)_ORDERDEPS)\
|
---|
1588 | $($(srcname)_ORDERDEPS)\
|
---|
1589 | $($(target)_ORDERDEPS)
|
---|
1590 | md5 := $(firstword \
|
---|
1591 | $($(target)_$(source)_MD5)\
|
---|
1592 | $($(target)_$(srcname)_MD5)\
|
---|
1593 | $($(source)_MD5)\
|
---|
1594 | $($(srcname)_MD5)\
|
---|
1595 | $($(target)_MD5)\
|
---|
1596 | )
|
---|
1597 | size := $(firstword \
|
---|
1598 | $($(target)_$(source)_SIZE)\
|
---|
1599 | $($(target)_$(srcname)_SIZE)\
|
---|
1600 | $($(source)_SIZE)\
|
---|
1601 | $($(srcname)_SIZE)\
|
---|
1602 | $($(target)_SIZE)\
|
---|
1603 | )
|
---|
1604 | dep := # not legal for fetch and unpack tools
|
---|
1605 |
|
---|
1606 |
|
---|
1607 | #
|
---|
1608 | # The fetching.
|
---|
1609 | #
|
---|
1610 | out := $(fetchdir)/$(srcname)
|
---|
1611 | archive := $(out)
|
---|
1612 | TARGET_$(target)_$(srcname) := $(out)
|
---|
1613 | dirdep := $(call DIRDEP,$(fetchdir))
|
---|
1614 | tool := $(firstword \
|
---|
1615 | $($(target)_$(source)_FETCHTOOL)\
|
---|
1616 | $($(target)_$(srcname)_FETCHTOOL)\
|
---|
1617 | $($(target)_$(source)_TOOL)\
|
---|
1618 | $($(target)_$(srcname)_TOOL)\
|
---|
1619 | $($(source)_FETCHTOOL)\
|
---|
1620 | $($(srcname)_FETCHTOOL)\
|
---|
1621 | $($(source)_TOOL)\
|
---|
1622 | $($(srcname)_TOOL)\
|
---|
1623 | $($(target)_FETCHTOOL)\
|
---|
1624 | $($(target)_TOOL)\
|
---|
1625 | )
|
---|
1626 | flags :=\
|
---|
1627 | $(TOOL_$(tool)_FETCHFLAGS)\
|
---|
1628 | $(FETCHFLAGS)\
|
---|
1629 | $($(target)_FETCHFLAGS)\
|
---|
1630 | $($(srcname)_FETCHFLAGS)\
|
---|
1631 | $($(source)_FETCHFLAGS)\
|
---|
1632 | $($(target)_$(srcname)_FETCHFLAGS)\
|
---|
1633 | $($(target)_$(source)_FETCHFLAGS)
|
---|
1634 |
|
---|
1635 | #$ (warning dbg: target=$(target) source=$(source) $(srcname)=$(srcname) tool=$(tool) out=$(out) flags=$(flags) dirdep=$(dirdep) fetchdir=$(fetchdir) md5=$(md5) size=$(size))
|
---|
1636 |
|
---|
1637 | ifndef TOOL_$(tool)_FETCH_CMDS
|
---|
1638 | $(warning kBuild: tools: \
|
---|
1639 | 1 $($(target)_$(source)_FETCHTOOL)\
|
---|
1640 | 2 $($(target)_$(srcname)_FETCHTOOL)\
|
---|
1641 | 3 $($(target)_$(source)_TOOL)\
|
---|
1642 | 4 $($(target)_$(srcname)_TOOL)\
|
---|
1643 | 5 $($(source)_FETCHTOOL)\
|
---|
1644 | 6 $($(srcname)_FETCHTOOL)\
|
---|
1645 | 7 $($(source)_TOOL)\
|
---|
1646 | 8 $($(srcname)_TOOL)\
|
---|
1647 | 9 $($(target)_FETCHTOOL)\
|
---|
1648 | 10 $($(target)_TOOL) )
|
---|
1649 | $(error kBuild: TOOL_$(tool)_FETCH_CMDS is not defined. source=$(source) target=$(target) )
|
---|
1650 | endif
|
---|
1651 |
|
---|
1652 | # call the tool
|
---|
1653 | $(target)_$(srcname)_FETCH_CMDS_ := $(TOOL_$(tool)_FETCH_CMDS)
|
---|
1654 | $(target)_$(srcname)_FETCH_OUTPUT_ := $(TOOL_$(tool)_FETCH_OUTPUT)
|
---|
1655 | $(target)_$(srcname)_FETCH_OUTPUT_MAYBE_ := $(TOOL_$(tool)_FETCH_OUTPUT_MAYBE)
|
---|
1656 | $(target)_$(srcname)_FETCH_DEPEND_ := $(TOOL_$(tool)_FETCH_DEPEND) $(deps)
|
---|
1657 | $(target)_$(srcname)_FETCH_DEPORD_ := $(TOOL_$(tool)_FETCH_DEPORD) $(dirdep) $(orderdeps)
|
---|
1658 |
|
---|
1659 | # generate the fetch rule.
|
---|
1660 | $(eval $(def_fetch_src_fetch_rule))
|
---|
1661 |
|
---|
1662 |
|
---|
1663 | #
|
---|
1664 | # The unpacking / installing.
|
---|
1665 | #
|
---|
1666 | out := $(inst)_kBuild_$(target)_$(srcname)_unpacked.lst
|
---|
1667 | dirdep := $(call DIRDEP,$(inst))
|
---|
1668 | tool := $(firstword \
|
---|
1669 | $($(target)_$(source)_UNPACKTOOL)\
|
---|
1670 | $($(target)_$(srcname)_UNPACKTOOL)\
|
---|
1671 | $($(target)_$(source)_TOOL)\
|
---|
1672 | $($(target)_$(srcname)_TOOL)\
|
---|
1673 | $($(source)_UNPACKTOOL)\
|
---|
1674 | $($(srcname)_UNPACKTOOL)\
|
---|
1675 | $($(source)_TOOL)\
|
---|
1676 | $($(srcname)_TOOL)\
|
---|
1677 | $($(target)_UNPACKTOOL)\
|
---|
1678 | $($(target)_TOOL) \
|
---|
1679 | )
|
---|
1680 | ifeq ($(tool),)
|
---|
1681 | tool := $(toupper $(subst .,,$(suffix $(subst tar.,TAR,$(srcname)))))
|
---|
1682 | $(eval $(value def_tools_include))
|
---|
1683 | endif
|
---|
1684 | flags :=\
|
---|
1685 | $(TOOL_$(tool)_UNPACKFLAGS)\
|
---|
1686 | $(UNPACKFLAGS)\
|
---|
1687 | $($(target)_UNPACKFLAGS)\
|
---|
1688 | $($(srcname)_UNPACKFLAGS)\
|
---|
1689 | $($(source)_UNPACKFLAGS)\
|
---|
1690 | $($(target)_$(srcname)_UNPACKFLAGS)\
|
---|
1691 | $($(target)_$(source)_UNPACKFLAGS)
|
---|
1692 |
|
---|
1693 | #$ (warning dbg: target=$(target) source=$(source) $(srcname)=$(srcname) tool=$(tool) out=$(out) flags=$(flags) dirdep=$(dirdep) inst=$(inst) md5=$(md5) size=$(size))
|
---|
1694 | ifndef TOOL_$(tool)_UNPACK_CMDS
|
---|
1695 | $(warning kBuild: tools: \
|
---|
1696 | 1 $($(target)_$(source)_UNPACKTOOL)\
|
---|
1697 | 2 $($(target)_$(srcname)_UNPACKTOOL)\
|
---|
1698 | 3 $($(target)_$(source)_TOOL)\
|
---|
1699 | 4 $($(target)_$(srcname)_TOOL)\
|
---|
1700 | 5 $($(source)_UNPACKTOOL)\
|
---|
1701 | 6 $($(srcname)_UNPACKTOOL)\
|
---|
1702 | 7 $($(source)_TOOL)\
|
---|
1703 | 8 $($(srcname)_TOOL)\
|
---|
1704 | 9 $($(target)_UNPACKTOOL)\
|
---|
1705 | 10 $($(target)_TOOL) \
|
---|
1706 | 11 $(toupper $(subst tar.,TAR,$(ext $(srcname)))) \
|
---|
1707 | )
|
---|
1708 | $(error kBuild: TOOL_$(tool)_UNPACK_CMDS is not defined. source=$(source) target=$(target) )
|
---|
1709 | endif
|
---|
1710 |
|
---|
1711 | # call the tool
|
---|
1712 | $(target)_$(srcname)_UNPACK_CMDS_ := $(TOOL_$(tool)_UNPACK_CMDS)
|
---|
1713 | $(target)_$(srcname)_UNPACK_OUTPUT_ := $(TOOL_$(tool)_UNPACK_OUTPUT)
|
---|
1714 | $(target)_$(srcname)_UNPACK_OUTPUT_MAYBE_ := $(TOOL_$(tool)_UNPACK_OUTPUT_MAYBE)
|
---|
1715 | $(target)_$(srcname)_UNPACK_DEPEND_ := $(TOOL_$(tool)_UNPACK_DEPEND) $(deps)
|
---|
1716 | $(target)_$(srcname)_UNPACK_DEPORD_ := $(TOOL_$(tool)_UNPACK_DEPORD) $(dirdep) $(orderdeps)
|
---|
1717 |
|
---|
1718 | # generate the fetch rule.
|
---|
1719 | $(eval $(def_fetch_src_unpack_rule))
|
---|
1720 |
|
---|
1721 | _DIRS += $(inst) $(fetchdir)
|
---|
1722 |
|
---|
1723 | endef
|
---|
1724 |
|
---|
1725 |
|
---|
1726 | ##
|
---|
1727 | # Define the target level rules for a fetch.
|
---|
1728 | # @param target
|
---|
1729 | # @param out
|
---|
1730 | # @param inst
|
---|
1731 | # @param _TARGET_$(target)_UNPACKED
|
---|
1732 | # @param _TARGET_$(target)_DIGEST
|
---|
1733 | # @param bld_trg
|
---|
1734 | # @param bld_trg_arch
|
---|
1735 | define def_fetch_rules
|
---|
1736 |
|
---|
1737 | $(out).lst: $(_TARGET_$(target)_UNPACKED) | $(call DIRDEP,$(inst))
|
---|
1738 | $$(call MSG_FETCH_OK,$(target))
|
---|
1739 | $$(QUIET)$$(RM) -f $$@ $$@.tmp
|
---|
1740 | $$(QUIET2)$$(APPEND) $$@.tmp '$(notdir $(out))'
|
---|
1741 | $$(QUIET)$(if $(_TARGET_$(target)_UNPACKED),$$(CAT_EXT) $(_TARGET_$(target)_UNPACKED) >> $$@.tmp)
|
---|
1742 | $$(QUIET)$$(MV) -f $$@.tmp $$@
|
---|
1743 |
|
---|
1744 | $(out)_unfetched:
|
---|
1745 | $$(call MSG_UNFETCH,$(target))
|
---|
1746 | $$(QUIET)$$(RM) -f $$(addprefix $(inst),$$(shell $$(CAT_EXT) $(out).lst 2> /dev/null | $$(SED) -e '/\/$$$$/d'))
|
---|
1747 | $$(QUIET)$$(RMDIR) -p --ignore-fail-on-non-empty --ignore-fail-on-not-exist $$(dir $$@) \
|
---|
1748 | $$(addprefix $(inst),$$(sort $$(dir $$(shell $$(CAT_EXT) $(out).lst 2> /dev/null))))
|
---|
1749 | $$(QUIET)$$(RM) -f $(out).lst $(out)
|
---|
1750 | $$(QUIET)$$(RMDIR) -p --ignore-fail-on-non-empty --ignore-fail-on-not-exist $$(dir $$@)
|
---|
1751 |
|
---|
1752 | $(out): $(comp-vars _TARGET_$(target)_DIGEST_PREV,_TARGET_$(target)_DIGEST,FORCE) | $(call DIRDEP,$(inst))
|
---|
1753 | $$(QUIET)$$(RM) -f $$@
|
---|
1754 | $$(if $$(_TARGET_$(target)_DIGEST),$$(if $$(wildcard $(out).lst)\
|
---|
1755 | ,$$(call MSG_REFETCH,$(target)),$$(call MSG_FETCH,$(target))),$$(call MSG_UNFETCH,$(target)))
|
---|
1756 | $$(QUIET)$$(if $$(wildcard $(out).lst ),$$(MAKE) -f $(MAKEFILE) --no-print-directory $(out)_unfetched)
|
---|
1757 | $$(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 $$@))
|
---|
1758 | $$(QUIET2)$$(if $$(_TARGET_$(target)_DIGEST),$$(APPEND) $$@ "_TARGET_$(target)_DIGEST_PREV := $(_TARGET_$(target)_DIGEST)")
|
---|
1759 |
|
---|
1760 | .NOTPARALLEL: $(out).lst $(out)_unfetched $(out)
|
---|
1761 |
|
---|
1762 | endef
|
---|
1763 |
|
---|
1764 |
|
---|
1765 | ##
|
---|
1766 | # Deal with one fetch target.
|
---|
1767 | # @param target
|
---|
1768 | # @param bld_trg
|
---|
1769 | # @param bld_trg_arch
|
---|
1770 | define def_fetch
|
---|
1771 | # common
|
---|
1772 | INSTARGET_$(target) := $($(target)_INST)
|
---|
1773 | ifneq ($(patsubst %/,ok,$(INSTARGET_$(target))),ok)
|
---|
1774 | $(error kBuild: Bad or missing INST property for target '$(target)'. \
|
---|
1775 | $(target)_INST='$($(target)_INST)' ($(origin $(target)_INST)))
|
---|
1776 | endif
|
---|
1777 | _TARGET_$(target)_FETCHED :=
|
---|
1778 | _TARGET_$(target)_UNPACKED :=
|
---|
1779 | _TARGET_$(target)_DIGEST :=
|
---|
1780 |
|
---|
1781 | # The 'sources'.
|
---|
1782 | #$ (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)))
|
---|
1783 | $(foreach source,$($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TYPE)) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_TARGET_ARCH)) $($(target)_SOURCES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)),\
|
---|
1784 | $(eval $(value def_fetch_src)))
|
---|
1785 |
|
---|
1786 | # The target.
|
---|
1787 | inst := $(INSTARGET_$(target))
|
---|
1788 | out := $(inst)_kBuild_fetch_$(target)
|
---|
1789 |
|
---|
1790 | $(eval includedep $(out))
|
---|
1791 |
|
---|
1792 | $(eval $(def_fetch_rules))
|
---|
1793 |
|
---|
1794 | # Define the aliases here (doesn't work if defined in def_fetch_rules, just like includedep).
|
---|
1795 | $(target): $(out)
|
---|
1796 | $(target)_unfetch: $(out)_unfetched
|
---|
1797 |
|
---|
1798 | _FETCHES += $(out)
|
---|
1799 | _DOWNLOADS += $(_TARGET_$(target)_FETCHED)
|
---|
1800 | _UNPACKS += $(_TARGET_$(target)_UNPACKED)
|
---|
1801 | _UNFETCHES += $(out)_unfetched
|
---|
1802 | _DIRS += $(inst)
|
---|
1803 |
|
---|
1804 | endef
|
---|
1805 |
|
---|
1806 | # Walk the FETCH target lists.
|
---|
1807 | bld_trg := $(BUILD_TARGET)
|
---|
1808 | bld_trg_arch := $(BUILD_TARGET_ARCH)
|
---|
1809 | $(foreach target, $(FETCHES) $(FETCHES.$(BUILD_TARGET)) $(FETCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
|
---|
1810 | $(eval $(value def_fetch)))
|
---|
1811 |
|
---|
1812 | # some aliases.
|
---|
1813 | download: $(_DOWNLOADS)
|
---|
1814 | unpack: $(_UNPACKS)
|
---|
1815 | fetch: $(_FETCHES)
|
---|
1816 | unfetch: $(_UNFETCHES)
|
---|
1817 |
|
---|
1818 | ifdef KBUILD_PROFILE_SELF
|
---|
1819 | _KBUILD_TS_NOW := $(nanots )
|
---|
1820 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done fetching targets)
|
---|
1821 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
1822 | endif
|
---|
1823 |
|
---|
1824 |
|
---|
1825 |
|
---|
1826 | ##
|
---|
1827 | ## Patching.
|
---|
1828 | ##
|
---|
1829 | ##
|
---|
1830 | #define def_patch_src
|
---|
1831 | #
|
---|
1832 | #endef
|
---|
1833 | #
|
---|
1834 | #
|
---|
1835 | ## Deal with one patch target.
|
---|
1836 | #define def_patch
|
---|
1837 | #
|
---|
1838 | #$(foreach source,$($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TYPE)) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_TARGET_ARCH)) $($(target)_SOURCES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)),\
|
---|
1839 | # $(eval $(value def_patch_src)))
|
---|
1840 | #
|
---|
1841 | #_PATCHES +=
|
---|
1842 | #endef
|
---|
1843 | #
|
---|
1844 | #$(foreach target, $(PATCHES) $(PATCHES.$(BUILD_TARGET)) $(PATCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
|
---|
1845 | # $(eval $(value def_patch)))
|
---|
1846 | #
|
---|
1847 |
|
---|
1848 |
|
---|
1849 | #
|
---|
1850 | # Object processing.
|
---|
1851 | #
|
---|
1852 |
|
---|
1853 | ## wrapper the compile command dependency check.
|
---|
1854 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
1855 | _DEP_COMPILE_CMDS = $(comp-cmds $(target)_$(source)_CMDS_PREV_,$(target)_$(source)_CMDS_,FORCE)
|
---|
1856 | else
|
---|
1857 | _DEP_COMPILE_CMDS =
|
---|
1858 | endif
|
---|
1859 |
|
---|
1860 | ## Generates the rules for building a specific object, and the aliases
|
---|
1861 | # for building a source file.
|
---|
1862 | # @param $(obj) The object file.
|
---|
1863 | define def_target_source_rule
|
---|
1864 |
|
---|
1865 | ifdef TOOL_$(tool)_COMPILE_$(type)_USES_KOBJCACHE
|
---|
1866 | $(outbase).koc +| $(obj) $($(target)_$(source)_OUTPUT_) $($(target)_$(source)_OUTPUT_MAYBE_) : \
|
---|
1867 | $($(target)_$(source)_DEPEND_) \
|
---|
1868 | $(_DEP_COMPILE_CMDS) \
|
---|
1869 | | \
|
---|
1870 | $($(target)_$(source)_DEPORD_) \
|
---|
1871 | $$($(target)_INTERMEDIATES)
|
---|
1872 | $$(call MSG_COMPILE,$(target),$(source),$$@,$(type))
|
---|
1873 | else
|
---|
1874 | $(obj) + $($(target)_$(source)_OUTPUT_) +| $($(target)_$(source)_OUTPUT_MAYBE_) : \
|
---|
1875 | $($(target)_$(source)_DEPEND_) \
|
---|
1876 | $(_DEP_COMPILE_CMDS) \
|
---|
1877 | | \
|
---|
1878 | $($(target)_$(source)_DEPORD_) \
|
---|
1879 | $$($(target)_INTERMEDIATES)
|
---|
1880 | $$(call MSG_COMPILE,$(target),$(source),$$@,$(type))
|
---|
1881 | ifdef TOOL_$(tool)_COMPILE_$(type)_DONT_PURGE_OUTPUT
|
---|
1882 | $$(QUIET)$$(RM) -f $(dep) $(obj) $($(target)_$(source)_OUTPUT_) $($(target)_OUTPUT_MAYBE_)
|
---|
1883 | endif
|
---|
1884 | endif
|
---|
1885 |
|
---|
1886 | $($(target)_$(source)_CMDS_)
|
---|
1887 |
|
---|
1888 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
1889 | $$(QUIET2)$$(APPEND) '$(dep)'
|
---|
1890 | $$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(source)_CMDS_PREV_'
|
---|
1891 | $$(QUIET2)$$(APPEND) -v '$(dep)' '$(target)_$(source)_CMDS_'
|
---|
1892 | $$(QUIET2)$$(APPEND) '$(dep)' 'endef'
|
---|
1893 | endif
|
---|
1894 |
|
---|
1895 | $(basename $(notdir $(obj))).o: $(obj)
|
---|
1896 | $(basename $(notdir $(obj))).obj: $(obj)
|
---|
1897 | endef
|
---|
1898 |
|
---|
1899 |
|
---|
1900 | ## wrapper the link command dependency check.
|
---|
1901 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
1902 | _DEP_LINK_CMDS = $(comp-cmds $(target)_CMDS_PREV_,$(target)_CMDS_,FORCE)
|
---|
1903 | else
|
---|
1904 | _DEP_LINK_CMDS =
|
---|
1905 | endif
|
---|
1906 |
|
---|
1907 | ## Generate the link rule for a target.
|
---|
1908 | # @param $(target) The normalized target name.
|
---|
1909 | # @param $(dirdep) Directories we depend upon begin created before linking.
|
---|
1910 | # @param $(dep) The name of the dependency file.
|
---|
1911 | # @param $(out)
|
---|
1912 | # @param $($(target)_OUTPUT_) Output files from the link.
|
---|
1913 | # @param $($(target)_OUTPUT_MAYBE_) Output files that the link may perhaps create.
|
---|
1914 | # @param $($(target)_DEPEND_) Dependencies.
|
---|
1915 | # @param $($(target)_DEPORD_) Dependencies which should only affect build order.
|
---|
1916 | # @param $($(target)_CMDS_) The link commands.
|
---|
1917 | # @param $($(target)_CMDS_PREV_) The link commands from the previous run.
|
---|
1918 | define def_link_rule
|
---|
1919 | $(out) + $($(target)_OUTPUT_) +| $($(target)_OUTPUT_MAYBE_) : \
|
---|
1920 | $($(target)_DEPEND_) \
|
---|
1921 | $(_DEP_LINK_CMDS) \
|
---|
1922 | | \
|
---|
1923 | $($(target)_DEPORD_)
|
---|
1924 | $$(call MSG_LINK,$(target),$$@,$(tool_do))
|
---|
1925 | $$(QUIET)$$(RM) -f $(dep) $(out) $($(target)_OUTPUT_) $($(target)_OUTPUT_MAYBE_)
|
---|
1926 |
|
---|
1927 | $($(target)_CMDS_)
|
---|
1928 |
|
---|
1929 | ifndef NO_LINK_CMDS_DEPS
|
---|
1930 | $$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_CMDS_PREV_'
|
---|
1931 | $$(QUIET2)$$(APPEND) -v '$(dep)' '$(target)_CMDS_'
|
---|
1932 | $$(QUIET2)$$(APPEND) '$(dep)' 'endef'
|
---|
1933 | endif
|
---|
1934 |
|
---|
1935 | $(basename $(notdir $(out))): $(out)
|
---|
1936 |
|
---|
1937 | endef
|
---|
1938 |
|
---|
1939 |
|
---|
1940 | ## Generate the link & lib install rule
|
---|
1941 | # @param $(target) Normalized target name.
|
---|
1942 | # @param $(out) The build target.
|
---|
1943 | # @param $(INSTARGET_$(target)) The installation targets.
|
---|
1944 | # @param $(mode) The file mode (optional)
|
---|
1945 | define def_link_install_rule
|
---|
1946 | $(INSTARGET_$(target)) : $(out) | $(call DIRDEP,$(dir $(INSTARGET_$(target))))
|
---|
1947 | $$(call MSG_INST_TRG,$(target),$(out),$$@)
|
---|
1948 | $$(QUIET)$$(INSTALL) $$(if $(mode),-m $(mode)) $(out) $$@
|
---|
1949 |
|
---|
1950 | ifdef KBUILD_DO_AUTO_INSTALL
|
---|
1951 | $(basename $(notdir $(out))): $(INSTARGET_$(target))
|
---|
1952 | endif
|
---|
1953 | endef
|
---|
1954 |
|
---|
1955 |
|
---|
1956 | ## def_src_handler_*
|
---|
1957 | #
|
---|
1958 | # @{
|
---|
1959 | define def_src_handler_c
|
---|
1960 | type := C
|
---|
1961 | $(kb-src-one )
|
---|
1962 | endef
|
---|
1963 |
|
---|
1964 | define def_src_handler_cxx
|
---|
1965 | type := CXX
|
---|
1966 | $(kb-src-one )
|
---|
1967 | endef
|
---|
1968 |
|
---|
1969 | define def_src_handler_objc
|
---|
1970 | type := OBJC
|
---|
1971 | $(kb-src-one )
|
---|
1972 | endef
|
---|
1973 |
|
---|
1974 | define def_src_handler_asm
|
---|
1975 | type := AS
|
---|
1976 | $(kb-src-one )
|
---|
1977 | endef
|
---|
1978 |
|
---|
1979 | define def_src_handler_rc
|
---|
1980 | type := RC
|
---|
1981 | $(kb-src-one )
|
---|
1982 | endef
|
---|
1983 |
|
---|
1984 | define def_src_handler_obj
|
---|
1985 | $(target)_OBJS_ += $(source)
|
---|
1986 | endef
|
---|
1987 | ## @}
|
---|
1988 |
|
---|
1989 | ## Handle one source.
|
---|
1990 | # .
|
---|
1991 | define def_src_handler_one
|
---|
1992 | suff := $(suffix $(source))
|
---|
1993 | src_handler := $(firstword $(filter $(suff):%, $($(target)_$(source)_SRC_HANDLERS) $($(source)_SRC_HANDLERS) $(target_src_handlers) ))
|
---|
1994 | handler := $(patsubst $(suff):%,%,$(src_handler))
|
---|
1995 | #$ (warning def_src_handler_one: source=$(source) suff=$(suff) src_handler=$(src_handler) handler=$(handler))
|
---|
1996 | ifneq ($(handler),)
|
---|
1997 | $(eval $(value $(handler)))
|
---|
1998 | else
|
---|
1999 | othersrc += $(source)
|
---|
2000 | endif
|
---|
2001 | endef
|
---|
2002 |
|
---|
2003 | ## Generic macro for processing all target sources.
|
---|
2004 | # @param $(target) Normalized target name.
|
---|
2005 | # @param $(defpath)
|
---|
2006 | # @param much-more...
|
---|
2007 | # @returns othersrc, $(target)_OBJS_, ++
|
---|
2008 | define def_target_sources
|
---|
2009 |
|
---|
2010 | target_src_handlers := $($(target)_SRC_HANDLERS) $(KBUILD_SRC_HANDLERS)
|
---|
2011 | $(foreach source,\
|
---|
2012 | $($(target)_SOURCES)\
|
---|
2013 | $($(target)_SOURCES.$(bld_trg))\
|
---|
2014 | $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch))\
|
---|
2015 | $($(target)_SOURCES.$(bld_trg_arch))\
|
---|
2016 | $($(target)_SOURCES.$(bld_trg_cpu))\
|
---|
2017 | $($(target)_SOURCES.$(bld_type))\
|
---|
2018 | ,$(eval $(value def_src_handler_one)) )
|
---|
2019 |
|
---|
2020 | endef
|
---|
2021 |
|
---|
2022 |
|
---|
2023 |
|
---|
2024 | ## Generic macro for generating the install rule(s) for a target
|
---|
2025 | # and update the globals with default out.
|
---|
2026 | #
|
---|
2027 | # @param $(target) Normalized target name.
|
---|
2028 | # @param $(out) The output file.
|
---|
2029 | # @param $(definst) The default _INST value.
|
---|
2030 | # @param $(typevar) The name of the variable with all the root targets of its type.
|
---|
2031 | # @remark Only library uses this now.
|
---|
2032 | define def_target_install_pluss
|
---|
2033 | ifndef $(target)_NOINST
|
---|
2034 | INSTARGET_$(target) := $(patsubst %/,%/$(notdir $(out)), \
|
---|
2035 | $(if $($(target)_INST), $(addprefix $(PATH_INS)/,$($(target)_INST)), $(definst)/))
|
---|
2036 |
|
---|
2037 | $(eval $(def_link_install_rule))
|
---|
2038 |
|
---|
2039 | _INSTALLS_FILES += $(INSTARGET_$(target))
|
---|
2040 |
|
---|
2041 | ifdef KBUILD_DO_AUTO_INSTALL
|
---|
2042 | $(typevar) += $(INSTARGET_$(target))
|
---|
2043 | else
|
---|
2044 | $(typevar) += $(out)
|
---|
2045 | endif
|
---|
2046 | else # _NOINST
|
---|
2047 | $(typevar) += $(out)
|
---|
2048 | endif
|
---|
2049 |
|
---|
2050 | _OUT_FILES += $($(target)_OUTPUT_) $($(target)_OUTPUT_MAYBE_) $(out)
|
---|
2051 | _CLEAN_FILES += $($(target)_CLEAN) $($(target)_CLEAN.$(bld_trg)) $($(target)_CLEAN.$(bld_trg).$(bld_trg_arch)) $($(target)_CLEAN.$(bld_trg_arch)) $($(target)_CLEAN.$(bld_trg_cpu)) $($(target)_CLEAN.$(bld_type))
|
---|
2052 | _DIRS += $($(target)_BLDDIRS) $($(target)_BLDDIRS.$(bld_trg)) $($(target)_BLDDIRS.$(bld_trg).$(bld_trg_arch)) $($(target)_BLDDIRS.$(bld_trg_arch)) $($(target)_BLDDIRS.$(bld_trg_cpu)) $($(target)_BLDDIRS.$(bld_type))
|
---|
2053 | _OBJS += $($(target)_OBJS_)
|
---|
2054 |
|
---|
2055 | endef
|
---|
2056 |
|
---|
2057 |
|
---|
2058 |
|
---|
2059 | #
|
---|
2060 | # LIBRARIES
|
---|
2061 | #
|
---|
2062 |
|
---|
2063 | ## Library (one).
|
---|
2064 | # @param $(target) Normalized library (target) name.
|
---|
2065 | define def_lib
|
---|
2066 | # library basics
|
---|
2067 | ## @todo prefix
|
---|
2068 | bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
|
---|
2069 | bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))
|
---|
2070 | bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_TARGET_ARCH))
|
---|
2071 | bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_TARGET_CPU))
|
---|
2072 | tool := $(call _TARGET_TOOL,$(target),AR)
|
---|
2073 | ifeq ($(tool),)
|
---|
2074 | $(error kBuild: Library target $(target) does not have a tool defined!)
|
---|
2075 | endif
|
---|
2076 | name := $(firstword\
|
---|
2077 | $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\
|
---|
2078 | $($(target)_NAME.$(bld_trg_arch))\
|
---|
2079 | $($(target)_NAME.$(bld_trg))\
|
---|
2080 | $($(target)_NAME.$(bld_type))\
|
---|
2081 | $($(target)_NAME)\
|
---|
2082 | $(target))
|
---|
2083 | outbase := $(call TARGET_BASE,$(name),$(target))
|
---|
2084 | ifndef PATH_$(target)
|
---|
2085 | PATH_$(target) := $(patsubst %/,%,$(dir $(outbase)))
|
---|
2086 | else
|
---|
2087 | ifneq ($(PATH_$(target)),$(patsubst %/,%,$(dir $(outbase))))
|
---|
2088 | $(error kBuild internal error: PATH_$(target)=$(PATH_$(target)) expected $(patsubst %/,%,$(dir $(outbase))))
|
---|
2089 | endif
|
---|
2090 | endif
|
---|
2091 | suff := $(firstword\
|
---|
2092 | $($(target)_LIBSUFF.$(bld_trg).$(bld_trg_arch))\
|
---|
2093 | $($(target)_LIBSUFF.$(bld_trg))\
|
---|
2094 | $($(target)_LIBSUFF)\
|
---|
2095 | $(TOOL_$(tool)_ARLIBSUFF.$(bld_trg).$(bld_trg_arch))\
|
---|
2096 | $(TOOL_$(tool)_ARLIBSUFF.$(bld_trg))\
|
---|
2097 | $(TOOL_$(tool)_ARLIBSUFF)\
|
---|
2098 | $(SUFF_LIB))
|
---|
2099 | out := $(outbase)$(suff)
|
---|
2100 | TARGET_$(target) := $(out)
|
---|
2101 | $(target)_OBJS_ :=
|
---|
2102 | defpath := $($(target)_PATH)
|
---|
2103 | othersrc :=
|
---|
2104 |
|
---|
2105 | # source -> object
|
---|
2106 | $(eval $(value def_target_sources))
|
---|
2107 |
|
---|
2108 | # library linking
|
---|
2109 | tool := $(call _TARGET_TOOL,$(target),AR)
|
---|
2110 | name := $(firstword\
|
---|
2111 | $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\
|
---|
2112 | $($(target)_NAME.$(bld_trg_arch))\
|
---|
2113 | $($(target)_NAME.$(bld_trg))\
|
---|
2114 | $($(target)_NAME.$(bld_type))\
|
---|
2115 | $($(target)_NAME)\
|
---|
2116 | $(target))
|
---|
2117 | outbase := $(call TARGET_BASE,$(name),$(target))
|
---|
2118 | flags :=\
|
---|
2119 | $(TOOL_$(tool)_ARFLAGS)\
|
---|
2120 | $(TOOL_$(tool)_ARFLAGS.$(bld_type))\
|
---|
2121 | $(ARFLAGS)\
|
---|
2122 | $(ARFLAGS.$(bld_type))\
|
---|
2123 | $($(target)_ARFLAGS)\
|
---|
2124 | $($(target)_ARFLAGS.$(bld_type)) \
|
---|
2125 | $($(target)_ARFLAGS.$(bld_trg)) \
|
---|
2126 | $($(target)_ARFLAGS.$(bld_trg_arch)) \
|
---|
2127 | $($(target)_ARFLAGS.$(bld_trg).$(bld_trg_arch)) \
|
---|
2128 | $($(target)_ARFLAGS.$(bld_trg_cpu))
|
---|
2129 | dirdep := $(call DIRDEP,$(dir $(out)))
|
---|
2130 | deps := $($(target)_DEPS)
|
---|
2131 | orderdeps := $($(target)_ORDERDEPS)
|
---|
2132 |
|
---|
2133 | # Adjust paths if we got a default path.
|
---|
2134 | ifneq ($(defpath),)
|
---|
2135 | $(target)_OBJS_ := $(abspathex $($(target)_OBJS_),$(defpath))
|
---|
2136 | deps := $(abspathex $(deps),$(defpath))
|
---|
2137 | orderdeps := $(abspathex $(orderdeps),$(defpath))
|
---|
2138 | othersrc := $(abspathex $(othersrc),$(defpath))
|
---|
2139 | endif
|
---|
2140 |
|
---|
2141 |
|
---|
2142 | # Custom pre-link actions.
|
---|
2143 | ifdef $(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)
|
---|
2144 | pre_cmds := $($(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type))
|
---|
2145 | else ifdef $(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch)
|
---|
2146 | pre_cmds := $($(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch))
|
---|
2147 | else ifdef $(target)_PRE_CMDS.$(bld_trg).$(bld_type)
|
---|
2148 | pre_cmds := $($(target)_PRE_CMDS.$(bld_trg).$(bld_type))
|
---|
2149 | else ifdef $(target)_PRE_CMDS.$(bld_trg_arch)
|
---|
2150 | pre_cmds := $($(target)_PRE_CMDS.$(bld_trg_arch))
|
---|
2151 | else ifdef $(target)_PRE_CMDS.$(bld_trg)
|
---|
2152 | pre_cmds := $($(target)_PRE_CMDS.$(bld_trg))
|
---|
2153 | else ifdef $(target)_PRE_CMDS.$(bld_type)
|
---|
2154 | pre_cmds := $($(target)_PRE_CMDS.$(bld_type))
|
---|
2155 | else ifdef $(target)_PRE_CMDS
|
---|
2156 | pre_cmds := $($(target)_PRE_CMDS)
|
---|
2157 | else ifdef PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)
|
---|
2158 | pre_cmds := $(PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type))
|
---|
2159 | else ifdef PRE_CMDS.$(bld_trg).$(bld_trg_arch)
|
---|
2160 | pre_cmds := $(PRE_CMDS.$(bld_trg).$(bld_trg_arch))
|
---|
2161 | else ifdef PRE_CMDS.$(bld_trg).$(bld_type)
|
---|
2162 | pre_cmds := $(PRE_CMDS.$(bld_trg).$(bld_type))
|
---|
2163 | else ifdef PRE_CMDS.$(bld_trg_arch)
|
---|
2164 | pre_cmds := $(PRE_CMDS.$(bld_trg_arch))
|
---|
2165 | else ifdef PRE_CMDS.$(bld_trg)
|
---|
2166 | pre_cmds := $(PRE_CMDS.$(bld_trg))
|
---|
2167 | else ifdef PRE_CMDS.$(bld_type)
|
---|
2168 | pre_cmds := $(PRE_CMDS.$(bld_type))
|
---|
2169 | else
|
---|
2170 | pre_cmds := $(PRE_CMDS)
|
---|
2171 | endif
|
---|
2172 |
|
---|
2173 | # Custom post-link actions.
|
---|
2174 | ifdef $(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)
|
---|
2175 | post_cmds := $($(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type))
|
---|
2176 | else ifdef $(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch)
|
---|
2177 | post_cmds := $($(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch))
|
---|
2178 | else ifdef $(target)_POST_CMDS.$(bld_trg).$(bld_type)
|
---|
2179 | post_cmds := $($(target)_POST_CMDS.$(bld_trg).$(bld_type))
|
---|
2180 | else ifdef $(target)_POST_CMDS.$(bld_trg_arch)
|
---|
2181 | post_cmds := $($(target)_POST_CMDS.$(bld_trg_arch))
|
---|
2182 | else ifdef $(target)_POST_CMDS.$(bld_trg)
|
---|
2183 | post_cmds := $($(target)_POST_CMDS.$(bld_trg))
|
---|
2184 | else ifdef $(target)_POST_CMDS.$(bld_type)
|
---|
2185 | post_cmds := $($(target)_POST_CMDS.$(bld_type))
|
---|
2186 | else ifdef $(target)_POST_CMDS
|
---|
2187 | post_cmds := $($(target)_POST_CMDS)
|
---|
2188 | else ifdef POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)
|
---|
2189 | post_cmds := $(POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type))
|
---|
2190 | else ifdef POST_CMDS.$(bld_trg).$(bld_trg_arch)
|
---|
2191 | post_cmds := $(POST_CMDS.$(bld_trg).$(bld_trg_arch))
|
---|
2192 | else ifdef POST_CMDS.$(bld_trg).$(bld_type)
|
---|
2193 | post_cmds := $(POST_CMDS.$(bld_trg).$(bld_type))
|
---|
2194 | else ifdef POST_CMDS.$(bld_trg_arch)
|
---|
2195 | post_cmds := $(POST_CMDS.$(bld_trg_arch))
|
---|
2196 | else ifdef POST_CMDS.$(bld_trg)
|
---|
2197 | post_cmds := $(POST_CMDS.$(bld_trg))
|
---|
2198 | else ifdef POST_CMDS.$(bld_type)
|
---|
2199 | post_cmds := $(POST_CMDS.$(bld_type))
|
---|
2200 | else
|
---|
2201 | post_cmds := $(POST_CMDS)
|
---|
2202 | endif
|
---|
2203 |
|
---|
2204 | # eliminate this guy?
|
---|
2205 | objs = $($(target)_OBJS_)
|
---|
2206 |
|
---|
2207 | # dependency file
|
---|
2208 | dep := $(out)$(SUFF_DEP)
|
---|
2209 | ifndef NO_LINK_CMDS_DEPS
|
---|
2210 | _DEPFILES_INCLUDED += $(dep)
|
---|
2211 | $(eval includedep $(dep))
|
---|
2212 | endif
|
---|
2213 |
|
---|
2214 | # check that the tool is defined.
|
---|
2215 | ifndef TOOL_$(tool)_LINK_LIBRARY_CMDS
|
---|
2216 | $(warning kBuild: tools: \
|
---|
2217 | 1 $($(target)_$(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
2218 | 2 $($(target)_$(source)TOOL.$(bld_trg)) \
|
---|
2219 | 3 $($(target)_$(source)TOOL) \
|
---|
2220 | 4 $($(target)_TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
2221 | 5 $($(target)_TOOL.$(bld_trg)) \
|
---|
2222 | 6 $($(target)_TOOL) \
|
---|
2223 | 7 $($(source)TOOL) \
|
---|
2224 | 8 $($(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
2225 | 9 $($(source)TOOL.$(bld_trg)) \
|
---|
2226 | 10 $(TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
2227 | 11 $(TOOL.$(bld_trg)) \
|
---|
2228 | 12 $(TOOL) )
|
---|
2229 | $(error kBuild: TOOL_$(tool)_LINK_LIBRARY_CMDS isn't defined! target=$(target) )
|
---|
2230 | endif
|
---|
2231 |
|
---|
2232 | # call the tool
|
---|
2233 | $(target)_CMDS_ := $(TOOL_$(tool)_LINK_LIBRARY_CMDS)
|
---|
2234 | ifneq ($(pre_cmds),)
|
---|
2235 | $(target)_CMDS_ := $(TAB)$(pre_cmds)$(NL)$(TAB)$($(target)_CMDS_)
|
---|
2236 | endif
|
---|
2237 | ifneq ($(post_cmds),)
|
---|
2238 | $(target)_CMDS_ := $($(target)_CMDS_)$(NL)$(TAB)$(post_cmds)
|
---|
2239 | endif
|
---|
2240 | $(target)_OUTPUT_ := $(TOOL_$(tool)_LINK_LIBRARY_OUTPUT)
|
---|
2241 | $(target)_OUTPUT_MAYBE_ := $(TOOL_$(tool)_LINK_LIBRARY_OUTPUT_MAYBE)
|
---|
2242 | $(target)_DEPEND_ := $(TOOL_$(tool)_LINK_LIBRARY_DEPEND) $(deps) $($(target)_OBJS_)
|
---|
2243 | $(target)_DEPORD_ := $(TOOL_$(tool)_LINK_LIBRARY_DEPORD) $(dirdep) $(orderdeps)
|
---|
2244 |
|
---|
2245 | # generate the link rule.
|
---|
2246 | $(eval $(def_link_rule))
|
---|
2247 |
|
---|
2248 | # installing and globals
|
---|
2249 | $(eval $(value def_target_install_pluss))
|
---|
2250 | endef
|
---|
2251 |
|
---|
2252 | # Process libraries
|
---|
2253 | definst := $(PATH_LIB)
|
---|
2254 | typevar := _LIBS
|
---|
2255 | tool_do := LINK_LIBRARY
|
---|
2256 | mode := 0644
|
---|
2257 | $(foreach target, $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)) $(LIBRARIES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), $(eval $(value def_lib)))
|
---|
2258 |
|
---|
2259 | ifdef KBUILD_PROFILE_SELF
|
---|
2260 | _KBUILD_TS_NOW := $(nanots )
|
---|
2261 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done library targets)
|
---|
2262 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
2263 | endif
|
---|
2264 |
|
---|
2265 |
|
---|
2266 | #
|
---|
2267 | # Link operations.
|
---|
2268 | #
|
---|
2269 |
|
---|
2270 | ##
|
---|
2271 | # Link prolog
|
---|
2272 | #
|
---|
2273 | # @param $(target) Normalized target name.
|
---|
2274 | # @param $(EXT) EXE,DLL,SYS.
|
---|
2275 | # @param $(definst) The default _INST value.
|
---|
2276 | # @param $(typevar) The name of the variable with all the root targets of its type.
|
---|
2277 | define def_link_common
|
---|
2278 | # basics
|
---|
2279 | bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
|
---|
2280 | bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_$(bld_trg_base_var)))
|
---|
2281 | bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_$(bld_trg_base_var)_ARCH))
|
---|
2282 | bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_$(bld_trg_base_var)_CPU))
|
---|
2283 |
|
---|
2284 | tool := $(call _TARGET_TOOL,$(target),LD)
|
---|
2285 | name := $(firstword\
|
---|
2286 | $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\
|
---|
2287 | $($(target)_NAME.$(bld_trg_arch))\
|
---|
2288 | $($(target)_NAME.$(bld_trg))\
|
---|
2289 | $($(target)_NAME.$(bld_type))\
|
---|
2290 | $($(target)_NAME)\
|
---|
2291 | $(target))
|
---|
2292 | outbase := $(call TARGET_BASE,$(name),$(target))
|
---|
2293 | ifndef PATH_$(target)
|
---|
2294 | PATH_$(target) := $(patsubst %/,%,$(dir $(outbase)))
|
---|
2295 | else
|
---|
2296 | ifneq ($(PATH_$(target)),$(patsubst %/,%,$(dir $(outbase))))
|
---|
2297 | $(error kBuild internal error: PATH_$(target)=$(PATH_$(target)) expected $(patsubst %/,%,$(dir $(outbase))))
|
---|
2298 | endif
|
---|
2299 | endif
|
---|
2300 | suff := $(firstword \
|
---|
2301 | $($(target)_$(EXT)SUFF) \
|
---|
2302 | $($(target)_$(EXT)SUFF) \
|
---|
2303 | $(TOOL_$(tool)_LD$(EXT)SUFF) \
|
---|
2304 | $($(EXTPRE)SUFF_$(EXT)))
|
---|
2305 | out := $(outbase)$(suff)
|
---|
2306 | TARGET_$(target) := $(out)
|
---|
2307 | $(target)_OBJS_ :=
|
---|
2308 | defpath := $($(target)_PATH)
|
---|
2309 | othersrc :=
|
---|
2310 |
|
---|
2311 | # source -> object
|
---|
2312 | $(eval $(value def_target_sources))
|
---|
2313 |
|
---|
2314 | # more link stuff.
|
---|
2315 | tool := $(call _TARGET_TOOL,$(target),LD)
|
---|
2316 | name := $(firstword\
|
---|
2317 | $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\
|
---|
2318 | $($(target)_NAME.$(bld_trg_arch))\
|
---|
2319 | $($(target)_NAME.$(bld_trg))\
|
---|
2320 | $($(target)_NAME.$(bld_type))\
|
---|
2321 | $($(target)_NAME)\
|
---|
2322 | $(target))
|
---|
2323 | outbase := $(call TARGET_BASE,$(name),$(target))
|
---|
2324 | flags :=\
|
---|
2325 | $(TOOL_$(tool)_LDFLAGS)\
|
---|
2326 | $(TOOL_$(tool)_LDFLAGS.$(bld_type))\
|
---|
2327 | $(TOOL_$(tool)_LDFLAGS.$(bld_trg))\
|
---|
2328 | $(TOOL_$(tool)_LDFLAGS.$(bld_trg_arch))\
|
---|
2329 | $(TOOL_$(tool)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\
|
---|
2330 | $(TOOL_$(tool)_LDFLAGS.$(bld_trg_cpu))\
|
---|
2331 | $(foreach sdk, $(SDKS) \
|
---|
2332 | $(SDKS.$(bld_type)) \
|
---|
2333 | $(SDKS.$(bld_trg)) \
|
---|
2334 | $(SDKS.$(bld_trg_arch)) \
|
---|
2335 | $(SDKS.$(bld_trg).$(bld_trg_arch)),\
|
---|
2336 | $(SDK_$(sdk)_LDFLAGS)\
|
---|
2337 | $(SDK_$(sdk)_LDFLAGS.$(bld_type))\
|
---|
2338 | $(SDK_$(sdk)_LDFLAGS.$(bld_trg))\
|
---|
2339 | $(SDK_$(sdk)_LDFLAGS.$(bld_trg_arch))\
|
---|
2340 | $(SDK_$(sdk)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\
|
---|
2341 | $(SDK_$(sdk)_LDFLAGS.$(bld_trg_cpu)))\
|
---|
2342 | $(LDFLAGS)\
|
---|
2343 | $(LDFLAGS.$(bld_type))\
|
---|
2344 | $(LDFLAGS.$(bld_trg))\
|
---|
2345 | $(LDFLAGS.$(bld_trg_arch))\
|
---|
2346 | $(LDFLAGS.$(bld_trg).$(bld_trg_arch))\
|
---|
2347 | $(LDFLAGS.$(bld_trg_cpu))\
|
---|
2348 | $(foreach sdk, $($(target)_SDKS) \
|
---|
2349 | $($(target)_SDKS.$(bld_type)) \
|
---|
2350 | $($(target)_SDKS.$(bld_trg)) \
|
---|
2351 | $($(target)_SDKS.$(bld_trg_arch)) \
|
---|
2352 | $($(target)_SDKS.$(bld_trg).$(bld_trg_arch)),\
|
---|
2353 | $(SDK_$(sdk)_LDFLAGS)\
|
---|
2354 | $(SDK_$(sdk)_LDFLAGS.$(bld_type))\
|
---|
2355 | $(SDK_$(sdk)_LDFLAGS.$(bld_trg))\
|
---|
2356 | $(SDK_$(sdk)_LDFLAGS.$(bld_trg_arch))\
|
---|
2357 | $(SDK_$(sdk)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\
|
---|
2358 | $(SDK_$(sdk)_LDFLAGS.$(bld_trg_cpu)))\
|
---|
2359 | $($(target)_LDFLAGS)\
|
---|
2360 | $($(target)_LDFLAGS.$(bld_type))\
|
---|
2361 | $($(target)_LDFLAGS.$(bld_trg))\
|
---|
2362 | $($(target)_LDFLAGS.$(bld_trg_arch))\
|
---|
2363 | $($(target)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\
|
---|
2364 | $($(target)_LDFLAGS.$(bld_trg_cpu))
|
---|
2365 | libs :=\
|
---|
2366 | $($(target)_LIBS.$(bld_trg_cpu))\
|
---|
2367 | $($(target)_LIBS.$(bld_trg).$(bld_trg_arch))\
|
---|
2368 | $($(target)_LIBS.$(bld_trg_arch))\
|
---|
2369 | $($(target)_LIBS.$(bld_trg))\
|
---|
2370 | $($(target)_LIBS.$(bld_type))\
|
---|
2371 | $($(target)_LIBS)\
|
---|
2372 | $(foreach sdk, $($(target)_SDKS.$(bld_trg).$(bld_trg_arch)) \
|
---|
2373 | $($(target)_SDKS.$(bld_trg_arch)) \
|
---|
2374 | $($(target)_SDKS.$(bld_trg)) \
|
---|
2375 | $($(target)_SDKS.$(bld_type)) \
|
---|
2376 | $($(target)_SDKS),\
|
---|
2377 | $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
|
---|
2378 | $(SDK_$(sdk)_LIBS.$(bld_trg).$(bld_trg_arch))\
|
---|
2379 | $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
|
---|
2380 | $(SDK_$(sdk)_LIBS.$(bld_trg))\
|
---|
2381 | $(SDK_$(sdk)_LIBS.$(bld_type))\
|
---|
2382 | $(SDK_$(sdk)_LIBS))\
|
---|
2383 | $(LIBS.$(bld_trg_cpu))\
|
---|
2384 | $(LIBS.$(bld_trg).$(bld_trg_arch))\
|
---|
2385 | $(LIBS.$(bld_trg_arch))\
|
---|
2386 | $(LIBS.$(bld_trg))\
|
---|
2387 | $(LIBS.$(bld_type))\
|
---|
2388 | $(LIBS)\
|
---|
2389 | $(foreach sdk, $(SDKS.$(bld_trg).$(bld_trg_arch)) \
|
---|
2390 | $(SDKS.$(bld_trg_arch)) \
|
---|
2391 | $(SDKS.$(bld_trg)) \
|
---|
2392 | $(SDKS.$(bld_type)) \
|
---|
2393 | $(SDKS),\
|
---|
2394 | $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
|
---|
2395 | $(SDK_$(sdk)_LIBS.$(bld_trg).$(bld_trg_arch))\
|
---|
2396 | $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
|
---|
2397 | $(SDK_$(sdk)_LIBS.$(bld_trg))\
|
---|
2398 | $(SDK_$(sdk)_LIBS.$(bld_type))\
|
---|
2399 | $(SDK_$(sdk)_LIBS))\
|
---|
2400 | $(TOOL_$(tool)_LIBS.$(bld_trg_cpu))\
|
---|
2401 | $(TOOL_$(tool)_LIBS.$(bld_trg).$(bld_trg_arch))\
|
---|
2402 | $(TOOL_$(tool)_LIBS.$(bld_trg_arch))\
|
---|
2403 | $(TOOL_$(tool)_LIBS.$(bld_trg))\
|
---|
2404 | $(TOOL_$(tool)_LIBS.$(bld_type))\
|
---|
2405 | $(TOOL_$(tool)_LIBS)
|
---|
2406 | libpath :=\
|
---|
2407 | $($(target)_LIBPATH.$(bld_trg_cpu))\
|
---|
2408 | $($(target)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
|
---|
2409 | $($(target)_LIBPATH.$(bld_trg_arch))\
|
---|
2410 | $($(target)_LIBPATH.$(bld_trg))\
|
---|
2411 | $($(target)_LIBPATH.$(bld_type))\
|
---|
2412 | $($(target)_LIBPATH)\
|
---|
2413 | $(foreach sdk, $($(target)_SDKS.$(bld_trg).$(bld_trg_arch)) \
|
---|
2414 | $($(target)_SDKS.$(bld_trg_arch)) \
|
---|
2415 | $($(target)_SDKS.$(bld_trg)) \
|
---|
2416 | $($(target)_SDKS.$(bld_type)) \
|
---|
2417 | $($(target)_SDKS),\
|
---|
2418 | $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
|
---|
2419 | $(SDK_$(sdk)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
|
---|
2420 | $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
|
---|
2421 | $(SDK_$(sdk)_LIBPATH.$(bld_trg))\
|
---|
2422 | $(SDK_$(sdk)_LIBPATH.$(bld_type))\
|
---|
2423 | $(SDK_$(sdk)_LIBPATH))\
|
---|
2424 | $(LIBPATH.$(bld_trg_cpu))\
|
---|
2425 | $(LIBPATH.$(bld_trg).$(bld_trg_arch))\
|
---|
2426 | $(LIBPATH.$(bld_trg_arch))\
|
---|
2427 | $(LIBPATH.$(bld_trg))\
|
---|
2428 | $(LIBPATH.$(bld_type))\
|
---|
2429 | $(LIBPATH)\
|
---|
2430 | $(foreach sdk, $(SDKS.$(bld_trg).$(bld_trg_arch)) \
|
---|
2431 | $(SDKS.$(bld_trg_arch)) \
|
---|
2432 | $(SDKS.$(bld_trg)) \
|
---|
2433 | $(SDKS.$(bld_type)) \
|
---|
2434 | $(SDKS),\
|
---|
2435 | $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
|
---|
2436 | $(SDK_$(sdk)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
|
---|
2437 | $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
|
---|
2438 | $(SDK_$(sdk)_LIBPATH.$(bld_trg))\
|
---|
2439 | $(SDK_$(sdk)_LIBPATH.$(bld_type))\
|
---|
2440 | $(SDK_$(sdk)_LIBPATH))\
|
---|
2441 | $(TOOL_$(tool)_LIBPATH.$(bld_trg_cpu))\
|
---|
2442 | $(TOOL_$(tool)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
|
---|
2443 | $(TOOL_$(tool)_LIBPATH.$(bld_trg_arch))\
|
---|
2444 | $(TOOL_$(tool)_LIBPATH.$(bld_trg))\
|
---|
2445 | $(TOOL_$(tool)_LIBPATH.$(bld_type))\
|
---|
2446 | $(TOOL_$(tool)_LIBPATH)
|
---|
2447 | dirdep := $(call DIRDEP,$(dir $(out)))
|
---|
2448 | deps := $($(target)_DEPS)
|
---|
2449 | orderdeps := $($(target)_ORDERDEPS)
|
---|
2450 |
|
---|
2451 | # Adjust paths if we got a default path.
|
---|
2452 | ifneq ($(defpath),)
|
---|
2453 | libpath := $(abspathex $(libpath),$(defpath))
|
---|
2454 | $(target)_OBJS_ := $(abspathex $($(target)_OBJS_),$(defpath))
|
---|
2455 | deps := $(abspathex $(deps),$(defpath))
|
---|
2456 | orderdeps := $(abspathex $(orderdeps),$(defpath))
|
---|
2457 | othersrc := $(abspathex $(othersrc),$(defpath))
|
---|
2458 | # libs are not subject to this because of the the -l<lib> stuff. Use $(<target>_PATH)/lib if relative to current dir!
|
---|
2459 | endif
|
---|
2460 |
|
---|
2461 | # Custom pre-link actions.
|
---|
2462 | ifdef $(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)
|
---|
2463 | pre_cmds := $($(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type))
|
---|
2464 | else ifdef $(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch)
|
---|
2465 | pre_cmds := $($(target)_PRE_CMDS.$(bld_trg).$(bld_trg_arch))
|
---|
2466 | else ifdef $(target)_PRE_CMDS.$(bld_trg).$(bld_type)
|
---|
2467 | pre_cmds := $($(target)_PRE_CMDS.$(bld_trg).$(bld_type))
|
---|
2468 | else ifdef $(target)_PRE_CMDS.$(bld_trg_arch)
|
---|
2469 | pre_cmds := $($(target)_PRE_CMDS.$(bld_trg_arch))
|
---|
2470 | else ifdef $(target)_PRE_CMDS.$(bld_trg)
|
---|
2471 | pre_cmds := $($(target)_PRE_CMDS.$(bld_trg))
|
---|
2472 | else ifdef $(target)_PRE_CMDS.$(bld_type)
|
---|
2473 | pre_cmds := $($(target)_PRE_CMDS.$(bld_type))
|
---|
2474 | else ifdef $(target)_PRE_CMDS
|
---|
2475 | pre_cmds := $($(target)_PRE_CMDS)
|
---|
2476 | else ifdef PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)
|
---|
2477 | pre_cmds := $(PRE_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type))
|
---|
2478 | else ifdef PRE_CMDS.$(bld_trg).$(bld_trg_arch)
|
---|
2479 | pre_cmds := $(PRE_CMDS.$(bld_trg).$(bld_trg_arch))
|
---|
2480 | else ifdef PRE_CMDS.$(bld_trg).$(bld_type)
|
---|
2481 | pre_cmds := $(PRE_CMDS.$(bld_trg).$(bld_type))
|
---|
2482 | else ifdef PRE_CMDS.$(bld_trg_arch)
|
---|
2483 | pre_cmds := $(PRE_CMDS.$(bld_trg_arch))
|
---|
2484 | else ifdef PRE_CMDS.$(bld_trg)
|
---|
2485 | pre_cmds := $(PRE_CMDS.$(bld_trg))
|
---|
2486 | else ifdef PRE_CMDS.$(bld_type)
|
---|
2487 | pre_cmds := $(PRE_CMDS.$(bld_type))
|
---|
2488 | else
|
---|
2489 | pre_cmds := $(PRE_CMDS)
|
---|
2490 | endif
|
---|
2491 |
|
---|
2492 | # Custom post-link actions.
|
---|
2493 | ifdef $(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)
|
---|
2494 | post_cmds := $($(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type))
|
---|
2495 | else ifdef $(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch)
|
---|
2496 | post_cmds := $($(target)_POST_CMDS.$(bld_trg).$(bld_trg_arch))
|
---|
2497 | else ifdef $(target)_POST_CMDS.$(bld_trg).$(bld_type)
|
---|
2498 | post_cmds := $($(target)_POST_CMDS.$(bld_trg).$(bld_type))
|
---|
2499 | else ifdef $(target)_POST_CMDS.$(bld_trg_arch)
|
---|
2500 | post_cmds := $($(target)_POST_CMDS.$(bld_trg_arch))
|
---|
2501 | else ifdef $(target)_POST_CMDS.$(bld_trg)
|
---|
2502 | post_cmds := $($(target)_POST_CMDS.$(bld_trg))
|
---|
2503 | else ifdef $(target)_POST_CMDS.$(bld_type)
|
---|
2504 | post_cmds := $($(target)_POST_CMDS.$(bld_type))
|
---|
2505 | else ifdef $(target)_POST_CMDS
|
---|
2506 | post_cmds := $($(target)_POST_CMDS)
|
---|
2507 | else ifdef POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type)
|
---|
2508 | post_cmds := $(POST_CMDS.$(bld_trg).$(bld_trg_arch).$(bld_type))
|
---|
2509 | else ifdef POST_CMDS.$(bld_trg).$(bld_trg_arch)
|
---|
2510 | post_cmds := $(POST_CMDS.$(bld_trg).$(bld_trg_arch))
|
---|
2511 | else ifdef POST_CMDS.$(bld_trg).$(bld_type)
|
---|
2512 | post_cmds := $(POST_CMDS.$(bld_trg).$(bld_type))
|
---|
2513 | else ifdef POST_CMDS.$(bld_trg_arch)
|
---|
2514 | post_cmds := $(POST_CMDS.$(bld_trg_arch))
|
---|
2515 | else ifdef POST_CMDS.$(bld_trg)
|
---|
2516 | post_cmds := $(POST_CMDS.$(bld_trg))
|
---|
2517 | else ifdef POST_CMDS.$(bld_type)
|
---|
2518 | post_cmds := $(POST_CMDS.$(bld_type))
|
---|
2519 | else
|
---|
2520 | post_cmds := $(POST_CMDS)
|
---|
2521 | endif
|
---|
2522 |
|
---|
2523 | # eliminate this guy?
|
---|
2524 | objs = $($(target)_OBJS_)
|
---|
2525 |
|
---|
2526 | # installation targets
|
---|
2527 | ifndef $(target)_NOINST
|
---|
2528 | INSTARGET_$(target) := $(patsubst %/,%/$(notdir $(out)), \
|
---|
2529 | $(if $($(target)_INST), $(addprefix $(PATH_INS)/,$($(target)_INST)), $(definst)/))
|
---|
2530 | ifdef KBUILD_DO_AUTO_INSTALL
|
---|
2531 | $(typevar) += $(INSTARGET_$(target))
|
---|
2532 | else
|
---|
2533 | $(typevar) += $(out)
|
---|
2534 | endif
|
---|
2535 | # generate the install rule
|
---|
2536 | $(eval $(def_link_install_rule))
|
---|
2537 |
|
---|
2538 | else # NOINST
|
---|
2539 | INSTARGET_$(target) :=
|
---|
2540 | $(typevar) += $(out)
|
---|
2541 | endif # NOINST
|
---|
2542 |
|
---|
2543 | # dependency file
|
---|
2544 | dep := $(outbase)$(SUFF_DEP)
|
---|
2545 | ifndef NO_LINK_CMDS_DEPS
|
---|
2546 | _DEPFILES_INCLUDED += $(dep)
|
---|
2547 | $(eval includedep $(dep))
|
---|
2548 | endif
|
---|
2549 |
|
---|
2550 | # check that the tool is defined.
|
---|
2551 | ifndef TOOL_$(tool)_$(tool_do)_CMDS
|
---|
2552 | $(warning kBuild: tools: \
|
---|
2553 | 1 $($(target)_$(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
2554 | 2 $($(target)_$(source)TOOL.$(bld_trg)) \
|
---|
2555 | 3 $($(target)_$(source)TOOL) \
|
---|
2556 | 4 $($(target)_TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
2557 | 5 $($(target)_TOOL.$(bld_trg)) \
|
---|
2558 | 6 $($(target)_TOOL) \
|
---|
2559 | 7 $($(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
2560 | 8 $($(source)TOOL.$(bld_trg)) \
|
---|
2561 | 9 $($(source)TOOL) \
|
---|
2562 | 10 $(TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
2563 | 11 $(TOOL.$(bld_trg)) \
|
---|
2564 | 12 $(TOOL) )
|
---|
2565 | $(error kBuild: TOOL_$(tool)_$(tool_do)_CMDS isn't defined! target=$(target) )
|
---|
2566 | endif
|
---|
2567 |
|
---|
2568 | # call the tool
|
---|
2569 | $(target)_CMDS_ := $(TOOL_$(tool)_$(tool_do)_CMDS)
|
---|
2570 | ifneq ($(pre_cmds),)
|
---|
2571 | $(target)_CMDS_ := $(TAB)$(pre_cmds)$(NL)$(TAB)$($(target)_CMDS_)
|
---|
2572 | endif
|
---|
2573 | ifneq ($(post_cmds),)
|
---|
2574 | $(target)_CMDS_ := $($(target)_CMDS_)$(NL)$(TAB)$(post_cmds)
|
---|
2575 | endif
|
---|
2576 | $(target)_OUTPUT_ := $(TOOL_$(tool)_$(tool_do)_OUTPUT)
|
---|
2577 | $(target)_OUTPUT_MAYBE_ := $(TOOL_$(tool)_$(tool_do)_OUTPUT_MAYBE)
|
---|
2578 | $(target)_DEPEND_ := $(TOOL_$(tool)_$(tool_do)_DEPEND) $(deps) $($(target)_OBJS_)
|
---|
2579 | $(target)_DEPORD_ := $(TOOL_$(tool)_$(tool_do)_DEPORD) $(dirdep) $(orderdeps)
|
---|
2580 |
|
---|
2581 | # generate the link rule.
|
---|
2582 | $(eval $(def_link_rule))
|
---|
2583 |
|
---|
2584 |
|
---|
2585 | # Update globals.
|
---|
2586 | _OBJS += $($(target)_OBJS_)
|
---|
2587 | _OUT_FILES += $($(target)_OUTPUT_) $(out)
|
---|
2588 | _CLEAN_FILES += $($(target)_CLEAN) $($(target)_CLEAN.$(bld_trg)) $($(target)_CLEAN.$(bld_trg).$(bld_trg_arch)) $($(target)_CLEAN.$(bld_trg_arch)) $($(target)_CLEAN.$(bld_trg_cpu)) $($(target)_CLEAN.$(bld_type))
|
---|
2589 | _DIRS += $($(target)_BLDDIRS) $($(target)_BLDDIRS.$(bld_trg)) $($(target)_BLDDIRS.$(bld_trg).$(bld_trg_arch)) $($(target)_BLDDIRS.$(bld_trg_arch)) $($(target)_BLDDIRS.$(bld_trg_cpu)) $($(target)_BLDDIRS.$(bld_type))
|
---|
2590 | _INSTALLS_FILES += $(INSTARGET_$(target))
|
---|
2591 |
|
---|
2592 | endef
|
---|
2593 |
|
---|
2594 |
|
---|
2595 | #
|
---|
2596 | # BLDPROGS
|
---|
2597 | #
|
---|
2598 |
|
---|
2599 | ## Build program (one).
|
---|
2600 | # @param $(target) Normalized target (program) name.
|
---|
2601 | define def_bldprog
|
---|
2602 |
|
---|
2603 | # set NOINST if not forced installation.
|
---|
2604 | ifndef $(target)_INST
|
---|
2605 | $(target)_NOINST := 1
|
---|
2606 | endif
|
---|
2607 |
|
---|
2608 | # do the usual stuff.
|
---|
2609 | $(eval $(value def_link_common))
|
---|
2610 |
|
---|
2611 | endef
|
---|
2612 |
|
---|
2613 | # Process build programs.
|
---|
2614 | EXT := EXE
|
---|
2615 | EXTPRE := HOST
|
---|
2616 | tool_do := LINK_PROGRAM
|
---|
2617 | definst := $(PATH_BIN)
|
---|
2618 | typevar := _BLDPROGS
|
---|
2619 | mode := 0755
|
---|
2620 | bld_trg_base_var := PLATFORM
|
---|
2621 | $(foreach target, $(BLDPROGS) $(BLDPROGS.$(BUILD_PLATFORM)) $(BLDPROGS.$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)), $(eval $(value def_bldprog)))
|
---|
2622 |
|
---|
2623 | ifdef KBUILD_PROFILE_SELF
|
---|
2624 | _KBUILD_TS_NOW := $(nanots )
|
---|
2625 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done build program targets)
|
---|
2626 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
2627 | endif
|
---|
2628 |
|
---|
2629 |
|
---|
2630 | #
|
---|
2631 | # DLLS
|
---|
2632 | #
|
---|
2633 |
|
---|
2634 | # Process dlls
|
---|
2635 | EXT := DLL
|
---|
2636 | EXTPRE :=
|
---|
2637 | tool_do := LINK_DLL
|
---|
2638 | definst := $(PATH_DLL)
|
---|
2639 | typevar := _DLLS
|
---|
2640 | mode := 0644
|
---|
2641 | bld_trg_base_var := TARGET
|
---|
2642 | $(foreach target, $(DLLS) $(DLLS.$(BUILD_TARGET)) $(DLLS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), $(eval $(value def_link_common)))
|
---|
2643 |
|
---|
2644 | ifdef KBUILD_PROFILE_SELF
|
---|
2645 | _KBUILD_TS_NOW := $(nanots )
|
---|
2646 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done dll targets)
|
---|
2647 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
2648 | endif
|
---|
2649 |
|
---|
2650 |
|
---|
2651 | #
|
---|
2652 | # IMPORT LIBRARIES
|
---|
2653 | #
|
---|
2654 | # - On OS/2 and windows these are libraries.
|
---|
2655 | # - On other platforms they are fake DLLs.
|
---|
2656 | #
|
---|
2657 | EXTPRE :=
|
---|
2658 | typevar := _IMPORT_LIBS
|
---|
2659 | mode := 0644
|
---|
2660 | bld_trg_base_var := TARGET
|
---|
2661 | ifeq ($(filter-out nt os2 win win64 win32,$(BUILD_TARGET)),)
|
---|
2662 | EXT := LIB
|
---|
2663 | tool_do := LINK_LIBRARY
|
---|
2664 | definst := $(PATH_LIB)
|
---|
2665 | $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)) $(IMPORT_LIBS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), $(eval $(value def_lib)))
|
---|
2666 | else
|
---|
2667 | EXT := DLL
|
---|
2668 | tool_do := LINK_DLL
|
---|
2669 | definst := $(PATH_DLL)
|
---|
2670 | $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)) $(IMPORT_LIBS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), $(eval $(value def_link_common)))
|
---|
2671 | endif
|
---|
2672 |
|
---|
2673 | ifdef KBUILD_PROFILE_SELF
|
---|
2674 | _KBUILD_TS_NOW := $(nanots )
|
---|
2675 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done import library targets)
|
---|
2676 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
2677 | endif
|
---|
2678 |
|
---|
2679 |
|
---|
2680 | #
|
---|
2681 | # PROGRAMS
|
---|
2682 | #
|
---|
2683 |
|
---|
2684 | # Process programs
|
---|
2685 | EXT := EXE
|
---|
2686 | EXTPRE :=
|
---|
2687 | tool_do := LINK_PROGRAM
|
---|
2688 | definst := $(PATH_BIN)
|
---|
2689 | typevar := _PROGRAMS
|
---|
2690 | mode := 0755
|
---|
2691 | bld_trg_base_var := TARGET
|
---|
2692 | $(foreach target, $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)) $(PROGRAMS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), $(eval $(value def_link_common)))
|
---|
2693 |
|
---|
2694 | ifdef KBUILD_PROFILE_SELF
|
---|
2695 | _KBUILD_TS_NOW := $(nanots )
|
---|
2696 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done program targets)
|
---|
2697 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
2698 | endif
|
---|
2699 |
|
---|
2700 |
|
---|
2701 | #
|
---|
2702 | # SYSMODS
|
---|
2703 | #
|
---|
2704 |
|
---|
2705 | # Process sysmods
|
---|
2706 | EXT := SYS
|
---|
2707 | EXTPRE :=
|
---|
2708 | tool_do := LINK_SYSMOD
|
---|
2709 | definst := $(PATH_SYS)
|
---|
2710 | typevar := _SYSMODS
|
---|
2711 | mode := 0644
|
---|
2712 | bld_trg_base_var := TARGET
|
---|
2713 | $(foreach target, $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)) $(SYSMODS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), $(eval $(value def_link_common)))
|
---|
2714 |
|
---|
2715 | ifdef KBUILD_PROFILE_SELF
|
---|
2716 | _KBUILD_TS_NOW := $(nanots )
|
---|
2717 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done sysmod targets)
|
---|
2718 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
2719 | endif
|
---|
2720 |
|
---|
2721 |
|
---|
2722 | #
|
---|
2723 | # OTHERS
|
---|
2724 | #
|
---|
2725 | _OTHERS = $(OTHERS) $(OTHERS.$(BUILD_TARGET)) $(OTHERS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH))
|
---|
2726 |
|
---|
2727 |
|
---|
2728 | #
|
---|
2729 | # INSTALLS
|
---|
2730 | #
|
---|
2731 |
|
---|
2732 | ## generate the install rule
|
---|
2733 | define def_install_src_rule
|
---|
2734 | # the install rule
|
---|
2735 | $(insdst) : $(srcsrc) | $(call DIRDEP,$(dir $(insdst)))
|
---|
2736 | $$(call MSG_INST_FILE,$(srcsrc),$(insdst))
|
---|
2737 | $$(QUIET)$(inscmd)
|
---|
2738 | endef
|
---|
2739 |
|
---|
2740 | ## install one file
|
---|
2741 | define def_install_src
|
---|
2742 |
|
---|
2743 | # deal with '=>' in the source file name.
|
---|
2744 | srcdst := $(subst =>, ,$(src))
|
---|
2745 | srcsrc := $(firstword $(srcdst))
|
---|
2746 | srcdstdir := $(dir $(word 2,$(srcdst)))
|
---|
2747 | srcdst := $(word $(words $(srcdst)),$(srcdst))
|
---|
2748 |
|
---|
2749 | # _INSTFUN
|
---|
2750 | ifdef $(srcsrc)_INSTFUN
|
---|
2751 | instfun := $(srcsrc)_INSTFUN
|
---|
2752 | else ifdef $(target)_INSTFUN
|
---|
2753 | instfun := $(target)_INSTFUN
|
---|
2754 | else
|
---|
2755 | instfun := _INSTALL_FILE
|
---|
2756 | endif
|
---|
2757 |
|
---|
2758 | # _INST
|
---|
2759 | ifdef $(srcsrc)_INST
|
---|
2760 | inst := $(patsubst %/,%,$($(srcsrc)_INST))/$(dir $(srcdstdir))
|
---|
2761 | else ifdef $(target)_INST
|
---|
2762 | inst := $(patsubst %/,%,$($(target)_INST))/$(dir $(srcdstdir))
|
---|
2763 | else
|
---|
2764 | inst := $(dir $(srcdstdir))
|
---|
2765 | endif
|
---|
2766 |
|
---|
2767 | # calc target
|
---|
2768 | insdst := $(call $(instfun),$(srcdst),$(target),$(inst),$(PATH_INS))
|
---|
2769 | #$(warning instfun=$(instfun) srcdst=$(srcdst) target=$(target) inst=$(inst) => insdst=$(insdst))
|
---|
2770 |
|
---|
2771 | # mode, uid and gid
|
---|
2772 | mode := $(firstword \
|
---|
2773 | $($(target)_$(srcsrc)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
2774 | $($(target)_$(srcsrc)_MODE.$(bld_trg)) \
|
---|
2775 | $($(target)_$(srcsrc)_MODE) \
|
---|
2776 | $($(target)_$(srcdst)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
2777 | $($(target)_$(srcdst)_MODE.$(bld_trg)) \
|
---|
2778 | $($(target)_$(srcdst)_MODE) \
|
---|
2779 | $($(srcsrc)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
2780 | $($(srcsrc)_MODE.$(bld_trg)) \
|
---|
2781 | $($(srcsrc)_MODE) \
|
---|
2782 | $($(srcdst)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
2783 | $($(srcdst)_MODE.$(bld_trg)) \
|
---|
2784 | $($(srcdst)_MODE) \
|
---|
2785 | $($(target)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
2786 | $($(target)_MODE.$(bld_trg)) \
|
---|
2787 | $($(target)_MODE))
|
---|
2788 | uid := $(firstword \
|
---|
2789 | $($(target)_$(srcsrc)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
2790 | $($(target)_$(srcsrc)_UID.$(bld_trg)) \
|
---|
2791 | $($(target)_$(srcsrc)_UID) \
|
---|
2792 | $($(target)_$(srcdst)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
2793 | $($(target)_$(srcdst)_UID.$(bld_trg)) \
|
---|
2794 | $($(target)_$(srcdst)_UID) \
|
---|
2795 | $($(srcsrc)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
2796 | $($(srcsrc)_UID.$(bld_trg)) \
|
---|
2797 | $($(srcsrc)_UID) \
|
---|
2798 | $($(srcdst)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
2799 | $($(srcdst)_UID.$(bld_trg)) \
|
---|
2800 | $($(srcdst)_UID) \
|
---|
2801 | $($(target)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
2802 | $($(target)_UID.$(bld_trg)) \
|
---|
2803 | $($(target)_UID))
|
---|
2804 | gid := $(firstword \
|
---|
2805 | $($(target)_$(srcsrc)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
2806 | $($(target)_$(srcsrc)_GID.$(bld_trg)) \
|
---|
2807 | $($(target)_$(srcsrc)_GID) \
|
---|
2808 | $($(target)_$(srcdst)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
2809 | $($(target)_$(srcdst)_GID.$(bld_trg)) \
|
---|
2810 | $($(target)_$(srcdst)_GID) \
|
---|
2811 | $($(srcsrc)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
2812 | $($(srcsrc)_GID.$(bld_trg)) \
|
---|
2813 | $($(srcsrc)_GID) \
|
---|
2814 | $($(srcdst)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
2815 | $($(srcdst)_GID.$(bld_trg)) \
|
---|
2816 | $($(srcdst)_GID) \
|
---|
2817 | $($(target)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
2818 | $($(target)_GID.$(bld_trg)) \
|
---|
2819 | $($(target)_GID))
|
---|
2820 | flags := \
|
---|
2821 | $($(target)_IFFLAGS) \
|
---|
2822 | $($(target)_IFFLAGS.$(bld_trg)) \
|
---|
2823 | $($(target)_IFFLAGS.$(bld_trg).$(bld_trg_arch)) \
|
---|
2824 | $($(srcdst)_IFFLAGS) \
|
---|
2825 | $($(srcdst)_IFFLAGS.$(bld_trg)) \
|
---|
2826 | $($(srcdst)_IFFLAGS.$(bld_trg).$(bld_trg_arch)) \
|
---|
2827 | $($(srcsrc)_IFFLAGS) \
|
---|
2828 | $($(srcsrc)_IFFLAGS.$(bld_trg)) \
|
---|
2829 | $($(srcsrc)_IFFLAGS.$(bld_trg).$(bld_trg_arch)) \
|
---|
2830 | $($(target)_$(srcdst)_IFFLAGS) \
|
---|
2831 | $($(target)_$(srcdst)_IFFLAGS.$(bld_trg)) \
|
---|
2832 | $($(target)_$(srcdst)_IFFLAGS.$(bld_trg).$(bld_trg_arch)) \
|
---|
2833 | $($(target)_$(srcsrc)_IFFLAGS) \
|
---|
2834 | $($(target)_$(srcsrc)_IFFLAGS.$(bld_trg)) \
|
---|
2835 | $($(target)_$(srcsrc)_IFFLAGS.$(bld_trg).$(bld_trg_arch))
|
---|
2836 |
|
---|
2837 |
|
---|
2838 | # Adjust the source if we got a default PATH. (This must be done this late!)
|
---|
2839 | ifdef $(target)_PATH
|
---|
2840 | srcsrc := $(abspathex $(srcsrc),$($(target)_PATH))
|
---|
2841 | endif
|
---|
2842 |
|
---|
2843 | # create the command
|
---|
2844 | ifdef $(srcsrc)_INSTALLER
|
---|
2845 | inscmd := $(call $(srcsrc)_INSTALLER,$(srcsrc),$(insdst),$(target),$(flags))
|
---|
2846 | else ifdef $(target)_INSTALLER
|
---|
2847 | inscmd := $(call $(target)_INSTALLER,$(srcsrc),$(insdst),$(target),$(flags))
|
---|
2848 | else
|
---|
2849 | inscmd := $$(INSTALL)\
|
---|
2850 | $(if $(uid),-o $(uid))\
|
---|
2851 | $(if $(gid),-g $(gid))\
|
---|
2852 | $(if $(mode),-m $(mode))\
|
---|
2853 | $(flags)\
|
---|
2854 | $(srcsrc) $(insdst)
|
---|
2855 | endif
|
---|
2856 |
|
---|
2857 | # generate the rule (need double evaluation here)
|
---|
2858 | $(eval $(def_install_src_rule))
|
---|
2859 |
|
---|
2860 | INSTARGET_$(target) += $(insdst)
|
---|
2861 | endef
|
---|
2862 |
|
---|
2863 |
|
---|
2864 | ## generate the symlink rule
|
---|
2865 | define def_install_symlink_rule
|
---|
2866 | # the install rule
|
---|
2867 | $(insdst) : | $(call DIRDEP,$(dir $(insdst)))
|
---|
2868 | $$(call MSG_INST_SYM,$(insdst),$(symdst))
|
---|
2869 | $$(QUIET)$$(RM) -f $$@
|
---|
2870 | $$(QUIET)$$(LN_SYMLINK) $(symdst) $(insdst)
|
---|
2871 | endef
|
---|
2872 |
|
---|
2873 | ## create one symlink
|
---|
2874 | define def_install_symlink
|
---|
2875 |
|
---|
2876 | # deal with '=>' in the source file name.
|
---|
2877 | symdst := $(subst =>, ,$(src))
|
---|
2878 | symlnk := $(firstword $(symdst))
|
---|
2879 | symdst := $(word $(words $(symdst)),$(symdst))
|
---|
2880 |
|
---|
2881 | # _INSTFUN
|
---|
2882 | ifdef $(symlnk)_INSTFUN
|
---|
2883 | instfun := $(symlnk)_INSTFUN
|
---|
2884 | else ifdef $(target)_INSTFUN
|
---|
2885 | instfun := $(target)_INSTFUN
|
---|
2886 | else
|
---|
2887 | instfun := _INSTALL_FILE
|
---|
2888 | endif
|
---|
2889 |
|
---|
2890 | # _INST
|
---|
2891 | ifdef $(symlnk)_INST
|
---|
2892 | inst := $(patsubst %/,%,$($(symlnk)_INST))/$(dir $(symlnk))
|
---|
2893 | else ifdef $(target)_INST
|
---|
2894 | inst := $(patsubst %/,%,$($(target)_INST))/$(dir $(symlnk))
|
---|
2895 | else
|
---|
2896 | inst := $(dir $(symlnk))
|
---|
2897 | endif
|
---|
2898 |
|
---|
2899 | # calc target
|
---|
2900 | insdst := $(call $(instfun),$(symlnk),$(target),$(inst),$(PATH_INS))
|
---|
2901 | #$(warning symlnk=$(symlnk) symdst=$(symdst) insdst=$(insdst) instfun=$(instfun) inst='$(inst)')
|
---|
2902 |
|
---|
2903 | # generate the rule (need double evaluation here)
|
---|
2904 | $(eval $(def_install_symlink_rule))
|
---|
2905 |
|
---|
2906 | INSTARGET_$(target) += $(insdst)
|
---|
2907 | endef
|
---|
2908 |
|
---|
2909 |
|
---|
2910 | ## generate the install rule
|
---|
2911 | define def_install_directory_rule
|
---|
2912 | # the install rule
|
---|
2913 | $(insdst):
|
---|
2914 | $$(call MSG_INST_DIR,$(insdst))
|
---|
2915 | $$(QUIET)$$(INSTALL) -d \
|
---|
2916 | $(if $(uid),-o $(uid))\
|
---|
2917 | $(if $(gid),-g $(gid))\
|
---|
2918 | $(if $(mode),-m $(mode))\
|
---|
2919 | $(flags)\
|
---|
2920 | $(insdst)
|
---|
2921 |
|
---|
2922 | .NOTPARALLEL: $(insdst)
|
---|
2923 | endef
|
---|
2924 |
|
---|
2925 |
|
---|
2926 | ## create one directory
|
---|
2927 | define def_install_directory
|
---|
2928 |
|
---|
2929 | # _INST
|
---|
2930 | ifdef $(directory)_INST
|
---|
2931 | inst := $(PATH_INS)/$(patsubst %/,%,$($(directory)_INST))
|
---|
2932 | else ifdef $(target)_INST
|
---|
2933 | inst := $(PATH_INS)/$(patsubst %/,%,$($(target)_INST))
|
---|
2934 | else
|
---|
2935 | inst := $(PATH_INS)
|
---|
2936 | endif
|
---|
2937 |
|
---|
2938 | mode := $(firstword \
|
---|
2939 | $($(target)_$(directory)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
2940 | $($(target)_$(directory)_MODE.$(bld_trg)) \
|
---|
2941 | $($(target)_$(directory)_MODE) \
|
---|
2942 | $($(directory)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
2943 | $($(directory)_MODE.$(bld_trg)) \
|
---|
2944 | $($(directory)_MODE) \
|
---|
2945 | $($(target)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
2946 | $($(target)_MODE.$(bld_trg)) \
|
---|
2947 | $($(target)_MODE))
|
---|
2948 | uid := $(firstword \
|
---|
2949 | $($(target)_$(directory)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
2950 | $($(target)_$(directory)_UID.$(bld_trg)) \
|
---|
2951 | $($(target)_$(directory)_UID) \
|
---|
2952 | $($(directory)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
2953 | $($(directory)_UID.$(bld_trg)) \
|
---|
2954 | $($(directory)_UID) \
|
---|
2955 | $($(target)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
2956 | $($(target)_UID.$(bld_trg)) \
|
---|
2957 | $($(target)_UID))
|
---|
2958 | gid := $(firstword \
|
---|
2959 | $($(target)_$(directory)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
2960 | $($(target)_$(directory)_GID.$(bld_trg)) \
|
---|
2961 | $($(target)_$(directory)_GID) \
|
---|
2962 | $($(directory)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
2963 | $($(directory)_GID.$(bld_trg)) \
|
---|
2964 | $($(directory)_GID) \
|
---|
2965 | $($(target)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
2966 | $($(target)_GID.$(bld_trg)) \
|
---|
2967 | $($(target)_GID))
|
---|
2968 | flags := \
|
---|
2969 | $($(target)_IDFLAGS)\
|
---|
2970 | $($(target)_IDFLAGS.$(bld_trg)) \
|
---|
2971 | $($(target)_IDFLAGS.$(bld_trg).$(bld_trg_arch)) \
|
---|
2972 | $($(directory)_IDFLAGS) \
|
---|
2973 | $($(directory)_IDFLAGS.$(bld_trg)) \
|
---|
2974 | $($(directory)_IDFLAGS.$(bld_trg).$(bld_trg_arch)) \
|
---|
2975 | $($(target)_$(directory)_IDFLAGS) \
|
---|
2976 | $($(target)_$(directory)_IDFLAGS.$(bld_trg)) \
|
---|
2977 | $($(target)_$(directory)_IDFLAGS.$(bld_trg).$(bld_trg_arch))
|
---|
2978 |
|
---|
2979 | insdst := $(inst)/$(directory)/
|
---|
2980 | #$(warning directory=$(directory) inst=$(inst) insdst=$(insdst) mode=$(mode) gid=$(gid) uid=$(uid))
|
---|
2981 |
|
---|
2982 | # generate the rule (need double evaluation here)
|
---|
2983 | $(eval $(def_install_directory_rule))
|
---|
2984 |
|
---|
2985 | INSTARGET_DIRS_$(target) += $(insdst)
|
---|
2986 | endef
|
---|
2987 |
|
---|
2988 |
|
---|
2989 | ## process one install target.
|
---|
2990 | define def_install
|
---|
2991 | # the basics.
|
---|
2992 | bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
|
---|
2993 | bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))
|
---|
2994 | bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_TARGET_ARCH))
|
---|
2995 | bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_TARGET_CPU))
|
---|
2996 |
|
---|
2997 | INSTARGET_$(target) := $($(target)_GOALS)
|
---|
2998 | INSTARGET_DIRS_$(target) :=
|
---|
2999 |
|
---|
3000 | $(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)), \
|
---|
3001 | $(eval $(value def_install_directory)))
|
---|
3002 |
|
---|
3003 | $(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)), \
|
---|
3004 | $(eval $(value def_install_src)))
|
---|
3005 |
|
---|
3006 | $(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)), \
|
---|
3007 | $(eval $(value def_install_symlink)))
|
---|
3008 |
|
---|
3009 | # the collection target
|
---|
3010 | TARGET_$(target) := $(PATH_TARGET)/$(target).ins
|
---|
3011 | $(TARGET_$(target)): $(INSTARGET_$(target)) | $(INSTARGET_DIRS_$(target)) $(call DIRDEP,$(PATH_TARGET))
|
---|
3012 | @$(QUIET2)$(APPEND) $@
|
---|
3013 |
|
---|
3014 | $(target): $(TARGET_$(target))
|
---|
3015 |
|
---|
3016 | _INSTALLS += $(TARGET_$(target))
|
---|
3017 | _INSTALLS_FILES += $(INSTARGET_$(target))
|
---|
3018 | _INSTALLS_DIRS += $(INSTARGET_DIRS_$(target))
|
---|
3019 | _CLEAN_FILES += $($(target)_CLEAN) $($(target)_CLEAN.$(bld_trg)) $($(target)_CLEAN.$(bld_trg).$(bld_trg_arch)) $($(target)_CLEAN.$(bld_trg_arch)) $($(target)_CLEAN.$(bld_trg_cpu)) $($(target)_CLEAN.$(bld_type))
|
---|
3020 | _DIRS += $($(target)_BLDDIRS) $($(target)_BLDDIRS.$(bld_trg)) $($(target)_BLDDIRS.$(bld_trg).$(bld_trg_arch)) $($(target)_BLDDIRS.$(bld_trg_arch)) $($(target)_BLDDIRS.$(bld_trg_cpu)) $($(target)_BLDDIRS.$(bld_type))
|
---|
3021 | endef
|
---|
3022 |
|
---|
3023 | ## process all install targets
|
---|
3024 | $(foreach target, $(INSTALLS) $(INSTALLS.$(BUILD_TARGET)) $(INSTALLS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
|
---|
3025 | $(eval $(value def_install)))
|
---|
3026 |
|
---|
3027 | ifdef KBUILD_PROFILE_SELF
|
---|
3028 | _KBUILD_TS_NOW := $(nanots )
|
---|
3029 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done install targets)
|
---|
3030 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
3031 | endif
|
---|
3032 |
|
---|
3033 |
|
---|
3034 | #
|
---|
3035 | # PACKING
|
---|
3036 | #
|
---|
3037 | _PACKING += $(PACKING) $(PACKING.$(BUILD_TARGET)) $(PACKING.$(BUILD_TARGET).$(BUILD_TARGET_ARCH))
|
---|
3038 |
|
---|
3039 |
|
---|
3040 | #
|
---|
3041 | # DOCS
|
---|
3042 | #
|
---|
3043 |
|
---|
3044 |
|
---|
3045 | #
|
---|
3046 | # DIRECTORIES
|
---|
3047 | #
|
---|
3048 | _DIR_ALL := $(sort $(addsuffix /,$(patsubst %/,%,$(_DIRS))) $(dir $(_OUT_FILES) $(_OBJS) $(_INSTALLS_FILES)))
|
---|
3049 | $(foreach directory,$(_INSTALLS_DIRS), $(eval _DIR_ALL := $(filter-out $(directory),$(_DIR_ALL))))
|
---|
3050 |
|
---|
3051 |
|
---|
3052 | define def_mkdir_rule
|
---|
3053 | $(directory):
|
---|
3054 | $$(call MSG_MKDIR,$$@)
|
---|
3055 | $$(QUIET)$$(MKDIR) -p $$@
|
---|
3056 | endef
|
---|
3057 |
|
---|
3058 | $(foreach directory,$(_DIR_ALL),$(eval $(def_mkdir_rule)))
|
---|
3059 |
|
---|
3060 | ifdef KBUILD_PROFILE_SELF
|
---|
3061 | _KBUILD_TS_NOW := $(nanots )
|
---|
3062 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done directories)
|
---|
3063 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
3064 | endif
|
---|
3065 |
|
---|
3066 |
|
---|
3067 | #
|
---|
3068 | # NOTHING
|
---|
3069 | #
|
---|
3070 | do-nothing:
|
---|
3071 | ifdef KBUILD_PROFILE_SELF
|
---|
3072 | @$(ECHO) 'prof: $(int-sub $(nanots ), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(nanots ), $(_KBUILD_TS_PREV)) - executing $@'
|
---|
3073 | endif
|
---|
3074 | $(call MSG_NOTHING)
|
---|
3075 |
|
---|
3076 |
|
---|
3077 | #
|
---|
3078 | # CLEAN UP
|
---|
3079 | #
|
---|
3080 | do-clean:
|
---|
3081 | $(call MSG_CLEAN)
|
---|
3082 | $(QUIET)$(RM) -f $(_OUT_FILES) $(_OBJS) $(_DEPFILES) $(_DEPFILES_INCLUDED) $(_CLEAN_FILES) $(OTHER_CLEAN)
|
---|
3083 | $(QUIET)$(RMDIR) -p --ignore-fail-on-non-empty --ignore-fail-on-not-exist $(rsort $(dir $(_OUT_FILES) $(_OBJS) $(_DEPFILES) $(_DEPFILES_INCLUDED) $(_CLEAN_FILES) $(OTHER_CLEAN)))
|
---|
3084 |
|
---|
3085 |
|
---|
3086 |
|
---|
3087 | #
|
---|
3088 | # PASSES (including directory and makefile walking)
|
---|
3089 | #
|
---|
3090 |
|
---|
3091 | ## Subdir
|
---|
3092 | # @param $(pass) Lowercase pass name.
|
---|
3093 | # @param $(PASS) Uppercase pass name.
|
---|
3094 | # @param $(subdir) Subdirectory
|
---|
3095 | # @param $(tag) tag to attach to the rule name.
|
---|
3096 | define def_pass_subdir
|
---|
3097 | pass_$(pass)$(tag):: $(dep)
|
---|
3098 | + $$(QUIET)$$(MAKE) -C $(subdir) -f $$(notdir $$(firstword $$(wildcard $$(addprefix $(subdir)/,$$(DEFAULT_MAKEFILE))))) pass_$(pass)
|
---|
3099 | endef
|
---|
3100 |
|
---|
3101 | ## Submakefile
|
---|
3102 | # @param $(pass) Lowercase pass name.
|
---|
3103 | # @param $(PASS) Uppercase pass name.
|
---|
3104 | # @param $(makefile) Makefile.
|
---|
3105 | # @param $(tag) tag to attach to the rule name.
|
---|
3106 | define def_pass_makefile
|
---|
3107 | pass_$(pass)$(tag):: $(dep)
|
---|
3108 | + $$(QUIET)$$(MAKE) -C $(patsubst %/,%,$(dir $(makefile))) -f $(notdir $(makefile)) pass_$(pass)
|
---|
3109 | endef
|
---|
3110 |
|
---|
3111 | ## Execute a pass.
|
---|
3112 | # @param $(pass) Lowercase pass name.
|
---|
3113 | # @param $(PASS) Uppercase pass name.
|
---|
3114 | define def_pass_old
|
---|
3115 | $(eval SUBDIRS_$(PASS) ?= $(SUBDIRS) $(SUBDIRS.$(BUILD_TARGET)) $(SUBDIRS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
|
---|
3116 | $(eval SUBDIRS_AFTER_$(PASS) ?= $(SUBDIRS_AFTER) $(SUBDIRS_AFTER.$(BUILD_TARGET)) $(SUBDIRS_AFTER.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
|
---|
3117 | $(eval MAKEFILES_BEFORE_$(PASS) ?= $(MAKEFILES_BEFORE) $(MAKEFILES_BEFORE.$(BUILD_TARGET)) $(MAKEFILES_BEFORE.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
|
---|
3118 | $(eval MAKEFILES_AFTER_$(PASS) ?= $(MAKEFILES_AFTER) $(MAKEFILES_AFTER.$(BUILD_TARGET)) $(MAKEFILES_AFTER.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
|
---|
3119 |
|
---|
3120 | $(eval tag:=_before)
|
---|
3121 | $(eval dep:=)
|
---|
3122 | $(foreach subdir,$(SUBDIRS_$(PASS)) $(SUBDIRS_$(PASS).$(BUILD_TARGET)) $(SUBDIRS_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir)))
|
---|
3123 | $(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(BUILD_TARGET)) $(MAKEFILES_BEFORE_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)),$(eval $(def_pass_makefile)))
|
---|
3124 |
|
---|
3125 | $(eval tag:=_after)
|
---|
3126 | $(eval dep:=pass_$(pass)_doit)
|
---|
3127 | $(foreach subdir,$(SUBDIRS_AFTER_$(PASS)) $(SUBDIRS_AFTER_$(PASS).$(BUILD_TARGET)) $(SUBDIRS_AFTER_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir)))
|
---|
3128 | $(foreach makefile,$(MAKEFILES_AFTER_$(PASS)) $(MAKEFILES_AFTER_$(PASS).$(BUILD_TARGET)) $(MAKEFILES_AFTER_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) ,$(eval $(def_pass_makefile)))
|
---|
3129 |
|
---|
3130 | .NOTPARALLEL: pass_$(pass)_before pass_$(pass)_after
|
---|
3131 | .PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_doit pass_$(pass)_after
|
---|
3132 | pass_$(pass)_doit: $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$(var))
|
---|
3133 | pass_$(pass)_this: pass_$(pass)_before
|
---|
3134 | + $$(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)_doit
|
---|
3135 | pass_$(pass)_after:: pass_$(pass)_this
|
---|
3136 | pass_$(pass): pass_$(pass)_after
|
---|
3137 |
|
---|
3138 | endef
|
---|
3139 |
|
---|
3140 | define def_pass
|
---|
3141 | $(eval SUBDIRS_$(PASS) ?= $(SUBDIRS) $(SUBDIRS.$(BUILD_TARGET)) $(SUBDIRS.$(BUILD_TARGET.$(BUILD_TARGET_ARCH))) )
|
---|
3142 | $(eval SUBDIRS_AFTER_$(PASS) ?= $(SUBDIRS_AFTER) $(SUBDIRS_AFTER.$(BUILD_TARGET)) $(SUBDIRS_AFTER.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
|
---|
3143 | $(eval MAKEFILES_BEFORE_$(PASS) ?= $(MAKEFILES_BEFORE) $(MAKEFILES_BEFORE.$(BUILD_TARGET)) $(MAKEFILES_BEFORE.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
|
---|
3144 | $(eval MAKEFILES_AFTER_$(PASS) ?= $(MAKEFILES_AFTER) $(MAKEFILES_AFTER.$(BUILD_TARGET)) $(MAKEFILES_AFTER.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
|
---|
3145 |
|
---|
3146 | $(eval tag:=_before)
|
---|
3147 | $(eval dep:=)
|
---|
3148 | $(foreach subdir,$(SUBDIRS_$(PASS)) $(SUBDIRS_$(PASS).$(BUILD_TARGET)) $(SUBDIRS_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir)))
|
---|
3149 | $(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(BUILD_TARGET)) $(MAKEFILES_BEFORE_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)),$(eval $(def_pass_makefile)))
|
---|
3150 |
|
---|
3151 | $(eval tag:=_after)
|
---|
3152 | $(eval dep:=pass_$(pass)_doit)
|
---|
3153 | $(foreach subdir,$(SUBDIRS_AFTER_$(PASS)) $(SUBDIRS_AFTER_$(PASS).$(BUILD_TARGET)) $(SUBDIRS_AFTER_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir)))
|
---|
3154 | $(foreach makefile,$(MAKEFILES_AFTER_$(PASS)) $(MAKEFILES_AFTER_$(PASS).$(BUILD_TARGET)) $(MAKEFILES_AFTER_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) ,$(eval $(def_pass_makefile)))
|
---|
3155 |
|
---|
3156 | ifdef KBUILD_SAFE_PARALLEL
|
---|
3157 | .NOTPARALLEL: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_this
|
---|
3158 | .PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_this pass_$(pass)_doit
|
---|
3159 | pass_$(pass)_doit: $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$(var))
|
---|
3160 | pass_$(pass)_this: pass_$(pass)_before
|
---|
3161 | + $$(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)_doit
|
---|
3162 | pass_$(pass)_after:: pass_$(pass)_this
|
---|
3163 | pass_$(pass): pass_$(pass)_after
|
---|
3164 | else
|
---|
3165 | .NOTPARALLEL: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_doit
|
---|
3166 | .PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_doit
|
---|
3167 | pass_$(pass)_doit: pass_$(pass)_before \
|
---|
3168 | $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var)))
|
---|
3169 | pass_$(pass): \
|
---|
3170 | pass_$(pass)_before \
|
---|
3171 | pass_$(pass)_doit \
|
---|
3172 | pass_$(pass)_after
|
---|
3173 | endif
|
---|
3174 |
|
---|
3175 | #$ (warning pass=$(pass) PASS=$(PASS): $(PASS_$(PASS)_trgs) $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var))))
|
---|
3176 | endef
|
---|
3177 |
|
---|
3178 | # Generate the defined passes.
|
---|
3179 | $(foreach PASS, $(PASSES), \
|
---|
3180 | $(eval pass := $(PASS_$(PASS)_pass)) \
|
---|
3181 | $(eval $(def_pass)))
|
---|
3182 |
|
---|
3183 | ## Pass order
|
---|
3184 | # @param $(pass) Current pass name.
|
---|
3185 | # @param $(prev_pass) The previous pass name.
|
---|
3186 | define def_pass_order
|
---|
3187 | ifdef KBUILD_SAFE_PARALLEL
|
---|
3188 | .NOTPARALLEL: pass_$(pass)_order
|
---|
3189 | .PHONY: pass_$(pass)_order
|
---|
3190 | pass_$(pass)_order: $(pass_prev)
|
---|
3191 | $$(call MSG_PASS,$$(if $$(PASS_$(PASS)),$$(PASS_$(PASS)),$(pass)))
|
---|
3192 | + $$(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)
|
---|
3193 | else
|
---|
3194 | .NOTPARALLEL: pass_$(pass)_order pass_$(pass)_banner
|
---|
3195 | .PHONY: pass_$(pass)_order pass_$(pass)_banner
|
---|
3196 | pass_$(pass)_banner:
|
---|
3197 | $$(call MSG_PASS,$$(if $$(PASS_$(PASS)),$$(PASS_$(PASS)),$(pass)))
|
---|
3198 | pass_$(pass)_order: \
|
---|
3199 | $(pass_prev) \
|
---|
3200 | pass_$(pass)_banner \
|
---|
3201 | pass_$(pass)
|
---|
3202 | endif
|
---|
3203 | $(eval pass_prev := pass_$(pass)_order)
|
---|
3204 | endef
|
---|
3205 |
|
---|
3206 | ## PASS: order
|
---|
3207 | # Use dependencies to ensure correct pass order.
|
---|
3208 | pass_prev :=
|
---|
3209 | $(foreach PASS,$(DEFAULT_PASSES),\
|
---|
3210 | $(eval pass := $(PASS_$(PASS)_pass)) \
|
---|
3211 | $(eval $(def_pass_order)))
|
---|
3212 |
|
---|
3213 | ifdef KBUILD_PROFILE_SELF
|
---|
3214 | _KBUILD_TS_NOW := $(nanots )
|
---|
3215 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done passes)
|
---|
3216 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
3217 | endif
|
---|
3218 |
|
---|
3219 |
|
---|
3220 | #
|
---|
3221 | # THE MAIN RULES
|
---|
3222 | #
|
---|
3223 | all_recursive: $(pass_prev)
|
---|
3224 |
|
---|
3225 | rebuild: clean
|
---|
3226 | + $(MAKE) -f $(firstword $(MAKEFILE_LIST)) all_recursive
|
---|
3227 |
|
---|
3228 | # @todo make this a non-default pass!
|
---|
3229 | uninstall:
|
---|
3230 | $(RM) -f $(_INSTALLS_FILES)
|
---|
3231 |
|
---|
3232 | install: pass_installs
|
---|
3233 |
|
---|
3234 | # misc shortcuts.
|
---|
3235 | targets: bldprogs libraries dlls programs sysmods others installs
|
---|
3236 | objects: $(_OBJS)
|
---|
3237 | bldprogs: $(_BLDPROGS)
|
---|
3238 | libraries: $(_LIBS) $(_IMPORT_LIBS) $(_OTHER_LIBRARIES)
|
---|
3239 | dlls: $(_DLLS)
|
---|
3240 | programs: $(_PROGRAMS)
|
---|
3241 | sysmods: $(_SYSMODS)
|
---|
3242 | others: $(_OTHERS)
|
---|
3243 | installs: $(_INSTALLS) $(_INSTALLS_DIRS) $(_INSTALLS_FILES)
|
---|
3244 |
|
---|
3245 |
|
---|
3246 |
|
---|
3247 | #
|
---|
3248 | # kBuild debugging stuff.
|
---|
3249 | #
|
---|
3250 | show_targets:
|
---|
3251 | @$(foreach target, $(_ALL_TARGETS),\
|
---|
3252 | @$(ECHO) "target: $(target)" $(NLTAB)\
|
---|
3253 | @$(ECHO) " PATH_$(target)=$(PATH_$(target))" $(NLTAB)\
|
---|
3254 | @$(ECHO) " TARGET_$(target)=$(TARGET_$(target))" $(NLTAB)\
|
---|
3255 | @$(ECHO) " INSTARGET_$(target)=$(INSTARGET_$(target))" $(NLTAB)\
|
---|
3256 | $(foreach prop,$(PROPS_SINGLE) $(PROPS_ACCUMULATE_L) $(PROPS_ACCUMULATE_R) OBJS_ CLEAN, \
|
---|
3257 | $(eval _tmp:=$(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))) \
|
---|
3258 | $(if $($(target)_$(prop).$(_tmp)),\
|
---|
3259 | @$(ECHO) " $(target)_$(prop).$(_tmp)=$($(target)_$(prop).$(_tmp))" $(NLTAB)) \
|
---|
3260 | $(if $($(target)_$(prop)), $(NLTAB)@$(ECHO) " $(target)_$(prop)=$($(target)_$(prop))" $(NLTAB)) \
|
---|
3261 | )\
|
---|
3262 | $(foreach prop,$(PROPS_DEFERRED), \
|
---|
3263 | $(eval _tmp:=$(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))) \
|
---|
3264 | $(if $(value $(target)_$(prop).$(_tmp)),\
|
---|
3265 | @$(ECHO) ' $(target)_$(prop).$(_tmp)=$(value $(TARGET)_$(prop).$(_tmp))' $(NLTAB)) \
|
---|
3266 | $(if $(value $(target)_$(prop)), $(NLTAB)@$(ECHO) ' $(target)_$(prop)=$(value $(target)_$(prop))' $(NLTAB)) \
|
---|
3267 | ))
|
---|
3268 |
|
---|
3269 |
|
---|
3270 |
|
---|
3271 | #
|
---|
3272 | # Include dependency files.
|
---|
3273 | #
|
---|
3274 | ifneq ($(_DEPFILES),)
|
---|
3275 | includedep $(_DEPFILES)
|
---|
3276 | endif
|
---|
3277 |
|
---|
3278 |
|
---|
3279 | ifdef KBUILD_PROFILE_SELF
|
---|
3280 | _KBUILD_TS_FOOTER_END := $(nanots )
|
---|
3281 | $(info prof: $(int-sub $(_KBUILD_TS_FOOTER_END), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_FOOTER_END), $(_KBUILD_TS_PREV)) - end of footer.kmk)
|
---|
3282 | $(info prof: footer.kmk: $(int-sub $(_KBUILD_TS_FOOTER_END), $(_KBUILD_TS_FOOTER_START)))
|
---|
3283 | _KBUILD_TS_PREV := $(_KBUILD_TS_FOOTER_END)
|
---|
3284 | endif
|
---|
3285 |
|
---|
3286 | # end-of-file-content
|
---|
3287 | __footer_kmk__ := target
|
---|
3288 | endif # __footer_kmk__
|
---|
3289 |
|
---|