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