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