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