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