1 | # $Id: footer.kmk 2518 2011-07-26 12:08:37Z bird $
|
---|
2 | ## @file
|
---|
3 | # kBuild - File included at top of makefile.
|
---|
4 | #
|
---|
5 |
|
---|
6 | #
|
---|
7 | # Copyright (c) 2004-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net>
|
---|
8 | #
|
---|
9 | # This file is part of kBuild.
|
---|
10 | #
|
---|
11 | # kBuild is free software; you can redistribute it and/or modify
|
---|
12 | # it under the terms of the GNU General Public License as published by
|
---|
13 | # the Free Software Foundation; either version source of the License, or
|
---|
14 | # (at your option) any later version.
|
---|
15 | #
|
---|
16 | # kBuild is distributed in the hope that it will be useful,
|
---|
17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
19 | # GNU General Public License for more details.
|
---|
20 | #
|
---|
21 | # You should have received a copy of the GNU General Public License
|
---|
22 | # along with kBuild; if not, write to the Free Software
|
---|
23 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
24 | #
|
---|
25 | #
|
---|
26 | # As a special exception you are granted permission to include this file, via
|
---|
27 | # the kmk include directive, as you wish without this in itself causing the
|
---|
28 | # resulting makefile, program or whatever to be covered by the GPL license.
|
---|
29 | # This exception does not however invalidate any other reasons why the makefile,
|
---|
30 | # program, whatever should not be covered the GPL.
|
---|
31 | #
|
---|
32 | #
|
---|
33 |
|
---|
34 | ifndef __footer_kmk__
|
---|
35 | # start-of-file-content
|
---|
36 | ifdef KBUILD_PROFILE_SELF
|
---|
37 | $(evalcall def_profile_self, start of footer.kmk)
|
---|
38 | _KBUILD_TS_FOOTER_START := $(_KBUILD_TS_PREV)
|
---|
39 | endif
|
---|
40 |
|
---|
41 | #
|
---|
42 | # Variables.
|
---|
43 | # (Some of these need initialization before including definitions using them.)
|
---|
44 | #
|
---|
45 |
|
---|
46 | # All targets of each types.
|
---|
47 | _ALL_BLDPROGS := $(BLDPROGS) $(BLDPROGS.$(KBUILD_HOST)) $(BLDPROGS.$(KBUILD_HOST).$(KBUILD_HOST_ARCH)) $(BLDPROGS.$(KBUILD_HOST_ARCH)) $(BLDPROGS.$(KBUILD_HOST_CPU)) $(BLDPROGS.$(KBUILD_TYPE))
|
---|
48 | _ALL_LIBRARIES := $(LIBRARIES) $(LIBRARIES.$(KBUILD_TARGET)) $(LIBRARIES.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) $(LIBRARIES.$(KBUILD_TARGET_ARCH)) $(LIBRARIES.$(KBUILD_TARGET_CPU)) $(LIBRARIES.$(KBUILD_TYPE))
|
---|
49 | _ALL_IMPORT_LIBS := $(IMPORT_LIBS) $(IMPORT_LIBS.$(KBUILD_TARGET)) $(IMPORT_LIBS.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) $(IMPORT_LIBS.$(KBUILD_TARGET_ARCH)) $(IMPORT_LIBS.$(KBUILD_TARGET_CPU)) $(IMPORT_LIBS.$(KBUILD_TYPE))
|
---|
50 | _ALL_DLLS := $(DLLS) $(DLLS.$(KBUILD_TARGET)) $(DLLS.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) $(DLLS.$(KBUILD_TARGET_ARCH)) $(DLLS.$(KBUILD_TARGET_CPU)) $(DLLS.$(KBUILD_TYPE))
|
---|
51 | _ALL_PROGRAMS := $(PROGRAMS) $(PROGRAMS.$(KBUILD_TARGET)) $(PROGRAMS.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) $(PROGRAMS.$(KBUILD_TARGET_ARCH)) $(PROGRAMS.$(KBUILD_TARGET_CPU)) $(PROGRAMS.$(KBUILD_TYPE))
|
---|
52 | _ALL_SYSMODS := $(SYSMODS) $(SYSMODS.$(KBUILD_TARGET)) $(SYSMODS.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) $(SYSMODS.$(KBUILD_TARGET_ARCH)) $(SYSMODS.$(KBUILD_TARGET_CPU)) $(SYSMODS.$(KBUILD_TYPE))
|
---|
53 | _ALL_MISCBINS := $(MISCBINS) $(MISCBINS.$(KBUILD_TARGET)) $(MISCBINS.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) $(MISCBINS.$(KBUILD_TARGET_ARCH)) $(MISCBINS.$(KBUILD_TARGET_CPU)) $(MISCBINS.$(KBUILD_TYPE))
|
---|
54 | _ALL_OTHERS := $(OTHERS) $(OTHERS.$(KBUILD_TARGET)) $(OTHERS.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) $(OTHERS.$(KBUILD_TARGET_ARCH)) $(OTHERS.$(KBUILD_TARGET_CPU)) $(OTHERS.$(KBUILD_TYPE))
|
---|
55 | _ALL_INSTALLS := $(INSTALLS) $(INSTALLS.$(KBUILD_TARGET)) $(INSTALLS.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) $(INSTALLS.$(KBUILD_TARGET_ARCH)) $(INSTALLS.$(KBUILD_TARGET_CPU)) $(INSTALLS.$(KBUILD_TYPE))
|
---|
56 | _ALL_FETCHES := $(FETCHES) $(FETCHES.$(KBUILD_TARGET)) $(FETCHES.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) $(FETCHES.$(KBUILD_TARGET_ARCH)) $(FETCHES.$(KBUILD_TARGET_CPU)) $(FETCHES.$(KBUILD_TYPE))
|
---|
57 | _ALL_PATCHES := $(PATCHES) $(PATCHES.$(KBUILD_TARGET)) $(PATCHES.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) $(PATCHES.$(KBUILD_TARGET_ARCH)) $(PATCHES.$(KBUILD_TARGET_CPU)) $(PATCHES.$(KBUILD_TYPE))
|
---|
58 |
|
---|
59 | # all targets.
|
---|
60 | _ALL_TARGETS = \
|
---|
61 | $(_ALL_FETCHES) \
|
---|
62 | $(_ALL_PATCHES) \
|
---|
63 | $(_ALL_BLDPROGS) \
|
---|
64 | $(_ALL_LIBRARIES) \
|
---|
65 | $(_ALL_IMPORT_LIBS) \
|
---|
66 | $(_ALL_DLLS) \
|
---|
67 | $(_ALL_PROGRAMS) \
|
---|
68 | $(_ALL_SYSMODS) \
|
---|
69 | $(_ALL_MISCBINS) \
|
---|
70 | $(_ALL_INSTALLS) \
|
---|
71 | $(_ALL_OTHERS)
|
---|
72 |
|
---|
73 | # all $(KBUILD_TARGET) targets.
|
---|
74 | _ALL_TARGET_TARGETS = \
|
---|
75 | $(_ALL_FETCHES) \
|
---|
76 | $(_ALL_PATCHES) \
|
---|
77 | $(_ALL_LIBRARIES) \
|
---|
78 | $(_ALL_IMPORT_LIBS) \
|
---|
79 | $(_ALL_DLLS) \
|
---|
80 | $(_ALL_PROGRAMS) \
|
---|
81 | $(_ALL_SYSMODS) \
|
---|
82 | $(_ALL_MISCBINS) \
|
---|
83 | $(_ALL_INSTALLS) \
|
---|
84 | $(_ALL_OTHERS)
|
---|
85 |
|
---|
86 | # all $(KBUILD_HOST) targets.
|
---|
87 | _ALL_HOST_TARGETS = \
|
---|
88 | $(_ALL_BLDPROGS)
|
---|
89 |
|
---|
90 | # all targets making use of srcname.
|
---|
91 | _ALL_SRCNAME_TARGETS = \
|
---|
92 | $(_ALL_FETCHES) \
|
---|
93 | $(_ALL_PATCHES)
|
---|
94 |
|
---|
95 | # Dependency files. (currently not on target level, only this global stuff)
|
---|
96 | _DEPFILES := $(DEPFILES) $(DEPFILES.$(KBUILD_TARGET)) $(DEPFILES.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) $(DEPFILES.$(KBUILD_TARGET_ARCH)) $(DEPFILES.$(KBUILD_TARGET_CPU)) $(DEPFILES.$(KBUILD_TYPE))
|
---|
97 |
|
---|
98 | # included dependency files.
|
---|
99 | _DEPFILES_INCLUDED :=
|
---|
100 |
|
---|
101 |
|
---|
102 | # All kind of output files except for _OBJS and _DEPFILES.
|
---|
103 | # Compiling or linking definition outputting other things that $@ and any
|
---|
104 | # required dependency file must add those output files to this variable.
|
---|
105 | _OUT_FILES :=
|
---|
106 |
|
---|
107 | # Files which only requires cleaning up.
|
---|
108 | _CLEAN_FILES :=
|
---|
109 |
|
---|
110 | # all of a type
|
---|
111 | _OBJS :=
|
---|
112 | _FETCHES :=
|
---|
113 | _DOWNLOADS:=
|
---|
114 | _UNPACKS :=
|
---|
115 | _PATCHES :=
|
---|
116 | _UNFETCHES:=
|
---|
117 | _BLDPROGS :=
|
---|
118 | _LIBS :=
|
---|
119 | _DLLS :=
|
---|
120 | _PROGRAMS :=
|
---|
121 | _SYSMODS :=
|
---|
122 | _MISCBINS :=
|
---|
123 | _STAGE_FILES :=
|
---|
124 | _STAGE_DIRS :=
|
---|
125 | _INSTALLS :=
|
---|
126 | _INSTALLS_FILES :=
|
---|
127 | _INSTALLS_DIRS :=
|
---|
128 | _OTHERS :=
|
---|
129 | _PACKING :=
|
---|
130 | _DIRS := $(PATH_TARGET)/ $(PATH_TARGET) $(BLDDIRS)
|
---|
131 | _IMPORT_LIBS :=
|
---|
132 |
|
---|
133 | # Implicit targets added while processing other targets (usually by units).
|
---|
134 | _ALL_INSTALLS_IMPLICIT :=
|
---|
135 |
|
---|
136 | # misc
|
---|
137 | pass_prev :=
|
---|
138 |
|
---|
139 |
|
---|
140 |
|
---|
141 | #
|
---|
142 | # Footer macros
|
---|
143 | #
|
---|
144 |
|
---|
145 | ## Figure out the tool for a target.
|
---|
146 | # @param $1 normalized target.
|
---|
147 | # @param $2 tooltype.
|
---|
148 | # @param bld_trg build target.
|
---|
149 | # @param bld_trg_arch build target architecture.
|
---|
150 | # @param bld_type build target type.
|
---|
151 | if 0
|
---|
152 | _TARGET_TOOL = $(strip $(firstword \
|
---|
153 | $($(1)_$(2)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
154 | $($(1)_$(2)TOOL.$(bld_trg)) \
|
---|
155 | $($(1)_$(2)TOOL) \
|
---|
156 | $($(1)_TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
157 | $($(1)_TOOL.$(bld_trg)) \
|
---|
158 | $($(1)_TOOL) \
|
---|
159 | $($(2)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
160 | $($(2)TOOL.$(bld_trg)) \
|
---|
161 | $($(2)TOOL) \
|
---|
162 | $(TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
163 | $(TOOL.$(bld_trg)) \
|
---|
164 | $(TOOL) \
|
---|
165 | ))
|
---|
166 | else
|
---|
167 | _TARGET_TOOL = $(strip $(firstword \
|
---|
168 | $($(1)_$(2)TOOL.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
|
---|
169 | $($(1)_$(2)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
170 | $($(1)_$(2)TOOL.$(bld_trg).$(bld_type)) \
|
---|
171 | $($(1)_$(2)TOOL.$(bld_trg_arch)) \
|
---|
172 | $($(1)_$(2)TOOL.$(bld_trg)) \
|
---|
173 | $($(1)_$(2)TOOL.$(bld_type)) \
|
---|
174 | $($(1)_$(2)TOOL) \
|
---|
175 | $($(1)_TOOL.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
|
---|
176 | $($(1)_TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
177 | $($(1)_TOOL.$(bld_trg).$(bld_type)) \
|
---|
178 | $($(1)_TOOL.$(bld_trg_arch)) \
|
---|
179 | $($(1)_TOOL.$(bld_trg)) \
|
---|
180 | $($(1)_TOOL.$(bld_type)) \
|
---|
181 | $($(1)_TOOL) \
|
---|
182 | $($(2)TOOL.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
|
---|
183 | $($(2)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
184 | $($(2)TOOL.$(bld_trg).$(bld_type)) \
|
---|
185 | $($(2)TOOL.$(bld_trg_arch)) \
|
---|
186 | $($(2)TOOL.$(bld_trg)) \
|
---|
187 | $($(2)TOOL.$(bld_type)) \
|
---|
188 | $($(2)TOOL) \
|
---|
189 | $(TOOL.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
|
---|
190 | $(TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
191 | $(TOOL.$(bld_trg).$(bld_type)) \
|
---|
192 | $(TOOL.$(bld_trg_arch)) \
|
---|
193 | $(TOOL.$(bld_trg)) \
|
---|
194 | $(TOOL.$(bld_type)) \
|
---|
195 | $(TOOL) \
|
---|
196 | ))
|
---|
197 | endif
|
---|
198 |
|
---|
199 | ## Figure out the actual name of an installed file.
|
---|
200 | # @param $1 The file to install.
|
---|
201 | # @param $2 The target name.
|
---|
202 | # @param $3 The _INST value (can be empty).
|
---|
203 | # @param $4 The installation root directory.
|
---|
204 | _INSTALL_FILE = $(patsubst %/,%/$(notdir $(1)),$(if $(3),$(4)/$(3),$(4)/))
|
---|
205 |
|
---|
206 |
|
---|
207 |
|
---|
208 | ## Converts a variable from simple to recursive flavor.
|
---|
209 | # This is used by def_inherit_template_one_accumulate_l and def_inherit_template_one_accumulate_r.
|
---|
210 | # @param $1 The variable name.
|
---|
211 | define def_simple_2_recursive
|
---|
212 | $1_DEFERRED := $$($1)
|
---|
213 | $1 = $$($1_DEFERRED)
|
---|
214 | endef
|
---|
215 |
|
---|
216 |
|
---|
217 | ## Inherit one keyword in a non-accumulative manner.
|
---|
218 | # @param $(trg) Target object.
|
---|
219 | # @param $(prop) The property.
|
---|
220 | # @param $(src_key) Source keyword.
|
---|
221 | # @param $(trg_key) Target keyword.
|
---|
222 | define def_inherit_one_keyword
|
---|
223 | ifdef $(trg)_$(prop).$(src_key)
|
---|
224 | ifndef $(trg)_$(prop).$(trg_key)
|
---|
225 | $(trg)_$(prop).$(trg_key) = $($(trg)_$(prop).$(src_key))
|
---|
226 | endif
|
---|
227 | endif
|
---|
228 | endef
|
---|
229 |
|
---|
230 |
|
---|
231 | # EXPAND_BY = overriding
|
---|
232 |
|
---|
233 | ## Inherit one keyword in a non-accumulative manner.
|
---|
234 | # @param $(trg) Target object.
|
---|
235 | # @param $(prop) The property.
|
---|
236 | # @param $(src_key) Source keyword.
|
---|
237 | # @param $(trg_key) Target keyword.
|
---|
238 | define def_inherit_one_keyword_overriding_now_l
|
---|
239 | ifdef $(trg)_$(prop).$(src_key)
|
---|
240 | ifndef $(trg)_$(prop).$(trg_key)
|
---|
241 | $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(src_key))
|
---|
242 | endif
|
---|
243 | endif
|
---|
244 | endef
|
---|
245 |
|
---|
246 | ## @copydoc def_inherit_one_overriding_now_l
|
---|
247 | define def_inherit_one_keyword_overriding_now_r
|
---|
248 | ifdef $(trg)_$(prop).$(src_key)
|
---|
249 | ifndef $(trg)_$(prop).$(trg_key)
|
---|
250 | $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(src_key))
|
---|
251 | endif
|
---|
252 | endif
|
---|
253 | endef
|
---|
254 |
|
---|
255 | ## Inherit one keyword in a non-accumulative manner, deferred expansion.
|
---|
256 | # @param $(trg) Target object.
|
---|
257 | # @param $(prop) The property.
|
---|
258 | # @param $(src_key) Source keyword.
|
---|
259 | # @param $(trg_key) Target keyword.
|
---|
260 | # @remark This define relies on double evaluation
|
---|
261 | define def_inherit_one_keyword_overriding_deferred
|
---|
262 | ifdef $(trg)_$(prop).$(src_key)
|
---|
263 | ifndef $(trg)_$(prop).$(trg_key)
|
---|
264 | $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key))
|
---|
265 | endif
|
---|
266 | endif
|
---|
267 | endef
|
---|
268 |
|
---|
269 | ## @copydoc def_inherit_one_overriding_deferred
|
---|
270 | define def_inherit_one_keyword_overriding_deferred_l
|
---|
271 | ifdef $(trg)_$(prop).$(src_key)
|
---|
272 | ifndef $(trg)_$(prop).$(trg_key)
|
---|
273 | $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key))
|
---|
274 | endif
|
---|
275 | endif
|
---|
276 | endef
|
---|
277 |
|
---|
278 | ## @copydoc def_inherit_one_overriding_deferred
|
---|
279 | define def_inherit_one_keyword_overriding_deferred_r
|
---|
280 | ifdef $(trg)_$(prop).$(src_key)
|
---|
281 | ifndef $(trg)_$(prop).$(trg_key)
|
---|
282 | $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key))
|
---|
283 | endif
|
---|
284 | endif
|
---|
285 | endef
|
---|
286 |
|
---|
287 |
|
---|
288 | # EXPAND_BY = prepending
|
---|
289 |
|
---|
290 | ## Inherit one keyword in a prepending manner.
|
---|
291 | # @param $(trg) Target object.
|
---|
292 | # @param $(prop) The property.
|
---|
293 | # @param $(src_key) Source keyword.
|
---|
294 | # @param $(trg_key) Target keyword.
|
---|
295 | define def_inherit_one_keyword_prepending_now_l
|
---|
296 | ifdef $(trg)_$(prop).$(src_key)
|
---|
297 | $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(src_key)) $($(trg)_$(prop).$(trg_key))
|
---|
298 | endif
|
---|
299 | endef
|
---|
300 |
|
---|
301 | ## @copydoc def_inherit_one_prepending_now_l
|
---|
302 | define def_inherit_one_keyword_prepending_now_r
|
---|
303 | ifdef $(trg)_$(prop).$(src_key)
|
---|
304 | $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(trg_key)) $($(trg)_$(prop).$(src_key))
|
---|
305 | endif
|
---|
306 | endef
|
---|
307 |
|
---|
308 | ## Inherit one keyword in a non-accumulative manner, deferred expansion.
|
---|
309 | # @param $(trg) Target object.
|
---|
310 | # @param $(prop) The property.
|
---|
311 | # @param $(src_key) Source keyword.
|
---|
312 | # @param $(trg_key) Target keyword.
|
---|
313 | # @remark This define relies on double evaluation
|
---|
314 | define def_inherit_one_keyword_prepending_deferred
|
---|
315 | ifdef $(trg)_$(prop).$(src_key)
|
---|
316 | ifndef $(trg)_$(prop).$(trg_key)
|
---|
317 | $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key))
|
---|
318 | endif
|
---|
319 | endif
|
---|
320 | endef
|
---|
321 |
|
---|
322 | ## Inherit one keyword in a prepending manner, deferred expansion.
|
---|
323 | # @param $(trg) Target object.
|
---|
324 | # @param $(prop) The property.
|
---|
325 | # @param $(src_key) Source keyword.
|
---|
326 | # @param $(trg_key) Target keyword.
|
---|
327 | define def_inherit_one_keyword_prepending_deferred_l
|
---|
328 | ifdef $(trg)_$(prop).$(src_key)
|
---|
329 | ifeq ($$(flavor $(trg)_$(prop).$(trg_key)),simple)
|
---|
330 | $$(evalcall2 def_simple_2_recursive,$(trg)_$(prop).$(trg_key))
|
---|
331 | endif
|
---|
332 | $(trg)_$(prop).$(trg_key) <= $$($(trg)_$(prop).$(src_key))
|
---|
333 | endif
|
---|
334 | endef
|
---|
335 |
|
---|
336 | ## @copydoc def_inherit_one_prepending_deferred_l
|
---|
337 | define def_inherit_one_keyword_prepending_deferred_r
|
---|
338 | ifdef $(trg)_$(prop).$(src_key)
|
---|
339 | ifeq ($$(flavor $(trg)_$(prop).$(trg_key)),simple)
|
---|
340 | $$(evalcall2 def_simple_2_recursive,$(trg)_$(prop).$(trg_key))
|
---|
341 | endif
|
---|
342 | $(trg)_$(prop).$(trg_key) += $$($(trg)_$(prop).$(src_key))
|
---|
343 | endif
|
---|
344 | endef
|
---|
345 |
|
---|
346 |
|
---|
347 | # EXPAND_BY = appending
|
---|
348 |
|
---|
349 | ## Inherit one keyword in an appending manner.
|
---|
350 | # @param $(trg) Target object.
|
---|
351 | # @param $(prop) The property.
|
---|
352 | # @param $(src_key) Source keyword.
|
---|
353 | # @param $(trg_key) Target keyword.
|
---|
354 | define def_inherit_one_keyword_appending_now_l
|
---|
355 | ifdef $(trg)_$(prop).$(src_key)
|
---|
356 | $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(trg_key)) $($(trg)_$(prop).$(src_key))
|
---|
357 | endif
|
---|
358 | endef
|
---|
359 |
|
---|
360 | ## @copydoc def_inherit_one_appending_now_l
|
---|
361 | define def_inherit_one_keyword_appending_now_r
|
---|
362 | ifdef $(trg)_$(prop).$(src_key)
|
---|
363 | $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(src_key)) $($(trg)_$(prop).$(trg_key))
|
---|
364 | endif
|
---|
365 | endef
|
---|
366 |
|
---|
367 | ## Inherit one keyword in a non-accumulative manner, deferred expansion.
|
---|
368 | # @param $(trg) Target object.
|
---|
369 | # @param $(prop) The property.
|
---|
370 | # @param $(src_key) Source keyword.
|
---|
371 | # @param $(trg_key) Target keyword.
|
---|
372 | # @remark This define relies on double evaluation
|
---|
373 | define def_inherit_one_keyword_appending_deferred
|
---|
374 | ifdef $(trg)_$(prop).$(src_key)
|
---|
375 | ifndef $(trg)_$(prop).$(trg_key)
|
---|
376 | $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key))
|
---|
377 | endif
|
---|
378 | endif
|
---|
379 | endef
|
---|
380 |
|
---|
381 | ## Inherit one keyword in an appending manner, deferred expansion.
|
---|
382 | # @param $(trg) Target object.
|
---|
383 | # @param $(prop) The property.
|
---|
384 | # @param $(src_key) Source keyword.
|
---|
385 | # @param $(trg_key) Target keyword.
|
---|
386 | define def_inherit_one_keyword_appending_deferred_l
|
---|
387 | ifdef $(trg)_$(prop).$(src_key)
|
---|
388 | ifeq ($$(flavor $(trg)_$(prop).$(trg_key)),simple)
|
---|
389 | $$(evalcall2 def_simple_2_recursive,$(trg)_$(prop).$(trg_key))
|
---|
390 | endif
|
---|
391 | $(trg)_$(prop).$(trg_key) += $$($(trg)_$(prop).$(src_key))
|
---|
392 | endif
|
---|
393 | endef
|
---|
394 |
|
---|
395 | ## @copydoc def_inherit_one_appending_deferred_l
|
---|
396 | define def_inherit_one_keyword_appending_deferred_r
|
---|
397 | ifdef $(trg)_$(prop).$(src_key)
|
---|
398 | ifeq ($$(flavor $(trg)_$(prop).$(trg_key)),simple)
|
---|
399 | $$(evalcall2 def_simple_2_recursive,$(trg)_$(prop).$(trg_key))
|
---|
400 | endif
|
---|
401 | $(trg)_$(prop).$(trg_key) <= $$($(trg)_$(prop).$(src_key))
|
---|
402 | endif
|
---|
403 | endef
|
---|
404 |
|
---|
405 |
|
---|
406 | ## Worker for def_inherit that deals with one keyword that makes
|
---|
407 | # use of inheritance.
|
---|
408 | # @param prefix_keyword key_prefix:keyword. The cool join/split game as usual.
|
---|
409 | # @param trg Object to consider for inheriting.
|
---|
410 | # @param properties List of the properties with straight expansion.
|
---|
411 | # @param properties_now_l List of the properties with immediate expansion, accumulating on the left side.
|
---|
412 | # @param properties_now_r List of the properties with immediate expansion, accumulating on the right side.
|
---|
413 | # @param properties_deferred List of the properties with deferred expansion (e.g. function), non-accumulative .
|
---|
414 | # @param properties_deferred_l List of the properties with deferred expansion (e.g. function), accumulating on the left side.
|
---|
415 | # @param properties_deferred_r List of the properties with deferred expansion (e.g. function), accumulating on the right side.
|
---|
416 | define def_inherit_keyword
|
---|
417 | local prefix := $(word 1,$(subst :, ,$(prefix_keyword)))
|
---|
418 | local trg_key := $(word 2,$(subst :, ,$(prefix_keyword)))
|
---|
419 | local src_key := $($(prefix)_$(trg_key)_EXTENDS)
|
---|
420 | local by := $($(prefix)_$(trg_key)_EXTENDS_BY)
|
---|
421 |
|
---|
422 | # Inherit the properties.
|
---|
423 | $(foreach prop, $(properties), $(eval $(def_inherit_one_keyword)))
|
---|
424 | $(foreach prop, $(properties_now_l), $(eval $(def_inherit_one_keyword_$(by)_now_l)))
|
---|
425 | $(foreach prop, $(properties_now_r), $(eval $(def_inherit_one_keyword_$(by)_now_r)))
|
---|
426 | $(foreach prop, $(properties_deferred), $(eval $(def_inherit_one_keyword_$(by)_deferred)))
|
---|
427 | $(foreach prop, $(properties_deferred_l), $(eval $(def_inherit_one_keyword_$(by)_deferred_l)))
|
---|
428 | $(foreach prop, $(properties_deferred_r), $(eval $(def_inherit_one_keyword_$(by)_deferred_r)))
|
---|
429 |
|
---|
430 | endef # def_inherit_keyword
|
---|
431 |
|
---|
432 |
|
---|
433 | ## Inherit one template property in a non-accumulative manner.
|
---|
434 | # @param $(prop) Property name
|
---|
435 | # @param $(src) Source (parent) object.
|
---|
436 | # @param $(trg) Target (child) object.
|
---|
437 | define def_inherit_one
|
---|
438 | ifdef $(src)_$(prop)
|
---|
439 | ifndef $(trg)_$(prop)
|
---|
440 | $(trg)_$(prop) = $($(src)_$(prop))
|
---|
441 | endif
|
---|
442 | endif
|
---|
443 | endef
|
---|
444 |
|
---|
445 |
|
---|
446 | # EXPAND_BY = overriding
|
---|
447 |
|
---|
448 | ## Inherit one template property in a non-accumulative manner.
|
---|
449 | # @param $(prop) Property name
|
---|
450 | # @param $(src) Source (parent) object.
|
---|
451 | # @param $(trg) Target (child) object.
|
---|
452 | define def_inherit_one_overriding_now_l
|
---|
453 | ifdef $(src)_$(prop)
|
---|
454 | ifndef $(trg)_$(prop)
|
---|
455 | $(trg)_$(prop) := $($(src)_$(prop))
|
---|
456 | endif
|
---|
457 | endif
|
---|
458 | endef
|
---|
459 |
|
---|
460 | ## @copydoc def_inherit_one_overriding_now_l
|
---|
461 | define def_inherit_one_overriding_now_r
|
---|
462 | ifdef $(src)_$(prop)
|
---|
463 | ifndef $(trg)_$(prop)
|
---|
464 | $(trg)_$(prop) := $($(src)_$(prop))
|
---|
465 | endif
|
---|
466 | endif
|
---|
467 | endef
|
---|
468 |
|
---|
469 | ## Inherit one template property in a non-accumulative manner, deferred expansion.
|
---|
470 | # @param $(prop) Property name
|
---|
471 | # @param $(src) Source
|
---|
472 | # @param $(trg) Target
|
---|
473 | # @remark This define relies on double evaluation
|
---|
474 | define def_inherit_one_overriding_deferred
|
---|
475 | ifdef $(src)_$(prop)
|
---|
476 | ifndef $(trg)_$(prop)
|
---|
477 | $(trg)_$(prop) = $$($(src)_$(prop))
|
---|
478 | endif
|
---|
479 | endif
|
---|
480 | endef
|
---|
481 |
|
---|
482 | ## @copydoc def_inherit_one_overriding_deferred
|
---|
483 | define def_inherit_one_overriding_deferred_l
|
---|
484 | ifdef $(src)_$(prop)
|
---|
485 | ifndef $(trg)_$(prop)
|
---|
486 | $(trg)_$(prop) = $$($(src)_$(prop))
|
---|
487 | endif
|
---|
488 | endif
|
---|
489 | endef
|
---|
490 |
|
---|
491 | ## @copydoc def_inherit_one_overriding_deferred
|
---|
492 | define def_inherit_one_overriding_deferred_r
|
---|
493 | ifdef $(src)_$(prop)
|
---|
494 | ifndef $(trg)_$(prop)
|
---|
495 | $(trg)_$(prop) = $$($(src)_$(prop))
|
---|
496 | endif
|
---|
497 | endif
|
---|
498 | endef
|
---|
499 |
|
---|
500 |
|
---|
501 | # EXPAND_BY = prepending
|
---|
502 |
|
---|
503 | ## Inherit one template property in a prepending manner.
|
---|
504 | # @param $(prop) Property name
|
---|
505 | # @param $(src) Source (parent) object.
|
---|
506 | # @param $(trg) Target (child) object.
|
---|
507 | define def_inherit_one_prepending_now_l
|
---|
508 | ifdef $(src)_$(prop)
|
---|
509 | $(trg)_$(prop) := $($(src)_$(prop)) $($(trg)_$(prop))
|
---|
510 | endif
|
---|
511 | endef
|
---|
512 |
|
---|
513 | ## @copydoc def_inherit_one_prepending_now_l
|
---|
514 | define def_inherit_one_prepending_now_r
|
---|
515 | ifdef $(src)_$(prop)
|
---|
516 | $(trg)_$(prop) := $($(trg)_$(prop)) $($(src)_$(prop))
|
---|
517 | endif
|
---|
518 | endef
|
---|
519 |
|
---|
520 | ## Inherit one template property in a non-accumulative manner, deferred expansion.
|
---|
521 | # @param $(prop) Property name
|
---|
522 | # @param $(src) Source
|
---|
523 | # @param $(trg) Target
|
---|
524 | # @remark This define relies on double evaluation
|
---|
525 | define def_inherit_one_prepending_deferred
|
---|
526 | ifdef $(src)_$(prop)
|
---|
527 | ifndef $(trg)_$(prop)
|
---|
528 | $(trg)_$(prop) = $$($(src)_$(prop))
|
---|
529 | endif
|
---|
530 | endif
|
---|
531 | endef
|
---|
532 |
|
---|
533 | ## Inherit one template property in a prepending manner, deferred expansion.
|
---|
534 | # @param $(prop) Property name
|
---|
535 | # @param $(src) Source (parent) object.
|
---|
536 | # @param $(trg) Target (child) object.
|
---|
537 | define def_inherit_one_prepending_deferred_l
|
---|
538 | ifdef $(src)_$(prop)
|
---|
539 | ifeq ($$(flavor $(trg)_$(prop)),simple)
|
---|
540 | $$(evalcall2 def_simple_2_recursive,$(trg)_$(prop))
|
---|
541 | endif
|
---|
542 | $(trg)_$(prop) <= $$($(src)_$(prop))
|
---|
543 | endif
|
---|
544 | endef
|
---|
545 |
|
---|
546 | ## @copydoc def_inherit_one_prepending_deferred_l
|
---|
547 | define def_inherit_one_prepending_deferred_r
|
---|
548 | ifdef $(src)_$(prop)
|
---|
549 | ifeq ($$(flavor $(trg)_$(prop)),simple)
|
---|
550 | $$(evalcall2 def_simple_2_recursive,$(trg)_$(prop))
|
---|
551 | endif
|
---|
552 | $(trg)_$(prop) += $$($(src)_$(prop))
|
---|
553 | endif
|
---|
554 | endef
|
---|
555 |
|
---|
556 |
|
---|
557 | # EXPAND_BY = appending
|
---|
558 |
|
---|
559 | ## Inherit one template property in an appending manner.
|
---|
560 | # @param $(prop) Property name
|
---|
561 | # @param $(src) Source (parent) object.
|
---|
562 | # @param $(trg) Target (child) object.
|
---|
563 | define def_inherit_one_appending_now_l
|
---|
564 | ifdef $(src)_$(prop)
|
---|
565 | $(trg)_$(prop) := $($(trg)_$(prop)) $($(src)_$(prop))
|
---|
566 | endif
|
---|
567 | endef
|
---|
568 |
|
---|
569 | ## @copydoc def_inherit_one_appending_now_l
|
---|
570 | define def_inherit_one_appending_now_r
|
---|
571 | ifdef $(src)_$(prop)
|
---|
572 | $(trg)_$(prop) := $($(src)_$(prop)) $($(trg)_$(prop))
|
---|
573 | endif
|
---|
574 | endef
|
---|
575 |
|
---|
576 | ## Inherit one template property in a non-accumulative manner, deferred expansion.
|
---|
577 | # @param $(prop) Property name
|
---|
578 | # @param $(src) Source
|
---|
579 | # @param $(trg) Target
|
---|
580 | # @remark This define relies on double evaluation
|
---|
581 | define def_inherit_one_appending_deferred
|
---|
582 | ifdef $(src)_$(prop)
|
---|
583 | ifndef $(trg)_$(prop)
|
---|
584 | $(trg)_$(prop) = $$($(src)_$(prop))
|
---|
585 | endif
|
---|
586 | endif
|
---|
587 | endef
|
---|
588 |
|
---|
589 | ## Inherit one template property in an appending manner, deferred expansion.
|
---|
590 | # @param $(prop) Property name
|
---|
591 | # @param $(src) Source (parent) object.
|
---|
592 | # @param $(trg) Target (child) object.
|
---|
593 | define def_inherit_one_appending_deferred_l
|
---|
594 | ifdef $(src)_$(prop)
|
---|
595 | ifeq ($$(flavor $(trg)_$(prop)),simple)
|
---|
596 | $$(evalcall2 def_simple_2_recursive,$(trg)_$(prop))
|
---|
597 | endif
|
---|
598 | $(trg)_$(prop) += $$($(src)_$(prop))
|
---|
599 | endif
|
---|
600 | endef
|
---|
601 |
|
---|
602 | ## @copydoc def_inherit_one_appending_deferred_l
|
---|
603 | define def_inherit_one_appending_deferred_r
|
---|
604 | ifdef $(src)_$(prop)
|
---|
605 | ifeq ($$(flavor $(trg)_$(prop)),simple)
|
---|
606 | $$(evalcall2 def_simple_2_recursive,$(trg)_$(prop))
|
---|
607 | endif
|
---|
608 | $(trg)_$(prop) <= $$($(src)_$(prop))
|
---|
609 | endif
|
---|
610 | endef
|
---|
611 |
|
---|
612 |
|
---|
613 | ## combines the specified properties $(1) with the $(_KEYWORDS) list.
|
---|
614 | _INHERIT_JOIN_KEYWORDS = $(1) $(foreach keyword,$(_KEYWORDS), $(addsuffix .$(keyword), $(1)))
|
---|
615 |
|
---|
616 |
|
---|
617 | ## Generic inheritance for use with targets templates and tools.
|
---|
618 | # @param trg Object to consider for inheriting.
|
---|
619 | # @param src_prefix What to prefix the value found in EXTENDS with to get the object.
|
---|
620 | # @param load_function Load function for stuff that needs
|
---|
621 | # @param properties List of the properties with straight expansion.
|
---|
622 | # @param properties_now_l List of the properties with immediate expansion, accumulating on the left side.
|
---|
623 | # @param properties_now_r List of the properties with immediate expansion, accumulating on the right side.
|
---|
624 | # @param properties_deferred List of the properties with deferred expansion (e.g. function), non-accumulative .
|
---|
625 | # @param properties_deferred_l List of the properties with deferred expansion (e.g. function), accumulating on the left side.
|
---|
626 | # @param properties_deferred_r List of the properties with deferred expansion (e.g. function), accumulating on the right side.
|
---|
627 | define def_inherit
|
---|
628 |
|
---|
629 | # Load it - loading is a mess, fix.
|
---|
630 | ifneq ($(load_function),)
|
---|
631 | local loading := $(patsubst $(src_prefix)%,%,$(trg))
|
---|
632 | $(evalvalctx $(load_function))
|
---|
633 | endif
|
---|
634 |
|
---|
635 | local src := $(strip $($(trg)_EXTENDS))
|
---|
636 | ifneq ($(src),)
|
---|
637 | ifndef $(trg)_EXTENDS_STATUS_
|
---|
638 | $(trg)_EXTENDS_STATUS_ := 0
|
---|
639 |
|
---|
640 | # Load the source.
|
---|
641 | ifneq ($(load_function),)
|
---|
642 | local loading := $(src)
|
---|
643 | $(evalvalctx $(load_function))
|
---|
644 | endif
|
---|
645 |
|
---|
646 | # less typing.
|
---|
647 | local src := $(src_prefix)$(src)
|
---|
648 |
|
---|
649 | # Recursivly process the parent (src) if it's inherting from somebody too.
|
---|
650 | ifdef $(src)_EXTENDS
|
---|
651 | ifneq ($($(src)_EXTENDS_STATUS_),42)
|
---|
652 | # 'foreach' will create 'trg' in a new variable context hiding
|
---|
653 | # out current variable. 'src' OTOH will be overwritten.
|
---|
654 | $(foreach trg, $(src), $(evalval def_inherit))
|
---|
655 | local src := $(src_prefix)$(strip $($(trg)_EXTENDS))
|
---|
656 | endif
|
---|
657 | endif
|
---|
658 |
|
---|
659 | # Get & check EXTENDS_BY.
|
---|
660 | local by = $(strip $($(trg)_EXTENDS_BY))
|
---|
661 | ifeq ($(by),)
|
---|
662 | local by = overriding
|
---|
663 | else ifn1of ($(by), overriding appending prepending)
|
---|
664 | $(error kBuild: Invalid EXTENDS_BY value '$(by)' on '$(trg)'!)
|
---|
665 | endif
|
---|
666 |
|
---|
667 | # Inherit the properties.
|
---|
668 | $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties)), $(eval $(def_inherit_one)))
|
---|
669 | $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties_now_l)), $(eval $(def_inherit_one_$(by)_now_l)))
|
---|
670 | $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties_now_r)), $(eval $(def_inherit_one_$(by)_now_r)))
|
---|
671 | $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties_deferred)), $(eval $(def_inherit_one_$(by)_deferred)))
|
---|
672 | $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties_deferred_l)), $(eval $(def_inherit_one_$(by)_deferred_l)))
|
---|
673 | $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties_deferred_r)), $(eval $(def_inherit_one_$(by)_deferred_r)))
|
---|
674 |
|
---|
675 | # Mark the target as done.
|
---|
676 | $(trg)_EXTENDS_STATUS_ := 42
|
---|
677 | else
|
---|
678 | # Check for inheritance loops.
|
---|
679 | ifneq ($($(trg)_EXTENDS_STATUS_),42)
|
---|
680 | $(error kBuild: Target inheritance loop! target=$(trg) $(trg)_EXTENDS_STATUS_=$($(trg)_EXTENDS_STATUS_))
|
---|
681 | endif
|
---|
682 | endif
|
---|
683 | endif
|
---|
684 |
|
---|
685 | # Keyword inheritance.
|
---|
686 | $(foreach prefix_keyword, $(join $(_KEYWORDS_PREFIX), $(addprefix :,$(_KEYWORDS_EXTENDS))), $(evalval def_inherit_keyword))
|
---|
687 |
|
---|
688 | endef # def_inherit
|
---|
689 |
|
---|
690 |
|
---|
691 | #
|
---|
692 | # Load global units before doing any inheriting so they can add new properties.
|
---|
693 | #
|
---|
694 | # This only applies to the guys listed in the global USES since there is
|
---|
695 | # no reliable way to deal with things on a target level without first
|
---|
696 | # applying templates. So, to avoid having USES mess up all targets,
|
---|
697 | # we'll make the global and per-target USES property work differently:
|
---|
698 | # The global USES does not apply to targets, just globally.
|
---|
699 | #
|
---|
700 |
|
---|
701 | ## Unit load function.
|
---|
702 | # @param loading The unit name
|
---|
703 | define def_unit_load_function
|
---|
704 | ifndef UNIT_$(loading)
|
---|
705 | UNIT_$(loading)_KMK_FILE := $(firstword $(foreach path, $(KBUILD_UNIT_PATHS) $(KBUILD_PATH)/units $(KBUILD_DEFAULT_PATHS), $(wildcard $(path)/$(loading).kmk)))
|
---|
706 | ifeq ($(UNIT_$(loading)_KMK_FILE),)
|
---|
707 | $(error kBuild: Cannot find include file for the unit '$(loading)'! Searched: $(KBUILD_UNIT_PATHS) $(KBUILD_PATH)/units $(KBUILD_DEFAULT_PATHS))
|
---|
708 | endif
|
---|
709 | include $(UNIT_$(loading)_KMK_FILE)
|
---|
710 | ifndef UNIT_$(loading)
|
---|
711 | $(warning kBuild: UNIT_$(loading) was not defined by $(UNIT_$(loading)_KMK_FILE)!)
|
---|
712 | endif
|
---|
713 | endif
|
---|
714 | endef # def_unit_load_function
|
---|
715 |
|
---|
716 | $(foreach loading, \
|
---|
717 | $(USES.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \
|
---|
718 | $(USES.$(KBUILD_TARGET_CPU)) \
|
---|
719 | $(USES.$(KBUILD_TARGET_ARCH)) \
|
---|
720 | $(USES.$(KBUILD_TARGET)) \
|
---|
721 | $(USES.$(KBUILD_HOST).$(KBUILD_HOST_ARCH)) \
|
---|
722 | $(USES.$(KBUILD_HOST_CPU)) \
|
---|
723 | $(USES.$(KBUILD_HOST_ARCH)) \
|
---|
724 | $(USES.$(KBUILD_TARGET)) \
|
---|
725 | $(USES.$(KBUILD_TYPE)) \
|
---|
726 | $(USES),$(evalval def_unit_load_function))
|
---|
727 |
|
---|
728 |
|
---|
729 | #
|
---|
730 | # Determin all the templates that is being used and make
|
---|
731 | # sure they are present before we try collect keywords.
|
---|
732 | #
|
---|
733 | _TEMPLATES := $(TEMPLATE)
|
---|
734 | define def_templates
|
---|
735 | ifdef $(target)_TEMPLATE
|
---|
736 | ifneq ("$($(target)_TEMPLATE)","$(strip $($(target)_TEMPLATE))")
|
---|
737 | $$(error kBuild: The template name of target '$(target)' contains tabs ($($(target)_TEMPLATE))). Please remove them)
|
---|
738 | endif
|
---|
739 | _TEMPLATES += $($(target)_TEMPLATE)
|
---|
740 | endif
|
---|
741 | endef # def_templates
|
---|
742 | $(foreach target, $(_ALL_TARGETS), $(eval $(def_templates)))
|
---|
743 | _TEMPLATES := $(sort $(_TEMPLATES))
|
---|
744 |
|
---|
745 | ## Template load function.
|
---|
746 | # @param loading The template name. This is prefixed.
|
---|
747 | define def_templates_load_function
|
---|
748 | ifndef TEMPLATE_$(loading)
|
---|
749 | TEMPLATE_$(loading)_KMK_FILE := $(firstword $(foreach path, $(KBUILD_TEMPLATE_PATHS) $(KBUILD_PATH)/templates $(KBUILD_DEFAULT_PATHS), $(wildcard $(path)/$(loading).kmk)))
|
---|
750 | ifeq ($(TEMPLATE_$(loading)_KMK_FILE),)
|
---|
751 | $(error kBuild: Cannot find include file for the template '$(loading)'! Searched: $(KBUILD_TEMPLATE_PATHS) $(KBUILD_PATH)/templates $(KBUILD_DEFAULT_PATHS))
|
---|
752 | endif
|
---|
753 | include $(TEMPLATE_$(loading)_KMK_FILE)
|
---|
754 | ifndef TEMPLATE_$(loading)
|
---|
755 | $(warning kBuild: TEMPLATE_$(loading) was not defined by $(TEMPLATE_$(loading)_KMK_FILE)!)
|
---|
756 | endif
|
---|
757 | endif
|
---|
758 | endef # def_templates_load_function
|
---|
759 | $(foreach loading, $(_TEMPLATES), $(evalval def_templates_load_function))
|
---|
760 |
|
---|
761 |
|
---|
762 | #
|
---|
763 | # Determin the keywords required for correct inherting and setup keyword inheritance.
|
---|
764 | #
|
---|
765 | # This means walking all the lists of immediate template and targets and
|
---|
766 | # pick up all the BLD_T* keywords. Since templates that are referenced
|
---|
767 | # indirectly in the inheritance hierarchy, the result from this exercise
|
---|
768 | # might not be 100% accurate... :-/
|
---|
769 | #
|
---|
770 | _BLD_TYPES := $(KBUILD_TYPE)
|
---|
771 | _BLD_TARGETS := $(KBUILD_TARGET) $(KBUILD_HOSTS)
|
---|
772 | _BLD_ARCHES := $(KBUILD_TARGET_ARCH) $(KBUILD_HOST_ARCH)
|
---|
773 | _BLD_CPUS := $(KBUILD_TARGET_CPU) $(KBUILD_HOST_CPU)
|
---|
774 |
|
---|
775 | define def_collect_bld_xyz
|
---|
776 | ifdef $(src)_BLD_TYPE
|
---|
777 | ifn1of ($($(src)_BLD_TYPE), $(KBUILD_BLD_TYPES))
|
---|
778 | $(error kBuild: $(src)_BLD_TYPE=$($(src)_BLD_TYPE) not in KBUILD_BLD_TYPES={$(KBUILD_BLD_TYPES)}!)
|
---|
779 | endif
|
---|
780 | _BLD_TYPES += $($(src)_BLD_TYPE)
|
---|
781 | endif
|
---|
782 | ifdef $(src)_BLD_TRG
|
---|
783 | ifn1of ($($(src)_BLD_TRG), $(KBUILD_OSES))
|
---|
784 | $(error kBuild: $(src)_BLD_TRG=$($(src)_BLD_TRG) not in KBUILD_OSES={$(KBUILD_OSES)}!)
|
---|
785 | endif
|
---|
786 | _BLD_TARGETS += $($(src)_BLD_TRG)
|
---|
787 | endif
|
---|
788 | ifdef $(src)_BLD_TRG_ARCH
|
---|
789 | ifn1of ($($(src)_BLD_TRG_ARCH), $(KBUILD_ARCHES))
|
---|
790 | $(error kBuild: $(src)_BLD_TRG_ARCH=$($(src)_BLD_TRG_ARCH) not in KBUILD_ARCHES={$(KBUILD_ARCHES)}!)
|
---|
791 | endif
|
---|
792 | _BLD_ARCHES += $($(src)_BLD_TRG_ARCH)
|
---|
793 | endif
|
---|
794 | ifdef $(src)_BLD_TRG_CPU
|
---|
795 | if1of ($($(src)_BLD_CPU), $(KBUILD_ARCHES) $(KBUILD_OSES) $(KBUILD_BLD_TYPES))
|
---|
796 | $(error kBuild: $(src)_BLD_TRG_CPU=$($(src)_BLD_TRG_CPU) found in KBUILD_ARCHES, KBUILD_OSES or KBUILD_BLD_TYPES!)
|
---|
797 | endif
|
---|
798 | _BLD_CPUS += $($(src)_BLD_TRG_CPU)
|
---|
799 | endif
|
---|
800 | endef # def_collect_bld_xyz
|
---|
801 | $(foreach src, $(addprefix TEMPLATE_, $(_TEMPLATES)) $(_ALL_TARGETS) \
|
---|
802 | ,$(evalval def_collect_bld_xyz))
|
---|
803 |
|
---|
804 | # Drop duplicate values.
|
---|
805 | # WARNING! These list might not include keywords only involved in inheritance.
|
---|
806 | _BLD_TYPES := $(sort $(_BLD_TYPES))
|
---|
807 | _BLD_TARGETS := $(sort $(_BLD_TARGETS))
|
---|
808 | _BLD_ARCHES := $(sort $(_BLD_ARCHES))
|
---|
809 | _BLD_CPUS := $(sort $(_BLD_CPUS))
|
---|
810 |
|
---|
811 | ## Look for keywords which extends others and order them.
|
---|
812 | # @param keyword
|
---|
813 | # @param prefix
|
---|
814 | # @param valid
|
---|
815 | define def_keyword_ordering
|
---|
816 | # Check for EXTENDS, fix and validate it if found.
|
---|
817 | local src := $(strip $($(prefix)_$(keyword)_EXTENDS))
|
---|
818 | ifneq ($(src),)
|
---|
819 | ifndef $(prefix)_$(keyword)_EXTENDS_STATUS_
|
---|
820 | ifn1of ($(src), $(valid))
|
---|
821 | $(error kBuild: $(keyword) tries to extend unknown keyword '$(src)'! (known = $(valid)))
|
---|
822 | endif
|
---|
823 |
|
---|
824 | # Recursivly process the parent (src).
|
---|
825 | ifneq ($($(prefix)_$(src)_EXTENDS_STATUS_),42)
|
---|
826 | $(prefix)_$(keyword)_EXTENDS_STATUS_ := 0
|
---|
827 | # 'foreach' will create 'keyword' in a new variable context hiding
|
---|
828 | # out current variable. 'src' OTOH will be overwritten.
|
---|
829 | $(foreach keyword, $(src), $(evalval def_keyword_ordering))
|
---|
830 | local src := $(strip $($(prefix)_$(keyword)_EXTENDS))
|
---|
831 | endif
|
---|
832 |
|
---|
833 | # Check and strip EXTENDS_BY.
|
---|
834 | local by = $(strip $($(prefix)_$(keyword)_EXTENDS_BY))
|
---|
835 | ifeq ($(by),)
|
---|
836 | local by = overriding
|
---|
837 | else ifn1of ($(by), overriding appending prepending)
|
---|
838 | $(error kBuild: Invalid EXTENDS_BY value '$(by)' on '$(keyword)'!)
|
---|
839 | endif
|
---|
840 |
|
---|
841 | # Update the attributes with stripped
|
---|
842 | $(prefix)_$(keyword)_EXTENDS_BY := $(by)
|
---|
843 | $(prefix)_$(keyword)_EXTENDS := $(src)
|
---|
844 |
|
---|
845 | # Add it to the list and mark it as done.
|
---|
846 | _KEYWORDS_EXTENDS += $(keyword)
|
---|
847 | _KEYWORDS_PREFIX += $(prefix)
|
---|
848 | $(prefix)_$(keyword)_EXTENDS_STATUS_ := 42
|
---|
849 | else
|
---|
850 | # Check for inheritance loops.
|
---|
851 | ifneq ($($(trg)_EXTENDS_STATUS_),42)
|
---|
852 | $(error kBuild: Keyword inheritance loop! keyword=$(keyword) $(prefix)_$(keyword)_EXTENDS_STATUS_=$($(prefix)_$(keyword)_EXTENDS_STATUS_))
|
---|
853 | endif
|
---|
854 | endif
|
---|
855 | else
|
---|
856 | # Add it to the ordered list and mark it as done.
|
---|
857 | _KEYWORDS_ORDERED += $(keyword)
|
---|
858 | $(prefix)_$(src)_EXTENDS_STATUS_ := 42
|
---|
859 | endif
|
---|
860 | endef # def_keyword_ordering
|
---|
861 | $(eval-opt-var def_keyword_ordering)
|
---|
862 |
|
---|
863 | # Look for keywords which extends others and their parents, and from this
|
---|
864 | # construct two lists.
|
---|
865 | _KEYWORDS_ORDERED :=
|
---|
866 | _KEYWORDS_EXTENDS :=
|
---|
867 | _KEYWORDS_PREFIX :=
|
---|
868 |
|
---|
869 | prefix := BLD_TYPE
|
---|
870 | valid := $(KBUILD_BLD_TYPES)
|
---|
871 | $(foreach keyword, $(_BLD_TYPES) , $(evalval def_keyword_ordering))
|
---|
872 |
|
---|
873 | prefix := BLD_TRG
|
---|
874 | valid := $(KBUILD_OSES)
|
---|
875 | $(foreach keyword, $(_BLD_TARGETS), $(evalval def_keyword_ordering))
|
---|
876 |
|
---|
877 | prefix := BLD_ARCH
|
---|
878 | valid := $(KBUILD_ARCHES)
|
---|
879 | $(foreach keyword, $(_BLD_ARCHES) , $(evalval def_keyword_ordering))
|
---|
880 |
|
---|
881 | prefix := BLD_CPU
|
---|
882 | valid := $(KBUILD_CPUS)
|
---|
883 | $(foreach keyword, $(_BLD_CPUS) , $(evalval def_keyword_ordering))
|
---|
884 |
|
---|
885 | ## @todo Inherit bld_trg.bld_arch for too?
|
---|
886 |
|
---|
887 | # Construct all the possible keywords.
|
---|
888 | _KEYWORDS := $(_KEYWORDS_ORDERED) $(_KEYWORDS_EXTENDS) \
|
---|
889 | $(foreach bld_trg,$(_BLD_TARGETS),$(addprefix $(bld_trg).,$(_BLD_ARCHES)))
|
---|
890 |
|
---|
891 | ifdef KBUILD_PROFILE_SELF
|
---|
892 | $(evalcall def_profile_self, done keywords)
|
---|
893 | endif
|
---|
894 |
|
---|
895 |
|
---|
896 | #
|
---|
897 | # Target inheritance.
|
---|
898 | #
|
---|
899 | # This has to be done on a per target list basis as to avoid adding
|
---|
900 | # incorrect properties that will wast memory, time, and may confuse
|
---|
901 | # later strictness checks. This also has to be done *before* templates
|
---|
902 | # are applied to the targets. Since we're doing that part rather
|
---|
903 | # early on, the target inheritance feature is a bit restricted at
|
---|
904 | # the moment. However, this will be addressed in a little(?) while.
|
---|
905 | #
|
---|
906 |
|
---|
907 | src_prefix :=
|
---|
908 | load_function :=
|
---|
909 | properties_deferred_l :=
|
---|
910 | properties_deferred_r :=
|
---|
911 |
|
---|
912 | # Fetches.
|
---|
913 | properties := $(PROPS_FETCHES_SINGLE)
|
---|
914 | properties_now_l := $(PROPS_FETCHES_ACCUMULATE_L)
|
---|
915 | properties_now_r := $(PROPS_FETCHES_ACCUMULATE_R)
|
---|
916 | properties_deferred := $(PROPS_FETCHES_DEFERRED)
|
---|
917 | $(foreach trg, $(_ALL_FETCHES),$(evalval def_inherit))
|
---|
918 |
|
---|
919 | ## Patches. - not implemented yet.
|
---|
920 | #properties := $(PROPS_PATCHES_SINGLE)
|
---|
921 | #properties_now_l := $(PROPS_PATCHES_ACCUMULATE_L)
|
---|
922 | #properties_now_r := $(PROPS_PATCHES_ACCUMULATE_R)
|
---|
923 | #properties_deferred := $(PROPS_PATCHES_DEFERRED)
|
---|
924 | #$(foreach trg, $(_ALL_PATCHES),$(evalval def_inherit))
|
---|
925 |
|
---|
926 | # Programs and build programs.
|
---|
927 | properties := $(PROPS_PROGRAMS_SINGLE)
|
---|
928 | properties_now_l := $(PROPS_PROGRAMS_ACCUMULATE_L)
|
---|
929 | properties_now_r := $(PROPS_PROGRAMS_ACCUMULATE_R)
|
---|
930 | properties_deferred := $(PROPS_PROGRAMS_DEFERRED)
|
---|
931 | $(foreach trg, $(_ALL_BLDPROGS) $(_ALL_PROGRAMS),$(evalval def_inherit))
|
---|
932 |
|
---|
933 | # Libraries and import libraries.
|
---|
934 | properties := $(PROPS_LIBRARIES_SINGLE)
|
---|
935 | properties_now_l := $(PROPS_LIBRARIES_ACCUMULATE_L)
|
---|
936 | properties_now_r := $(PROPS_LIBRARIES_ACCUMULATE_R)
|
---|
937 | properties_deferred := $(PROPS_LIBRARIES_DEFERRED)
|
---|
938 | if1of ($(KBUILD_TARGET), nt os2 win)
|
---|
939 | $(foreach trg, $(_ALL_LIBRARIES) $(_ALL_IMPORT_LIBS),$(evalval def_inherit))
|
---|
940 | else
|
---|
941 | $(foreach trg, $(_ALL_LIBRARIES),$(evalval def_inherit))
|
---|
942 | endif
|
---|
943 |
|
---|
944 | # DLLs.
|
---|
945 | properties := $(PROPS_DLLS_SINGLE)
|
---|
946 | properties_now_l := $(PROPS_DLLS_ACCUMULATE_L)
|
---|
947 | properties_now_r := $(PROPS_DLLS_ACCUMULATE_R)
|
---|
948 | properties_deferred := $(PROPS_DLLS_DEFERRED)
|
---|
949 | if1of ($(KBUILD_TARGET), nt os2 win)
|
---|
950 | $(foreach trg, $(_ALL_DLLS),$(evalval def_inherit))
|
---|
951 | else
|
---|
952 | $(foreach trg, $(_ALL_DLLS) $(_ALL_IMPORT_LIBS),$(evalval def_inherit))
|
---|
953 | endif
|
---|
954 |
|
---|
955 | # System modules.
|
---|
956 | properties := $(PROPS_SYSMODS_SINGLE)
|
---|
957 | properties_now_l := $(PROPS_SYSMODS_ACCUMULATE_L)
|
---|
958 | properties_now_r := $(PROPS_SYSMODS_ACCUMULATE_R)
|
---|
959 | properties_deferred := $(PROPS_SYSMODS_DEFERRED)
|
---|
960 | $(foreach trg, $(_ALL_SYSMODS),$(evalval def_inherit))
|
---|
961 |
|
---|
962 | # Misc binaries.
|
---|
963 | properties := $(PROPS_MISCBINS_SINGLE)
|
---|
964 | properties_now_l := $(PROPS_MISCBINS_ACCUMULATE_L)
|
---|
965 | properties_now_r := $(PROPS_MISCBINS_ACCUMULATE_R)
|
---|
966 | properties_deferred := $(PROPS_MISCBINS_DEFERRED)
|
---|
967 | $(foreach trg, $(_ALL_MISCBINS),$(evalval def_inherit))
|
---|
968 |
|
---|
969 | # Installs.
|
---|
970 | properties := $(PROPS_INSTALLS_SINGLE)
|
---|
971 | properties_now_l := $(PROPS_INSTALLS_ACCUMULATE_L)
|
---|
972 | properties_now_r := $(PROPS_INSTALLS_ACCUMULATE_R)
|
---|
973 | properties_deferred := $(PROPS_INSTALLS_DEFERRED)
|
---|
974 | $(foreach trg, $(_ALL_INSTALLS),$(evalval def_inherit))
|
---|
975 |
|
---|
976 | ifdef KBUILD_PROFILE_SELF
|
---|
977 | $(evalcall def_profile_self, done target inheritance)
|
---|
978 | endif
|
---|
979 |
|
---|
980 |
|
---|
981 | #
|
---|
982 | # Template Inheritance.
|
---|
983 | #
|
---|
984 | # This is much the same as with target inheritance, except we cannot
|
---|
985 | # restrict the properties involved since we haven't got a clue which
|
---|
986 | # target platforms/archs are using them. But, we can drop the instance
|
---|
987 | # expansion we're doing for targets since there won't be any more
|
---|
988 | # changes to either the source nor the target templates beyond this
|
---|
989 | # exercise.
|
---|
990 | #
|
---|
991 |
|
---|
992 | src_prefix := TEMPLATE_
|
---|
993 | load_function := def_templates_load_function
|
---|
994 | properties :=
|
---|
995 | properties_now_l :=
|
---|
996 | properties_now_r :=
|
---|
997 | properties_deferred := $(PROPS_SINGLE) $(PROPS_DEFERRED)
|
---|
998 | properties_deferred_l := $(PROPS_ACCUMULATE_L)
|
---|
999 | properties_deferred_r := $(PROPS_ACCUMULATE_R)
|
---|
1000 | $(foreach trg, $(addprefix TEMPLATE_,$(_TEMPLATES)),$(evalval def_inherit))
|
---|
1001 |
|
---|
1002 | # done inheriting.
|
---|
1003 | src_prefix :=
|
---|
1004 | load_function :=
|
---|
1005 | properties :=
|
---|
1006 | properties_now_l :=
|
---|
1007 | properties_now_r :=
|
---|
1008 | properties_deferred :=
|
---|
1009 | properties_deferred_l :=
|
---|
1010 | properties_deferred_r :=
|
---|
1011 |
|
---|
1012 | ifdef KBUILD_PROFILE_SELF
|
---|
1013 | $(evalcall def_profile_self, done template inheritance)
|
---|
1014 | endif
|
---|
1015 |
|
---|
1016 |
|
---|
1017 |
|
---|
1018 |
|
---|
1019 | #
|
---|
1020 | # Template/Target Expansion.
|
---|
1021 | #
|
---|
1022 | # Extend all targets with the values from the template. Doing this up front
|
---|
1023 | # allows more generic code and less mess down in the pass 2 target handling.
|
---|
1024 | # However it does eat a good deal of memory.
|
---|
1025 | #
|
---|
1026 |
|
---|
1027 | define def_inherit_template_workaround_target
|
---|
1028 | local _tmpl := $(firstword $($(target)_TEMPLATE) $(TEMPLATE))
|
---|
1029 | local _bld_type := $(firstword $($(target)_BLD_TYPE) $(TEMPLATE_$(_tmpl)_BLD_TYPE) $(KBUILD_TYPE))
|
---|
1030 | local _bld_trg := $(firstword $($(target)_BLD_TRG) $(TEMPLATE_$(_tmpl)_BLD_TRG) $(KBUILD_TARGET))
|
---|
1031 | local _bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(TEMPLATE_$(_tmpl)_BLD_TRG_ARCH) $(KBUILD_TARGET_ARCH))
|
---|
1032 | local _bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(TEMPLATE_$(_tmpl)_BLD_TRG_CPU) $(KBUILD_TARGET_CPU))
|
---|
1033 | $(kb-exp-tmpl 1,$(target),$(_bld_trg),$(_bld_trg_arch),$(_bld_trg_cpu),$(_bld_type))
|
---|
1034 | endef # def_inherit_template_workaround_target
|
---|
1035 | #$(kb-exp-tmpl 1,$(_ALL_TARGET_TARGETS),$(KBUILD_TARGET),$(KBUILD_TARGET_ARCH),$(KBUILD_TARGET_CPU),$(KBUILD_TYPE))
|
---|
1036 | $(foreach target,$(_ALL_TARGET_TARGETS),$(evalval def_inherit_template_workaround_target))
|
---|
1037 |
|
---|
1038 | define def_inherit_template_workaround_host
|
---|
1039 | local _tmpl := $(firstword $($(target)_TEMPLATE) $(TEMPLATE))
|
---|
1040 | local _bld_type := $(firstword $($(target)_BLD_TYPE) $(TEMPLATE_$(_tmpl)_BLD_TYPE) $(KBUILD_TYPE))
|
---|
1041 | local _bld_trg := $(firstword $($(target)_BLD_TRG) $(TEMPLATE_$(_tmpl)_BLD_TRG) $(KBUILD_HOST))
|
---|
1042 | local _bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(TEMPLATE_$(_tmpl)_BLD_TRG_ARCH) $(KBUILD_HOST_ARCH))
|
---|
1043 | local _bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(TEMPLATE_$(_tmpl)_BLD_TRG_CPU) $(KBUILD_HOST_CPU))
|
---|
1044 | $(kb-exp-tmpl 1,$(target),$(_bld_trg),$(_bld_trg_arch),$(_bld_trg_cpu),$(_bld_type))
|
---|
1045 | endef # def_inherit_template_workaround_target
|
---|
1046 | #$(kb-exp-tmpl 1,$(_ALL_HOST_TARGETS),$(KBUILD_HOST),$(KBUILD_HOST_ARCH),$(KBUILD_HOST_CPU),$(KBUILD_TYPE))
|
---|
1047 | $(foreach target,$(_ALL_HOST_TARGETS),$(evalval def_inherit_template_workaround_host))
|
---|
1048 |
|
---|
1049 | ifdef KBUILD_PROFILE_SELF
|
---|
1050 | $(evalcall def_profile_self, done template/target expansion)
|
---|
1051 | endif
|
---|
1052 |
|
---|
1053 |
|
---|
1054 | #
|
---|
1055 | # Include tools, sdks and units.
|
---|
1056 | #
|
---|
1057 | # The first part of this exercise is to figure out which TOOLS and SDKS
|
---|
1058 | # that should be included.
|
---|
1059 | #
|
---|
1060 | _TOOLS := $(TOOL.$(KBUILD_TARGET)) $(TOOL.$(KBUILD_TARGET_ARCH)) $(TOOL.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \
|
---|
1061 | $(TOOL.$(KBUILD_HOST)) $(TOOL.$(KBUILD_HOST_ARCH)) $(TOOL.$(KBUILD_HOST).$(KBUILD_HOST_ARCH)) \
|
---|
1062 | $(TOOL)
|
---|
1063 | _SDKS := $(SDKS.$(KBUILD_TARGET)) $(SDKS.$(KBUILD_TARGET_ARCH)) $(SDKS.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \
|
---|
1064 | $(SDKS.$(KBUILD_HOST)) $(SDKS.$(KBUILD_HOST_ARCH)) $(SDKS.$(KBUILD_HOST).$(KBUILD_HOST_ARCH)) \
|
---|
1065 | $(SDKS.$(KBUILD_TYPE)) \
|
---|
1066 | $(SDKS)
|
---|
1067 | _USES := $(USES.$(KBUILD_TARGET)) $(USES.$(KBUILD_TARGET_ARCH)) $(USES.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \
|
---|
1068 | $(USES.$(KBUILD_HOST)) $(USES.$(KBUILD_HOST_ARCH)) $(USES.$(KBUILD_HOST).$(KBUILD_HOST_ARCH)) \
|
---|
1069 | $(USES.$(KBUILD_TYPE)) \
|
---|
1070 | $(USES)
|
---|
1071 | define def_tools_sdks_target_source
|
---|
1072 | $(eval _TOOLS += $(foreach prop, $(PROPS_TOOLS), \
|
---|
1073 | $($(source)_$(prop).$(_bld_trg)) \
|
---|
1074 | $($(target)_$(source)_$(prop).$(_bld_trg)) \
|
---|
1075 | $($(source)_$(prop).$(_bld_trg).$(_bld_trg_arch)) \
|
---|
1076 | $($(target)_$(source)_$(prop).$(_bld_trg).$(_bld_trg_arch)) \
|
---|
1077 | $($(source)_$(prop).$(_bld_trg_arch)) \
|
---|
1078 | $($(target)_$(source)_$(prop).$(_bld_trg_arch)) \
|
---|
1079 | $($(source)_$(prop)) \
|
---|
1080 | $($(target)_$(source)_$(prop))))
|
---|
1081 | $(eval _SDKS += \
|
---|
1082 | $($(source)_SDKS.$(_bld_trg)) \
|
---|
1083 | $($(target)_$(source)_SDKS.$(_bld_trg)) \
|
---|
1084 | $($(source)_SDKS.$(_bld_trg).$(_bld_trg_arch)) \
|
---|
1085 | $($(target)_$(source)_SDKS.$(_bld_trg).$(_bld_trg_arch)) \
|
---|
1086 | $($(source)_SDKS.$(_bld_trg_arch)) \
|
---|
1087 | $($(target)_$(source)_SDKS.$(_bld_trg_arch)) \
|
---|
1088 | $($(source)_SDKS.$(KBUILD_TYPE)) \
|
---|
1089 | $($(target)_$(source)_SDKS.$(KBUILD_TYPE)) \
|
---|
1090 | $($(source)_SDKS) \
|
---|
1091 | $($(target)_$(source)_SDKS))
|
---|
1092 | $(eval _USES += \
|
---|
1093 | $($(source)_USES.$(_bld_trg)) \
|
---|
1094 | $($(target)_$(source)_USES.$(_bld_trg)) \
|
---|
1095 | $($(source)_USES.$(_bld_trg).$(_bld_trg_arch)) \
|
---|
1096 | $($(target)_$(source)_USES.$(_bld_trg).$(_bld_trg_arch)) \
|
---|
1097 | $($(source)_USES.$(_bld_trg_arch)) \
|
---|
1098 | $($(target)_$(source)_USES.$(_bld_trg_arch)) \
|
---|
1099 | $($(source)_USES.$(KBUILD_TYPE)) \
|
---|
1100 | $($(target)_$(source)_USES.$(KBUILD_TYPE)) \
|
---|
1101 | $($(source)_USES) \
|
---|
1102 | $($(target)_$(source)_USES))
|
---|
1103 | endef # def_tools_sdks_target_source
|
---|
1104 | $(eval-opt-var def_tools_sdks_target_source)
|
---|
1105 |
|
---|
1106 | define def_tools_sdks_target
|
---|
1107 | local _bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE))
|
---|
1108 | local _bld_trg := $(firstword $($(target)_BLD_TRG) $(bld_trg))
|
---|
1109 | local _bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(bld_trg_arch))
|
---|
1110 | local _bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(bld_trg_cpu))
|
---|
1111 |
|
---|
1112 | $(eval _TOOLS += $(foreach prop, $(PROPS_TOOLS), \
|
---|
1113 | $($(target)_$(prop).$(_bld_trg)) \
|
---|
1114 | $($(target)_$(prop).$(_bld_trg_arch)) \
|
---|
1115 | $($(target)_$(prop).$(_bld_trg).$(_bld_trg_arch)) \
|
---|
1116 | $($(target)_$(prop))))
|
---|
1117 | $(eval _SDKS += \
|
---|
1118 | $($(target)_SDKS.$(_bld_trg)) \
|
---|
1119 | $($(target)_SDKS.$(_bld_trg_arch)) \
|
---|
1120 | $($(target)_SDKS.$(_bld_trg).$(_bld_trg_arch)) \
|
---|
1121 | $($(target)_SDKS))
|
---|
1122 | $(eval _USES += \
|
---|
1123 | $($(target)_USES.$(_bld_trg)) \
|
---|
1124 | $($(target)_USES.$(_bld_trg_arch)) \
|
---|
1125 | $($(target)_USES.$(_bld_trg).$(_bld_trg_arch)) \
|
---|
1126 | $($(target)_USES))
|
---|
1127 | $(foreach source, \
|
---|
1128 | $($(target)_SOURCES.$(_bld_trg)) \
|
---|
1129 | $($(target)_SOURCES.$(_bld_trg_arch)) \
|
---|
1130 | $($(target)_SOURCES.$(_bld_trg).$(_bld_trg_arch)) \
|
---|
1131 | $($(target)_SOURCES.$(_bld_trg_cpu)) \
|
---|
1132 | $($(target)_SOURCES.$(_bld_type)) \
|
---|
1133 | $($(target)_SOURCES) \
|
---|
1134 | , $(evalval def_tools_sdks_target_source))
|
---|
1135 | endef # def_tools_sdks_target
|
---|
1136 | $(eval-opt-var def_tools_sdks_target)
|
---|
1137 |
|
---|
1138 | define def_tools_srcname_target
|
---|
1139 | local _bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE))
|
---|
1140 | local _bld_trg := $(firstword $($(target)_BLD_TRG) $(bld_trg))
|
---|
1141 | local _bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(bld_trg_arch))
|
---|
1142 | local _bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(bld_trg_cpu))
|
---|
1143 |
|
---|
1144 | $(foreach source, $(notdir\
|
---|
1145 | $($(target)_SOURCES.$(_bld_trg)) \
|
---|
1146 | $($(target)_SOURCES.$(_bld_trg_arch)) \
|
---|
1147 | $($(target)_SOURCES.$(_bld_trg).$(_bld_trg_arch)) \
|
---|
1148 | $($(target)_SOURCES.$(_bld_trg_cpu)) \
|
---|
1149 | $($(target)_SOURCES.$(_bld_type)) \
|
---|
1150 | $($(target)_SOURCES) \
|
---|
1151 | ), $(evalval def_tools_sdks_target_source))
|
---|
1152 | endef # def_tools_srcname_target
|
---|
1153 | $(eval-opt-var def_tools_srcname_target)
|
---|
1154 |
|
---|
1155 | bld_trg := $(KBUILD_TARGET)
|
---|
1156 | bld_trg_arch := $(KBUILD_TARGET_ARCH)
|
---|
1157 | bld_trg_cpu := $(KBUILD_TARGET_CPU)
|
---|
1158 | $(foreach target, $(_ALL_TARGET_TARGETS), $(evalval def_tools_sdks_target))
|
---|
1159 | $(foreach target, $(_ALL_SRCNAME_TARGETS), $(evalval def_tools_srcname_target))
|
---|
1160 |
|
---|
1161 | bld_trg := $(KBUILD_HOST)
|
---|
1162 | bld_trg_arch := $(KBUILD_HOST_ARCH)
|
---|
1163 | bld_trg_cpu := $(KBUILD_HOST_CPU)
|
---|
1164 | $(foreach target, $(_ALL_HOST_TARGETS), $(evalval def_tools_sdks_target))
|
---|
1165 |
|
---|
1166 | _TOOLS := $(sort $(_TOOLS))
|
---|
1167 | _SDKS := $(sort $(_SDKS))
|
---|
1168 |
|
---|
1169 | ## Tool load function.
|
---|
1170 | # @param loading The tool name
|
---|
1171 | define def_tools_load_function
|
---|
1172 | ifndef TOOL_$(loading)
|
---|
1173 | TOOL_$(loading)_KMK_FILE := $(firstword $(foreach path, $(KBUILD_TOOL_PATHS) $(KBUILD_PATH)/tools $(KBUILD_DEFAULT_PATHS), $(wildcard $(path)/$(loading).kmk)))
|
---|
1174 | ifeq ($(TOOL_$(loading)_KMK_FILE),)
|
---|
1175 | $(error kBuild: Cannot find include file for the tool '$(loading)'! Searched: $(KBUILD_TOOL_PATHS) $(KBUILD_PATH)/tools $(KBUILD_DEFAULT_PATHS))
|
---|
1176 | endif
|
---|
1177 | include $(TOOL_$(loading)_KMK_FILE)
|
---|
1178 | ifndef TOOL_$(loading)
|
---|
1179 | $(warning kBuild: TOOL_$(loading) was not defined by $(TOOL_$(loading)_KMK_FILE)!)
|
---|
1180 | endif
|
---|
1181 | endif
|
---|
1182 | endef # def_tools_include
|
---|
1183 |
|
---|
1184 | ## SDK load function.
|
---|
1185 | # @param loading The tool name
|
---|
1186 | define def_sdk_load_function
|
---|
1187 | ifndef SDK_$(loading)
|
---|
1188 | SDK_$(loading)_KMK_FILE := $(firstword $(foreach path, $(KBUILD_SDK_PATHS) $(KBUILD_PATH)/sdks $(KBUILD_DEFAULT_PATHS), $(wildcard $(path)/$(loading).kmk)))
|
---|
1189 | ifeq ($(SDK_$(loading)_KMK_FILE),)
|
---|
1190 | $(error kBuild: Cannot find include file for the SDK '$(loading)'! Searched: $(KBUILD_SDK_PATHS) $(KBUILD_PATH)/sdks $(KBUILD_DEFAULT_PATHS))
|
---|
1191 | endif
|
---|
1192 | include $(SDK_$(loading)_KMK_FILE)
|
---|
1193 | ifndef SDK_$(loading)
|
---|
1194 | $(warning kBuild: SDK_$(loading) was not defined by $(SDK_$(loading)_KMK_FILE)!)
|
---|
1195 | endif
|
---|
1196 | endif
|
---|
1197 | endef # def_sdk_load_function
|
---|
1198 |
|
---|
1199 |
|
---|
1200 | properties :=
|
---|
1201 | properties_now_l :=
|
---|
1202 | properties_now_r :=
|
---|
1203 | properties_deferred := $(PROPS_SINGLE) $(PROPS_DEFERRED)
|
---|
1204 | properties_deferred_l := $(PROPS_ACCUMULATE_L)
|
---|
1205 | properties_deferred_r := $(PROPS_ACCUMULATE_R)
|
---|
1206 |
|
---|
1207 | src_prefix := SDK_
|
---|
1208 | load_function := def_sdk_load_function
|
---|
1209 | $(foreach trg, $(addprefix SDK_,$(_SDKS)), $(evalval def_inherit))
|
---|
1210 |
|
---|
1211 | properties_deferred := $(PROPS_SINGLE) $(PROPS_DEFERRED) $(PROPS_TOOLS_ONLY)
|
---|
1212 | src_prefix := TOOL_
|
---|
1213 | load_function := def_tools_load_function
|
---|
1214 | $(foreach trg, $(addprefix TOOL_,$(_TOOLS)), $(evalval def_inherit))
|
---|
1215 |
|
---|
1216 | # done inheriting.
|
---|
1217 | src_prefix :=
|
---|
1218 | load_function :=
|
---|
1219 | properties :=
|
---|
1220 | properties_now_l :=
|
---|
1221 | properties_now_r :=
|
---|
1222 | properties_deferred :=
|
---|
1223 | properties_deferred_l :=
|
---|
1224 | properties_deferred_r :=
|
---|
1225 |
|
---|
1226 | # No inheriting for the uses, they're just global 'code'.
|
---|
1227 | $(foreach loading, $(_USES), $(evalval def_unit_load_function))
|
---|
1228 |
|
---|
1229 |
|
---|
1230 | ifdef KBUILD_PROFILE_SELF
|
---|
1231 | $(evalcall def_profile_self, done tools + sdks + units)
|
---|
1232 | endif
|
---|
1233 |
|
---|
1234 |
|
---|
1235 |
|
---|
1236 | #
|
---|
1237 | #
|
---|
1238 | # Target lists - Pass 1
|
---|
1239 | #
|
---|
1240 | # This pass is for defining variables that might be referenced in
|
---|
1241 | # properties of other targets.
|
---|
1242 | #
|
---|
1243 | #
|
---|
1244 |
|
---|
1245 | # Don't do anything for fetch targets (yet).
|
---|
1246 |
|
---|
1247 | ##
|
---|
1248 | # Link prolog for Pass 1.
|
---|
1249 | #
|
---|
1250 | # @param $(target) Normalized target name.
|
---|
1251 | # @param $(EXT) EXE,DLL,SYS,LIB.
|
---|
1252 | # @param $(EXTPRE) HOST or nothing.
|
---|
1253 | # @param $(definst) The default _INST value.
|
---|
1254 | # @param $(tool_prefix) LD or AR.
|
---|
1255 | # @param $(bld_trg_base_var) TARGET or PLATFORM.
|
---|
1256 | define def_pass1_link_common
|
---|
1257 |
|
---|
1258 | local bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE))
|
---|
1259 | local bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_$(bld_trg_base_var)))
|
---|
1260 | local bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_$(bld_trg_base_var)_ARCH))
|
---|
1261 | local bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_$(bld_trg_base_var)_CPU))
|
---|
1262 |
|
---|
1263 | local tool := $(call _TARGET_TOOL,$(target),$(tool_prefix))
|
---|
1264 | local name := $(firstword\
|
---|
1265 | $($(target)_NAME.$(bld_trg).$(bld_trg_arch).$(bld_type))\
|
---|
1266 | $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\
|
---|
1267 | $($(target)_NAME.$(bld_trg).$(bld_type))\
|
---|
1268 | $($(target)_NAME.$(bld_trg_arch))\
|
---|
1269 | $($(target)_NAME.$(bld_trg))\
|
---|
1270 | $($(target)_NAME.$(bld_type))\
|
---|
1271 | $($(target)_NAME)\
|
---|
1272 | $(target))
|
---|
1273 | local outbase := $(call TARGET_BASE,$(name),$(target))
|
---|
1274 | $(target)_0_OUTDIR:= $(patsubst %/,%,$(dir $(outbase)))
|
---|
1275 | $(call KB_FN_ASSIGN_DEPRECATED,PATH_$(target),$($(target)_0_OUTDIR), $(target)_0_OUTDIR)
|
---|
1276 |
|
---|
1277 | ## @todo fix the fun at the last line (AR != LIB => mess).
|
---|
1278 | local suff := $(firstword \
|
---|
1279 | $($(target)_$(EXT)SUFF.$(bld_trg).$(bld_trg_arch))\
|
---|
1280 | $($(target)_$(EXT)SUFF.$(bld_trg))\
|
---|
1281 | $($(target)_$(EXT)SUFF)\
|
---|
1282 | $(TOOL_$(tool)_$(tool_prefix)$(EXT)SUFF.$(bld_trg).$(bld_trg_arch))\
|
---|
1283 | $(TOOL_$(tool)_$(tool_prefix)$(EXT)SUFF.$(bld_trg))\
|
---|
1284 | $(TOOL_$(tool)_$(tool_prefix)$(EXT)SUFF)\
|
---|
1285 | $(if $(eq $(tool_prefix),AR),$(SUFF_LIB),$($(EXTPRE)SUFF_$(EXT))) )
|
---|
1286 | local out := $(outbase)$(suff)
|
---|
1287 |
|
---|
1288 | # Object directory target variable.
|
---|
1289 | $(target)_1_TARGET := $(out)
|
---|
1290 | $(call KB_FN_ASSIGN_DEPRECATED,TARGET_$(target),$($(target)_1_TARGET), $(target)_1_TARGET)
|
---|
1291 |
|
---|
1292 | # Staging and install directory target variables.
|
---|
1293 | local insttype := $(firstword \
|
---|
1294 | $($(target)_INSTTYPE) \
|
---|
1295 | $($(target)_INSTTYPE.$(bld_trg)) \
|
---|
1296 | $($(target)_INSTTYPE.$(bld_trg).$(bld_trg_arch)) \
|
---|
1297 | $($(target)_INSTTYPE.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
|
---|
1298 | $($(target)_INSTTYPE.$(bld_trg_arch)) \
|
---|
1299 | $($(target)_INSTTYPE.$(bld_trg_cpu)) \
|
---|
1300 | $($(target)_INSTTYPE.$(bld_type)) \
|
---|
1301 | )
|
---|
1302 | ifeq ($(insttype),)
|
---|
1303 | ifneq ($(firstword \
|
---|
1304 | $($(target)_NOINST) \
|
---|
1305 | $($(target)_NOINST.$(bld_trg)) \
|
---|
1306 | $($(target)_NOINST.$(bld_trg).$(bld_trg_arch)) \
|
---|
1307 | $($(target)_NOINST.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
|
---|
1308 | $($(target)_NOINST.$(bld_trg_arch)) \
|
---|
1309 | $($(target)_NOINST.$(bld_trg_cpu)) \
|
---|
1310 | $($(target)_NOINST.$(bld_type)) ),)
|
---|
1311 | local insttype := none
|
---|
1312 | else
|
---|
1313 | local insttype := both
|
---|
1314 | endif
|
---|
1315 | endif
|
---|
1316 | ifn1of ($(insttype), none both stage)
|
---|
1317 | $(error kBuild: Unknown value '$(insttype)' for '$(target)_INSTTYPE'. Valid values are 'none', 'both' and 'stage'.)
|
---|
1318 | endif
|
---|
1319 | $(target)_1_INSTTYPE := $(insttype)
|
---|
1320 |
|
---|
1321 | if1of ($(insttype), stage both)
|
---|
1322 | local stage := $(strip $(firstdefined \
|
---|
1323 | $(target)_STAGE.$(bld_trg).$(bld_trg_arch).$(bld_type) \
|
---|
1324 | $(target)_INST.$(bld_trg).$(bld_trg_arch).$(bld_type) \
|
---|
1325 | $(target)_STAGE.$(bld_trg).$(bld_trg_arch) \
|
---|
1326 | $(target)_INST.$(bld_trg).$(bld_trg_arch) \
|
---|
1327 | $(target)_STAGE.$(bld_trg).$(bld_type) \
|
---|
1328 | $(target)_INST.$(bld_trg).$(bld_type) \
|
---|
1329 | $(target)_STAGE.$(bld_trg_arch) \
|
---|
1330 | $(target)_INST.$(bld_trg_arch) \
|
---|
1331 | $(target)_STAGE.$(bld_trg) \
|
---|
1332 | $(target)_INST.$(bld_trg) \
|
---|
1333 | $(target)_STAGE.$(bld_type) \
|
---|
1334 | $(target)_INST.$(bld_type) \
|
---|
1335 | $(target)_STAGE \
|
---|
1336 | $(target)_INST \
|
---|
1337 | definst \
|
---|
1338 | ,value))
|
---|
1339 | $(target)_1_STAGE := $(stage)
|
---|
1340 | if "$(substr $(stage),-1,1)" == "/" # Multicast support requires addprefix/suffix.
|
---|
1341 | $(target)_1_STAGE_TARGET := $(addprefix $(PATH_STAGE)/,$(addsuffix $(notdir $(out)),$(stage)))
|
---|
1342 | else if "$(stage)" == ""
|
---|
1343 | $(target)_1_STAGE_TARGET := $(PATH_STAGE)/$(notdir $(out))
|
---|
1344 | else
|
---|
1345 | $(target)_1_STAGE_TARGET := $(addprefix $(PATH_STAGE)/,$(stage))
|
---|
1346 | endif
|
---|
1347 | else
|
---|
1348 | $(target)_1_STAGE :=
|
---|
1349 | $(target)_1_STAGE_TARGET :=
|
---|
1350 | endif
|
---|
1351 | INSTARGET_$(target) := $($(target)_1_STAGE_TARGET)
|
---|
1352 |
|
---|
1353 | if1of ($(insttype), both)
|
---|
1354 | local inst := $(strip $(firstdefined \
|
---|
1355 | $(target)_INST.$(bld_trg).$(bld_trg_arch).$(bld_type) \
|
---|
1356 | $(target)_INST.$(bld_trg).$(bld_trg_arch) \
|
---|
1357 | $(target)_INST.$(bld_trg).$(bld_type) \
|
---|
1358 | $(target)_INST.$(bld_trg_arch) \
|
---|
1359 | $(target)_INST.$(bld_trg) \
|
---|
1360 | $(target)_INST.$(bld_type) \
|
---|
1361 | $(target)_INST \
|
---|
1362 | definst \
|
---|
1363 | ,value))
|
---|
1364 | $(target)_1_INST := $(inst)
|
---|
1365 | if "$(substr $(inst),-1,1)" == "/" # Multicast support requires addprefix/suffix.
|
---|
1366 | $(target)_1_INST_TARGET := $(addprefix $(PATH_INS)/,$(addsuffix $(notdir $(out)),$(inst)))
|
---|
1367 | else if "$(inst)" == ""
|
---|
1368 | $(target)_1_INST_TARGET := $(PATH_INS)/$(notdir $(out))
|
---|
1369 | else
|
---|
1370 | $(target)_1_INST_TARGET := $(addprefix $(PATH_INS)/,$(inst))
|
---|
1371 | endif
|
---|
1372 | else
|
---|
1373 | $(target)_1_INST :=
|
---|
1374 | $(target)_1_INST_TARGET :=
|
---|
1375 | endif
|
---|
1376 |
|
---|
1377 | endef # def_pass1_link_common
|
---|
1378 | $(eval-opt-var def_pass1_link_common)
|
---|
1379 |
|
---|
1380 |
|
---|
1381 | #
|
---|
1382 | # BLDPROGS (Pass 1)
|
---|
1383 | #
|
---|
1384 | define def_pass1_bldprog
|
---|
1385 | # set NOINST if not forced installation before doing the usual stuff.
|
---|
1386 | ifndef $(target)_INST
|
---|
1387 | $(target)_INSTTYPE := none
|
---|
1388 | endif
|
---|
1389 | $(evalval def_pass1_link_common)
|
---|
1390 | endef
|
---|
1391 |
|
---|
1392 | EXT := EXE
|
---|
1393 | EXTPRE := HOST
|
---|
1394 | definst := $(INST_BIN)
|
---|
1395 | tool_prefix := LD
|
---|
1396 | bld_trg_base_var := PLATFORM
|
---|
1397 | $(foreach target, $(_ALL_BLDPROGS), \
|
---|
1398 | $(evalval def_pass1_bldprog))
|
---|
1399 |
|
---|
1400 |
|
---|
1401 | #
|
---|
1402 | # LIBRARIES (Pass 1)
|
---|
1403 | #
|
---|
1404 | EXT := LIB
|
---|
1405 | EXTPRE :=
|
---|
1406 | definst := $(INST_LIB)
|
---|
1407 | tool_prefix := AR
|
---|
1408 | bld_trg_base_var := TARGET
|
---|
1409 | $(foreach target, $(_ALL_LIBRARIES), \
|
---|
1410 | $(evalval def_pass1_link_common))
|
---|
1411 |
|
---|
1412 |
|
---|
1413 | #
|
---|
1414 | # DLLS (Pass 1)
|
---|
1415 | #
|
---|
1416 | EXT := DLL
|
---|
1417 | EXTPRE :=
|
---|
1418 | definst := $(INST_DLL)
|
---|
1419 | tool_prefix := LD
|
---|
1420 | bld_trg_base_var := TARGET
|
---|
1421 | $(foreach target, $(_ALL_DLLS), \
|
---|
1422 | $(evalval def_pass1_link_common))
|
---|
1423 |
|
---|
1424 |
|
---|
1425 | #
|
---|
1426 | # IMPORT LIBRARIES (Pass 1)
|
---|
1427 | #
|
---|
1428 | # - On OS/2 and windows these are libraries.
|
---|
1429 | # - On other platforms they are fake DLLs.
|
---|
1430 | #
|
---|
1431 | if1of ($(KBUILD_TARGET), nt os2 win win64 win32)
|
---|
1432 | EXT := LIB
|
---|
1433 | EXTPRE :=
|
---|
1434 | definst := $(INST_LIB)
|
---|
1435 | tool_prefix := AR
|
---|
1436 | bld_trg_base_var := TARGET
|
---|
1437 | $(foreach target, $(_ALL_IMPORT_LIBS), \
|
---|
1438 | $(evalval def_pass1_link_common))
|
---|
1439 | else
|
---|
1440 | EXT := DLL
|
---|
1441 | EXTPRE :=
|
---|
1442 | definst := $(INST_DLL)
|
---|
1443 | tool_prefix := LD
|
---|
1444 | bld_trg_base_var := TARGET
|
---|
1445 | $(foreach target, $(_ALL_IMPORT_LIBS), \
|
---|
1446 | $(evalval def_pass1_link_common))
|
---|
1447 | endif
|
---|
1448 |
|
---|
1449 |
|
---|
1450 | #
|
---|
1451 | # PROGRAMS (Pass 1)
|
---|
1452 | #
|
---|
1453 | EXT := EXE
|
---|
1454 | EXTPRE :=
|
---|
1455 | definst := $(INST_BIN)
|
---|
1456 | tool_prefix := LD
|
---|
1457 | bld_trg_base_var := TARGET
|
---|
1458 | $(foreach target, $(_ALL_PROGRAMS), \
|
---|
1459 | $(evalval def_pass1_link_common))
|
---|
1460 |
|
---|
1461 |
|
---|
1462 | #
|
---|
1463 | # SYSMODS (Pass 1)
|
---|
1464 | #
|
---|
1465 | EXT := SYS
|
---|
1466 | EXTPRE :=
|
---|
1467 | definst := $(INST_SYS)
|
---|
1468 | tool_prefix := LD
|
---|
1469 | bld_trg_base_var := TARGET
|
---|
1470 | $(foreach target, $(_ALL_SYSMODS), \
|
---|
1471 | $(evalval def_pass1_link_common))
|
---|
1472 |
|
---|
1473 |
|
---|
1474 | #
|
---|
1475 | # MISCBINS (Pass 1)
|
---|
1476 | #
|
---|
1477 | EXT := BIN
|
---|
1478 | EXTPRE :=
|
---|
1479 | definst := $(INST_BIN)
|
---|
1480 | tool_prefix := LD
|
---|
1481 | bld_trg_base_var := TARGET
|
---|
1482 | $(foreach target, $(_ALL_MISCBINS), \
|
---|
1483 | $(evalval def_pass1_link_common))
|
---|
1484 |
|
---|
1485 |
|
---|
1486 | #
|
---|
1487 | # INSTALLS (Pass 1)
|
---|
1488 | # Note! INSTARGET_* for INSTALLS aren't available until later.
|
---|
1489 | #
|
---|
1490 | define def_pass1_install
|
---|
1491 | local bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE))
|
---|
1492 | local bld_trg := $(firstword $($(target)_BLD_TRG) $(KBUILD_TARGET))
|
---|
1493 | local bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(KBUILD_TARGET_ARCH))
|
---|
1494 | local bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(KBUILD_TARGET_CPU))
|
---|
1495 | # _1_TARGET
|
---|
1496 | $(target)_1_TARGET := $(PATH_TARGET)/$(target).ins
|
---|
1497 | $(call KB_FN_ASSIGN_DEPRECATED,TARGET_$(target),$($(target)_1_TARGET), $(target)_1_TARGET)
|
---|
1498 |
|
---|
1499 | # Determine and set 1_INSTTYPE.
|
---|
1500 | local insttype := $(firstword \
|
---|
1501 | $($(target)_INSTTYPE) \
|
---|
1502 | $($(target)_INSTTYPE.$(bld_trg)) \
|
---|
1503 | $($(target)_INSTTYPE.$(bld_trg).$(bld_trg_arch)) \
|
---|
1504 | $($(target)_INSTTYPE.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
|
---|
1505 | $($(target)_INSTTYPE.$(bld_trg_arch)) \
|
---|
1506 | $($(target)_INSTTYPE.$(bld_trg_cpu)) \
|
---|
1507 | $($(target)_INSTTYPE.$(bld_type)) \
|
---|
1508 | )
|
---|
1509 | ifeq ($(insttype),)
|
---|
1510 | ifneq ($(firstword \
|
---|
1511 | $($(target)_NOINST) \
|
---|
1512 | $($(target)_NOINST.$(bld_trg)) \
|
---|
1513 | $($(target)_NOINST.$(bld_trg).$(bld_trg_arch)) \
|
---|
1514 | $($(target)_NOINST.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
|
---|
1515 | $($(target)_NOINST.$(bld_trg_arch)) \
|
---|
1516 | $($(target)_NOINST.$(bld_trg_cpu)) \
|
---|
1517 | $($(target)_NOINST.$(bld_type)) ),)
|
---|
1518 | local insttype := none
|
---|
1519 | else
|
---|
1520 | local insttype := both
|
---|
1521 | endif
|
---|
1522 | endif
|
---|
1523 | ifn1of ($(insttype), none both stage)
|
---|
1524 | $(error kBuild: Unknown value '$(insttype)' for '$(target)_INSTTYPE'. Valid values are 'none', 'both' and 'stage'.)
|
---|
1525 | endif
|
---|
1526 | $(target)_1_INSTTYPE := $(insttype)
|
---|
1527 |
|
---|
1528 | # Determine the actual INST and STAGE sub-dirs to use for this target.
|
---|
1529 | if1of ($(insttype), stage both)
|
---|
1530 | local stage := $(strip $(firstdefined \
|
---|
1531 | $(target)_STAGE.$(bld_trg).$(bld_trg_arch).$(bld_type) \
|
---|
1532 | $(target)_INST.$(bld_trg).$(bld_trg_arch).$(bld_type) \
|
---|
1533 | $(target)_STAGE.$(bld_trg).$(bld_trg_arch) \
|
---|
1534 | $(target)_INST.$(bld_trg).$(bld_trg_arch) \
|
---|
1535 | $(target)_STAGE.$(bld_trg).$(bld_type) \
|
---|
1536 | $(target)_INST.$(bld_trg).$(bld_type) \
|
---|
1537 | $(target)_STAGE.$(bld_trg_arch) \
|
---|
1538 | $(target)_INST.$(bld_trg_arch) \
|
---|
1539 | $(target)_STAGE.$(bld_trg) \
|
---|
1540 | $(target)_INST.$(bld_trg) \
|
---|
1541 | $(target)_STAGE.$(bld_type) \
|
---|
1542 | $(target)_INST.$(bld_type) \
|
---|
1543 | $(target)_STAGE \
|
---|
1544 | $(target)_INST \
|
---|
1545 | definst \
|
---|
1546 | ,value))
|
---|
1547 | if $(words $(stage)) > 1
|
---|
1548 | $(warning kBuild: The STAGE/INST property of install '$(target)' specifies multiple location, that is not supported.)
|
---|
1549 | local stage := $(word 1, $(stage))
|
---|
1550 | endif
|
---|
1551 | $(target)_1_STAGE := $(stage)
|
---|
1552 | else
|
---|
1553 | $(target)_1_STAGE = $(error _1_STAGE not used)
|
---|
1554 | endif
|
---|
1555 |
|
---|
1556 | if1of ($(insttype), both)
|
---|
1557 | local inst := $(strip $(firstdefined \
|
---|
1558 | $(target)_INST.$(bld_trg).$(bld_trg_arch).$(bld_type) \
|
---|
1559 | $(target)_INST.$(bld_trg).$(bld_trg_arch) \
|
---|
1560 | $(target)_INST.$(bld_trg).$(bld_type) \
|
---|
1561 | $(target)_INST.$(bld_trg_arch) \
|
---|
1562 | $(target)_INST.$(bld_trg) \
|
---|
1563 | $(target)_INST.$(bld_type) \
|
---|
1564 | $(target)_INST \
|
---|
1565 | definst \
|
---|
1566 | ,value))
|
---|
1567 | if $(words $(inst)) > 1
|
---|
1568 | $(warning kBuild: The INST property of install '$(target)' specifies multiple location, that is not supported.)
|
---|
1569 | local inst := $(word 1, $(inst))
|
---|
1570 | endif
|
---|
1571 | ifneq ($(root $(stage)),)
|
---|
1572 | $(error kBuild: The effective INST property of install '$(target)' should not start with a root specification)
|
---|
1573 | endif
|
---|
1574 | $(target)_1_INST := $(inst)
|
---|
1575 | else
|
---|
1576 | $(target)_1_INST = $(error _1_INST not used)
|
---|
1577 | endif
|
---|
1578 |
|
---|
1579 | # Block properties that we put off setting until pass 2 for INSTALLS.
|
---|
1580 | $(target)_1_STAGE_TARGET = $(error The '_1_STAGE_TARGET' property is not present on install targets. Use '_2_STAGE_TARGETS' instead (set by pass 2!).)
|
---|
1581 | $(target)_1_INST_TARGET = $(error The '_1_INST_TARGET' property is not present on install targets. Use '_2_INST_TARGETS' instead (set by pass 2!).)
|
---|
1582 | INSTARGET_$(target) = $(error The 'INSTARGET_' is deprecated and besides, it is being accessed to early. Consider '_2_STAGE_TARGETS' or '_2_INST_TARGETS'.)
|
---|
1583 |
|
---|
1584 | # INSTARGET_ later.
|
---|
1585 | # PATH_*
|
---|
1586 | local outbase := $(call TARGET_BASE,$(target),$(target))
|
---|
1587 | $(target)_0_OUTDIR := $(patsubst %/,%,$(dir $(outbase)))
|
---|
1588 | $(call KB_FN_ASSIGN_DEPRECATED,PATH_$(target),$($(target)_0_OUTDIR), $(target)_0_OUTDIR)
|
---|
1589 | endef # def_pass1_install
|
---|
1590 | $(eval-opt-var def_pass1_install)
|
---|
1591 |
|
---|
1592 | $(foreach target, $(_ALL_INSTALLS), \
|
---|
1593 | $(evalval def_pass1_install))
|
---|
1594 |
|
---|
1595 | ifdef KBUILD_PROFILE_SELF
|
---|
1596 | $(evalcall def_profile_self, done pass 1)
|
---|
1597 | endif
|
---|
1598 |
|
---|
1599 |
|
---|
1600 |
|
---|
1601 |
|
---|
1602 | #
|
---|
1603 | #
|
---|
1604 | # Target lists - Pass 2
|
---|
1605 | #
|
---|
1606 | #
|
---|
1607 |
|
---|
1608 |
|
---|
1609 | ## @page pg_fetches Fetching Tools, Sources and Similar.
|
---|
1610 | #
|
---|
1611 | # The targets listed in the the FETCHES target list have the following attributes:
|
---|
1612 | # SOURCES
|
---|
1613 | # INST
|
---|
1614 | # FETCHTOOL
|
---|
1615 | # FETCHFLAGS
|
---|
1616 | # FETCHDIR
|
---|
1617 | # UNPACKTOOL
|
---|
1618 | # UNPACKFLAGS
|
---|
1619 | #
|
---|
1620 | # As usual the target name is an alias for 'creating' the target. Other
|
---|
1621 | # aliases are:
|
---|
1622 | # pass_fetches
|
---|
1623 | # fetch
|
---|
1624 | # unfetch
|
---|
1625 | # download
|
---|
1626 | # unpack
|
---|
1627 | #
|
---|
1628 | # @remark
|
---|
1629 | #
|
---|
1630 | # This is a little bit complex because we must guarantee that if a source file
|
---|
1631 | # changes only sligtly we must refetch it and to a proper unpacking of it. It
|
---|
1632 | # is also a desire that fetched archives and unpacked files can be deleted to
|
---|
1633 | # save space.
|
---|
1634 | #
|
---|
1635 | # Thus, we must be able to cleanup what we've unpacked should any of the
|
---|
1636 | # sources be removed. We do this by maintaining a file listing the files
|
---|
1637 | # and directories that was unpacked. This operation is named 'unfetch'.
|
---|
1638 | #
|
---|
1639 | # We make use of the SIZE and MD5 attributes for each of the sources to
|
---|
1640 | # create a digest that is stored in the primary target file. Subsequent
|
---|
1641 | # runswill compare their digest with it to decide if a refetch is required.
|
---|
1642 | # When a refetch is found necessary, an 'unfetch' is performed first to
|
---|
1643 | # clean out old files and directores. Note even changes in source order
|
---|
1644 | # will cause a refetch due to the way the digest is constructed and
|
---|
1645 | # evaluated.
|
---|
1646 | #
|
---|
1647 | # By not depending directly on the archives (nor on any unpacked files)
|
---|
1648 | # but on a goal made up from the archive name, size and md5, we allow
|
---|
1649 | # the user to delete the archives. Naturally, this means we'll have to
|
---|
1650 | # check and fetch missing archives before attempting to unpack them.
|
---|
1651 | #
|
---|
1652 | # @remark
|
---|
1653 | #
|
---|
1654 | # This feature will *NOT* work correctly with vanilla GNU make becuase
|
---|
1655 | # it makes use of includedep to avoid too many unnecessary files.
|
---|
1656 | #
|
---|
1657 | # @todo
|
---|
1658 | # 0. Move the fetches out into a unit.
|
---|
1659 | # 1. Download corruption / continuation.
|
---|
1660 | # 2. It's quite possible that there is one too many indirect dependency now...
|
---|
1661 | #
|
---|
1662 |
|
---|
1663 | ## generates the fetch rule
|
---|
1664 | define def_fetch_src_fetch_rule
|
---|
1665 | # Indirect goal for downloading something.
|
---|
1666 | .PRECIOUS: $(out)
|
---|
1667 | $(out) + $($(target)_$(srcname)_FETCH_2_OUTPUT) +| $($(target)_$(srcname)_FETCH_2_OUTPUT_MAYBE) : \
|
---|
1668 | | $($(target)_$(srcname)_FETCH_2_DEPORD)
|
---|
1669 | %$$(call MSG_FETCH_DL,$(target),$(source),$(out))
|
---|
1670 | @## @todo do fancy stuff like download continuation.
|
---|
1671 | $$(QUIET)$$(RM) -f -- $(out)
|
---|
1672 | $(cmds)
|
---|
1673 | $$(QUIET)$(if $(md5),$$(MD5SUM_EXT) -b -C $(md5) $(out))
|
---|
1674 |
|
---|
1675 |
|
---|
1676 |
|
---|
1677 | # Intermediate goal for making sure the md5 and size matches. it will (re) fetch the archive if necessary.
|
---|
1678 | $(out).checked_$(md5)_$(size): $($(target)_$(srcname)_FETCH_2_DEPEND) | $($(target)_$(srcname)_FETCH_2_DEPORD)
|
---|
1679 | %$$(call MSG_FETCH_CHK,$(target),$(source),$(out))
|
---|
1680 | $$(QUIET)$$(RM) -f -- $$@
|
---|
1681 | @# (re)fetch the file if it doesn't exist or if it doesn't matches the md5.
|
---|
1682 | @## @todo do fancy stuff like download continuation.
|
---|
1683 | $$(QUIET)( test -f $(out) && $(if $(md5),$$(MD5SUM_EXT) -b -C $(md5) $(out), true) ) \
|
---|
1684 | || ( $$(RM_EXT) -f $(out) \
|
---|
1685 | && $$(MAKE) $(out) -f $(MAKEFILE) --no-print-directory )
|
---|
1686 | $$(QUIET2)$$(APPEND) $$@
|
---|
1687 |
|
---|
1688 | _TARGET_$(target)_FETCHED += $(out) $(out).checked_$(md5)_$(size)
|
---|
1689 |
|
---|
1690 | # Just a little precaution.
|
---|
1691 | .NOTPARALLEL: $(out) $(out).checked_$(md5)_$(size)
|
---|
1692 |
|
---|
1693 | endef # def_fetch_src_fetch_rule
|
---|
1694 | $(eval-opt-var def_fetch_src_fetch_rule)
|
---|
1695 |
|
---|
1696 | ## generates the unpack rule
|
---|
1697 | define def_fetch_src_unpack_rule
|
---|
1698 | # This is the unpack rule. it has an order-only dependency on the download check.
|
---|
1699 | $(out) + $($(target)_$(srcname)_UNPACK_2_OUTPUT) +| $($(target)_$(srcname)_UNPACK_2_OUTPUT_MAYBE) : \
|
---|
1700 | $($(target)_$(srcname)_UNPACK_2_DEPEND) \
|
---|
1701 | | $($(target)_$(srcname)_UNPACK_2_DEPORD) \
|
---|
1702 | $(archive).checked_$(md5)_$(size) \
|
---|
1703 | $(dir $(out))
|
---|
1704 | %$$(call MSG_FETCH_UP,$(target),$(archive),$(inst))
|
---|
1705 | $$(QUIET)$$(RM) -f -- $(out)
|
---|
1706 | $$(QUIET)$$(MKDIR) -p -- $(dir $(out))
|
---|
1707 | @# if the source archive doesn't exist fetch it (may have been deleted to save space).
|
---|
1708 | $$(QUIET)test -f $(archive) \
|
---|
1709 | || ( $$(RM_EXT) -f $(archive).checked_$(md5)_$(size) \
|
---|
1710 | && $$(MAKE) $(archive).checked_$(md5)_$(size) -f $(MAKEFILE) --no-print-directory )
|
---|
1711 | $(cmds)
|
---|
1712 | $$(QUIET2)$$(APPEND) $(out) $(notdir $(archive).checked_$(md5)_$(size))
|
---|
1713 | $$(QUIET2)$$(APPEND) $(out) $(notdir $(out))
|
---|
1714 |
|
---|
1715 | $(eval _TARGET_$(target)_UNPACKED += $(out))
|
---|
1716 | _TARGET_$(target)_DIGEST := $(_TARGET_$(target)_DIGEST)-$(srcname)_$(md5)_$(size)
|
---|
1717 |
|
---|
1718 | .NOTPARALLEL: $(out)
|
---|
1719 |
|
---|
1720 | endef # def_fetch_src_unpack_rule
|
---|
1721 | $(eval-opt-var def_fetch_src_unpack_rule)
|
---|
1722 |
|
---|
1723 | ## Processes a fetch source
|
---|
1724 | #
|
---|
1725 | define def_fetch_src
|
---|
1726 | #$ (warning dbg: def_fetch_src: source='$(source)' target='$(target)')
|
---|
1727 |
|
---|
1728 | # common
|
---|
1729 | local srcname := $(notdir $(source))
|
---|
1730 | local inst := $(firstword \
|
---|
1731 | $($(target)_$(source)_INST)\
|
---|
1732 | $($(target)_$(srcname)_INST)\
|
---|
1733 | $($(source)_INST)\
|
---|
1734 | $($(srcname)_INST)\
|
---|
1735 | $($(target)_INST)\
|
---|
1736 | )
|
---|
1737 | ifneq ($(patsubst %/,ok,$(inst)),ok)
|
---|
1738 | $(error kBuild: Bad or missing INST property for source '$(source)' in target '$(target)': $(inst))
|
---|
1739 | endif
|
---|
1740 | ## @todo Install-revamp: FIXME
|
---|
1741 | INSTARGET_$(target)_$(srcname) := $(inst)
|
---|
1742 | local fetchdir := $(firstword \
|
---|
1743 | $($(target)_$(source)_FETCHDIR)\
|
---|
1744 | $($(target)_$(srcname)_FETCHDIR)\
|
---|
1745 | $($(source)_FETCHDIR)\
|
---|
1746 | $($(srcname)_FETCHDIR)\
|
---|
1747 | $($(target)_FETCHDIR)\
|
---|
1748 | $(FETCHDIR)\
|
---|
1749 | $(PATH_TARGET)\
|
---|
1750 | )
|
---|
1751 | local deps := \
|
---|
1752 | $($(target)_$(source)_DEPS)\
|
---|
1753 | $($(target)_$(srcname)_DEPS)\
|
---|
1754 | $($(source)_DEPS)\
|
---|
1755 | $($(srcname)_DEPS)\
|
---|
1756 | $($(target)_DEPS)
|
---|
1757 | local orderdeps := \
|
---|
1758 | $($(target)_$(source)_ORDERDEPS)\
|
---|
1759 | $($(target)_$(srcname)_ORDERDEPS)\
|
---|
1760 | $($(source)_ORDERDEPS)\
|
---|
1761 | $($(srcname)_ORDERDEPS)\
|
---|
1762 | $($(target)_ORDERDEPS)
|
---|
1763 | local md5 := $(firstword \
|
---|
1764 | $($(target)_$(source)_MD5)\
|
---|
1765 | $($(target)_$(srcname)_MD5)\
|
---|
1766 | $($(source)_MD5)\
|
---|
1767 | $($(srcname)_MD5)\
|
---|
1768 | $($(target)_MD5)\
|
---|
1769 | )
|
---|
1770 | local size := $(firstword \
|
---|
1771 | $($(target)_$(source)_SIZE)\
|
---|
1772 | $($(target)_$(srcname)_SIZE)\
|
---|
1773 | $($(source)_SIZE)\
|
---|
1774 | $($(srcname)_SIZE)\
|
---|
1775 | $($(target)_SIZE)\
|
---|
1776 | )
|
---|
1777 | clean_files += \
|
---|
1778 | $($(target)_$(source)_CLEAN)\
|
---|
1779 | $($(target)_$(srcname)_CLEAN)\
|
---|
1780 | $($(source)_CLEAN)\
|
---|
1781 | $($(srcname)_CLEAN)
|
---|
1782 | local dep := # not legal for fetch and unpack tools
|
---|
1783 |
|
---|
1784 |
|
---|
1785 | #
|
---|
1786 | # The fetching.
|
---|
1787 | #
|
---|
1788 | local out := $(fetchdir)/$(srcname)
|
---|
1789 | local archive := $(out)
|
---|
1790 | $(target)_$(srcname)_1_TARGET = $(TARGET_$(target)_$(srcname))
|
---|
1791 | $(call KB_FN_ASSIGN_DEPRECATED,TARGET_$(target)_$(srcname),$(TARGET_$(target)_$(srcname)),TARGET_$(target)_$(srcname))
|
---|
1792 |
|
---|
1793 | local dirdep := $(call DIRDEP,$(fetchdir))
|
---|
1794 | local tool := $(firstword \
|
---|
1795 | $($(target)_$(source)_FETCHTOOL)\
|
---|
1796 | $($(target)_$(srcname)_FETCHTOOL)\
|
---|
1797 | $($(target)_$(source)_TOOL)\
|
---|
1798 | $($(target)_$(srcname)_TOOL)\
|
---|
1799 | $($(source)_FETCHTOOL)\
|
---|
1800 | $($(srcname)_FETCHTOOL)\
|
---|
1801 | $($(source)_TOOL)\
|
---|
1802 | $($(srcname)_TOOL)\
|
---|
1803 | $($(target)_FETCHTOOL)\
|
---|
1804 | $($(target)_TOOL)\
|
---|
1805 | )
|
---|
1806 | local flags :=\
|
---|
1807 | $(TOOL_$(tool)_FETCHFLAGS)\
|
---|
1808 | $(FETCHFLAGS)\
|
---|
1809 | $($(target)_FETCHFLAGS)\
|
---|
1810 | $($(srcname)_FETCHFLAGS)\
|
---|
1811 | $($(source)_FETCHFLAGS)\
|
---|
1812 | $($(target)_$(srcname)_FETCHFLAGS)\
|
---|
1813 | $($(target)_$(source)_FETCHFLAGS)
|
---|
1814 |
|
---|
1815 | #$ (warning dbg: target=$(target) source=$(source) $(srcname)=$(srcname) tool=$(tool) out=$(out) flags=$(flags) dirdep=$(dirdep) fetchdir=$(fetchdir) md5=$(md5) size=$(size))
|
---|
1816 |
|
---|
1817 | ifndef TOOL_$(tool)_FETCH_CMDS
|
---|
1818 | $(warning kBuild: tools: \
|
---|
1819 | 1 $($(target)_$(source)_FETCHTOOL)\
|
---|
1820 | 2 $($(target)_$(srcname)_FETCHTOOL)\
|
---|
1821 | 3 $($(target)_$(source)_TOOL)\
|
---|
1822 | 4 $($(target)_$(srcname)_TOOL)\
|
---|
1823 | 5 $($(source)_FETCHTOOL)\
|
---|
1824 | 6 $($(srcname)_FETCHTOOL)\
|
---|
1825 | 7 $($(source)_TOOL)\
|
---|
1826 | 8 $($(srcname)_TOOL)\
|
---|
1827 | 9 $($(target)_FETCHTOOL)\
|
---|
1828 | 10 $($(target)_TOOL) )
|
---|
1829 | $(error kBuild: TOOL_$(tool)_FETCH_CMDS is not defined. source=$(source) target=$(target) )
|
---|
1830 | endif
|
---|
1831 |
|
---|
1832 | # call the tool
|
---|
1833 | local cmds := $(TOOL_$(tool)_FETCH_CMDS)
|
---|
1834 | $(target)_$(srcname)_FETCH_2_OUTPUT := $(TOOL_$(tool)_FETCH_OUTPUT)
|
---|
1835 | $(target)_$(srcname)_FETCH_2_OUTPUT_MAYBE := $(TOOL_$(tool)_FETCH_OUTPUT_MAYBE)
|
---|
1836 | $(target)_$(srcname)_FETCH_2_DEPEND := $(TOOL_$(tool)_FETCH_DEPEND) $(deps)
|
---|
1837 | $(target)_$(srcname)_FETCH_2_DEPORD := $(TOOL_$(tool)_FETCH_DEPORD) $(dirdep) $(orderdeps)
|
---|
1838 |
|
---|
1839 | # generate the fetch rule.
|
---|
1840 | $(eval $(def_fetch_src_fetch_rule))
|
---|
1841 |
|
---|
1842 |
|
---|
1843 | #
|
---|
1844 | # The unpacking / installing.
|
---|
1845 | #
|
---|
1846 | local out := $(inst)_kBuild_$(target)_$(srcname)_unpacked.lst
|
---|
1847 | local dirdep := $(call DIRDEP,$(inst))
|
---|
1848 | local tool := $(firstword \
|
---|
1849 | $($(target)_$(source)_UNPACKTOOL)\
|
---|
1850 | $($(target)_$(srcname)_UNPACKTOOL)\
|
---|
1851 | $($(target)_$(source)_TOOL)\
|
---|
1852 | $($(target)_$(srcname)_TOOL)\
|
---|
1853 | $($(source)_UNPACKTOOL)\
|
---|
1854 | $($(srcname)_UNPACKTOOL)\
|
---|
1855 | $($(source)_TOOL)\
|
---|
1856 | $($(srcname)_TOOL)\
|
---|
1857 | $($(target)_UNPACKTOOL)\
|
---|
1858 | $($(target)_TOOL) \
|
---|
1859 | )
|
---|
1860 | ifeq ($(tool),)
|
---|
1861 | local tool := $(toupper $(subst .,,$(suffix $(subst tar.,TAR,$(srcname)))))
|
---|
1862 | $(evalval def_tools_include)
|
---|
1863 | endif
|
---|
1864 | local flags :=\
|
---|
1865 | $(TOOL_$(tool)_UNPACKFLAGS)\
|
---|
1866 | $(UNPACKFLAGS)\
|
---|
1867 | $($(target)_UNPACKFLAGS)\
|
---|
1868 | $($(srcname)_UNPACKFLAGS)\
|
---|
1869 | $($(source)_UNPACKFLAGS)\
|
---|
1870 | $($(target)_$(srcname)_UNPACKFLAGS)\
|
---|
1871 | $($(target)_$(source)_UNPACKFLAGS)
|
---|
1872 |
|
---|
1873 | #$ (warning dbg: target=$(target) source=$(source) $(srcname)=$(srcname) tool=$(tool) out=$(out) flags=$(flags) dirdep=$(dirdep) inst=$(inst) md5=$(md5) size=$(size))
|
---|
1874 | ifndef TOOL_$(tool)_UNPACK_CMDS
|
---|
1875 | $(warning kBuild: tools: \
|
---|
1876 | 1 $($(target)_$(source)_UNPACKTOOL)\
|
---|
1877 | 2 $($(target)_$(srcname)_UNPACKTOOL)\
|
---|
1878 | 3 $($(target)_$(source)_TOOL)\
|
---|
1879 | 4 $($(target)_$(srcname)_TOOL)\
|
---|
1880 | 5 $($(source)_UNPACKTOOL)\
|
---|
1881 | 6 $($(srcname)_UNPACKTOOL)\
|
---|
1882 | 7 $($(source)_TOOL)\
|
---|
1883 | 8 $($(srcname)_TOOL)\
|
---|
1884 | 9 $($(target)_UNPACKTOOL)\
|
---|
1885 | 10 $($(target)_TOOL) \
|
---|
1886 | 11 $(toupper $(subst tar.,TAR,$(ext $(srcname)))) \
|
---|
1887 | )
|
---|
1888 | $(error kBuild: TOOL_$(tool)_UNPACK_CMDS is not defined. source=$(source) target=$(target) )
|
---|
1889 | endif
|
---|
1890 |
|
---|
1891 | # call the tool
|
---|
1892 | local cmds := $(TOOL_$(tool)_UNPACK_CMDS)
|
---|
1893 | $(target)_$(srcname)_UNPACK_2_OUTPUT := $(TOOL_$(tool)_UNPACK_OUTPUT)
|
---|
1894 | $(target)_$(srcname)_UNPACK_2_OUTPUT_MAYBE := $(TOOL_$(tool)_UNPACK_OUTPUT_MAYBE)
|
---|
1895 | $(target)_$(srcname)_UNPACK_2_DEPEND := $(TOOL_$(tool)_UNPACK_DEPEND) $(deps)
|
---|
1896 | $(target)_$(srcname)_UNPACK_2_DEPORD := $(TOOL_$(tool)_UNPACK_DEPORD) $(dirdep) $(orderdeps)
|
---|
1897 |
|
---|
1898 | # generate the fetch rule.
|
---|
1899 | $(eval $(def_fetch_src_unpack_rule))
|
---|
1900 |
|
---|
1901 | _DIRS += $(inst) $(fetchdir)
|
---|
1902 |
|
---|
1903 | endef # def_fetch_src
|
---|
1904 | $(eval-opt-var def_fetch_src)
|
---|
1905 |
|
---|
1906 |
|
---|
1907 | ##
|
---|
1908 | # Define the target level rules for a fetch.
|
---|
1909 | # @param target
|
---|
1910 | # @param out
|
---|
1911 | # @param inst
|
---|
1912 | # @param _TARGET_$(target)_UNPACKED
|
---|
1913 | # @param _TARGET_$(target)_DIGEST
|
---|
1914 | # @param bld_trg
|
---|
1915 | # @param bld_trg_arch
|
---|
1916 | define def_fetch_rules
|
---|
1917 |
|
---|
1918 | $(out).lst: $(_TARGET_$(target)_UNPACKED) | $(call DIRDEP,$(inst))
|
---|
1919 | %$$(call MSG_FETCH_OK,$(target))
|
---|
1920 | $$(QUIET)$$(RM) -f -- $$@ $$@.tmp
|
---|
1921 | $$(QUIET2)$$(APPEND) $$@.tmp '$(notdir $(out))'
|
---|
1922 | $$(QUIET)$(if $(_TARGET_$(target)_UNPACKED),$$(CAT_EXT) $(_TARGET_$(target)_UNPACKED) >> $$@.tmp)
|
---|
1923 | $$(QUIET)$$(MV) -f -- $$@.tmp $$@
|
---|
1924 |
|
---|
1925 | $(out)_unfetched:
|
---|
1926 | %$$(call MSG_UNFETCH,$(target))
|
---|
1927 | $$(QUIET)$$(RM) -f -- $$(addprefix $(inst),$$(shell $$(CAT_EXT) $(out).lst 2> /dev/null | $$(SED) -e '/\/$$$$/d'))
|
---|
1928 | $$(QUIET)$$(RMDIR) -p --ignore-fail-on-non-empty --ignore-fail-on-not-exist -- $$(dir $$@) \
|
---|
1929 | $$(addprefix $(inst),$$(sort $$(dir $$(shell $$(CAT_EXT) $(out).lst 2> /dev/null))))
|
---|
1930 | $$(QUIET)$$(RM) -f -- $(out).lst $(out)
|
---|
1931 | $$(QUIET)$$(RMDIR) -p --ignore-fail-on-non-empty --ignore-fail-on-not-exist -- $$(dir $$@)
|
---|
1932 |
|
---|
1933 | $(out): $(comp-vars _TARGET_$(target)_DIGEST_PREV,_TARGET_$(target)_DIGEST,FORCE) | $(call DIRDEP,$(inst))
|
---|
1934 | $$(QUIET)$$(RM) -f -- $$@
|
---|
1935 | %$$(if $$(_TARGET_$(target)_DIGEST),$$(if $$(eq $$(file-size $(out).lst),-1)\
|
---|
1936 | ,$$(call MSG_REFETCH,$(target)),$$(call MSG_FETCH,$(target))),$$(call MSG_UNFETCH,$(target)))
|
---|
1937 | $$(QUIET)$(TEST_EXT) -f $(out).lst -- $$(MAKE) -f $(MAKEFILE) --no-print-directory $(out)_unfetched
|
---|
1938 | $$(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 $$@))
|
---|
1939 | $$(QUIET2)$$(if $$(_TARGET_$(target)_DIGEST),$$(APPEND) $$@ "_TARGET_$(target)_DIGEST_PREV := $(_TARGET_$(target)_DIGEST)")
|
---|
1940 |
|
---|
1941 | .NOTPARALLEL: $(out).lst $(out)_unfetched $(out)
|
---|
1942 |
|
---|
1943 | endef
|
---|
1944 |
|
---|
1945 |
|
---|
1946 | ##
|
---|
1947 | # Deal with one fetch target.
|
---|
1948 | # @param target
|
---|
1949 | # @param bld_trg
|
---|
1950 | # @param bld_trg_arch
|
---|
1951 | define def_fetch
|
---|
1952 | # common
|
---|
1953 | ## @todo Install-revamp: FIXME
|
---|
1954 | INSTARGET_$(target) := $($(target)_INST)
|
---|
1955 | ifneq ($(patsubst %/,ok,$(INSTARGET_$(target))),ok)
|
---|
1956 | $(error kBuild: Bad or missing INST property for target '$(target)'. \
|
---|
1957 | $(target)_INST='$($(target)_INST)' ($(origin $(target)_INST)))
|
---|
1958 | endif
|
---|
1959 | _TARGET_$(target)_FETCHED :=
|
---|
1960 | _TARGET_$(target)_UNPACKED :=
|
---|
1961 | _TARGET_$(target)_DIGEST :=
|
---|
1962 | local clean_files := $($(target)_CLEAN) $($(target)_CLEAN.$(bld_trg)) $($(target)_CLEAN.$(bld_trg).$(bld_trg_arch)) $($(target)_CLEAN.$(bld_trg_arch)) $($(target)_CLEAN.$(KBUILD_TYPE))
|
---|
1963 |
|
---|
1964 | # The 'sources'.
|
---|
1965 | #$ (warning dbg fetch: target=$(target) sources=$($(target)_SOURCES) $($(target)_SOURCES.$(KBUILD_TYPE)) $($(target)_SOURCES.$(KBUILD_TARGET)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(KBUILD_TARGET).$(bld_trg_arch)))
|
---|
1966 | $(foreach source,$($(target)_SOURCES) $($(target)_SOURCES.$(KBUILD_TYPE)) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)),\
|
---|
1967 | $(evalval def_fetch_src))
|
---|
1968 |
|
---|
1969 | # The target.
|
---|
1970 | local inst := $(INSTARGET_$(target))
|
---|
1971 | local out := $(inst)_kBuild_fetch_$(target)
|
---|
1972 |
|
---|
1973 | $(eval includedep $(out))
|
---|
1974 |
|
---|
1975 | $(eval $(def_fetch_rules))
|
---|
1976 |
|
---|
1977 | # Define the aliases here (doesn't work if defined in def_fetch_rules, just like includedep).
|
---|
1978 | $(target): $(out)
|
---|
1979 | $(target)_unfetch: $(out)_unfetched
|
---|
1980 |
|
---|
1981 | _FETCHES += $(out)
|
---|
1982 | _DOWNLOADS += $(_TARGET_$(target)_FETCHED)
|
---|
1983 | _UNPACKS += $(_TARGET_$(target)_UNPACKED)
|
---|
1984 | _UNFETCHES += $(out)_unfetched
|
---|
1985 | _DIRS += $(inst)
|
---|
1986 | _CLEAN_FILES += $(clean_files)
|
---|
1987 |
|
---|
1988 | endef
|
---|
1989 | $(eval-opt-var def_fetch)
|
---|
1990 |
|
---|
1991 | # Walk the FETCH target lists.
|
---|
1992 | bld_trg := $(KBUILD_TARGET)
|
---|
1993 | bld_trg_arch := $(KBUILD_TARGET_ARCH)
|
---|
1994 | $(foreach target, $(_ALL_FETCHES), \
|
---|
1995 | $(evalvalctx def_fetch))
|
---|
1996 |
|
---|
1997 | # some aliases.
|
---|
1998 | download: $(_DOWNLOADS)
|
---|
1999 | unpack: $(_UNPACKS)
|
---|
2000 | fetch: $(_FETCHES)
|
---|
2001 | unfetch: $(_UNFETCHES)
|
---|
2002 |
|
---|
2003 | ifdef KBUILD_PROFILE_SELF
|
---|
2004 | $(evalcall def_profile_self, done fetching targets)
|
---|
2005 | endif
|
---|
2006 |
|
---|
2007 |
|
---|
2008 |
|
---|
2009 | ##
|
---|
2010 | ## Patching.
|
---|
2011 | ##
|
---|
2012 | ##
|
---|
2013 | #define def_patch_src
|
---|
2014 | #
|
---|
2015 | #endef
|
---|
2016 | #
|
---|
2017 | #
|
---|
2018 | ## Deal with one patch target.
|
---|
2019 | #define def_patch
|
---|
2020 | #
|
---|
2021 | #$(foreach source,$($(target)_SOURCES) $($(target)_SOURCES.$(KBUILD_TYPE)) $($(target)_SOURCES.$(KBUILD_TARGET)) $($(target)_SOURCES.$(KBUILD_TARGET_ARCH)) $($(target)_SOURCES.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)),\
|
---|
2022 | # $(evalval def_patch_src))
|
---|
2023 | #
|
---|
2024 | #_PATCHES +=
|
---|
2025 | #endef
|
---|
2026 | #
|
---|
2027 | #$(foreach target, $(_ALL_PATCHES), \
|
---|
2028 | # $(evalval def_patch))
|
---|
2029 | #
|
---|
2030 |
|
---|
2031 |
|
---|
2032 | #
|
---|
2033 | # Object processing.
|
---|
2034 | #
|
---|
2035 |
|
---|
2036 | ## wrapper the compile command dependency check.
|
---|
2037 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
2038 | if1of ($(KMK_FEATURES),dot-must-make)
|
---|
2039 | _DEP_COMPILE_CMDS =
|
---|
2040 | # for debugging: $$(warning MUST_MAKE=$$$$(comp-cmds-ex $$$$($(target)_$(subst :,_,$(source))_CMDS_PREV_), $$$$(commands $$@)) -> $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_CMDS_PREV_),$$(commands $$@),FORCE))
|
---|
2041 | else
|
---|
2042 | _DEP_COMPILE_CMDS = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_CMDS_PREV_),$$(commands $(obj)),FORCE)
|
---|
2043 | endif
|
---|
2044 | else
|
---|
2045 | _DEP_COMPILE_CMDS =
|
---|
2046 | endif
|
---|
2047 |
|
---|
2048 |
|
---|
2049 | ## Generates the rules for building a specific object, and the aliases
|
---|
2050 | # for building a source file.
|
---|
2051 | # @param $(obj) The object file.
|
---|
2052 | define def_target_source_rule
|
---|
2053 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
2054 | $(obj): .MUST_MAKE = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_CMDS_PREV_),$$(commands $$@),FORCE)
|
---|
2055 | endif
|
---|
2056 | ifdef TOOL_$(tool)_COMPILE_$(type)_USES_KOBJCACHE
|
---|
2057 | _OUT_FILES += $(outbase).koc
|
---|
2058 | $(outbase).koc +| $(obj) $($(target)_$(source)_OUTPUT_) $($(target)_$(source)_OUTPUT_MAYBE_) : \
|
---|
2059 | $($(target)_$(source)_DEPEND_) \
|
---|
2060 | $(value _DEP_COMPILE_CMDS) \
|
---|
2061 | | \
|
---|
2062 | $($(target)_$(source)_DEPORD_) \
|
---|
2063 | $$$$($(target)_INTERMEDIATES) \
|
---|
2064 | $$$$($(target)_INTERMEDIATES.$(bld_trg)) \
|
---|
2065 | $$$$($(target)_INTERMEDIATES.$(bld_trg).$(bld_trg_arch)) \
|
---|
2066 | $$$$($(target)_INTERMEDIATES.$(bld_trg_arch)) \
|
---|
2067 | $$$$($(target)_INTERMEDIATES.$(bld_trg_cpu)) \
|
---|
2068 | $$$$($(target)_INTERMEDIATES.$(bld_type))
|
---|
2069 | %$$(call MSG_COMPILE,$(target),$(source),$$@,$(type))
|
---|
2070 | else
|
---|
2071 | $(obj) + $($(target)_$(source)_OUTPUT_) +| $($(target)_$(source)_OUTPUT_MAYBE_) : \
|
---|
2072 | $($(target)_$(source)_DEPEND_) \
|
---|
2073 | $(value _DEP_COMPILE_CMDS) \
|
---|
2074 | | \
|
---|
2075 | $($(target)_$(source)_DEPORD_) \
|
---|
2076 | $$$$($(target)_INTERMEDIATES) \
|
---|
2077 | $$$$($(target)_INTERMEDIATES.$(bld_trg)) \
|
---|
2078 | $$$$($(target)_INTERMEDIATES.$(bld_trg).$(bld_trg_arch)) \
|
---|
2079 | $$$$($(target)_INTERMEDIATES.$(bld_trg_arch)) \
|
---|
2080 | $$$$($(target)_INTERMEDIATES.$(bld_trg_cpu)) \
|
---|
2081 | $$$$($(target)_INTERMEDIATES.$(bld_type))
|
---|
2082 | %$$(call MSG_COMPILE,$(target),$(source),$$@,$(type))
|
---|
2083 | ifdef TOOL_$(tool)_COMPILE_$(type)_DONT_PURGE_OUTPUT
|
---|
2084 | $$(QUIET)$$(RM) -f -- $(dep) $(obj) $($(target)_$(source)_OUTPUT_) $($(target)_OUTPUT_MAYBE_)
|
---|
2085 | endif
|
---|
2086 | endif
|
---|
2087 |
|
---|
2088 | $($(target)_$(source)_CMDS_)
|
---|
2089 |
|
---|
2090 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
2091 | %$$(QUIET2)$$(APPEND) '$(dep)'
|
---|
2092 | %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_CMDS_PREV_'
|
---|
2093 | %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(obj)'
|
---|
2094 | %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
|
---|
2095 | endif
|
---|
2096 |
|
---|
2097 | $(basename $(notdir $(obj))).o: $(obj)
|
---|
2098 | $(basename $(notdir $(obj))).obj: $(obj)
|
---|
2099 |
|
---|
2100 | ## @todo make this 'local cmds,output,output_maybe,depend and depord' in 0.2.x or when a new kb-src-one is added.
|
---|
2101 | $(target)_$(source)_CMDS_ :=
|
---|
2102 | $(target)_$(source)_OUTPUT_ :=
|
---|
2103 | $(target)_$(source)_OUTPUT_MAYBE_ :=
|
---|
2104 | $(target)_$(source)_DEPEND_ :=
|
---|
2105 | $(target)_$(source)_DEPORD_ :=
|
---|
2106 | endef # def_target_source_rule
|
---|
2107 | $(eval-opt-var def_target_source_rule)
|
---|
2108 |
|
---|
2109 |
|
---|
2110 | ## wrapper the link command dependency check.
|
---|
2111 | ifndef NO_LINK_CMDS_DEPS
|
---|
2112 | if1of ($(KMK_FEATURES),dot-must-make)
|
---|
2113 | _DEP_LINK_CMDS =
|
---|
2114 | else
|
---|
2115 | _DEP_LINK_CMDS = $$(comp-cmds-ex $$($(target)_CMDS_PREV_),$$(commands $(out)),FORCE)
|
---|
2116 | endif
|
---|
2117 | else
|
---|
2118 | _DEP_LINK_CMDS =
|
---|
2119 | endif
|
---|
2120 |
|
---|
2121 | ## Generate the link rule for a target.
|
---|
2122 | # @param $(target) The normalized target name.
|
---|
2123 | # @param $(dirdep) Directories we depend upon begin created before linking.
|
---|
2124 | # @param $(dep) The name of the dependency file.
|
---|
2125 | # @param $(out)
|
---|
2126 | # @param $($(target)_2_OUTPUT) Output files from the link.
|
---|
2127 | # @param $($(target)_2_OUTPUT_MAYBE) Output files that the link may perhaps create.
|
---|
2128 | # @param $($(target)_2_DEPEND) Dependencies.
|
---|
2129 | # @param $($(target)_2_DEPORD) Dependencies which should only affect build order.
|
---|
2130 | # @param $(cmds) The link commands.
|
---|
2131 | # @param $($(target)_CMDS_PREV_) The link commands from the previous run.
|
---|
2132 | define def_link_rule
|
---|
2133 | ifndef NO_LINK_CMDS_DEPS
|
---|
2134 | $(out): .MUST_MAKE = $$(comp-cmds-ex $$($(target)_CMDS_PREV_),$$(commands $$@),FORCE)
|
---|
2135 | endif
|
---|
2136 | $(out) + $($(target)_2_OUTPUT) +| $($(target)_2_OUTPUT_MAYBE) : \
|
---|
2137 | $$$$($(target)_2_DEPEND) \
|
---|
2138 | $(value _DEP_LINK_CMDS) \
|
---|
2139 | | \
|
---|
2140 | $$$$($(target)_2_DEPORD)
|
---|
2141 | %$$(call MSG_LINK,$(target),$$@,$(tool_do))
|
---|
2142 | $$(QUIET)$$(RM) -f -- $(dep) $(out) $($(target)_2_OUTPUT) $($(target)_2_OUTPUT_MAYBE)
|
---|
2143 |
|
---|
2144 | $(cmds)
|
---|
2145 |
|
---|
2146 | ifndef NO_LINK_CMDS_DEPS
|
---|
2147 | %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_CMDS_PREV_'
|
---|
2148 | %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
|
---|
2149 | %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
|
---|
2150 | endif
|
---|
2151 |
|
---|
2152 | $(basename $(notdir $(out))):: $(out)
|
---|
2153 |
|
---|
2154 | endef # def_link_rule
|
---|
2155 | $(eval-opt-var def_link_rule)
|
---|
2156 |
|
---|
2157 |
|
---|
2158 | ## Generate the link & lib install rule
|
---|
2159 | # Implicit parameters: target, out, $(target)_1_STAGE_TARGET, mode,
|
---|
2160 | # pre_install_cmds, post_install_cmds
|
---|
2161 | define def_link_install_rule
|
---|
2162 | $($(target)_1_INST_TARGET): $(out) | $$$$(dir $$$$@)
|
---|
2163 | %$$(call MSG_INST_TRG,$(target),$(out),$$@)
|
---|
2164 | $(pre_install_cmds)
|
---|
2165 |
|
---|
2166 | $$(QUIET)$$(INSTALL) $(if $(mode),-m $(mode)) $(if $(uid),-o $(uid)) $(if $(gid),-g $(gid)) -- $(out) $$@
|
---|
2167 | $(post_install_cmds)
|
---|
2168 |
|
---|
2169 | endef
|
---|
2170 |
|
---|
2171 |
|
---|
2172 | ## Generate the link & lib stage installation rule
|
---|
2173 | # Implicit parameters: target, out, $(target)_1_STAGE_TARGET, mode,
|
---|
2174 | # pre_install_cmds, post_install_cmds
|
---|
2175 | define def_link_stage_rule
|
---|
2176 | $($(target)_1_STAGE_TARGET): $(out) | $$$$(dir $$$$@)
|
---|
2177 | %$$(call MSG_INST_TRG,$(target),$(out),$$@)
|
---|
2178 | $(pre_install_cmds)
|
---|
2179 |
|
---|
2180 | $$(QUIET)$$(INSTALL_STAGING) $(if $(mode),-m $(mode)) $(if $(uid),-o $(uid)) $(if $(gid),-g $(gid)) -- $(out) $$@
|
---|
2181 | $(post_install_cmds)
|
---|
2182 |
|
---|
2183 |
|
---|
2184 | $(basename $(notdir $(out))):: $($(target)_1_STAGE_TARGET)
|
---|
2185 |
|
---|
2186 | endef
|
---|
2187 |
|
---|
2188 |
|
---|
2189 | ## def_src_handler_*
|
---|
2190 | #
|
---|
2191 | # @{
|
---|
2192 | define def_src_handler_c
|
---|
2193 | local type := C
|
---|
2194 | $(kb-src-one 2)
|
---|
2195 | endef
|
---|
2196 |
|
---|
2197 | define def_src_handler_cxx
|
---|
2198 | local type := CXX
|
---|
2199 | $(kb-src-one 2)
|
---|
2200 | endef
|
---|
2201 |
|
---|
2202 | define def_src_handler_objc
|
---|
2203 | local type := OBJC
|
---|
2204 | $(kb-src-one 2)
|
---|
2205 | endef
|
---|
2206 |
|
---|
2207 | define def_src_handler_objcxx
|
---|
2208 | local type := OBJCXX
|
---|
2209 | $(kb-src-one 2)
|
---|
2210 | endef
|
---|
2211 |
|
---|
2212 | define def_src_handler_asm
|
---|
2213 | local type := AS
|
---|
2214 | $(kb-src-one 2)
|
---|
2215 | endef
|
---|
2216 |
|
---|
2217 | define def_src_handler_rc
|
---|
2218 | local type := RC
|
---|
2219 | $(kb-src-one 2)
|
---|
2220 | endef
|
---|
2221 |
|
---|
2222 | define def_src_handler_obj
|
---|
2223 | ifeq ($(defpath),)
|
---|
2224 | $(target)_2_OBJS += $(source)
|
---|
2225 | else
|
---|
2226 | $(target)_2_OBJS += $(abspathex $(source), $(defpath))
|
---|
2227 | endif
|
---|
2228 | endef
|
---|
2229 | ## @}
|
---|
2230 |
|
---|
2231 | ## Handle one source.
|
---|
2232 | # .
|
---|
2233 | define def_src_handler_one
|
---|
2234 | local suff := $(suffix $(source))
|
---|
2235 | local src_handler := $(firstword $(filter $(suff):%, $($(target)_$(source)_SRC_HANDLERS) $($(source)_SRC_HANDLERS) $(target_src_handlers) ))
|
---|
2236 | local handler := $(patsubst $(suff):%,%,$(src_handler))
|
---|
2237 | ifneq ($(handler),)
|
---|
2238 | $(evalvalctx $(handler))
|
---|
2239 | else
|
---|
2240 | othersrc += $(source)
|
---|
2241 | endif
|
---|
2242 | endef # def_src_handler_one
|
---|
2243 |
|
---|
2244 | ## Generic macro for processing all target sources.
|
---|
2245 | # @param $(target) Normalized target name.
|
---|
2246 | # @param $(defpath)
|
---|
2247 | # @param much-more...
|
---|
2248 | # @returns othersrc, $(target)_2_OBJS, ++
|
---|
2249 | define def_target_sources
|
---|
2250 | local target_src_handlers := $($(target)_SRC_HANDLERS) $(KBUILD_SRC_HANDLERS)
|
---|
2251 | $(foreach source,\
|
---|
2252 | $($(target)_SOURCES)\
|
---|
2253 | $($(target)_SOURCES.$(bld_trg))\
|
---|
2254 | $($(target)_SOURCES.$(bld_trg).$(bld_type))\
|
---|
2255 | $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch))\
|
---|
2256 | $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch).$(bld_type))\
|
---|
2257 | $($(target)_SOURCES.$(bld_trg_arch))\
|
---|
2258 | $($(target)_SOURCES.$(bld_trg_cpu))\
|
---|
2259 | $($(target)_SOURCES.$(bld_type))\
|
---|
2260 | ,$(evalval def_src_handler_one) )
|
---|
2261 |
|
---|
2262 | $(foreach source,\
|
---|
2263 | $($(target)_GEN_SOURCES_)\
|
---|
2264 | $($(target)_GEN_SOURCES_.$(bld_trg))\
|
---|
2265 | $($(target)_GEN_SOURCES_.$(bld_trg).$(bld_type))\
|
---|
2266 | $($(target)_GEN_SOURCES_.$(bld_trg).$(bld_trg_arch))\
|
---|
2267 | $($(target)_GEN_SOURCES_.$(bld_trg).$(bld_trg_arch).$(bld_type))\
|
---|
2268 | $($(target)_GEN_SOURCES_.$(bld_trg_arch))\
|
---|
2269 | $($(target)_GEN_SOURCES_.$(bld_trg_cpu))\
|
---|
2270 | $($(target)_GEN_SOURCES_.$(bld_type))\
|
---|
2271 | ,$(evalval def_src_handler_one) )
|
---|
2272 | endef # def_target_sources
|
---|
2273 | $(eval-opt-var def_target_sources)
|
---|
2274 |
|
---|
2275 |
|
---|
2276 | ##
|
---|
2277 | # Function for getting the first defined propert value.
|
---|
2278 | #
|
---|
2279 | # @param 1 The property name.
|
---|
2280 | # @note Implicit parameters: target, bld_trg, bld_trg_arch, bld_trg_cpu, bld_type.
|
---|
2281 | # @returns Expanded property value.
|
---|
2282 | #
|
---|
2283 | ## @todo bld_trg_cpu is missing here.
|
---|
2284 | define def_fn_prop_get_first_defined
|
---|
2285 | ifdef $(target)_$(1).$(bld_trg).$(bld_trg_arch).$(bld_type)
|
---|
2286 | local .RETURN := $($(target)_$(1).$(bld_trg).$(bld_trg_arch).$(bld_type))
|
---|
2287 | else ifdef $(target)_$(1).$(bld_trg).$(bld_trg_arch)
|
---|
2288 | local .RETURN := $($(target)_$(1).$(bld_trg).$(bld_trg_arch))
|
---|
2289 | else ifdef $(target)_$(1).$(bld_trg).$(bld_type)
|
---|
2290 | local .RETURN := $($(target)_$(1).$(bld_trg).$(bld_type))
|
---|
2291 | else ifdef $(target)_$(1).$(bld_trg_arch)
|
---|
2292 | local .RETURN := $($(target)_$(1).$(bld_trg_arch))
|
---|
2293 | else ifdef $(target)_$(1).$(bld_trg)
|
---|
2294 | local .RETURN := $($(target)_$(1).$(bld_trg))
|
---|
2295 | else ifdef $(target)_$(1).$(bld_type)
|
---|
2296 | local .RETURN := $($(target)_$(1).$(bld_type))
|
---|
2297 | else ifdef $(target)_$(1)
|
---|
2298 | local .RETURN := $($(target)_$(1))
|
---|
2299 | else ifdef $(1).$(bld_trg).$(bld_trg_arch).$(bld_type)
|
---|
2300 | local .RETURN := $($(1).$(bld_trg).$(bld_trg_arch).$(bld_type))
|
---|
2301 | else ifdef $(1).$(bld_trg).$(bld_trg_arch)
|
---|
2302 | local .RETURN := $($(1).$(bld_trg).$(bld_trg_arch))
|
---|
2303 | else ifdef $(1).$(bld_trg).$(bld_type)
|
---|
2304 | local .RETURN := $($(1).$(bld_trg).$(bld_type))
|
---|
2305 | else ifdef $(1).$(bld_trg_arch)
|
---|
2306 | local .RETURN := $($(1).$(bld_trg_arch))
|
---|
2307 | else ifdef $(1).$(bld_trg)
|
---|
2308 | local .RETURN := $($(1).$(bld_trg))
|
---|
2309 | else ifdef $(1).$(bld_type)
|
---|
2310 | local .RETURN := $($(1).$(bld_type))
|
---|
2311 | else
|
---|
2312 | local .RETURN := $($(1))
|
---|
2313 | endif
|
---|
2314 | endef # def_fn_prop_get_first_defined
|
---|
2315 |
|
---|
2316 |
|
---|
2317 | ## Generic macro for generating the install rule(s) for a target.
|
---|
2318 | #
|
---|
2319 | # @param $(target) Normalized target name.
|
---|
2320 | # @param $(out) The output file.
|
---|
2321 | # @param $(typevar) The name of the variable with all the root targets of its type.
|
---|
2322 | # @param $(target_type_mode) The default file mode implied by the target type.
|
---|
2323 | define def_target_install_only
|
---|
2324 | ifneq ($($(target)_1_INSTTYPE),none)
|
---|
2325 | local mode := $(firstword \
|
---|
2326 | $($(target)_MODE.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
|
---|
2327 | $($(target)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
2328 | $($(target)_MODE.$(bld_trg).$(bld_type)) \
|
---|
2329 | $($(target)_MODE.$(bld_trg_arch)) \
|
---|
2330 | $($(target)_MODE.$(bld_trg)) \
|
---|
2331 | $($(target)_MODE.$(bld_type)) \
|
---|
2332 | $($(target)_MODE) \
|
---|
2333 | $(target_type_mode) )
|
---|
2334 | local uid := $(firstword \
|
---|
2335 | $($(target)_UID.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
|
---|
2336 | $($(target)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
2337 | $($(target)_UID.$(bld_trg).$(bld_type)) \
|
---|
2338 | $($(target)_UID.$(bld_trg_arch)) \
|
---|
2339 | $($(target)_UID.$(bld_trg)) \
|
---|
2340 | $($(target)_UID.$(bld_type)) \
|
---|
2341 | $($(target)_UID) )
|
---|
2342 | local gid := $(firstword \
|
---|
2343 | $($(target)_GID.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
|
---|
2344 | $($(target)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
2345 | $($(target)_GID.$(bld_trg).$(bld_type)) \
|
---|
2346 | $($(target)_GID.$(bld_trg_arch)) \
|
---|
2347 | $($(target)_GID.$(bld_trg)) \
|
---|
2348 | $($(target)_GID.$(bld_type)) \
|
---|
2349 | $($(target)_GID) )
|
---|
2350 | local pre_install_cmds := $(evalcall def_fn_prop_get_first_defined,PRE_INST_CMDS)
|
---|
2351 | local post_install_cmds := $(evalcall def_fn_prop_get_first_defined,POST_INST_CMDS)
|
---|
2352 |
|
---|
2353 | # Generate the rules
|
---|
2354 | ifeq ($($(target)_1_INSTTYPE),both)
|
---|
2355 | $(eval $(def_link_install_rule))
|
---|
2356 | _INSTALLS_FILES += $($(target)_1_INST_TARGET)
|
---|
2357 | endif
|
---|
2358 | $(eval $(def_link_stage_rule))
|
---|
2359 | _STAGE_FILES += $($(target)_1_STAGE_TARGET)
|
---|
2360 | $(typevar) += $($(target)_1_STAGE_TARGET)
|
---|
2361 | else # INSTTYPE == none
|
---|
2362 | $(typevar) += $(out)
|
---|
2363 | endif # INSTTYPE == none
|
---|
2364 |
|
---|
2365 | endef # def_target_install_only
|
---|
2366 |
|
---|
2367 |
|
---|
2368 |
|
---|
2369 | #
|
---|
2370 | # LIBRARIES
|
---|
2371 | #
|
---|
2372 |
|
---|
2373 | ## Library (one).
|
---|
2374 | # @param $(target) Normalized library (target) name.
|
---|
2375 | define def_lib
|
---|
2376 | # library basics
|
---|
2377 | ## @todo prefix
|
---|
2378 | local bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE))
|
---|
2379 | local bld_trg := $(firstword $($(target)_BLD_TRG) $(KBUILD_TARGET))
|
---|
2380 | local bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(KBUILD_TARGET_ARCH))
|
---|
2381 | local bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(KBUILD_TARGET_CPU))
|
---|
2382 | local tool := $(call _TARGET_TOOL,$(target),AR)
|
---|
2383 | ifeq ($(tool),)
|
---|
2384 | $(error kBuild: Library target $(target) does not have a tool defined!)
|
---|
2385 | endif
|
---|
2386 | local name := $(firstword\
|
---|
2387 | $($(target)_NAME.$(bld_trg).$(bld_trg_arch).$(bld_type))\
|
---|
2388 | $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\
|
---|
2389 | $($(target)_NAME.$(bld_trg).$(bld_type))\
|
---|
2390 | $($(target)_NAME.$(bld_trg_arch))\
|
---|
2391 | $($(target)_NAME.$(bld_trg))\
|
---|
2392 | $($(target)_NAME.$(bld_type))\
|
---|
2393 | $($(target)_NAME)\
|
---|
2394 | $(target))
|
---|
2395 | local outbase := $(call TARGET_BASE,$(name),$(target))
|
---|
2396 | $(target)_0_OUTDIR:= $(patsubst %/,%,$(dir $(outbase)))
|
---|
2397 | $(call KB_FN_ASSIGN_DEPRECATED,PATH_$(target),$($(target)_0_OUTDIR), $(target)_0_OUTDIR)
|
---|
2398 | local suff := $(firstword\
|
---|
2399 | $($(target)_LIBSUFF.$(bld_trg).$(bld_trg_arch))\
|
---|
2400 | $($(target)_LIBSUFF.$(bld_trg))\
|
---|
2401 | $($(target)_LIBSUFF)\
|
---|
2402 | $(TOOL_$(tool)_ARLIBSUFF.$(bld_trg).$(bld_trg_arch))\
|
---|
2403 | $(TOOL_$(tool)_ARLIBSUFF.$(bld_trg))\
|
---|
2404 | $(TOOL_$(tool)_ARLIBSUFF)\
|
---|
2405 | $(SUFF_LIB))
|
---|
2406 | local out := $(outbase)$(suff)
|
---|
2407 | local defpath := $($(target)_DEFPATH)
|
---|
2408 | ifeq ($(defpath),)
|
---|
2409 | local defpath := $($(target)_PATH)
|
---|
2410 | endif
|
---|
2411 | $(target)_1_TARGET:= $(out)
|
---|
2412 | $(call KB_FN_ASSIGN_DEPRECATED,TARGET_$(target),$($(target)_1_TARGET), $(target)_1_TARGET)
|
---|
2413 | # no local here - must be writable across some foreachs.
|
---|
2414 | othersrc :=
|
---|
2415 | $(target)_2_OBJS :=
|
---|
2416 |
|
---|
2417 | # Do units pre source callouts.
|
---|
2418 | local units := \
|
---|
2419 | $($(target)_USES.$(bld_trg).$(bld_trg_arch))\
|
---|
2420 | $($(target)_USES.$(bld_trg_arch))\
|
---|
2421 | $($(target)_USES.$(bld_trg))\
|
---|
2422 | $($(target)_USES.$(bld_type))\
|
---|
2423 | $($(target)_USES)
|
---|
2424 | $(foreach unit,$(units),$(evalval def_unit_$(unit)_target_pre))
|
---|
2425 |
|
---|
2426 | # source -> object
|
---|
2427 | $(evalval def_target_sources)
|
---|
2428 |
|
---|
2429 | # library linking
|
---|
2430 | local tool := $(call _TARGET_TOOL,$(target),AR)
|
---|
2431 | local name := $(firstword\
|
---|
2432 | $($(target)_NAME.$(bld_trg).$(bld_trg_arch).$(bld_type))\
|
---|
2433 | $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\
|
---|
2434 | $($(target)_NAME.$(bld_trg).$(bld_type))\
|
---|
2435 | $($(target)_NAME.$(bld_trg_arch))\
|
---|
2436 | $($(target)_NAME.$(bld_trg))\
|
---|
2437 | $($(target)_NAME.$(bld_type))\
|
---|
2438 | $($(target)_NAME)\
|
---|
2439 | $(target))
|
---|
2440 | local outbase := $(call TARGET_BASE,$(name),$(target))
|
---|
2441 | local flags :=\
|
---|
2442 | $(TOOL_$(tool)_ARFLAGS)\
|
---|
2443 | $(TOOL_$(tool)_ARFLAGS.$(bld_type))\
|
---|
2444 | $(ARFLAGS)\
|
---|
2445 | $(ARFLAGS.$(bld_type))\
|
---|
2446 | $($(target)_ARFLAGS)\
|
---|
2447 | $($(target)_ARFLAGS.$(bld_type)) \
|
---|
2448 | $($(target)_ARFLAGS.$(bld_trg)) \
|
---|
2449 | $($(target)_ARFLAGS.$(bld_trg_arch)) \
|
---|
2450 | $($(target)_ARFLAGS.$(bld_trg).$(bld_trg_arch)) \
|
---|
2451 | $($(target)_ARFLAGS.$(bld_trg_cpu))
|
---|
2452 | local dirdep := $(call DIRDEP,$(dir $(out)))
|
---|
2453 | local deps := \
|
---|
2454 | $($(target)_DEPS.$(bld_trg_cpu)) \
|
---|
2455 | $($(target)_DEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
|
---|
2456 | $($(target)_DEPS.$(bld_trg).$(bld_trg_arch)) \
|
---|
2457 | $($(target)_DEPS.$(bld_trg).$(bld_type)) \
|
---|
2458 | $($(target)_DEPS.$(bld_trg_arch)) \
|
---|
2459 | $($(target)_DEPS.$(bld_trg)) \
|
---|
2460 | $($(target)_DEPS.$(bld_type)) \
|
---|
2461 | $($(target)_DEPS) \
|
---|
2462 | $($(target)_LNK_DEPS.$(bld_trg_cpu)) \
|
---|
2463 | $($(target)_LNK_DEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
|
---|
2464 | $($(target)_LNK_DEPS.$(bld_trg).$(bld_trg_arch)) \
|
---|
2465 | $($(target)_LNK_DEPS.$(bld_trg).$(bld_type)) \
|
---|
2466 | $($(target)_LNK_DEPS.$(bld_trg_arch)) \
|
---|
2467 | $($(target)_LNK_DEPS.$(bld_trg)) \
|
---|
2468 | $($(target)_LNK_DEPS.$(bld_type)) \
|
---|
2469 | $($(target)_LNK_DEPS)
|
---|
2470 | local orderdeps := \
|
---|
2471 | $($(target)_ORDERDEPS.$(bld_trg_cpu)) \
|
---|
2472 | $($(target)_ORDERDEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
|
---|
2473 | $($(target)_ORDERDEPS.$(bld_trg).$(bld_trg_arch)) \
|
---|
2474 | $($(target)_ORDERDEPS.$(bld_trg).$(bld_type)) \
|
---|
2475 | $($(target)_ORDERDEPS.$(bld_trg_arch)) \
|
---|
2476 | $($(target)_ORDERDEPS.$(bld_trg)) \
|
---|
2477 | $($(target)_ORDERDEPS.$(bld_type)) \
|
---|
2478 | $($(target)_ORDERDEPS) \
|
---|
2479 | $($(target)_LNK_ORDERDEPS.$(bld_trg_cpu)) \
|
---|
2480 | $($(target)_LNK_ORDERDEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
|
---|
2481 | $($(target)_LNK_ORDERDEPS.$(bld_trg).$(bld_trg_arch)) \
|
---|
2482 | $($(target)_LNK_ORDERDEPS.$(bld_trg).$(bld_type)) \
|
---|
2483 | $($(target)_LNK_ORDERDEPS.$(bld_trg_arch)) \
|
---|
2484 | $($(target)_LNK_ORDERDEPS.$(bld_trg)) \
|
---|
2485 | $($(target)_LNK_ORDERDEPS.$(bld_type)) \
|
---|
2486 | $($(target)_LNK_ORDERDEPS)
|
---|
2487 |
|
---|
2488 | # Adjust paths if we got a default path.
|
---|
2489 | ifneq ($(defpath),)
|
---|
2490 | local deps := $(abspathex $(deps),$(defpath))
|
---|
2491 | local orderdeps := $(abspathex $(orderdeps),$(defpath))
|
---|
2492 | othersrc := $(abspathex $(othersrc),$(defpath))
|
---|
2493 | endif
|
---|
2494 |
|
---|
2495 |
|
---|
2496 | # Custom pre-link actions.
|
---|
2497 | local pre_cmds := $(evalcall def_fn_prop_get_first_defined,PRE_CMDS)
|
---|
2498 | local post_cmds := $(evalcall def_fn_prop_get_first_defined,POST_CMDS)
|
---|
2499 |
|
---|
2500 | # eliminate this guy?
|
---|
2501 | local objs = $($(target)_2_OBJS)
|
---|
2502 |
|
---|
2503 | # dependency file
|
---|
2504 | local dep := $(out)$(SUFF_DEP)
|
---|
2505 | ifndef NO_LINK_CMDS_DEPS
|
---|
2506 | _DEPFILES_INCLUDED += $(dep)
|
---|
2507 | ifdef KB_HAVE_INCLUDEDEP_QUEUE
|
---|
2508 | includedep-queue $(dep)
|
---|
2509 | else
|
---|
2510 | includedep $(dep)
|
---|
2511 | endif
|
---|
2512 | endif
|
---|
2513 |
|
---|
2514 | # check that the tool is defined.
|
---|
2515 | ifndef TOOL_$(tool)_LINK_LIBRARY_CMDS
|
---|
2516 | $(warning kBuild: tools: \
|
---|
2517 | 1 $($(target)_$(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
2518 | 2 $($(target)_$(source)TOOL.$(bld_trg)) \
|
---|
2519 | 3 $($(target)_$(source)TOOL) \
|
---|
2520 | 4 $($(target)_TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
2521 | 5 $($(target)_TOOL.$(bld_trg)) \
|
---|
2522 | 6 $($(target)_TOOL) \
|
---|
2523 | 7 $($(source)TOOL) \
|
---|
2524 | 8 $($(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
2525 | 9 $($(source)TOOL.$(bld_trg)) \
|
---|
2526 | 10 $(TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
2527 | 11 $(TOOL.$(bld_trg)) \
|
---|
2528 | 12 $(TOOL) )
|
---|
2529 | $(error kBuild: TOOL_$(tool)_LINK_LIBRARY_CMDS isn't defined! target=$(target) )
|
---|
2530 | endif
|
---|
2531 |
|
---|
2532 | # call the tool
|
---|
2533 | local cmds := $(TOOL_$(tool)_LINK_LIBRARY_CMDS)
|
---|
2534 | ifneq ($(pre_cmds),)
|
---|
2535 | local cmds := $(TAB)$(pre_cmds)$(NL)$(TAB)$(cmds)
|
---|
2536 | endif
|
---|
2537 | ifneq ($(post_cmds),)
|
---|
2538 | local cmds := $(cmds)$(NL)$(TAB)$(post_cmds)
|
---|
2539 | endif
|
---|
2540 | $(target)_2_OUTPUT := $(TOOL_$(tool)_LINK_LIBRARY_OUTPUT)
|
---|
2541 | $(target)_2_OUTPUT_MAYBE := $(TOOL_$(tool)_LINK_LIBRARY_OUTPUT_MAYBE)
|
---|
2542 | $(target)_2_DEPEND := $(TOOL_$(tool)_LINK_LIBRARY_DEPEND) $(deps) $($(target)_2_OBJS)
|
---|
2543 | $(target)_2_DEPORD := $(TOOL_$(tool)_LINK_LIBRARY_DEPORD) $(dirdep) $(orderdeps)
|
---|
2544 |
|
---|
2545 | # generate the link rule.
|
---|
2546 | $(eval $(def_link_rule))
|
---|
2547 |
|
---|
2548 | # installing and globals.
|
---|
2549 | local target_type_mode := a+r,u+w
|
---|
2550 | $(evalval def_target_install_only)
|
---|
2551 |
|
---|
2552 | _OUT_FILES += $($(target)_2_OUTPUT) $($(target)_2_OUTPUT_MAYBE) $(out)
|
---|
2553 | _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))
|
---|
2554 | _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))
|
---|
2555 | _OBJS += $($(target)_2_OBJS)
|
---|
2556 |
|
---|
2557 | endef # def_lib
|
---|
2558 | $(eval-opt-var def_lib)
|
---|
2559 |
|
---|
2560 | # Process libraries
|
---|
2561 | typevar := _LIBS
|
---|
2562 | tool_do := LINK_LIBRARY
|
---|
2563 | mode := 0644
|
---|
2564 | $(foreach target, $(_ALL_LIBRARIES), $(evalval def_lib))
|
---|
2565 |
|
---|
2566 | ifdef KBUILD_PROFILE_SELF
|
---|
2567 | $(evalcall def_profile_self, done library targets)
|
---|
2568 | endif
|
---|
2569 |
|
---|
2570 |
|
---|
2571 | #
|
---|
2572 | # Link operations.
|
---|
2573 | #
|
---|
2574 |
|
---|
2575 | ##
|
---|
2576 | # Link prolog
|
---|
2577 | #
|
---|
2578 | # @param $(target) Normalized target name.
|
---|
2579 | # @param $(EXT) EXE,DLL,SYS.
|
---|
2580 | # @param $(typevar) The name of the variable with all the root targets of its type.
|
---|
2581 | define def_link_common
|
---|
2582 | # basics
|
---|
2583 | local bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE))
|
---|
2584 | local bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_$(bld_trg_base_var)))
|
---|
2585 | local bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_$(bld_trg_base_var)_ARCH))
|
---|
2586 | local bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_$(bld_trg_base_var)_CPU))
|
---|
2587 |
|
---|
2588 | local tool := $(call _TARGET_TOOL,$(target),LD)
|
---|
2589 | local name := $(firstword\
|
---|
2590 | $($(target)_NAME.$(bld_trg).$(bld_trg_arch).$(bld_type))\
|
---|
2591 | $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\
|
---|
2592 | $($(target)_NAME.$(bld_trg).$(bld_type))\
|
---|
2593 | $($(target)_NAME.$(bld_trg_arch))\
|
---|
2594 | $($(target)_NAME.$(bld_trg))\
|
---|
2595 | $($(target)_NAME.$(bld_type))\
|
---|
2596 | $($(target)_NAME)\
|
---|
2597 | $(target))
|
---|
2598 | local outbase := $(call TARGET_BASE,$(name),$(target))
|
---|
2599 | $(target)_0_OUTDIR:= $(patsubst %/,%,$(dir $(outbase)))
|
---|
2600 | $(call KB_FN_ASSIGN_DEPRECATED,PATH_$(target),$($(target)_0_OUTDIR), $(target)_0_OUTDIR)
|
---|
2601 | local suff := $(firstword \
|
---|
2602 | $($(target)_$(EXT)SUFF.$(bld_trg).$(bld_trg_arch))\
|
---|
2603 | $($(target)_$(EXT)SUFF.$(bld_trg))\
|
---|
2604 | $($(target)_$(EXT)SUFF)\
|
---|
2605 | $(TOOL_$(tool)_LD$(EXT)SUFF.$(bld_trg).$(bld_trg_arch))\
|
---|
2606 | $(TOOL_$(tool)_LD$(EXT)SUFF.$(bld_trg))\
|
---|
2607 | $(TOOL_$(tool)_LD$(EXT)SUFF)\
|
---|
2608 | $($(EXTPRE)SUFF_$(EXT)) )
|
---|
2609 | local out := $(outbase)$(suff)
|
---|
2610 | $(target)_1_TARGET:= $(out)
|
---|
2611 | $(call KB_FN_ASSIGN_DEPRECATED,TARGET_$(target),$($(target)_1_TARGET), $(target)_1_TARGET)
|
---|
2612 | local defpath := $($(target)_DEFPATH)
|
---|
2613 | ifeq ($(defpath),)
|
---|
2614 | local defpath := $($(target)_PATH)
|
---|
2615 | endif
|
---|
2616 | # no local here - must be writable across some foreachs.
|
---|
2617 | othersrc :=
|
---|
2618 | $(target)_2_OBJS :=
|
---|
2619 |
|
---|
2620 | # Do units pre source callouts.
|
---|
2621 | local units := \
|
---|
2622 | $($(target)_USES.$(bld_trg).$(bld_trg_arch))\
|
---|
2623 | $($(target)_USES.$(bld_trg_arch))\
|
---|
2624 | $($(target)_USES.$(bld_trg))\
|
---|
2625 | $($(target)_USES.$(bld_type))\
|
---|
2626 | $($(target)_USES)
|
---|
2627 | $(foreach unit,$(units),$(evalval def_unit_$(unit)_target_pre))
|
---|
2628 |
|
---|
2629 | # source -> object
|
---|
2630 | $(evalval def_target_sources)
|
---|
2631 |
|
---|
2632 | # more link stuff.
|
---|
2633 | local tool := $(call _TARGET_TOOL,$(target),LD)
|
---|
2634 | local name := $(firstword\
|
---|
2635 | $($(target)_NAME.$(bld_trg).$(bld_trg_arch).$(bld_type))\
|
---|
2636 | $($(target)_NAME.$(bld_trg).$(bld_trg_arch))\
|
---|
2637 | $($(target)_NAME.$(bld_trg).$(bld_type))\
|
---|
2638 | $($(target)_NAME.$(bld_trg_arch))\
|
---|
2639 | $($(target)_NAME.$(bld_trg))\
|
---|
2640 | $($(target)_NAME.$(bld_type))\
|
---|
2641 | $($(target)_NAME)\
|
---|
2642 | $(target))
|
---|
2643 | local outbase := $(call TARGET_BASE,$(name),$(target))
|
---|
2644 | local flags :=\
|
---|
2645 | $(TOOL_$(tool)_LDFLAGS)\
|
---|
2646 | $(TOOL_$(tool)_LDFLAGS.$(bld_type))\
|
---|
2647 | $(TOOL_$(tool)_LDFLAGS.$(bld_trg))\
|
---|
2648 | $(TOOL_$(tool)_LDFLAGS.$(bld_trg_arch))\
|
---|
2649 | $(TOOL_$(tool)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\
|
---|
2650 | $(TOOL_$(tool)_LDFLAGS.$(bld_trg_cpu))\
|
---|
2651 | $(foreach sdk, $(SDKS) \
|
---|
2652 | $(SDKS.$(bld_type)) \
|
---|
2653 | $(SDKS.$(bld_trg)) \
|
---|
2654 | $(SDKS.$(bld_trg_arch)) \
|
---|
2655 | $(SDKS.$(bld_trg).$(bld_trg_arch)),\
|
---|
2656 | $(SDK_$(sdk)_LDFLAGS)\
|
---|
2657 | $(SDK_$(sdk)_LDFLAGS.$(bld_type))\
|
---|
2658 | $(SDK_$(sdk)_LDFLAGS.$(bld_trg))\
|
---|
2659 | $(SDK_$(sdk)_LDFLAGS.$(bld_trg_arch))\
|
---|
2660 | $(SDK_$(sdk)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\
|
---|
2661 | $(SDK_$(sdk)_LDFLAGS.$(bld_trg_cpu)))\
|
---|
2662 | $(LDFLAGS)\
|
---|
2663 | $(LDFLAGS.$(bld_type))\
|
---|
2664 | $(LDFLAGS.$(bld_trg))\
|
---|
2665 | $(LDFLAGS.$(bld_trg_arch))\
|
---|
2666 | $(LDFLAGS.$(bld_trg).$(bld_trg_arch))\
|
---|
2667 | $(LDFLAGS.$(bld_trg_cpu))\
|
---|
2668 | $(foreach sdk, $($(target)_SDKS) \
|
---|
2669 | $($(target)_SDKS.$(bld_type)) \
|
---|
2670 | $($(target)_SDKS.$(bld_trg)) \
|
---|
2671 | $($(target)_SDKS.$(bld_trg_arch)) \
|
---|
2672 | $($(target)_SDKS.$(bld_trg).$(bld_trg_arch)),\
|
---|
2673 | $(SDK_$(sdk)_LDFLAGS)\
|
---|
2674 | $(SDK_$(sdk)_LDFLAGS.$(bld_type))\
|
---|
2675 | $(SDK_$(sdk)_LDFLAGS.$(bld_trg))\
|
---|
2676 | $(SDK_$(sdk)_LDFLAGS.$(bld_trg_arch))\
|
---|
2677 | $(SDK_$(sdk)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\
|
---|
2678 | $(SDK_$(sdk)_LDFLAGS.$(bld_trg_cpu)))\
|
---|
2679 | $($(target)_LDFLAGS)\
|
---|
2680 | $($(target)_LDFLAGS.$(bld_type))\
|
---|
2681 | $($(target)_LDFLAGS.$(bld_trg))\
|
---|
2682 | $($(target)_LDFLAGS.$(bld_trg_arch))\
|
---|
2683 | $($(target)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\
|
---|
2684 | $($(target)_LDFLAGS.$(bld_trg_cpu))
|
---|
2685 | local libs :=\
|
---|
2686 | $($(target)_LIBS.$(bld_trg_cpu))\
|
---|
2687 | $($(target)_LIBS.$(bld_trg).$(bld_trg_arch))\
|
---|
2688 | $($(target)_LIBS.$(bld_trg_arch))\
|
---|
2689 | $($(target)_LIBS.$(bld_trg))\
|
---|
2690 | $($(target)_LIBS.$(bld_type))\
|
---|
2691 | $($(target)_LIBS)\
|
---|
2692 | $(foreach sdk, $($(target)_SDKS.$(bld_trg).$(bld_trg_arch)) \
|
---|
2693 | $($(target)_SDKS.$(bld_trg_arch)) \
|
---|
2694 | $($(target)_SDKS.$(bld_trg)) \
|
---|
2695 | $($(target)_SDKS.$(bld_type)) \
|
---|
2696 | $($(target)_SDKS),\
|
---|
2697 | $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
|
---|
2698 | $(SDK_$(sdk)_LIBS.$(bld_trg).$(bld_trg_arch))\
|
---|
2699 | $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
|
---|
2700 | $(SDK_$(sdk)_LIBS.$(bld_trg))\
|
---|
2701 | $(SDK_$(sdk)_LIBS.$(bld_type))\
|
---|
2702 | $(SDK_$(sdk)_LIBS))\
|
---|
2703 | $(LIBS.$(bld_trg_cpu))\
|
---|
2704 | $(LIBS.$(bld_trg).$(bld_trg_arch))\
|
---|
2705 | $(LIBS.$(bld_trg_arch))\
|
---|
2706 | $(LIBS.$(bld_trg))\
|
---|
2707 | $(LIBS.$(bld_type))\
|
---|
2708 | $(LIBS)\
|
---|
2709 | $(foreach sdk, $(SDKS.$(bld_trg).$(bld_trg_arch)) \
|
---|
2710 | $(SDKS.$(bld_trg_arch)) \
|
---|
2711 | $(SDKS.$(bld_trg)) \
|
---|
2712 | $(SDKS.$(bld_type)) \
|
---|
2713 | $(SDKS),\
|
---|
2714 | $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
|
---|
2715 | $(SDK_$(sdk)_LIBS.$(bld_trg).$(bld_trg_arch))\
|
---|
2716 | $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
|
---|
2717 | $(SDK_$(sdk)_LIBS.$(bld_trg))\
|
---|
2718 | $(SDK_$(sdk)_LIBS.$(bld_type))\
|
---|
2719 | $(SDK_$(sdk)_LIBS))\
|
---|
2720 | $(TOOL_$(tool)_LIBS.$(bld_trg_cpu))\
|
---|
2721 | $(TOOL_$(tool)_LIBS.$(bld_trg).$(bld_trg_arch))\
|
---|
2722 | $(TOOL_$(tool)_LIBS.$(bld_trg_arch))\
|
---|
2723 | $(TOOL_$(tool)_LIBS.$(bld_trg))\
|
---|
2724 | $(TOOL_$(tool)_LIBS.$(bld_type))\
|
---|
2725 | $(TOOL_$(tool)_LIBS)
|
---|
2726 | local libpath :=\
|
---|
2727 | $($(target)_LIBPATH.$(bld_trg_cpu))\
|
---|
2728 | $($(target)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
|
---|
2729 | $($(target)_LIBPATH.$(bld_trg_arch))\
|
---|
2730 | $($(target)_LIBPATH.$(bld_trg))\
|
---|
2731 | $($(target)_LIBPATH.$(bld_type))\
|
---|
2732 | $($(target)_LIBPATH)\
|
---|
2733 | $(foreach sdk, $($(target)_SDKS.$(bld_trg).$(bld_trg_arch)) \
|
---|
2734 | $($(target)_SDKS.$(bld_trg_arch)) \
|
---|
2735 | $($(target)_SDKS.$(bld_trg)) \
|
---|
2736 | $($(target)_SDKS.$(bld_type)) \
|
---|
2737 | $($(target)_SDKS),\
|
---|
2738 | $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
|
---|
2739 | $(SDK_$(sdk)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
|
---|
2740 | $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
|
---|
2741 | $(SDK_$(sdk)_LIBPATH.$(bld_trg))\
|
---|
2742 | $(SDK_$(sdk)_LIBPATH.$(bld_type))\
|
---|
2743 | $(SDK_$(sdk)_LIBPATH))\
|
---|
2744 | $(LIBPATH.$(bld_trg_cpu))\
|
---|
2745 | $(LIBPATH.$(bld_trg).$(bld_trg_arch))\
|
---|
2746 | $(LIBPATH.$(bld_trg_arch))\
|
---|
2747 | $(LIBPATH.$(bld_trg))\
|
---|
2748 | $(LIBPATH.$(bld_type))\
|
---|
2749 | $(LIBPATH)\
|
---|
2750 | $(foreach sdk, $(SDKS.$(bld_trg).$(bld_trg_arch)) \
|
---|
2751 | $(SDKS.$(bld_trg_arch)) \
|
---|
2752 | $(SDKS.$(bld_trg)) \
|
---|
2753 | $(SDKS.$(bld_type)) \
|
---|
2754 | $(SDKS),\
|
---|
2755 | $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
|
---|
2756 | $(SDK_$(sdk)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
|
---|
2757 | $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
|
---|
2758 | $(SDK_$(sdk)_LIBPATH.$(bld_trg))\
|
---|
2759 | $(SDK_$(sdk)_LIBPATH.$(bld_type))\
|
---|
2760 | $(SDK_$(sdk)_LIBPATH))\
|
---|
2761 | $(TOOL_$(tool)_LIBPATH.$(bld_trg_cpu))\
|
---|
2762 | $(TOOL_$(tool)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
|
---|
2763 | $(TOOL_$(tool)_LIBPATH.$(bld_trg_arch))\
|
---|
2764 | $(TOOL_$(tool)_LIBPATH.$(bld_trg))\
|
---|
2765 | $(TOOL_$(tool)_LIBPATH.$(bld_type))\
|
---|
2766 | $(TOOL_$(tool)_LIBPATH)
|
---|
2767 | local dirdep := $(call DIRDEP,$(dir $(out)))
|
---|
2768 | local deps := \
|
---|
2769 | $($(target)_DEPS.$(bld_trg_cpu)) \
|
---|
2770 | $($(target)_DEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
|
---|
2771 | $($(target)_DEPS.$(bld_trg).$(bld_trg_arch)) \
|
---|
2772 | $($(target)_DEPS.$(bld_trg).$(bld_type)) \
|
---|
2773 | $($(target)_DEPS.$(bld_trg_arch)) \
|
---|
2774 | $($(target)_DEPS.$(bld_trg)) \
|
---|
2775 | $($(target)_DEPS.$(bld_type)) \
|
---|
2776 | $($(target)_DEPS) \
|
---|
2777 | $($(target)_LNK_DEPS.$(bld_trg_cpu)) \
|
---|
2778 | $($(target)_LNK_DEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
|
---|
2779 | $($(target)_LNK_DEPS.$(bld_trg).$(bld_trg_arch)) \
|
---|
2780 | $($(target)_LNK_DEPS.$(bld_trg).$(bld_type)) \
|
---|
2781 | $($(target)_LNK_DEPS.$(bld_trg_arch)) \
|
---|
2782 | $($(target)_LNK_DEPS.$(bld_trg)) \
|
---|
2783 | $($(target)_LNK_DEPS.$(bld_type)) \
|
---|
2784 | $($(target)_LNK_DEPS)
|
---|
2785 | local orderdeps := \
|
---|
2786 | $($(target)_ORDERDEPS.$(bld_trg_cpu)) \
|
---|
2787 | $($(target)_ORDERDEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
|
---|
2788 | $($(target)_ORDERDEPS.$(bld_trg).$(bld_trg_arch)) \
|
---|
2789 | $($(target)_ORDERDEPS.$(bld_trg).$(bld_type)) \
|
---|
2790 | $($(target)_ORDERDEPS.$(bld_trg_arch)) \
|
---|
2791 | $($(target)_ORDERDEPS.$(bld_trg)) \
|
---|
2792 | $($(target)_ORDERDEPS.$(bld_type)) \
|
---|
2793 | $($(target)_ORDERDEPS) \
|
---|
2794 | $($(target)_LNK_ORDERDEPS.$(bld_trg_cpu)) \
|
---|
2795 | $($(target)_LNK_ORDERDEPS.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
|
---|
2796 | $($(target)_LNK_ORDERDEPS.$(bld_trg).$(bld_trg_arch)) \
|
---|
2797 | $($(target)_LNK_ORDERDEPS.$(bld_trg).$(bld_type)) \
|
---|
2798 | $($(target)_LNK_ORDERDEPS.$(bld_trg_arch)) \
|
---|
2799 | $($(target)_LNK_ORDERDEPS.$(bld_trg)) \
|
---|
2800 | $($(target)_LNK_ORDERDEPS.$(bld_type)) \
|
---|
2801 | $($(target)_LNK_ORDERDEPS)
|
---|
2802 |
|
---|
2803 | # Adjust paths if we got a default path.
|
---|
2804 | ifneq ($(defpath),)
|
---|
2805 | local libpath := $(abspathex $(libpath),$(defpath))
|
---|
2806 | local deps := $(abspathex $(deps),$(defpath))
|
---|
2807 | local orderdeps := $(abspathex $(orderdeps),$(defpath))
|
---|
2808 | othersrc := $(abspathex $(othersrc),$(defpath))
|
---|
2809 | # libs are not subject to this because of the the -l<lib> stuff. Use $(<target>_DEFPATH)/lib if relative to current dir!
|
---|
2810 | endif
|
---|
2811 |
|
---|
2812 | # Custom pre/post-link actions.
|
---|
2813 | local pre_cmds := $(evalcall def_fn_prop_get_first_defined,PRE_CMDS)
|
---|
2814 | local post_cmds := $(evalcall def_fn_prop_get_first_defined,POST_CMDS)
|
---|
2815 |
|
---|
2816 | # eliminate this guy?
|
---|
2817 | local objs = $($(target)_2_OBJS)
|
---|
2818 |
|
---|
2819 | # installation targets
|
---|
2820 | local target_type_mode :=
|
---|
2821 | $(evalval def_target_install_only)
|
---|
2822 |
|
---|
2823 | # dependency file
|
---|
2824 | local dep := $(outbase)$(SUFF_DEP)
|
---|
2825 | ifndef NO_LINK_CMDS_DEPS
|
---|
2826 | _DEPFILES_INCLUDED += $(dep)
|
---|
2827 | ifdef KB_HAVE_INCLUDEDEP_QUEUE
|
---|
2828 | includedep-queue $(dep)
|
---|
2829 | else
|
---|
2830 | includedep $(dep)
|
---|
2831 | endif
|
---|
2832 | endif
|
---|
2833 |
|
---|
2834 | # check that the tool is defined.
|
---|
2835 | ifndef TOOL_$(tool)_$(tool_do)_CMDS
|
---|
2836 | $(warning kBuild: tools: \
|
---|
2837 | 1 $($(target)_$(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
2838 | 2 $($(target)_$(source)TOOL.$(bld_trg)) \
|
---|
2839 | 3 $($(target)_$(source)TOOL) \
|
---|
2840 | 4 $($(target)_TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
2841 | 5 $($(target)_TOOL.$(bld_trg)) \
|
---|
2842 | 6 $($(target)_TOOL) \
|
---|
2843 | 7 $($(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
2844 | 8 $($(source)TOOL.$(bld_trg)) \
|
---|
2845 | 9 $($(source)TOOL) \
|
---|
2846 | 10 $(TOOL.$(bld_trg).$(bld_trg_arch)) \
|
---|
2847 | 11 $(TOOL.$(bld_trg)) \
|
---|
2848 | 12 $(TOOL) )
|
---|
2849 | $(error kBuild: TOOL_$(tool)_$(tool_do)_CMDS isn't defined! target=$(target) )
|
---|
2850 | endif
|
---|
2851 |
|
---|
2852 | # call the tool
|
---|
2853 | local cmds := $(TOOL_$(tool)_$(tool_do)_CMDS)
|
---|
2854 | ifneq ($(pre_cmds),)
|
---|
2855 | local cmds := $(TAB)$(pre_cmds)$(NL)$(TAB)$(cmds)
|
---|
2856 | endif
|
---|
2857 | ifneq ($(post_cmds),)
|
---|
2858 | local cmds := $(cmds)$(NL)$(TAB)$(post_cmds)
|
---|
2859 | endif
|
---|
2860 | $(target)_2_OUTPUT := $(TOOL_$(tool)_$(tool_do)_OUTPUT)
|
---|
2861 | $(target)_2_OUTPUT_MAYBE := $(TOOL_$(tool)_$(tool_do)_OUTPUT_MAYBE)
|
---|
2862 | $(target)_2_DEPEND := $(TOOL_$(tool)_$(tool_do)_DEPEND) $(deps) $($(target)_2_OBJS)
|
---|
2863 | $(target)_2_DEPORD := $(TOOL_$(tool)_$(tool_do)_DEPORD) $(dirdep) $(orderdeps)
|
---|
2864 |
|
---|
2865 | # generate the link rule.
|
---|
2866 | $(eval $(def_link_rule))
|
---|
2867 |
|
---|
2868 |
|
---|
2869 | # Update globals.
|
---|
2870 | _OBJS += $($(target)_2_OBJS)
|
---|
2871 | _OUT_FILES += $($(target)_2_OUTPUT) $($(target)_2_OUTPUT_MAYBE) $(out)
|
---|
2872 | _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))
|
---|
2873 | _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))
|
---|
2874 | _INSTALLS_FILES += $(INSTARGET_$(target))
|
---|
2875 |
|
---|
2876 | endef # def_link_common
|
---|
2877 | $(eval-opt-var def_link_common)
|
---|
2878 |
|
---|
2879 |
|
---|
2880 | #
|
---|
2881 | # BLDPROGS
|
---|
2882 | #
|
---|
2883 |
|
---|
2884 | # Process build programs.
|
---|
2885 | EXT := EXE
|
---|
2886 | EXTPRE := HOST
|
---|
2887 | tool_do := LINK_PROGRAM
|
---|
2888 | typevar := _BLDPROGS
|
---|
2889 | mode := 0755
|
---|
2890 | bld_trg_base_var := PLATFORM
|
---|
2891 | $(foreach target, $(_ALL_BLDPROGS), $(evalval def_link_common))
|
---|
2892 |
|
---|
2893 | ifdef KBUILD_PROFILE_SELF
|
---|
2894 | $(evalcall def_profile_self, done build program targets)
|
---|
2895 | endif
|
---|
2896 |
|
---|
2897 |
|
---|
2898 | #
|
---|
2899 | # DLLS
|
---|
2900 | #
|
---|
2901 |
|
---|
2902 | # Process dlls
|
---|
2903 | EXT := DLL
|
---|
2904 | EXTPRE :=
|
---|
2905 | tool_do := LINK_DLL
|
---|
2906 | typevar := _DLLS
|
---|
2907 | mode := 0644
|
---|
2908 | bld_trg_base_var := TARGET
|
---|
2909 | $(foreach target, $(_ALL_DLLS), $(evalval def_link_common))
|
---|
2910 |
|
---|
2911 | ifdef KBUILD_PROFILE_SELF
|
---|
2912 | $(evalcall def_profile_self, done dll targets)
|
---|
2913 | endif
|
---|
2914 |
|
---|
2915 |
|
---|
2916 | #
|
---|
2917 | # IMPORT LIBRARIES
|
---|
2918 | #
|
---|
2919 | # - On OS/2 and windows these are libraries.
|
---|
2920 | # - On other platforms they are fake DLLs.
|
---|
2921 | #
|
---|
2922 | EXTPRE :=
|
---|
2923 | typevar := _IMPORT_LIBS
|
---|
2924 | mode := 0644
|
---|
2925 | bld_trg_base_var := TARGET
|
---|
2926 | ifeq ($(filter-out nt os2 win win64 win32,$(KBUILD_TARGET)),)
|
---|
2927 | EXT := LIB
|
---|
2928 | tool_do := LINK_LIBRARY
|
---|
2929 | $(foreach target, $(_ALL_IMPORT_LIBS), $(evalval def_lib))
|
---|
2930 | else
|
---|
2931 | EXT := DLL
|
---|
2932 | tool_do := LINK_DLL
|
---|
2933 | $(foreach target, $(_ALL_IMPORT_LIBS), $(evalval def_link_common))
|
---|
2934 | endif
|
---|
2935 |
|
---|
2936 | ifdef KBUILD_PROFILE_SELF
|
---|
2937 | $(evalcall def_profile_self, done import library targets)
|
---|
2938 | endif
|
---|
2939 |
|
---|
2940 |
|
---|
2941 | #
|
---|
2942 | # PROGRAMS
|
---|
2943 | #
|
---|
2944 |
|
---|
2945 | # Process programs
|
---|
2946 | EXT := EXE
|
---|
2947 | EXTPRE :=
|
---|
2948 | tool_do := LINK_PROGRAM
|
---|
2949 | typevar := _PROGRAMS
|
---|
2950 | mode := 0755
|
---|
2951 | bld_trg_base_var := TARGET
|
---|
2952 | $(foreach target, $(_ALL_PROGRAMS), $(evalval def_link_common))
|
---|
2953 |
|
---|
2954 | ifdef KBUILD_PROFILE_SELF
|
---|
2955 | $(evalcall def_profile_self, done program targets)
|
---|
2956 | endif
|
---|
2957 |
|
---|
2958 |
|
---|
2959 | #
|
---|
2960 | # SYSMODS
|
---|
2961 | #
|
---|
2962 |
|
---|
2963 | # Process sysmods
|
---|
2964 | EXT := SYS
|
---|
2965 | EXTPRE :=
|
---|
2966 | tool_do := LINK_SYSMOD
|
---|
2967 | typevar := _SYSMODS
|
---|
2968 | mode := 0644
|
---|
2969 | bld_trg_base_var := TARGET
|
---|
2970 | $(foreach target, $(_ALL_SYSMODS), $(evalval def_link_common))
|
---|
2971 |
|
---|
2972 | ifdef KBUILD_PROFILE_SELF
|
---|
2973 | $(evalcall def_profile_self, done sysmod targets)
|
---|
2974 | endif
|
---|
2975 |
|
---|
2976 |
|
---|
2977 | #
|
---|
2978 | # MISCBINS
|
---|
2979 | #
|
---|
2980 |
|
---|
2981 | # Process MISCBINS
|
---|
2982 | EXT := BIN
|
---|
2983 | EXTPRE :=
|
---|
2984 | tool_do := LINK_MISCBIN
|
---|
2985 | typevar := _MISCBINS
|
---|
2986 | mode := 0644
|
---|
2987 | bld_trg_base_var := TARGET
|
---|
2988 | $(foreach target, $(_ALL_MISCBINS), $(evalval def_link_common))
|
---|
2989 |
|
---|
2990 | ifdef KBUILD_PROFILE_SELF
|
---|
2991 | $(evalcall def_profile_self, done misc binary targets)
|
---|
2992 | endif
|
---|
2993 |
|
---|
2994 |
|
---|
2995 | #
|
---|
2996 | # OTHERS
|
---|
2997 | #
|
---|
2998 | _OTHERS = $(OTHERS) $(OTHERS.$(KBUILD_TARGET)) $(OTHERS.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH))
|
---|
2999 |
|
---|
3000 |
|
---|
3001 | #
|
---|
3002 | # INSTALLS
|
---|
3003 | #
|
---|
3004 |
|
---|
3005 | ##
|
---|
3006 | # Generate the staging rules.
|
---|
3007 | #
|
---|
3008 | define def_install_src_rule_staging
|
---|
3009 | $(stagedst) : $(srcsrc) | $(dir $(stagedst))
|
---|
3010 | %$$(call MSG_INST_FILE,$(srcsrc),$(stagedst))
|
---|
3011 | $$(QUIET)$(stagecmd)
|
---|
3012 | endef
|
---|
3013 | $(eval-opt-var def_install_src_rule_staging)
|
---|
3014 |
|
---|
3015 | define def_install_src_rule_installing
|
---|
3016 | $(instdst) : $(srcsrc) | $(dir $(instdst))
|
---|
3017 | %$$(call MSG_INST_FILE,$(srcsrc),$(instdst))
|
---|
3018 | $$(QUIET)$(instcmd)
|
---|
3019 | endef
|
---|
3020 | $(eval-opt-var def_install_src_rule_installing)
|
---|
3021 |
|
---|
3022 | ##
|
---|
3023 | # Install one file.
|
---|
3024 | #
|
---|
3025 | define def_install_src
|
---|
3026 |
|
---|
3027 | # deal with '=>' in the source file name.
|
---|
3028 | ifeq ($(src),=>)
|
---|
3029 | $(error kBuild: Install target '$(target)' has a bad source specifier containing '=>' without any file names)
|
---|
3030 | endif
|
---|
3031 | ifeq ($(substr $(src),1,2),=>)
|
---|
3032 | $(warning kBuild: Install target '$(target)' has a bad source specifier: $(src))
|
---|
3033 | endif
|
---|
3034 | ifeq ($(substr $(src),-2),=>)
|
---|
3035 | $(warning kBuild: Install target '$(target)' has a bad source specifier: $(src))
|
---|
3036 | endif
|
---|
3037 | local srcdst := $(subst =>, ,$(src))
|
---|
3038 | local srcsrc := $(firstword $(srcdst))
|
---|
3039 | local srcdstdir := $(dir $(word 2,$(srcdst)))
|
---|
3040 | local srcdst := $(word $(words $(srcdst)),$(srcdst))
|
---|
3041 |
|
---|
3042 | # instfun, mode, uid and gid.
|
---|
3043 | ifdef $(srcsrc)_INSTFUN
|
---|
3044 | local instfun := $(srcsrc)_INSTFUN
|
---|
3045 | else
|
---|
3046 | local instfun := $(top_instfun)
|
---|
3047 | endif
|
---|
3048 | local mode := $(firstword \
|
---|
3049 | $($(target)_$(srcsrc)$(source_type_prefix)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
3050 | $($(target)_$(srcsrc)$(source_type_prefix)_MODE.$(bld_trg)) \
|
---|
3051 | $($(target)_$(srcsrc)$(source_type_prefix)_MODE) \
|
---|
3052 | $($(target)_$(srcdst)$(source_type_prefix)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
3053 | $($(target)_$(srcdst)$(source_type_prefix)_MODE.$(bld_trg)) \
|
---|
3054 | $($(target)_$(srcdst)$(source_type_prefix)_MODE) \
|
---|
3055 | $($(srcsrc)$(source_type_prefix)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
3056 | $($(srcsrc)$(source_type_prefix)_MODE.$(bld_trg)) \
|
---|
3057 | $($(srcsrc)$(source_type_prefix)_MODE) \
|
---|
3058 | $($(srcdst)$(source_type_prefix)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
3059 | $($(srcdst)$(source_type_prefix)_MODE.$(bld_trg)) \
|
---|
3060 | $($(srcdst)$(source_type_prefix)_MODE) \
|
---|
3061 | $(source_type_mode))
|
---|
3062 | local uid := $(firstword \
|
---|
3063 | $($(target)_$(srcsrc)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
3064 | $($(target)_$(srcsrc)_UID.$(bld_trg)) \
|
---|
3065 | $($(target)_$(srcsrc)_UID) \
|
---|
3066 | $($(target)_$(srcdst)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
3067 | $($(target)_$(srcdst)_UID.$(bld_trg)) \
|
---|
3068 | $($(target)_$(srcdst)_UID) \
|
---|
3069 | $($(srcsrc)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
3070 | $($(srcsrc)_UID.$(bld_trg)) \
|
---|
3071 | $($(srcsrc)_UID) \
|
---|
3072 | $($(srcdst)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
3073 | $($(srcdst)_UID.$(bld_trg)) \
|
---|
3074 | $($(srcdst)_UID) \
|
---|
3075 | $(top_uid))
|
---|
3076 | local gid := $(firstword \
|
---|
3077 | $($(target)_$(srcsrc)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
3078 | $($(target)_$(srcsrc)_GID.$(bld_trg)) \
|
---|
3079 | $($(target)_$(srcsrc)_GID) \
|
---|
3080 | $($(target)_$(srcdst)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
3081 | $($(target)_$(srcdst)_GID.$(bld_trg)) \
|
---|
3082 | $($(target)_$(srcdst)_GID) \
|
---|
3083 | $($(srcsrc)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
3084 | $($(srcsrc)_GID.$(bld_trg)) \
|
---|
3085 | $($(srcsrc)_GID) \
|
---|
3086 | $($(srcdst)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
3087 | $($(srcdst)_GID.$(bld_trg)) \
|
---|
3088 | $($(srcdst)_GID) \
|
---|
3089 | $(top_gid))
|
---|
3090 | local flags := \
|
---|
3091 | $(top_ifflags) \
|
---|
3092 | $($(srcdst)$(source_type_prefix)_IFFLAGS) \
|
---|
3093 | $($(srcdst)$(source_type_prefix)_IFFLAGS.$(bld_trg)) \
|
---|
3094 | $($(srcdst)$(source_type_prefix)_IFFLAGS.$(bld_trg).$(bld_trg_arch)) \
|
---|
3095 | $($(srcsrc)$(source_type_prefix)_IFFLAGS) \
|
---|
3096 | $($(srcsrc)$(source_type_prefix)_IFFLAGS.$(bld_trg)) \
|
---|
3097 | $($(srcsrc)$(source_type_prefix)_IFFLAGS.$(bld_trg).$(bld_trg_arch)) \
|
---|
3098 | $($(target)_$(srcdst)$(source_type_prefix)_IFFLAGS) \
|
---|
3099 | $($(target)_$(srcdst)$(source_type_prefix)_IFFLAGS.$(bld_trg)) \
|
---|
3100 | $($(target)_$(srcdst)$(source_type_prefix)_IFFLAGS.$(bld_trg).$(bld_trg_arch)) \
|
---|
3101 | $($(target)_$(srcsrc)$(source_type_prefix)_IFFLAGS) \
|
---|
3102 | $($(target)_$(srcsrc)$(source_type_prefix)_IFFLAGS.$(bld_trg)) \
|
---|
3103 | $($(target)_$(srcsrc)$(source_type_prefix)_IFFLAGS.$(bld_trg).$(bld_trg_arch))
|
---|
3104 | clean_files += \
|
---|
3105 | $($(srcdst)_CLEAN) \
|
---|
3106 | $($(srcdst)_CLEAN.$(bld_trg)) \
|
---|
3107 | $($(srcdst)_CLEAN.$(bld_trg).$(bld_trg_arch)) \
|
---|
3108 | $($(srcsrc)_CLEAN) \
|
---|
3109 | $($(srcsrc)_CLEAN.$(bld_trg)) \
|
---|
3110 | $($(srcsrc)_CLEAN.$(bld_trg).$(bld_trg_arch)) \
|
---|
3111 | $($(target)_$(srcdst)_CLEAN) \
|
---|
3112 | $($(target)_$(srcdst)_CLEAN.$(bld_trg)) \
|
---|
3113 | $($(target)_$(srcdst)_CLEAN.$(bld_trg).$(bld_trg_arch)) \
|
---|
3114 | $($(target)_$(srcsrc)_CLEAN) \
|
---|
3115 | $($(target)_$(srcsrc)_CLEAN.$(bld_trg)) \
|
---|
3116 | $($(target)_$(srcsrc)_CLEAN.$(bld_trg).$(bld_trg_arch))
|
---|
3117 |
|
---|
3118 |
|
---|
3119 | # Adjust the source if we got a default PATH. (This must be done this late!)
|
---|
3120 | ifdef $(target)_DEFPATH
|
---|
3121 | local defpath := $($(target)_DEFPATH)
|
---|
3122 | else ifdef $(target)_PATH
|
---|
3123 | local defpath := $($(target)_PATH)
|
---|
3124 | else
|
---|
3125 | local defpath :=
|
---|
3126 | endif
|
---|
3127 | ifneq ($(defpath),)
|
---|
3128 | local srcsrc := $(abspathex $(srcsrc),$(defpath))
|
---|
3129 | endif
|
---|
3130 |
|
---|
3131 | # Generate the staging rule (requires double evaluation).
|
---|
3132 | local stage := $(strip $(firstdefined $(srcsrc)_STAGE $(srcsrc)_INST $(target)_1_STAGE,value))
|
---|
3133 | if "$(substr $(stage),-1)" != "/" && "$(stage)" != ""
|
---|
3134 | $(warning kBuild: File $(srcsrc) in install target $(target) has a STAGE/INST property without a trailing slash: '$(stage)')
|
---|
3135 | local stage := $(stage)/
|
---|
3136 | endif
|
---|
3137 | local stage := $(stage)$(dir $(srcdstdir))
|
---|
3138 | ifeq ($(root $(stage)),)
|
---|
3139 | local stagedst := $(call $(instfun),$(srcdst),$(target),$(stage),$(PATH_STAGE))
|
---|
3140 | else
|
---|
3141 | local stage := $(abspath $(stage))/
|
---|
3142 | ifeq ($(pos $(PATH_OBJ),$(stage)),1)
|
---|
3143 | local stage := $(substr $(stage), $(expr $(length-var PATH_OBJ) + 2))
|
---|
3144 | local stagedst := $(call $(instfun),$(srcdst),$(target),$(stage),$(PATH_OBJ))
|
---|
3145 | else
|
---|
3146 | $(error kBuild: File $(srcsrc) in install target $(target) has a STAGE/INST property with an absolute path outside PATH_OBJ: '$(stage)')
|
---|
3147 | endif
|
---|
3148 | endif
|
---|
3149 | ifdef $(srcsrc)_INSTALLER
|
---|
3150 | local stagecmd := $(call $(srcsrc)_INSTALLER,$(srcsrc),$(stagedst),$(target),$(flags),stage)
|
---|
3151 | else ifdef $(target)_INSTALLER
|
---|
3152 | local stagecmd := $(call $(target)_INSTALLER,$(srcsrc),$(stagedst),$(target),$(flags),stage)
|
---|
3153 | else
|
---|
3154 | local stagecmd := $$(INSTALL_STAGING)\
|
---|
3155 | $(if $(uid),-o $(uid))\
|
---|
3156 | $(if $(gid),-g $(gid))\
|
---|
3157 | $(if $(mode),-m $(mode))\
|
---|
3158 | $(flags) -- \
|
---|
3159 | $(srcsrc) $(stagedst)
|
---|
3160 | endif
|
---|
3161 | $(eval $(def_install_src_rule_staging))
|
---|
3162 | $(target)_2_STAGE_TARGETS += $(stagedst)
|
---|
3163 |
|
---|
3164 | # Generate the install rule
|
---|
3165 | ifeq ($(insttype),both)
|
---|
3166 | local inst := $(strip $(firstdefined $(srcsrc)_INST $(target)_1_INST,value))
|
---|
3167 | if "$(substr $(inst),-1)" != "/" && "$(inst)" != ""
|
---|
3168 | $(warning kBuild: File $(srcsrc) in install target $(target) has a INST property without a trailing slash: '$(inst)')
|
---|
3169 | local inst := $(inst)/
|
---|
3170 | endif
|
---|
3171 | local inst := $(inst)$(dir $(srcdstdir))
|
---|
3172 | ifneq ($(root $(inst)),)
|
---|
3173 | $(error kBuild: File $(srcsrc) in install target $(target) has a INST property with an absolute path: '$(inst)')
|
---|
3174 | endif
|
---|
3175 | local instdst := $(call $(instfun),$(srcdst),$(target),$(inst),$(PATH_INS))
|
---|
3176 |
|
---|
3177 | ifdef $(srcsrc)_INSTALLER
|
---|
3178 | local instcmd := $(call $(srcsrc)_INSTALLER,$(srcsrc),$(instdst),$(target),$(flags),install)
|
---|
3179 | else ifdef $(target)_INSTALLER
|
---|
3180 | local instcmd := $(call $(target)_INSTALLER,$(srcsrc),$(instdst),$(target),$(flags),install)
|
---|
3181 | else
|
---|
3182 | local instcmd := $$(INSTALL)\
|
---|
3183 | $(if $(uid),-o $(uid))\
|
---|
3184 | $(if $(gid),-g $(gid))\
|
---|
3185 | $(if $(mode),-m $(mode))\
|
---|
3186 | $(flags) -- \
|
---|
3187 | $(srcsrc) $(instdst)
|
---|
3188 | endif
|
---|
3189 | $(eval $(def_install_src_rule_installing))
|
---|
3190 | $(target)_2_INST_TARGETS += $(instdst)
|
---|
3191 | endif
|
---|
3192 |
|
---|
3193 | #$(warning instfun=$(instfun) srcdst=$(srcdst) target=$(target) inst=$(inst) => instdst=$(instdst); stage=$(stage) => stagedst=$(stagedst))
|
---|
3194 | endef # def_install_src
|
---|
3195 | $(eval-opt-var def_install_src)
|
---|
3196 |
|
---|
3197 |
|
---|
3198 | ##
|
---|
3199 | # Generate the symlink rules.
|
---|
3200 | #
|
---|
3201 | define def_install_symlink_rule_staging
|
---|
3202 | $(stagedst) : | $(dir $(stagedst))
|
---|
3203 | %$$(call MSG_INST_SYM,$(stagedst),$(symdst))
|
---|
3204 | $$(QUIET)$$(RM) -f -- $$@
|
---|
3205 | $$(QUIET)$$(LN_SYMLINK) $(symdst) $(stagedst)
|
---|
3206 | endef
|
---|
3207 | $(eval-opt-var def_install_symlink_rule_staging)
|
---|
3208 |
|
---|
3209 | define def_install_symlink_rule_installing
|
---|
3210 | $(instdst) : | $(dir $(instdst))
|
---|
3211 | %$$(call MSG_INST_SYM,$(instdst),$(symdst))
|
---|
3212 | $$(QUIET)$$(RM) -f -- $$@
|
---|
3213 | $$(QUIET)$$(LN_SYMLINK) $(symdst) $(instdst)
|
---|
3214 | endef
|
---|
3215 | $(eval-opt-var def_install_symlink_rule_installing)
|
---|
3216 |
|
---|
3217 |
|
---|
3218 | ##
|
---|
3219 | # Create one symlink.
|
---|
3220 | #
|
---|
3221 | define def_install_symlink
|
---|
3222 |
|
---|
3223 | # deal with '=>' in the source file name.
|
---|
3224 | local symdst := $(subst =>, ,$(src))
|
---|
3225 | local symlnk := $(firstword $(symdst))
|
---|
3226 | local symdst := $(word $(words $(symdst)),$(symdst))
|
---|
3227 |
|
---|
3228 | # Figure which install function to use below.
|
---|
3229 | ifdef $(symlnk)_INSTFUN
|
---|
3230 | local instfun := $(symlnk)_INSTFUN
|
---|
3231 | else
|
---|
3232 | local instfun := $(top_instfun)
|
---|
3233 | endif
|
---|
3234 |
|
---|
3235 | # Calc stage destination and generate the rule (requires double evaluation).
|
---|
3236 | local stage := $(strip $(firstdefined $(symlnk)_STAGE $(symlnk)_INST $(target)_1_STAGE,value))
|
---|
3237 | if "$(substr $(stage),-1)" != "/" && "$(stage)" != ""
|
---|
3238 | $(warning kBuild: Symlink $(symlnk) in install target $(target) has a STAGE/INST property without a trailing slash: '$(stage)')
|
---|
3239 | local stage := $(stage)/
|
---|
3240 | endif
|
---|
3241 | local stage := $(stage)$(dir $(srcdstdir))
|
---|
3242 | ifeq ($(root $(stage)),)
|
---|
3243 | local stagedst := $(call $(instfun),$(symlnk),$(target),$(stage),$(PATH_STAGE))
|
---|
3244 | else
|
---|
3245 | local stage := $(abspath $(stage))/
|
---|
3246 | ifeq ($(pos $(PATH_OBJ),$(stage)),1)
|
---|
3247 | local stage := $(substr $(stage), $(expr $(length-var PATH_OBJ) + 2))
|
---|
3248 | local stagedst := $(call $(instfun),$(symlnk),$(target),$(stage),$(PATH_OBJ))
|
---|
3249 | else
|
---|
3250 | $(error kBuild: Symlink $(symlnk) in install target $(target) has a STAGE/INST property with an absolute path outside PATH_OBJ: '$(stage)')
|
---|
3251 | endif
|
---|
3252 | endif
|
---|
3253 |
|
---|
3254 | $(eval $(def_install_symlink_rule_staging))
|
---|
3255 | $(target)_2_STAGE_TARGETS += $(stagedst)
|
---|
3256 |
|
---|
3257 | # Calcuate the install destiation and generate the rule (if necessary).
|
---|
3258 | ifeq ($(instmode),both)
|
---|
3259 | local inst := $(strip $(firstdefined $(symlnk)_INST $(target)_1_INST,value))
|
---|
3260 | if "$(substr $(inst),-1)" != "/" && "$(inst)" != ""
|
---|
3261 | $(warning kBuild: Symlink $(symlnk) in install target $(target) has a INST property without a trailing slash: '$(inst)')
|
---|
3262 | local inst := $(inst)/
|
---|
3263 | endif
|
---|
3264 | ifneq ($(root $(inst)),)
|
---|
3265 | $(error kBuild: Symlink $(symlnk) in install target $(target) has a INST property with an absolute path: '$(inst)')
|
---|
3266 | endif
|
---|
3267 | local inst := $(inst)$(dir $(srcdstdir))
|
---|
3268 | local instdst := $(call $(instfun),$(symlnk),$(target),$(inst),$(PATH_INS))
|
---|
3269 | $(eval $(def_install_symlink_rule_installing))
|
---|
3270 | $(target)_2_INST_TARGETS += $(instdst)
|
---|
3271 | endif
|
---|
3272 |
|
---|
3273 | #$(warning symlnk=$(symlnk) symdst=$(symdst) instdst=$(instdst) stagedst=$(stagedst) instfun=$(instfun) inst=$(inst) stage='$(stage)')
|
---|
3274 | endef # def_install_symlink
|
---|
3275 | $(optmize def_install_symlink)
|
---|
3276 |
|
---|
3277 |
|
---|
3278 | ##
|
---|
3279 | # Generate an directory installtion rule.
|
---|
3280 | # Note. Used both for staging and real install rules.
|
---|
3281 | #
|
---|
3282 | define def_install_directory_rule
|
---|
3283 | # the install rule
|
---|
3284 | $(insdst):
|
---|
3285 | %$$(call MSG_INST_DIR,$(insdst))
|
---|
3286 | $$(QUIET)$$(INSTALL) -d \
|
---|
3287 | $(if $(uid),-o $(uid))\
|
---|
3288 | $(if $(gid),-g $(gid))\
|
---|
3289 | $(if $(mode),-m $(mode))\
|
---|
3290 | $(flags) -- \
|
---|
3291 | $(insdst)
|
---|
3292 |
|
---|
3293 | .NOTPARALLEL: $(insdst)
|
---|
3294 | endef # def_install_directory_rule
|
---|
3295 | $(eval-opt-var def_install_directory_rule)
|
---|
3296 |
|
---|
3297 | ##
|
---|
3298 | # Create one directory.
|
---|
3299 | #
|
---|
3300 | define def_install_directory
|
---|
3301 |
|
---|
3302 | # gather common properties.
|
---|
3303 | local mode := $(firstword \
|
---|
3304 | $($(target)_$(directory)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
3305 | $($(target)_$(directory)_MODE.$(bld_trg)) \
|
---|
3306 | $($(target)_$(directory)_MODE) \
|
---|
3307 | $($(directory)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
3308 | $($(directory)_MODE.$(bld_trg)) \
|
---|
3309 | $($(directory)_MODE) \
|
---|
3310 | $(top_mode) )
|
---|
3311 | local uid := $(firstword \
|
---|
3312 | $($(target)_$(directory)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
3313 | $($(target)_$(directory)_UID.$(bld_trg)) \
|
---|
3314 | $($(target)_$(directory)_UID) \
|
---|
3315 | $($(directory)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
3316 | $($(directory)_UID.$(bld_trg)) \
|
---|
3317 | $($(directory)_UID) \
|
---|
3318 | $(top_uid) )
|
---|
3319 | local gid := $(firstword \
|
---|
3320 | $($(target)_$(directory)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
3321 | $($(target)_$(directory)_GID.$(bld_trg)) \
|
---|
3322 | $($(target)_$(directory)_GID) \
|
---|
3323 | $($(directory)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
3324 | $($(directory)_GID.$(bld_trg)) \
|
---|
3325 | $($(directory)_GID) \
|
---|
3326 | $(top_gid) )
|
---|
3327 | local flags := \
|
---|
3328 | $(top_idflags) \
|
---|
3329 | $($(directory)_IDFLAGS) \
|
---|
3330 | $($(directory)_IDFLAGS.$(bld_trg)) \
|
---|
3331 | $($(directory)_IDFLAGS.$(bld_trg).$(bld_trg_arch)) \
|
---|
3332 | $($(target)_$(directory)_IDFLAGS) \
|
---|
3333 | $($(target)_$(directory)_IDFLAGS.$(bld_trg)) \
|
---|
3334 | $($(target)_$(directory)_IDFLAGS.$(bld_trg).$(bld_trg_arch)) \
|
---|
3335 |
|
---|
3336 | # The staging rule (requires double evaluation).
|
---|
3337 | local stage := $(strip $(firstdefined $(directory)_STAGE $(directory)_INST $(target)_1_STAGE,value))
|
---|
3338 | if "$(substr $(stage),-1)" != "/" && "$(stage)" != ""
|
---|
3339 | $(warning kBuild: Directory $(directory) in install target $(target) has a STAGE/INST property without a trailing slash: '$(stage)')
|
---|
3340 | local stage := $(stage)/
|
---|
3341 | endif
|
---|
3342 | ifeq ($(root $(stage)),)
|
---|
3343 | local insdst := $(PATH_STAGE)/$(stage)$(directory)/
|
---|
3344 | else
|
---|
3345 | local stage := $(abspath $(stage))/
|
---|
3346 | ifeq ($(pos $(PATH_OBJ),$(stage)),1)
|
---|
3347 | local insdst := $(stage)$(directory)/
|
---|
3348 | else
|
---|
3349 | $(error kBuild: Directory $(directory) in install target $(target) has a STAGE/INST property with an absolute path outside PATH_OBJ: '$(stage)')
|
---|
3350 | endif
|
---|
3351 | endif
|
---|
3352 |
|
---|
3353 | $(target)_2_STAGE_DIR_TARGETS += $(insdst)
|
---|
3354 | $(eval $(def_install_directory_rule))
|
---|
3355 |
|
---|
3356 | # The install rule.
|
---|
3357 | ifeq ($(insttype),both)
|
---|
3358 | local inst := $(strip $(firstdefined $(directory)_INST $(target)_1_INST,value))
|
---|
3359 | ifneq ($(substr $(inst),-1),/)
|
---|
3360 | $(warning kBuild: Directory $(directory) in install target $(target) has a INST property without a trailing slash: '$(inst)')
|
---|
3361 | local inst := $(inst)/
|
---|
3362 | endif
|
---|
3363 | ifeq ($(root $(stage)),)
|
---|
3364 | $(error kBuild: Directory $(directory) in install target $(target) has a INST property with an absoluate path: '$(inst)')
|
---|
3365 | endif
|
---|
3366 | local insdst := $(PATH_INS)/$(inst)$(directory)/
|
---|
3367 | $(target)_2_INST_DIR_TARGETS += $(insdst)
|
---|
3368 | $(eval $(def_install_directory_rule))
|
---|
3369 | endif
|
---|
3370 |
|
---|
3371 | #$(warning directory=$(directory) inst=$(inst) stage=$(stage) mode=$(mode) gid=$(gid) uid=$(uid))
|
---|
3372 | endef # def_install_directory
|
---|
3373 | $(eval-opt-var def_install_directory)
|
---|
3374 |
|
---|
3375 |
|
---|
3376 | ##
|
---|
3377 | # Process one install target.
|
---|
3378 | #
|
---|
3379 | define def_install
|
---|
3380 | # the basics.
|
---|
3381 | local bld_type := $(firstword $($(target)_BLD_TYPE) $(KBUILD_TYPE))
|
---|
3382 | local bld_trg := $(firstword $($(target)_BLD_TRG) $(KBUILD_TARGET))
|
---|
3383 | local bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(KBUILD_TARGET_ARCH))
|
---|
3384 | local bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(KBUILD_TARGET_CPU))
|
---|
3385 | local insttype := $($(target)_1_INSTTYPE)
|
---|
3386 |
|
---|
3387 | ifneq ($(insttype),none)
|
---|
3388 | $(target)_2_STAGE_TARGETS := $($(target)_GOALS) $($(target)_STAGE_ONLY_GOALS)
|
---|
3389 | else
|
---|
3390 | $(target)_2_STAGE_TARGETS :=
|
---|
3391 | endif
|
---|
3392 | $(target)_2_STAGE_DIR_TARGETS :=
|
---|
3393 |
|
---|
3394 | ifeq ($(insttype),both)
|
---|
3395 | $(target)_2_INST_TARGETS := $($(target)_GOALS) $($(target)_INST_ONLY_GOALS)
|
---|
3396 | else
|
---|
3397 | $(target)_2_INST_TARGETS :=
|
---|
3398 | endif
|
---|
3399 | $(target)_2_INST_DIR_TARGETS :=
|
---|
3400 |
|
---|
3401 |
|
---|
3402 | local outbase := $(call TARGET_BASE,$(target),$(target))
|
---|
3403 | $(target)_0_OUTDIR := $(patsubst %/,%,$(dir $(outbase)))
|
---|
3404 | $(call KB_FN_ASSIGN_DEPRECATED,PATH_$(target),$($(target)_0_OUTDIR), $(target)_0_OUTDIR)
|
---|
3405 |
|
---|
3406 | ifneq ($(insttype),none)
|
---|
3407 | # cache top level target properties.
|
---|
3408 | local top_mode := $(firstword \
|
---|
3409 | $($(target)_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
3410 | $($(target)_MODE.$(bld_trg)) \
|
---|
3411 | $($(target)_MODE) )
|
---|
3412 | local top_exec_mode := $(firstword \
|
---|
3413 | $($(target)_EXEC_MODE.$(bld_trg).$(bld_trg_arch)) \
|
---|
3414 | $($(target)_EXEC_MODE.$(bld_trg)) \
|
---|
3415 | $($(target)_EXEC_MODE) )
|
---|
3416 | local top_uid := $(firstword \
|
---|
3417 | $($(target)_UID.$(bld_trg).$(bld_trg_arch)) \
|
---|
3418 | $($(target)_UID.$(bld_trg)) \
|
---|
3419 | $($(target)_UID) )
|
---|
3420 | local top_gid := $(firstword \
|
---|
3421 | $($(target)_GID.$(bld_trg).$(bld_trg_arch)) \
|
---|
3422 | $($(target)_GID.$(bld_trg)) \
|
---|
3423 | $($(target)_GID) )
|
---|
3424 | local top_ifflags := \
|
---|
3425 | $($(target)_IFFLAGS) \
|
---|
3426 | $($(target)_IFFLAGS.$(bld_trg)) \
|
---|
3427 | $($(target)_IFFLAGS.$(bld_trg).$(bld_trg_arch))
|
---|
3428 | local top_idflags := \
|
---|
3429 | $($(target)_IDFLAGS) \
|
---|
3430 | $($(target)_IDFLAGS.$(bld_trg)) \
|
---|
3431 | $($(target)_IDFLAGS.$(bld_trg).$(bld_trg_arch))
|
---|
3432 | ifdef $(target)_INSTFUN
|
---|
3433 | local top_instfun := $(target)_INSTFUN
|
---|
3434 | else
|
---|
3435 | local top_instfun := _INSTALL_FILE
|
---|
3436 | endif
|
---|
3437 |
|
---|
3438 | $(foreach directory, \
|
---|
3439 | $($(target)_DIRS) \
|
---|
3440 | $($(target)_DIRS.$(bld_trg)) \
|
---|
3441 | $($(target)_DIRS.$(bld_trg).$(bld_trg_arch)) \
|
---|
3442 | $($(target)_DIRS.$(bld_trg_arch)) \
|
---|
3443 | $($(target)_DIRS.$(bld_trg_cpu)) \
|
---|
3444 | $($(target)_DIRS.$(bld_type)), \
|
---|
3445 | $(evalval def_install_directory))
|
---|
3446 |
|
---|
3447 | local clean_files := \
|
---|
3448 | $($(target)_CLEAN) \
|
---|
3449 | $($(target)_CLEAN.$(bld_trg)) \
|
---|
3450 | $($(target)_CLEAN.$(bld_trg).$(bld_trg_arch)) \
|
---|
3451 | $($(target)_CLEAN.$(bld_trg_arch)) \
|
---|
3452 | $($(target)_CLEAN.$(bld_trg_cpu)) \
|
---|
3453 | $($(target)_CLEAN.$(bld_type))
|
---|
3454 |
|
---|
3455 | local source_type_prefix :=
|
---|
3456 | local source_type_mode := $(firstword $(top_mode) a+r,u+w)
|
---|
3457 | $(foreach src,\
|
---|
3458 | $($(target)_SOURCES) \
|
---|
3459 | $($(target)_SOURCES.$(bld_trg)) \
|
---|
3460 | $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) \
|
---|
3461 | $($(target)_SOURCES.$(bld_trg_arch)) \
|
---|
3462 | $($(target)_SOURCES.$(bld_trg_cpu)) \
|
---|
3463 | $($(target)_SOURCES.$(bld_type)), \
|
---|
3464 | $(evalval def_install_src))
|
---|
3465 |
|
---|
3466 | local source_type_prefix := EXEC_
|
---|
3467 | local source_type_mode := $(firstword $(top_exec_mode) a+xr,u+w)
|
---|
3468 | $(foreach src,\
|
---|
3469 | $($(target)_EXEC_SOURCES) \
|
---|
3470 | $($(target)_EXEC_SOURCES.$(bld_trg)) \
|
---|
3471 | $($(target)_EXEC_SOURCES.$(bld_trg).$(bld_trg_arch)) \
|
---|
3472 | $($(target)_EXEC_SOURCES.$(bld_trg_arch)) \
|
---|
3473 | $($(target)_EXEC_SOURCES.$(bld_trg_cpu)) \
|
---|
3474 | $($(target)_EXEC_SOURCES.$(bld_type)), \
|
---|
3475 | $(evalval def_install_src))
|
---|
3476 |
|
---|
3477 | $(foreach src,\
|
---|
3478 | $($(target)_SYMLINKS) \
|
---|
3479 | $($(target)_SYMLINKS.$(bld_trg)) \
|
---|
3480 | $($(target)_SYMLINKS.$(bld_trg).$(bld_trg_arch)) \
|
---|
3481 | $($(target)_SYMLINKS.$(bld_trg_arch)) \
|
---|
3482 | $($(target)_SYMLINKS.$(bld_trg_cpu)) \
|
---|
3483 | $($(target)_SYMLINKS.$(bld_type)), \
|
---|
3484 | $(evalval def_install_symlink))
|
---|
3485 | else # none
|
---|
3486 | local clean_files :=
|
---|
3487 | endif
|
---|
3488 |
|
---|
3489 | # The collection targets (staging only).
|
---|
3490 | local clean_files += $($(target)_1_TARGET)
|
---|
3491 | $($(target)_1_TARGET): $$($(target)_2_STAGE_TARGETS) | $$($(target)_2_STAGE_DIR_TARGETS) $$(dir $$@)
|
---|
3492 | @$(QUIET2)$(APPEND) $@
|
---|
3493 |
|
---|
3494 | $(target): $$($(target)_1_TARGET)
|
---|
3495 |
|
---|
3496 | # Update Global lists.
|
---|
3497 | _INSTALLS += $($(target)_1_TARGET)
|
---|
3498 | _STAGE_FILES += $($(target)_2_STAGE_TARGETS)
|
---|
3499 | _STAGE_DIRS += $($(target)_2_STAGE_DIR_TARGETS)
|
---|
3500 | _INSTALLS_FILES += $($(target)_2_INST_TARGETS)
|
---|
3501 | _INSTALLS_DIRS += $($(target)_2_INST_DIR_TARGETS)
|
---|
3502 | _CLEAN_FILES += $(clean_files)
|
---|
3503 | _DIRS += \
|
---|
3504 | $($(target)_0_OUTDIR) \
|
---|
3505 | $($(target)_BLDDIRS) \
|
---|
3506 | $($(target)_BLDDIRS.$(bld_trg)) \
|
---|
3507 | $($(target)_BLDDIRS.$(bld_trg).$(bld_trg_arch)) \
|
---|
3508 | $($(target)_BLDDIRS.$(bld_trg_arch)) \
|
---|
3509 | $($(target)_BLDDIRS.$(bld_trg_cpu)) \
|
---|
3510 | $($(target)_BLDDIRS.$(bld_type))
|
---|
3511 |
|
---|
3512 | # Deprecated properties.
|
---|
3513 | INSTARGET_$(target) := $($(target)_2_STAGE_TARGETS)
|
---|
3514 | INSTARGET_DIRS_$(target) := $($(target)_2_STAGE_DIR_TARGETS)
|
---|
3515 |
|
---|
3516 | endef # def_install
|
---|
3517 | $(eval-opt-var def_install)
|
---|
3518 |
|
---|
3519 | ## Do pass 1 on the implicit targets and add them to the list.
|
---|
3520 | $(foreach target, $(_ALL_INSTALLS_IMPLICIT), \
|
---|
3521 | $(evalval def_pass1_install))
|
---|
3522 | _ALL_INSTALLS += $(_ALL_INSTALLS_IMPLICIT)
|
---|
3523 |
|
---|
3524 | ## Do pass 2 on all install targets.
|
---|
3525 | $(foreach target, $(_ALL_INSTALLS), \
|
---|
3526 | $(evalvalctx def_install))
|
---|
3527 |
|
---|
3528 | ifdef KBUILD_PROFILE_SELF
|
---|
3529 | $(evalcall def_profile_self, done install targets)
|
---|
3530 | endif
|
---|
3531 |
|
---|
3532 | #
|
---|
3533 | # Some introspection targets that can be useful for package maintainers.
|
---|
3534 | #
|
---|
3535 | .PHONY: kbuild-show-install-files kbuild-show-install-dirs
|
---|
3536 | kbuild-show-install-files::
|
---|
3537 | $(addprefix $(NL)$(TAB)$(QUIET)$(ECHO) , $(subst $(PATH_INS)/,,$(_INSTALLS_FILES)))
|
---|
3538 |
|
---|
3539 | kbuild-show-install-dirs::
|
---|
3540 | $(addprefix $(NL)$(TAB)$(QUIET)$(ECHO) , $(subst $(PATH_INS)/,,$(_INSTALLS_DIRS)))
|
---|
3541 |
|
---|
3542 | kbuild-show-stage-files::
|
---|
3543 | $(addprefix $(NL)$(TAB)$(QUIET)$(ECHO) , $(subst $(PATH_STAGE)/,,$(_STAGE_FILES)))
|
---|
3544 |
|
---|
3545 | kbuild-show-stage-dirs::
|
---|
3546 | $(addprefix $(NL)$(TAB)$(QUIET)$(ECHO) , $(subst $(PATH_STAGE)/,,$(_STAGE_DIRS)))
|
---|
3547 |
|
---|
3548 |
|
---|
3549 | #
|
---|
3550 | # TESTING
|
---|
3551 | #
|
---|
3552 | _TESTING += $(TESTING) \
|
---|
3553 | $(TESTING.$(KBUILD_TARGET)) \
|
---|
3554 | $(TESTING.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \
|
---|
3555 | $(TESTING.$(KBUILD_TARGET_ARCH)) \
|
---|
3556 | $(TESTING.$(KBUILD_TARGET_CPU))
|
---|
3557 |
|
---|
3558 |
|
---|
3559 | #
|
---|
3560 | # PACKING
|
---|
3561 | #
|
---|
3562 | _PACKING += $(PACKING) \
|
---|
3563 | $(PACKING.$(KBUILD_TARGET)) \
|
---|
3564 | $(PACKING.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \
|
---|
3565 | $(PACKING.$(KBUILD_TARGET_ARCH)) \
|
---|
3566 | $(PACKING.$(KBUILD_TARGET_CPU))
|
---|
3567 |
|
---|
3568 |
|
---|
3569 | #
|
---|
3570 | # DOCS
|
---|
3571 | #
|
---|
3572 |
|
---|
3573 |
|
---|
3574 | #
|
---|
3575 | # DIRECTORIES
|
---|
3576 | #
|
---|
3577 | _DIR_ALL := $(sort $(addsuffix /,$(patsubst %/,%,$(_DIRS))) $(dir $(_OUT_FILES) $(_OBJS) $(_INSTALLS_FILES) $(_STAGE_FILES)))
|
---|
3578 | $(foreach directory,$(_INSTALLS_DIRS) $(_STAGE_DIRS), $(eval _DIR_ALL := $(filter-out $(directory),$(_DIR_ALL))))
|
---|
3579 |
|
---|
3580 |
|
---|
3581 | define def_mkdir_rule
|
---|
3582 | $(directory):
|
---|
3583 | %$$(call MSG_MKDIR,$$@)
|
---|
3584 | $$(QUIET)$$(MKDIR) -p -- $$@
|
---|
3585 | endef
|
---|
3586 |
|
---|
3587 | $(foreach directory,$(_DIR_ALL),$(eval $(def_mkdir_rule)))
|
---|
3588 |
|
---|
3589 | ifdef KBUILD_PROFILE_SELF
|
---|
3590 | $(evalcall def_profile_self, done directories)
|
---|
3591 | endif
|
---|
3592 |
|
---|
3593 |
|
---|
3594 | #
|
---|
3595 | # NOTHING
|
---|
3596 | #
|
---|
3597 | do-nothing:
|
---|
3598 | %$(call MSG_NOTHING)
|
---|
3599 | ifdef KBUILD_PROFILE_SELF
|
---|
3600 | @$(ECHO) 'prof: $(call _KBUILD_FMT_ELAPSED_EX, $(nanots ), $(_KBUILD_TS_HEADER_START)) - $(call _KBUILD_FMT_ELAPSED_EX, $(nanots ), $(_KBUILD_TS_PREV)) - executing $@'
|
---|
3601 | ifeq ($(KBUILD_PROFILE_SELF),2)
|
---|
3602 | @$(ECHO) 'stat: $(make-stats )'
|
---|
3603 | endif
|
---|
3604 | endif
|
---|
3605 |
|
---|
3606 |
|
---|
3607 | #
|
---|
3608 | # CLEAN UP
|
---|
3609 | #
|
---|
3610 | do-clean:
|
---|
3611 | %$(call MSG_CLEAN)
|
---|
3612 | $(QUIET)$(RM) -f -- \
|
---|
3613 | $(_OUT_FILES) \
|
---|
3614 | $(_OBJS) \
|
---|
3615 | $(_DEPFILES) \
|
---|
3616 | $(_DEPFILES_INCLUDED) \
|
---|
3617 | $(_CLEAN_FILES) \
|
---|
3618 | $(OTHER_CLEAN) \
|
---|
3619 | $(_STAGE_FILES)
|
---|
3620 | $(QUIET)$(RMDIR) -p --ignore-fail-on-non-empty --ignore-fail-on-not-exist -- \
|
---|
3621 | $(rsort $(dir $(_OUT_FILES) \
|
---|
3622 | $(_OBJS) \
|
---|
3623 | $(_DEPFILES) \
|
---|
3624 | $(_DEPFILES_INCLUDED) \
|
---|
3625 | $(_CLEAN_FILES) \
|
---|
3626 | $(OTHER_CLEAN))\
|
---|
3627 | $(_STAGE_DIRS) )
|
---|
3628 |
|
---|
3629 |
|
---|
3630 |
|
---|
3631 | #
|
---|
3632 | # PASSES (including directory and makefile walking)
|
---|
3633 | #
|
---|
3634 |
|
---|
3635 | #
|
---|
3636 | # First, check whether we need to order the passes explicitly or not.
|
---|
3637 | # This depends on whether we're a leaf makefile or not. A leaf will
|
---|
3638 | # know all its dependencies, while a recursive one relies on the
|
---|
3639 | # order sub-directories and other makefiles are executed it.
|
---|
3640 | #
|
---|
3641 |
|
---|
3642 | ## Setup a pass and check for optimizations.
|
---|
3643 | # @param $(PASS) Uppercase pass name.
|
---|
3644 | define def_pass_setup_and_optimize
|
---|
3645 |
|
---|
3646 | # The setup. ## @todo This is looks a bit weird...
|
---|
3647 | ifndef SUBDIRS_$(PASS)
|
---|
3648 | SUBDIRS_$(PASS) := $(SUBDIRS) $(SUBDIRS.$(KBUILD_TARGET)) $(SUBDIRS.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH))
|
---|
3649 | endif
|
---|
3650 | ifndef SUBDIRS_AFTER_$(PASS)
|
---|
3651 | SUBDIRS_AFTER_$(PASS) := $(SUBDIRS_AFTER) $(SUBDIRS_AFTER.$(KBUILD_TARGET)) $(SUBDIRS_AFTER.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH))
|
---|
3652 | endif
|
---|
3653 | ifndef MAKEFILES_BEFORE_$(PASS)
|
---|
3654 | MAKEFILES_BEFORE_$(PASS) := $(MAKEFILES_BEFORE) $(MAKEFILES_BEFORE.$(KBUILD_TARGET)) $(MAKEFILES_BEFORE.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH))
|
---|
3655 | endif
|
---|
3656 | ifndef MAKEFILES_AFTER_$(PASS)
|
---|
3657 | MAKEFILES_AFTER_$(PASS) := $(MAKEFILES_AFTER) $(MAKEFILES_AFTER.$(KBUILD_TARGET)) $(MAKEFILES_AFTER.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH))
|
---|
3658 | endif
|
---|
3659 |
|
---|
3660 | # The check.
|
---|
3661 | ifeq ($(_KBUILD_STRICT_PASS_ORDER),nonstrict)
|
---|
3662 | ifneq ($(strip \
|
---|
3663 | $(SUBDIRS_$(PASS)) $(SUBDIRS_$(PASS).$(KBUILD_TARGET)) $(SUBDIRS_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \
|
---|
3664 | $(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(KBUILD_TARGET)) $(MAKEFILES_BEFORE_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \
|
---|
3665 | $(SUBDIRS_AFTER_$(PASS)) $(SUBDIRS_AFTER_$(PASS).$(KBUILD_TARGET)) $(SUBDIRS_AFTER_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \
|
---|
3666 | $(MAKEFILES_AFTER_$(PASS)) $(MAKEFILES_AFTER_$(PASS).$(KBUILD_TARGET)) $(MAKEFILES_AFTER_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \
|
---|
3667 | ),)
|
---|
3668 | _KBUILD_STRICT_PASS_ORDER := strict
|
---|
3669 | endif
|
---|
3670 | endif # _KBUILD_STRICT_PASS_ORDER == nonstrict
|
---|
3671 | endef # def_pass_setup_and_optimize
|
---|
3672 | $(eval-opt-var def_pass_setup_and_optimize)
|
---|
3673 |
|
---|
3674 | ## PASS: Setup & optimization.
|
---|
3675 | # Check if we can apply the non-strict pass order optimzation (no SUBDIRS_* and MAKEFILES_*),
|
---|
3676 | # and set up the pass specific variables as we go along.
|
---|
3677 | _KBUILD_STRICT_PASS_ORDER := nonstrict
|
---|
3678 | $(foreach PASS, $(PASSES), $(evalval def_pass_setup_and_optimize))
|
---|
3679 | #$ (error _KBUILD_STRICT_PASS_ORDER=$(_KBUILD_STRICT_PASS_ORDER))
|
---|
3680 |
|
---|
3681 | ifeq ($(_KBUILD_STRICT_PASS_ORDER),strict)
|
---|
3682 | if !defined(KBUILD_SAFE_PARALLEL) || "$(KMK_OPT_JOBS)" == "1"
|
---|
3683 | _KBUILD_STRICT_PASS_ORDER := strict_unsafe
|
---|
3684 | endif
|
---|
3685 | endif
|
---|
3686 |
|
---|
3687 |
|
---|
3688 | ## Subdir
|
---|
3689 | # @param $(pass) Lowercase pass name.
|
---|
3690 | # @param $(PASS) Uppercase pass name.
|
---|
3691 | # @param $(subdir) Subdirectory
|
---|
3692 | # @param $(tag) tag to attach to the rule name.
|
---|
3693 | define def_pass_subdir
|
---|
3694 | pass_$(pass)$(tag):: $(dep)
|
---|
3695 | + $$(QUIET)$$(MAKE) -C $(subdir) -f $$(notdir $$(firstword $$(wildcard $$(addprefix $(subdir)/,$$(DEFAULT_MAKEFILE))))) pass_$(pass)
|
---|
3696 | endef
|
---|
3697 |
|
---|
3698 | ## Submakefile
|
---|
3699 | # @param $(pass) Lowercase pass name.
|
---|
3700 | # @param $(PASS) Uppercase pass name.
|
---|
3701 | # @param $(makefile) Makefile.
|
---|
3702 | # @param $(tag) tag to attach to the rule name.
|
---|
3703 | define def_pass_makefile
|
---|
3704 | pass_$(pass)$(tag):: $(dep)
|
---|
3705 | + $$(QUIET)$$(MAKE) -C $(patsubst %/,%,$(dir $(makefile))) -f $(notdir $(makefile)) pass_$(pass)
|
---|
3706 | endef
|
---|
3707 |
|
---|
3708 | ## Execute a pass, strict order.
|
---|
3709 | # @param $(pass) Lowercase pass name.
|
---|
3710 | # @param $(PASS) Uppercase pass name.
|
---|
3711 | define def_pass_strict
|
---|
3712 | $(eval tag:=_before)
|
---|
3713 | $(eval dep:= )
|
---|
3714 | $(foreach subdir, $(SUBDIRS_$(PASS)) $(SUBDIRS_$(PASS).$(KBUILD_TARGET)) $(SUBDIRS_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir)))
|
---|
3715 | $(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(KBUILD_TARGET)) $(MAKEFILES_BEFORE_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)),$(eval $(def_pass_makefile)))
|
---|
3716 |
|
---|
3717 | $(eval tag:=_after)
|
---|
3718 | $(eval dep:=pass_$(pass)_doit)
|
---|
3719 | $(foreach subdir, $(SUBDIRS_AFTER_$(PASS)) $(SUBDIRS_AFTER_$(PASS).$(KBUILD_TARGET)) $(SUBDIRS_AFTER_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir)))
|
---|
3720 | $(foreach makefile,$(MAKEFILES_AFTER_$(PASS)) $(MAKEFILES_AFTER_$(PASS).$(KBUILD_TARGET)) $(MAKEFILES_AFTER_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) ,$(eval $(def_pass_makefile)))
|
---|
3721 |
|
---|
3722 | .NOTPARALLEL: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_this
|
---|
3723 | .PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_this pass_$(pass)_doit
|
---|
3724 | pass_$(pass)_doit: $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var)))
|
---|
3725 | pass_$(pass)_this: pass_$(pass)_before
|
---|
3726 | + $$(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)_doit
|
---|
3727 | pass_$(pass)_after:: pass_$(pass)_this
|
---|
3728 | pass_$(pass): pass_$(pass)_after
|
---|
3729 | #$ (warning pass=$(pass) PASS=$(PASS): $(PASS_$(PASS)_trgs) $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var))))
|
---|
3730 | endef # def_pass_strict
|
---|
3731 | $(eval-opt-var def_pass_strict)
|
---|
3732 |
|
---|
3733 | ## Execute a pass, strict order.
|
---|
3734 | # @param $(pass) Lowercase pass name.
|
---|
3735 | # @param $(PASS) Uppercase pass name.
|
---|
3736 | define def_pass_strict_unsafe
|
---|
3737 | $(eval tag:=_before)
|
---|
3738 | $(eval dep:= )
|
---|
3739 | $(foreach subdir, $(SUBDIRS_$(PASS)) $(SUBDIRS_$(PASS).$(KBUILD_TARGET)) $(SUBDIRS_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir)))
|
---|
3740 | $(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(KBUILD_TARGET)) $(MAKEFILES_BEFORE_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)),$(eval $(def_pass_makefile)))
|
---|
3741 |
|
---|
3742 | $(eval tag:=_after)
|
---|
3743 | $(eval dep:=pass_$(pass)_doit)
|
---|
3744 | $(foreach subdir, $(SUBDIRS_AFTER_$(PASS)) $(SUBDIRS_AFTER_$(PASS).$(KBUILD_TARGET)) $(SUBDIRS_AFTER_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir)))
|
---|
3745 | $(foreach makefile,$(MAKEFILES_AFTER_$(PASS)) $(MAKEFILES_AFTER_$(PASS).$(KBUILD_TARGET)) $(MAKEFILES_AFTER_$(PASS).$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) ,$(eval $(def_pass_makefile)))
|
---|
3746 |
|
---|
3747 | .PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_doit
|
---|
3748 | .NOTPARALLEL: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_doit
|
---|
3749 | pass_$(pass)_doit: pass_$(pass)_before \
|
---|
3750 | $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var)))
|
---|
3751 | pass_$(pass): \
|
---|
3752 | pass_$(pass)_before \
|
---|
3753 | pass_$(pass)_doit \
|
---|
3754 | pass_$(pass)_after
|
---|
3755 | #$ (warning pass=$(pass) PASS=$(PASS): $(PASS_$(PASS)_trgs) $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var))))
|
---|
3756 | endef # def_pass_strict_unsafe
|
---|
3757 | $(eval-opt-var def_pass_strict_unsafe)
|
---|
3758 |
|
---|
3759 | ## Execute a pass, non-strict pass ordering.
|
---|
3760 | # @param $(pass) Lowercase pass name.
|
---|
3761 | # @param $(PASS) Uppercase pass name.
|
---|
3762 | define def_pass_nonstrict
|
---|
3763 | .PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_doit
|
---|
3764 | pass_$(pass)_doit: $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$$$$($(var)))
|
---|
3765 | pass_$(pass): pass_$(pass)_doit
|
---|
3766 | endef # def_pass_nonstrict
|
---|
3767 |
|
---|
3768 | ## PASS: rules
|
---|
3769 | # Generate the rules for the defined passes.
|
---|
3770 | $(foreach PASS, $(PASSES), \
|
---|
3771 | $(eval pass := $(PASS_$(PASS)_pass)) \
|
---|
3772 | $(eval $(def_pass_$(_KBUILD_STRICT_PASS_ORDER))))
|
---|
3773 |
|
---|
3774 |
|
---|
3775 | ## Pass order, strict.
|
---|
3776 | # @param $(pass) Current pass name.
|
---|
3777 | # @param $(prev_pass) The previous pass name.
|
---|
3778 | define def_pass_order_strict
|
---|
3779 | .PHONY: pass_$(pass)_order
|
---|
3780 | .NOTPARALLEL: pass_$(pass)_order
|
---|
3781 | pass_$(pass)_order: $(pass_prev)
|
---|
3782 | %$$(call MSG_PASS,$$(if $$(PASS_$(PASS)),$$(PASS_$(PASS)),$(pass)))
|
---|
3783 | + $$(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)
|
---|
3784 | $(eval pass_prev := pass_$(pass)_order)
|
---|
3785 | endef # def_pass_order_strict
|
---|
3786 | $(eval-opt-var def_pass_order_strict)
|
---|
3787 |
|
---|
3788 | ## Pass order, strict unsafe.
|
---|
3789 | # @param $(pass) Current pass name.
|
---|
3790 | # @param $(prev_pass) The previous pass name.
|
---|
3791 | define def_pass_order_strict_unsafe
|
---|
3792 | .NOTPARALLEL: pass_$(pass)_order pass_$(pass)_banner
|
---|
3793 | .PHONY: pass_$(pass)_order pass_$(pass)_banner
|
---|
3794 | pass_$(pass)_banner: $(pass_prev)
|
---|
3795 | %$$(call MSG_PASS,$$(if $$(PASS_$(PASS)),$$(PASS_$(PASS)),$(pass)))
|
---|
3796 | pass_$(pass)_order: $(pass_prev) \
|
---|
3797 | pass_$(pass)_banner \
|
---|
3798 | pass_$(pass)
|
---|
3799 | $(eval pass_prev := pass_$(pass)_order)
|
---|
3800 | endef # def_pass_order_strict_unsafe
|
---|
3801 | $(eval-opt-var def_pass_order_strict_unsafe)
|
---|
3802 |
|
---|
3803 | ## Pass order, non-strict.
|
---|
3804 | # @param $(pass) Current pass name.
|
---|
3805 | # @param $(prev_pass) The previous pass name.
|
---|
3806 | define def_pass_order_nonstrict
|
---|
3807 | .PHONY: pass_$(pass)_order pass_$(pass)_banner
|
---|
3808 | pass_$(pass)_banner:
|
---|
3809 | %$$(call MSG_PASS,$$(if $$(PASS_$(PASS)),$$(PASS_$(PASS)),$(pass)))
|
---|
3810 | pass_$(pass)_order: \
|
---|
3811 | $(pass_prev) \
|
---|
3812 | pass_$(pass)_banner \
|
---|
3813 | pass_$(pass)
|
---|
3814 | $(eval pass_prev := pass_$(pass)_order)
|
---|
3815 | endef # def_pass_order_nonstrict
|
---|
3816 | $(eval-opt-var def_pass_order_nonstrict)
|
---|
3817 |
|
---|
3818 | ## PASS: order
|
---|
3819 | # Use dependencies to ensure correct pass order.
|
---|
3820 | pass_prev :=
|
---|
3821 | $(foreach PASS,$(DEFAULT_PASSES),\
|
---|
3822 | $(eval pass := $(PASS_$(PASS)_pass)) \
|
---|
3823 | $(eval $(def_pass_order_$(_KBUILD_STRICT_PASS_ORDER))))
|
---|
3824 |
|
---|
3825 | ifdef KBUILD_PROFILE_SELF
|
---|
3826 | $(evalcall def_profile_self, done passes)
|
---|
3827 | endif
|
---|
3828 |
|
---|
3829 | # Some common pass aliases
|
---|
3830 | ifndef KBUILD_NO_PASS_ALIASES
|
---|
3831 | .PHONY: clean
|
---|
3832 | clean: pass_clean
|
---|
3833 |
|
---|
3834 | .PHONY: nothing
|
---|
3835 | nothing: pass_nothing
|
---|
3836 |
|
---|
3837 | .PHONY: staging
|
---|
3838 | staging: pass_staging
|
---|
3839 |
|
---|
3840 | .PHONY: packing
|
---|
3841 | packing: pass_packing
|
---|
3842 |
|
---|
3843 | ifndef KBUILD_NO_TESTING_PASS_ALIASES
|
---|
3844 | .PHONY: check
|
---|
3845 | check:: pass_testing
|
---|
3846 |
|
---|
3847 | .PHONY: test
|
---|
3848 | test:: pass_testing
|
---|
3849 | endif # KBUILD_NO_TESTING_PASS_ALIASES
|
---|
3850 | endif # KBUILD_NO_PASS_ALIASES
|
---|
3851 |
|
---|
3852 |
|
---|
3853 | #
|
---|
3854 | # THE MAIN RULES
|
---|
3855 | #
|
---|
3856 | all_recursive: $(pass_prev)
|
---|
3857 |
|
---|
3858 | rebuild: clean
|
---|
3859 | + $(MAKE) -f $(firstword $(MAKEFILE_LIST)) all_recursive
|
---|
3860 |
|
---|
3861 | # @todo make this a non-default pass!
|
---|
3862 | uninstall::
|
---|
3863 | $(RM) -f -- $(_INSTALLS_FILES)
|
---|
3864 |
|
---|
3865 | install:: pass_installs
|
---|
3866 |
|
---|
3867 | # misc shortcuts (use secondary expansion here to save strcache[file] space).
|
---|
3868 | targets: bldprogs libraries dlls programs sysmods miscbins others installs
|
---|
3869 | objects: $$(_OBJS)
|
---|
3870 | bldprogs: $$(_BLDPROGS)
|
---|
3871 | libraries: $$(_LIBS) $$(_IMPORT_LIBS) $$(_OTHER_LIBRARIES)
|
---|
3872 | dlls: $$(_DLLS)
|
---|
3873 | programs: $$(_PROGRAMS)
|
---|
3874 | sysmods: $$(_SYSMODS)
|
---|
3875 | miscbins: $$(_MISCBINS)
|
---|
3876 | others: $$(_OTHERS)
|
---|
3877 | stagings: $$(_INSTALLS) $$(_STAGE_DIRS) $$(_STAGE_FILES)
|
---|
3878 | installs: $$(_INSTALLS_DIRS) $$(_INSTALLS_FILES)
|
---|
3879 |
|
---|
3880 |
|
---|
3881 |
|
---|
3882 | #
|
---|
3883 | # kBuild debugging stuff.
|
---|
3884 | #
|
---|
3885 | ## @todo this doesn't work. Move to a debug unit and expand it.
|
---|
3886 | show_targets:
|
---|
3887 | @$(foreach target, $(_ALL_TARGETS),\
|
---|
3888 | @$(ECHO) "target: $(target)" $(NLTAB)\
|
---|
3889 | @$(ECHO) " $(target)_0_OUTDIR=$($(target)_0_OUTDIR)" $(NLTAB)\
|
---|
3890 | @$(ECHO) " $(target)_1_TARGET=$($(target)_1_TARGET)" $(NLTAB)\
|
---|
3891 | @$(ECHO) " INSTARGET_$(target)=$(INSTARGET_$(target))" $(NLTAB)\
|
---|
3892 | $(foreach prop,$(PROPS_SINGLE) $(PROPS_ACCUMULATE_L) $(PROPS_ACCUMULATE_R) 2_OBJS CLEAN, \
|
---|
3893 | $(eval _tmp:=$(firstword $($(target)_BLD_TRG) $(KBUILD_TARGET))) \
|
---|
3894 | $(if $($(target)_$(prop).$(_tmp)),\
|
---|
3895 | @$(ECHO) " $(target)_$(prop).$(_tmp)=$($(target)_$(prop).$(_tmp))" $(NLTAB)) \
|
---|
3896 | $(if $($(target)_$(prop)), $(NLTAB)@$(ECHO) " $(target)_$(prop)=$($(target)_$(prop))" $(NLTAB)) \
|
---|
3897 | )\
|
---|
3898 | $(foreach prop,$(PROPS_DEFERRED), \
|
---|
3899 | $(eval _tmp:=$(firstword $($(target)_BLD_TRG) $(KBUILD_TARGET))) \
|
---|
3900 | $(if $(value $(target)_$(prop).$(_tmp)),\
|
---|
3901 | @$(ECHO) ' $(target)_$(prop).$(_tmp)=$(value $(TARGET)_$(prop).$(_tmp))' $(NLTAB)) \
|
---|
3902 | $(if $(value $(target)_$(prop)), $(NLTAB)@$(ECHO) ' $(target)_$(prop)=$(value $(target)_$(prop))' $(NLTAB)) \
|
---|
3903 | ))
|
---|
3904 |
|
---|
3905 |
|
---|
3906 |
|
---|
3907 | #
|
---|
3908 | # Include dependency files.
|
---|
3909 | #
|
---|
3910 | ifdef _DEPFILES
|
---|
3911 | # TODO: first works the second doesn't, provided _KB_INCLUDE_DEPS is undefined:
|
---|
3912 | # if "$(_KB_INCLUDE_DEPS)" == "1"
|
---|
3913 | # if $(_KB_INCLUDE_DEPS) == "1"
|
---|
3914 |
|
---|
3915 | ifdef KB_HAVE_INCLUDEDEP_QUEUE
|
---|
3916 | includedep-queue $(_DEPFILES)
|
---|
3917 | else
|
---|
3918 | $(foreach dep, $(_DEPFILES), $(eval includedep $(dep)))
|
---|
3919 | endif
|
---|
3920 | endif
|
---|
3921 |
|
---|
3922 |
|
---|
3923 | ifdef KBUILD_PROFILE_SELF
|
---|
3924 | $(evalcall def_profile_self, end of footer.kmk)
|
---|
3925 | _KBUILD_TS_FOOTER_END := $(_KBUILD_TS_PREV)
|
---|
3926 |
|
---|
3927 | ifneq ($(KBUILD_PROFILE_SELF),0)
|
---|
3928 | $(info prof: ALL=$(words $(_ALL_TARGETS)) BLDPROGS=$(words $(_ALL_BLDPROGS)) LIBRARIES=$(words $(_ALL_LIBRARIES)) IMPORT_LIBS=$(words $(IMPORT_LIBS)) DLLS=$(words $(DLLS)) PROGRAMS=$(words $(_ALL_PROGRAMS)) )
|
---|
3929 | $(info prof: SYSMODS=$(words $(_ALL_SYSMODS)) MISCBINS=$(words $(_ALL_MISCBINS)) OTHERS=$(words $(_ALL_OTHERS)) INSTALLS=$(words $(_ALL_INSTALLS)) FETCHES=$(words $(_ALL_FETCHES)) PACKING=$(words $(_PACKING)) TESTING=$(words $(TESTING)) )
|
---|
3930 | $(info prof: DIRS=$(words $(_DIR_ALL)) TOOLS=$(words $(_TOOLS)) SDKS=$(words $(_SDKS)) USES=$(words $(_USES)) OUT_FILES=$(words $(_OUT_FILES)) OBJS=$(words $(_OBJS)) CLEAN_FILES=$(words $(CLEAN_FILES) $(OTHER_CLEAN)) )
|
---|
3931 | $(info prof: DEPFILES_INCLUDED=$(words $(_DEPFILES_INCLUDED)) DEPFILES=$(words $(_DEPFILES)) MAKEFILES=$(words $(MAKEFILE_LIST)) )
|
---|
3932 | endif
|
---|
3933 | endif
|
---|
3934 |
|
---|
3935 |
|
---|
3936 | # end-of-file-content
|
---|
3937 | __footer_kmk__ := target
|
---|
3938 | endif # !defined(__footer_kmk__)
|
---|
3939 |
|
---|