1 | # $Id: footer.kmk 148 2004-09-07 20:16:14Z bird $
|
---|
2 | ## @file
|
---|
3 | #
|
---|
4 | # kBuild - File included at top of makefile.
|
---|
5 | #
|
---|
6 | # Copyright (c) source004 knut st. osmundsen <bird-srcspam@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 typetype0, Boston, MA 0sourcetargettargettarget-targettype07 USA
|
---|
24 | #
|
---|
25 | #
|
---|
26 |
|
---|
27 | ifndef __footer_kmk__
|
---|
28 | # start-of-file-content
|
---|
29 |
|
---|
30 | #
|
---|
31 | # Variables.
|
---|
32 | # (Some of these need initialization before including definitions using them.)
|
---|
33 | #
|
---|
34 |
|
---|
35 | # all targets.
|
---|
36 | ALL_TARGETS := \
|
---|
37 | $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)) \
|
---|
38 | $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)) \
|
---|
39 | $(DLLS) $(DLLS.$(BUILD_TARGET)) \
|
---|
40 | $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)) \
|
---|
41 | $(OTHERS) $(OTHERS.$(BUILD_TARGET))
|
---|
42 |
|
---|
43 | # dependency files.
|
---|
44 | _DEPFILES :=
|
---|
45 |
|
---|
46 | # All kind of output files except for _OBJS and _DEPFILES.
|
---|
47 | # Compiling or linking definition outputting other things that $@ and any
|
---|
48 | # required dependency file must add those output files to this variable.
|
---|
49 | _OUT_FILES :=
|
---|
50 |
|
---|
51 | # all of a type
|
---|
52 | _OBJS :=
|
---|
53 | _LIBS :=
|
---|
54 | _DLLS :=
|
---|
55 | _EXES :=
|
---|
56 | _SYSMODS:=
|
---|
57 | _DIRS :=
|
---|
58 |
|
---|
59 | # all objs of a specific target
|
---|
60 | define def_objs_var
|
---|
61 | _OBJS_$target :=
|
---|
62 | endef
|
---|
63 | $(foreach target, $(ALL_TARGETS), $(eval _OBJS_$(target) := ))
|
---|
64 |
|
---|
65 | #
|
---|
66 | # Basic macros
|
---|
67 | #
|
---|
68 |
|
---|
69 | ## Figure out the tool for a source
|
---|
70 | # @param $target source file
|
---|
71 | # @param $source normalized main target
|
---|
72 | # @param $type tooltype
|
---|
73 | _SOURCE_TOOL = $(strip $(firstword \
|
---|
74 | $($(target)_$(source)_$(type)TOOL.$(BUILD_TARGET)) \
|
---|
75 | $($(target)_$(source)_$(type)TOOL) \
|
---|
76 | $($(target)_$(source)_TOOL.$(BUILD_TARGET)) \
|
---|
77 | $($(target)_$(source)_TOOL) \
|
---|
78 | $($(target)_$(type)TOOL.$(BUILD_TARGET)) \
|
---|
79 | $($(target)_$(type)TOOL) \
|
---|
80 | $($(target)_TOOL.$(BUILD_TARGET)) \
|
---|
81 | $($(target)_TOOL) \
|
---|
82 | $($(source)_$(type)TOOL.$(BUILD_TARGET)) \
|
---|
83 | $($(source)_$(type)TOOL) \
|
---|
84 | $($(source)_TOOL.$(BUILD_TARGET)) \
|
---|
85 | $($(source)_TOOL) \
|
---|
86 | $($(type)TOOL.$(BUILD_TARGET)) \
|
---|
87 | $($(type)TOOL) \
|
---|
88 | $(TOOL.$(BUILD_TARGET)) \
|
---|
89 | $(TOOL) ))
|
---|
90 |
|
---|
91 | _SOURCE_TOOL_OLD = $(strip $(firstword \
|
---|
92 | $($(target)_$(source)_$(type)TOOL.$(BUILD_TARGET)) $($(target)_$(source)_TOOL.$(BUILD_TARGET)) \
|
---|
93 | $($(target)_$(source)_$(type)TOOL) $($target_$source_TOOL) \
|
---|
94 | $($(target)_$(type)TOOL.$(BUILD_TARGET)) $($(target)_TOOL.$(BUILD_TARGET)) \
|
---|
95 | $($(target)_$(type)TOOL) $($target_TOOL) \
|
---|
96 | $($(source)_$(type)TOOL.$(BUILD_TARGET)) $($(source)_TOOL.$(BUILD_TARGET)) \
|
---|
97 | $($(source)_$(type)TOOL) $($(source)_TOOL) \
|
---|
98 | $($(type)TOOL.$(BUILD_TARGET)) $(TOOL.$(BUILD_TARGET)) \
|
---|
99 | $($(type)TOOL) $(TOOL) ))
|
---|
100 |
|
---|
101 | ## Figure out the tool for a target.
|
---|
102 | # @param $target normalized target.
|
---|
103 | # @param $source tooltype.
|
---|
104 | _TARGET_TOOL = $(strip $(firstword \
|
---|
105 | $($(target)_$(source)TOOL.$(BUILD_TARGET)) \
|
---|
106 | $($(target)_$(source)TOOL) \
|
---|
107 | $($(target)_TOOL.$(BUILD_TARGET)) \
|
---|
108 | $($(target)_TOOL) \
|
---|
109 | $($(source)TOOL) \
|
---|
110 | $($(source)TOOL.$(BUILD_TARGET)) \
|
---|
111 | $(TOOL.$(BUILD_TARGET)) \
|
---|
112 | $(TOOL) \
|
---|
113 | ))
|
---|
114 |
|
---|
115 | ## Removes the drive letter from a path (if it has one)
|
---|
116 | # @param $1 the path
|
---|
117 | no-drive=$(word $(words $(subst :, ,$(1))),$(subst :, ,$(1)))
|
---|
118 |
|
---|
119 | ## Removes the root slash from a path (if it has one)
|
---|
120 | # @param $1 the path
|
---|
121 | no-root-slash=$(patsubst /%,%,$(1))
|
---|
122 |
|
---|
123 | ## Figure out where to put object files.
|
---|
124 | # @param $1 source file
|
---|
125 | # @param $2 normalized main target
|
---|
126 | _OBJECT_BASE = $(PATH_TARGET)/$(2)/$(call no-root-slash,$(call no-drive,$(basename $(patsubst $(PATH_TARGET)/$(2)/%,gen/%,$(1)))))
|
---|
127 |
|
---|
128 | ## Figure out where to put object files.
|
---|
129 | # @param $1 real target name.
|
---|
130 | # @param $2 normalized main target
|
---|
131 | _TARGET_BASE = $(PATH_TARGET)/$(2)/$(call no-root-slash,$(call no-drive,$(basename $(1))))
|
---|
132 |
|
---|
133 |
|
---|
134 | #
|
---|
135 | # Include templates
|
---|
136 | #
|
---|
137 | _TEMPLATES := $(TEMPLATE)
|
---|
138 | define def_templates
|
---|
139 | ifdef $(target)_TEMPLATE
|
---|
140 | _TEMPLATES += $($(target)_TEMPLATE)
|
---|
141 | endif
|
---|
142 | endef
|
---|
143 | $(foreach target, $(ALL_TARGETS), $(eval $(def_templates)))
|
---|
144 | _TEMPLATES := $(sort $(_TEMPLATES))
|
---|
145 | # $ (warning dbg: _TEMPLATES=$(_TEMPLATES))
|
---|
146 |
|
---|
147 | define def_templates_include
|
---|
148 | ifndef TEMPLATE_$(template)
|
---|
149 | include $(firstword $(wildcard $(PATH_KBUILD)/templates/$(template).kmk))
|
---|
150 | endif
|
---|
151 | endef
|
---|
152 | $(foreach template, $(_TEMPLATES), $(eval $(def_templates)))
|
---|
153 |
|
---|
154 |
|
---|
155 | #
|
---|
156 | # Common Inheritance
|
---|
157 | #
|
---|
158 |
|
---|
159 | ## Inherit defaults property
|
---|
160 | # @param $(prop) Property name
|
---|
161 | # @param $(target) Target name.
|
---|
162 | define def_inherit_defaults_one
|
---|
163 | ifndef $(target)_$(prop)
|
---|
164 | ifndef $(target)_$(prop).$(BUILD_TARGET)
|
---|
165 | ifdef $(prop)
|
---|
166 | $$(eval $(target)_$(prop) := $($(prop)))
|
---|
167 | endif
|
---|
168 | ifdef $(prop).$(BUILD_TARGET)
|
---|
169 | $$(eval $(target)_$(prop).$(BUILD_TARGET) := $($(prop).$(BUILD_TARGET)))
|
---|
170 | endif
|
---|
171 | endif
|
---|
172 | endif
|
---|
173 | endef
|
---|
174 |
|
---|
175 | ## Inherit default properties for one target.
|
---|
176 | # A bit tricky this one, but it depends a bit on whether or not TEMPLATE
|
---|
177 | # is inherited from the default properties.
|
---|
178 | # @param $(target) Target name
|
---|
179 | #
|
---|
180 | define def_inherit_defaults
|
---|
181 | ifdef $(target)_TEMPLATE
|
---|
182 | ifeq ($(strip $(TEMPLATE_$($(target)_TEMPLATE)_TOOL) $(TEMPLATE_$($(target)_TEMPLATE)_TOOL.$(BUILD_TARGET))),)
|
---|
183 | $$(foreach prop,TOOL, $$(eval $$(def_inherit_defaults_one)))
|
---|
184 | endif
|
---|
185 | ifeq ($(strip $(TEMPLATE_$($(target)_TEMPLATE)_SDKS) $(TEMPLATE_$($(target)_TEMPLATE)_SDKS.$(BUILD_TARGET))),)
|
---|
186 | $$(foreach prop,SDKS, $$(eval $$(def_inherit_defaults_one)))
|
---|
187 | endif
|
---|
188 | else
|
---|
189 | $$(foreach prop,TEMPLATE TOOL SDKS, $$(eval $$(def_inherit_defaults_one)))
|
---|
190 | endif
|
---|
191 | endef
|
---|
192 | # Inherit default properties.
|
---|
193 | # !!!!!!THIS IS MESSY AND NOT NECESSARY!!!!!!
|
---|
194 | $(foreach target, $(ALL_TARGETS),$(eval $(def_inherit_defaults)))
|
---|
195 |
|
---|
196 |
|
---|
197 | ## Inherit one template property in a accumulative manner.
|
---|
198 | # @param $(prop) Property name
|
---|
199 | # @param $(target) Target name
|
---|
200 | # @todo fix the precedence order for some properties.
|
---|
201 | define def_inherit_template_one
|
---|
202 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
|
---|
203 | ifndef $(target)_$(prop)
|
---|
204 | #$$ (warning dbgtarget: $(target)_$(prop):='$(TEMPLATE_$($(target)_TEMPLATE)_$(prop))' TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
---|
205 | $$(target)_$$(prop) := $$(TEMPLATE_$$($$(target)_TEMPLATE)_$$(prop))
|
---|
206 | endif
|
---|
207 | endif
|
---|
208 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)
|
---|
209 | ifndef $(target)_$(prop).$(BUILD_TARGET)
|
---|
210 | #$$ (warning dbgsource: $(target)_$(prop).$(BUILD_TARGET)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET))
|
---|
211 | $$(target)_$$(prop).$$(BUILD_TARGET) := $$(TEMPLATE_$$($$(target)_TEMPLATE)_$$(prop).$$(BUILD_TARGET))
|
---|
212 | endif
|
---|
213 | endif
|
---|
214 | endef
|
---|
215 |
|
---|
216 | ## Inherit one template property.
|
---|
217 | # @param $(prop) Property name
|
---|
218 | # @param $(target) Target name
|
---|
219 | define def_inherit_template_one_accumulate
|
---|
220 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
|
---|
221 | #$$ (warning dbgtype: TEMPLATE_$($(target)_TEMPLATE)_$(prop) $(target)_$(prop)=$($(target)_$(prop)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop)))
|
---|
222 | $$(eval $(target)_$(prop) := $($(target)_$(prop)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop)))
|
---|
223 | #$$ (warning dbgtype: $(target)_$(prop)=$($(target)_$(prop)))
|
---|
224 | endif
|
---|
225 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)
|
---|
226 | #$$ (warning dbg4: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET))
|
---|
227 | $$(eval $(target)_$(prop).$(BUILD_TARGET) := $($(target)_$(prop).$(BUILD_TARGET)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)))
|
---|
228 | endif
|
---|
229 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_CPU)
|
---|
230 | #$$ (warning dbg5: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_CPU))
|
---|
231 | $$(eval $(target)_$(prop).$(BUILD_TARGET_CPU) := $($(target)_$(prop).$(BUILD_TARGET)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_CPU)))
|
---|
232 | endif
|
---|
233 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_ARCH)
|
---|
234 | #$$ (warning dbg6: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_ARCH))
|
---|
235 | $$(eval $(target)_$(prop).$(BUILD_TARGET_ARCH) := $($(target)_$(prop).$(BUILD_TARGET)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_ARCH)))
|
---|
236 | endif
|
---|
237 | endef
|
---|
238 |
|
---|
239 |
|
---|
240 | ## Inherit template properties for on target.
|
---|
241 | # @param $(target) Target name.
|
---|
242 | define def_inherit_template
|
---|
243 | $$(foreach prop, TOOL ARTOOL CTOOL CXXTOOL ASTOOL LDTOOL\
|
---|
244 | ,$$(eval $$(def_inherit_template_one)))
|
---|
245 | $$(foreach prop,SDKS DEFS INCS COPTS CFLAGS CDEFS CINCS CXXOPTS CXXFLAGS CXXDEFS CXXINCS ASOPTS ASFLAGS ASDEFS ASINCS LDFLAGS LIBS LIBPATH \
|
---|
246 | ,$$(eval $$(def_inherit_template_one_accumulate)))
|
---|
247 | endef
|
---|
248 | # Inherit template properties
|
---|
249 | $(foreach target, $(ALL_TARGETS),$(eval $(def_inherit_template)))
|
---|
250 |
|
---|
251 |
|
---|
252 | #
|
---|
253 | # Include tools
|
---|
254 | #
|
---|
255 | _TOOLS := $(TOOL)
|
---|
256 | define def_tools_target_source
|
---|
257 | $(foreach tool,\
|
---|
258 | $($(source)_TOOL.$(BUILD_TARGET)) $($(target)_$(source)_TOOL.$(BUILD_TARGET))\
|
---|
259 | $($(source)_TOOL) $($(target)_$(source)_TOOL)\
|
---|
260 | $($(source)_CTOOL.$(BUILD_TARGET)) $($(target)_$(source)_CTOOL.$(BUILD_TARGET))\
|
---|
261 | $($(source)_CTOOL) $($(target)_$(source)_CTOOL)\
|
---|
262 | $($(source)_CXXTOOL.$(BUILD_TARGET)) $($(target)_$(source)_CXXTOOL.$(BUILD_TARGET))\
|
---|
263 | $($(source)_CXXTOOL) $($(target)_$(source)_CXXTOOL)\
|
---|
264 | $($(source)_ASTOOL.$(BUILD_TARGET)) $($(target)_$(source)_ASTOOL.$(BUILD_TARGET))\
|
---|
265 | $($(source)_ASTOOL) $($(target)_$(source)_ASTOOL)\
|
---|
266 | $($(source)_ARTOOL.$(BUILD_TARGET)) $($(target)_$(source)_ARTOOL.$(BUILD_TARGET))\
|
---|
267 | $($(source)_ARTOOL) $($(target)_$(source)_ARTOOL)\
|
---|
268 | $($(source)_LDTOOL.$(BUILD_TARGET)) $($(target)_$(source)_LDTOOL.$(BUILD_TARGET))\
|
---|
269 | $($(source)_LDTOOL) $($(target)_$(source)_LDTOOL)\
|
---|
270 | ,$(eval _TOOLS += $(tool)))
|
---|
271 | endef
|
---|
272 | define def_tools_target
|
---|
273 | $(foreach tool,\
|
---|
274 | $($(target)_TOOL.$(BUILD_TARGET))\
|
---|
275 | $($(target)_TOOL)\
|
---|
276 | $($(target)_CTOOL.$(BUILD_TARGET))\
|
---|
277 | $($(target)_CTOOL)\
|
---|
278 | $($(target)_CXXTOOL.$(BUILD_TARGET))\
|
---|
279 | $($(target)_CXXTOOL)\
|
---|
280 | $($(target)_ASTOOL.$(BUILD_TARGET))\
|
---|
281 | $($(target)_ASTOOL)\
|
---|
282 | $($(target)_ARTOOL.$(BUILD_TARGET))\
|
---|
283 | $($(target)_ARTOOL)\
|
---|
284 | $($(target)_LDTOOL.$(BUILD_TARGET))\
|
---|
285 | $($(target)_LDTOOL)\
|
---|
286 | ,$(eval _TOOLS += $(tool)))
|
---|
287 | $(foreach source, $($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_MODE)) \
|
---|
288 | , $(eval $(def_tools_target_source)))
|
---|
289 | endef
|
---|
290 | $(foreach target, $(ALL_TARGETS), $(eval $(def_tools_target)))
|
---|
291 | _TOOLS := $(sort $(_TOOLS))
|
---|
292 |
|
---|
293 | define def_tools_include
|
---|
294 | ifndef TOOL_$(tool)
|
---|
295 | include $(firstword $(wildcard $(PATH_KBUILD)/tools/$(tool).kmk))
|
---|
296 | endif
|
---|
297 | endef
|
---|
298 | $(foreach tool, $(_TOOLS), $(eval $(def_tools_include)))
|
---|
299 |
|
---|
300 |
|
---|
301 | #
|
---|
302 | # Include SDKs
|
---|
303 | #
|
---|
304 | _SDKS := $(SDKS)
|
---|
305 | define def_sdks_target_source
|
---|
306 | $(foreach sdk, $($(source)_SDKS) $($(source)_SDKS.$(BUILD_TARGET)) $($(source)_SDKS.$(BUILD_MODE)) \
|
---|
307 | $($(target)_$(source)_SDKS) $($(target)_$(source)_SDKS.$(BUILD_TARGET)) $($(target)_$(source)_SDKS.$(BUILD_MODE)), \
|
---|
308 | $(eval _SDKS += $(sdk)))
|
---|
309 | endef
|
---|
310 | define def_sdks_target
|
---|
311 | $(foreach sdk, $($(target)_SDKS) $($(target)_SDKS.$(BUILD_TARGET)) $($(target)_SDKS.$(BUILD_MODE))\
|
---|
312 | , $(eval _SDKS += $(sdk)))
|
---|
313 | $(foreach source, $($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_MODE))\
|
---|
314 | , $(eval $(def_sdks_target_source)))
|
---|
315 | endef
|
---|
316 | $(foreach target, $(ALL_TARGETS), $(eval $(def_sdks_target)))
|
---|
317 | _SDKS := $(sort $(_SDKS))
|
---|
318 |
|
---|
319 | define def_sdks_include_one
|
---|
320 | ifndef SDK_$(sdk)
|
---|
321 | include $(firstword $(wildcard $(PATH_KBUILD)/sdks/$(sdk).kmk))
|
---|
322 | endif
|
---|
323 | endef
|
---|
324 | $(foreach sdk, $(_SDKS), $(eval $(def_sdks_include_one)))
|
---|
325 |
|
---|
326 | #
|
---|
327 | # Object processing.
|
---|
328 | #
|
---|
329 |
|
---|
330 | ## Generic macro for processing C, C++ and Assembly sources.
|
---|
331 | # @param $(target) Normalized target name.
|
---|
332 | # @param $(source) Source file name.
|
---|
333 | # @param $(type) Source type. {C,CXX,AS}
|
---|
334 | #
|
---|
335 | # @remark I've no clue why I've to $(eval ..) everything in this define. MAKE bug?
|
---|
336 | # @remark I now have a clue. Have to use $$ if not.
|
---|
337 | define def_target_source_c_cpp_asm
|
---|
338 | #$ (warning dbg: def_target_source_c_cpp_asm: source='$(source)' target='$(target)' type='$(type)')
|
---|
339 |
|
---|
340 | $(eval tool:=$(call _SOURCE_TOOL,$(source),$(target),$(type)))
|
---|
341 | $(eval outbase := $(call _OBJECT_BASE,$(source),$(target)))
|
---|
342 | $(eval PATH_$(target)_$(source) := $(patsubst %/,%,$(dir $(outbase))))
|
---|
343 | $(eval dirdep := $(dir $(outbase)).dir_created)
|
---|
344 | $(eval defs :=\
|
---|
345 | $(TOOL_$(tool)_DEFS)\
|
---|
346 | $(TOOL_$(tool)_DEFS.$(BUILD_TYPE))\
|
---|
347 | $(TOOL_$(tool)_DEFS.$(BUILD_TARGET))\
|
---|
348 | $(TOOL_$(tool)_DEFS.$(BUILD_TARGET_ARCH))\
|
---|
349 | $(TOOL_$(tool)_DEFS.$(BUILD_TARGET_CPU))\
|
---|
350 | $(TOOL_$(tool)_$(type)DEFS)\
|
---|
351 | $(TOOL_$(tool)_$(type)DEFS.$(BUILD_TYPE))\
|
---|
352 | $(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
|
---|
353 | $(SDKS.$(BUILD_TYPE)) \
|
---|
354 | $(SDKS),\
|
---|
355 | $(SDK_$(sdk)_DEFS)\
|
---|
356 | $(SDK_$(sdk)_DEFS.$(BUILD_TYPE))\
|
---|
357 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET))\
|
---|
358 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_ARCH))\
|
---|
359 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_CPU))\
|
---|
360 | $(SDK_$(sdk)_$(type)DEFS)\
|
---|
361 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TYPE))\
|
---|
362 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET))\
|
---|
363 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
|
---|
364 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_CPU)))\
|
---|
365 | $(DEFS)\
|
---|
366 | $(DEFS.$(BUILD_TYPE))\
|
---|
367 | $(DEFS.$(BUILD_TARGET))\
|
---|
368 | $(DEFS.$(BUILD_TARGET_ARCH))\
|
---|
369 | $(DEFS.$(BUILD_TARGET_CPU))\
|
---|
370 | $($(type)DEFS)\
|
---|
371 | $($(type)DEFS.$(BUILD_TYPE))\
|
---|
372 | $($(type)DEFS.$(BUILD_TARGET))\
|
---|
373 | $($(type)DEFS.$(BUILD_TARGET_ARCH))\
|
---|
374 | $($(type)DEFS.$(BUILD_TARGET_CPU))\
|
---|
375 | $(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
|
---|
376 | $($(target)_SDKS.$(BUILD_TYPE)) \
|
---|
377 | $($(target)_SDKS),\
|
---|
378 | $(SDK_$(sdk)_DEFS)\
|
---|
379 | $(SDK_$(sdk)_DEFS.$(BUILD_TYPE))\
|
---|
380 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET))\
|
---|
381 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_ARCH))\
|
---|
382 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_CPU))\
|
---|
383 | $(SDK_$(sdk)_$(type)DEFS)\
|
---|
384 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TYPE))\
|
---|
385 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET))\
|
---|
386 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
|
---|
387 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_CPU)))\
|
---|
388 | $($(target)_DEFS)\
|
---|
389 | $($(target)_DEFS.$(BUILD_TYPE))\
|
---|
390 | $($(target)_DEFS.$(BUILD_TARGET))\
|
---|
391 | $($(target)_DEFS.$(BUILD_TARGET_ARCH))\
|
---|
392 | $($(target)_DEFS.$(BUILD_TARGET_CPU))\
|
---|
393 | $($(target)_$(type)DEFS)\
|
---|
394 | $($(target)_$(type)DEFS.$(BUILD_TYPE))\
|
---|
395 | $($(target)_$(type)DEFS.$(BUILD_TARGET))\
|
---|
396 | $($(target)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
|
---|
397 | $($(target)_$(type)DEFS.$(BUILD_TARGET_CPU))\
|
---|
398 | $(foreach sdk, $($(source)_SDKS.$(BUILD_TARGET)) \
|
---|
399 | $($(source)_SDKS.$(BUILD_TYPE)) \
|
---|
400 | $($(source)_SDKS),\
|
---|
401 | $(SDK_$(sdk)_DEFS)\
|
---|
402 | $(SDK_$(sdk)_DEFS.$(BUILD_TYPE))\
|
---|
403 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET))\
|
---|
404 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_ARCH))\
|
---|
405 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_CPU))\
|
---|
406 | $(SDK_$(sdk)_$(type)DEFS)\
|
---|
407 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TYPE))\
|
---|
408 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET))\
|
---|
409 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
|
---|
410 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_CPU)))\
|
---|
411 | $($(source)_DEFS)\
|
---|
412 | $($(source)_DEFS.$(BUILD_TYPE))\
|
---|
413 | $($(source)_DEFS.$(BUILD_TARGET))\
|
---|
414 | $($(source)_DEFS.$(BUILD_TARGET_ARCH))\
|
---|
415 | $($(source)_DEFS.$(BUILD_TARGET_CPU))\
|
---|
416 | $($(source)_$(type)DEFS)\
|
---|
417 | $($(source)_$(type)DEFS.$(BUILD_TYPE))\
|
---|
418 | $($(source)_$(type)DEFS.$(BUILD_TARGET))\
|
---|
419 | $($(source)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
|
---|
420 | $($(source)_$(type)DEFS.$(BUILD_TARGET_CPU))\
|
---|
421 | $(foreach sdk, $($(target)_$(source)_SDKS.$(BUILD_TARGET)) \
|
---|
422 | $($(target)_$(source)_SDKS.$(BUILD_TYPE)) \
|
---|
423 | $($(target)_$(source)_SDKS),\
|
---|
424 | $(SDK_$(sdk)_DEFS)\
|
---|
425 | $(SDK_$(sdk)_DEFS.$(BUILD_TYPE))\
|
---|
426 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET))\
|
---|
427 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_ARCH))\
|
---|
428 | $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_CPU))\
|
---|
429 | $(SDK_$(sdk)_$(type)DEFS)\
|
---|
430 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TYPE))\
|
---|
431 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET))\
|
---|
432 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
|
---|
433 | $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_CPU)))\
|
---|
434 | $($(target)_$(source)_DEFS)\
|
---|
435 | $($(target)_$(source)_DEFS.$(BUILD_TYPE))\
|
---|
436 | $($(target)_$(source)_DEFS.$(BUILD_TARGET))\
|
---|
437 | $($(target)_$(source)_DEFS.$(BUILD_TARGET_ARCH))\
|
---|
438 | $($(target)_$(source)_DEFS.$(BUILD_TARGET_CPU))\
|
---|
439 | $($(target)_$(source)_$(type)DEFS)\
|
---|
440 | $($(target)_$(source)_$(type)DEFS.$(BUILD_TYPE))\
|
---|
441 | $($(target)_$(source)_$(type)DEFS.$(BUILD_TARGET))\
|
---|
442 | $($(target)_$(source)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
|
---|
443 | $($(target)_$(source)_$(type)DEFS.$(BUILD_TARGET_CPU))\
|
---|
444 | )
|
---|
445 | $(eval incs :=\
|
---|
446 | $($(target)_$(source)_$(type)INCS.$(BUILD_TARGET_CPU))\
|
---|
447 | $($(target)_$(source)_$(type)INCS.$(BUILD_TARGET_ARCH))\
|
---|
448 | $($(target)_$(source)_$(type)INCS.$(BUILD_TARGET))\
|
---|
449 | $($(target)_$(source)_$(type)INCS.$(BUILD_TYPE))\
|
---|
450 | $($(target)_$(source)_$(type)INCS)\
|
---|
451 | $($(target)_$(source)_INCS.$(BUILD_TARGET_CPU))\
|
---|
452 | $($(target)_$(source)_INCS.$(BUILD_TARGET_ARCH))\
|
---|
453 | $($(target)_$(source)_INCS.$(BUILD_TARGET))\
|
---|
454 | $($(target)_$(source)_INCS.$(BUILD_TYPE))\
|
---|
455 | $($(target)_$(source)_INCS)\
|
---|
456 | $(foreach sdk, $($(target)_$(source)_SDKS.$(BUILD_TARGET)) \
|
---|
457 | $($(target)_$(source)_SDKS.$(BUILD_TYPE)) \
|
---|
458 | $($(target)_$(source)_SDKS),\
|
---|
459 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_CPU))\
|
---|
460 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_ARCH))\
|
---|
461 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET))\
|
---|
462 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TYPE))\
|
---|
463 | $(SDK_$(sdk)_$(type)INCS)\
|
---|
464 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET_CPU))\
|
---|
465 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET_ARCH))\
|
---|
466 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET))\
|
---|
467 | $(SDK_$(sdk)_INCS.$(BUILD_TYPE))\
|
---|
468 | $(SDK_$(sdk)_INCS))\
|
---|
469 | $($(source)_$(type)INCS.$(BUILD_TARGET_CPU))\
|
---|
470 | $($(source)_$(type)INCS.$(BUILD_TARGET_ARCH))\
|
---|
471 | $($(source)_$(type)INCS.$(BUILD_TARGET))\
|
---|
472 | $($(source)_$(type)INCS.$(BUILD_TYPE))\
|
---|
473 | $($(source)_$(type)INCS)\
|
---|
474 | $($(source)_INCS.$(BUILD_TARGET_CPU))\
|
---|
475 | $($(source)_INCS.$(BUILD_TARGET_ARCH))\
|
---|
476 | $($(source)_INCS.$(BUILD_TARGET))\
|
---|
477 | $($(source)_INCS.$(BUILD_TYPE))\
|
---|
478 | $($(source)_INCS)\
|
---|
479 | $(foreach sdk, $($(source)_SDKS.$(BUILD_TARGET)) \
|
---|
480 | $($(source)_SDKS.$(BUILD_TYPE)) \
|
---|
481 | $($(source)_SDKS),\
|
---|
482 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_CPU))\
|
---|
483 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_ARCH))\
|
---|
484 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET))\
|
---|
485 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TYPE))\
|
---|
486 | $(SDK_$(sdk)_$(type)INCS)\
|
---|
487 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET_CPU))\
|
---|
488 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET_ARCH))\
|
---|
489 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET))\
|
---|
490 | $(SDK_$(sdk)_INCS.$(BUILD_TYPE))\
|
---|
491 | $(SDK_$(sdk)_INCS))\
|
---|
492 | $($(target)_$(type)INCS.$(BUILD_TARGET_CPU))\
|
---|
493 | $($(target)_$(type)INCS.$(BUILD_TARGET_ARCH))\
|
---|
494 | $($(target)_$(type)INCS.$(BUILD_TARGET))\
|
---|
495 | $($(target)_$(type)INCS.$(BUILD_TYPE))\
|
---|
496 | $($(target)_$(type)INCS)\
|
---|
497 | $($(target)_INCS.$(BUILD_TARGET_CPU))\
|
---|
498 | $($(target)_INCS.$(BUILD_TARGET_ARCH))\
|
---|
499 | $($(target)_INCS.$(BUILD_TARGET))\
|
---|
500 | $($(target)_INCS.$(BUILD_TYPE))\
|
---|
501 | $($(target)_INCS)\
|
---|
502 | $(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
|
---|
503 | $($(target)_SDKS.$(BUILD_TYPE)) \
|
---|
504 | $($(target)_SDKS),\
|
---|
505 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_CPU))\
|
---|
506 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_ARCH))\
|
---|
507 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET))\
|
---|
508 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TYPE))\
|
---|
509 | $(SDK_$(sdk)_$(type)INCS)\
|
---|
510 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET_CPU))\
|
---|
511 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET_ARCH))\
|
---|
512 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET))\
|
---|
513 | $(SDK_$(sdk)_INCS.$(BUILD_TYPE))\
|
---|
514 | $(SDK_$(sdk)_INCS))\
|
---|
515 | $(INCS.$(BUILD_TARGET_CPU))\
|
---|
516 | $(INCS.$(BUILD_TARGET_ARCH))\
|
---|
517 | $(INCS.$(BUILD_TARGET))\
|
---|
518 | $(INCS.$(BUILD_TYPE))\
|
---|
519 | $(INCS)\
|
---|
520 | $(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
|
---|
521 | $(SDKS.$(BUILD_TYPE)) \
|
---|
522 | $(SDKS),\
|
---|
523 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_CPU))\
|
---|
524 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_ARCH))\
|
---|
525 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET))\
|
---|
526 | $(SDK_$(sdk)_$(type)INCS.$(BUILD_TYPE))\
|
---|
527 | $(SDK_$(sdk)_$(type)INCS)\
|
---|
528 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET_CPU))\
|
---|
529 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET_ARCH))\
|
---|
530 | $(SDK_$(sdk)_INCS.$(BUILD_TARGET))\
|
---|
531 | $(SDK_$(sdk)_INCS.$(BUILD_TYPE))\
|
---|
532 | $(SDK_$(sdk)_INCS))\
|
---|
533 | $(TOOL_$(tool)_$(type)INCS.$(BUILD_TARGET_CPU))\
|
---|
534 | $(TOOL_$(tool)_$(type)INCS.$(BUILD_TARGET_ARCH))\
|
---|
535 | $(TOOL_$(tool)_$(type)INCS.$(BUILD_TARGET))\
|
---|
536 | $(TOOL_$(tool)_$(type)INCS.$(BUILD_TYPE))\
|
---|
537 | $(TOOL_$(tool)_$(type)INCS)\
|
---|
538 | )
|
---|
539 | $(eval flags :=\
|
---|
540 | $(TOOL_$(tool)_$(type)FLAGS)\
|
---|
541 | $(TOOL_$(tool)_$(type)FLAGS.$(BUILD_TYPE))\
|
---|
542 | $(TOOL_$(tool)_$(type)FLAGS.$(BUILD_TARGET))\
|
---|
543 | $(TOOL_$(tool)_$(type)FLAGS.$(BUILD_TARGET_ARCH))\
|
---|
544 | $(TOOL_$(tool)_$(type)FLAGS.$(BUILD_TARGET_CPU))\
|
---|
545 | $($(type)FLAGS)\
|
---|
546 | $($(type)FLAGS.$(BUILD_TYPE))\
|
---|
547 | $($(type)FLAGS.$(BUILD_TARGET))\
|
---|
548 | $($(type)FLAGS.$(BUILD_TARGET_ARCH))\
|
---|
549 | $($(type)FLAGS.$(BUILD_TARGET_CPU))\
|
---|
550 | $($(target)_$(type)FLAGS)\
|
---|
551 | $($(target)_$(type)FLAGS.$(BUILD_TYPE))\
|
---|
552 | $($(target)_$(type)FLAGS.$(BUILD_TARGET))\
|
---|
553 | $($(target)_$(type)FLAGS.$(BUILD_TARGET_ARCH))\
|
---|
554 | $($(target)_$(type)FLAGS.$(BUILD_TARGET_CPU))\
|
---|
555 | $($(source)_$(type)FLAGS)\
|
---|
556 | $($(source)_$(type)FLAGS.$(BUILD_TYPE))\
|
---|
557 | $($(source)_$(type)FLAGS.$(BUILD_TARGET))\
|
---|
558 | $($(source)_$(type)FLAGS.$(BUILD_TARGET_ARCH))\
|
---|
559 | $($(source)_$(type)FLAGS.$(BUILD_TARGET_CPU))\
|
---|
560 | $($(target)_$(source)_$(type)FLAGS)\
|
---|
561 | $($(target)_$(source)_$(type)FLAGS.$(BUILD_TYPE))\
|
---|
562 | $($(target)_$(source)_$(type)FLAGS.$(BUILD_TARGET))\
|
---|
563 | $($(target)_$(source)_$(type)FLAGS.$(BUILD_TARGET_ARCH))\
|
---|
564 | $($(target)_$(source)_$(type)FLAGS.$(BUILD_TARGET_CPU))\
|
---|
565 | )
|
---|
566 | $(eval objsuff := $(firstword \
|
---|
567 | $($(target)_$(source)_OBJSUFF.$(BUILD_TARGET))\
|
---|
568 | $($(target)_$(source)_OBJSUFF)\
|
---|
569 | $($(source)_OBJSUFF.$(BUILD_TARGET))\
|
---|
570 | $($(source)_OBJSUFF)\
|
---|
571 | $($(target)_OBJSUFF.$(BUILD_TARGET))\
|
---|
572 | $($(target)_OBJSUFF)\
|
---|
573 | $(TOOL_$(tool)_$(type)OBJSUFF.$(BUILD_TARGET))\
|
---|
574 | $(TOOL_$(tool)_$(type)OBJSUFF)\
|
---|
575 | $(SUFF_OBJ)\
|
---|
576 | ))
|
---|
577 | $(eval obj := $(outbase)$(objsuff))
|
---|
578 | $(eval dep := $(outbase)$(SUFF_DEP))
|
---|
579 |
|
---|
580 | #$ (warning dbg: target=$(target) source=$(source) tool=$(tool) obj=$(obj) dep=$(dep) flags=$(flags) defs=$(defs) incs=$(incs) dirdep=$(dirdep) outbase=$(outbase) objsuff=$(objsuff))
|
---|
581 | ifndef TOOL_$(tool)_COMPILE_$(type)
|
---|
582 | $$(warning kBuild: TOOL_$(tool)_COMPILE_$(type) is not defined. source=$(source) target=$(target) )
|
---|
583 | $$(warning kBuild: tools: \
|
---|
584 | 1 $($(target)_$(source)_$(type)TOOL.$(BUILD_TARGET)) \
|
---|
585 | 2 $($(target)_$(source)_$(type)TOOL) \
|
---|
586 | 3 $($(target)_$(source)_TOOL.$(BUILD_TARGET)) \
|
---|
587 | 4 $($(target)_$(source)_TOOL) \
|
---|
588 | 5 $($(target)_$(type)TOOL.$(BUILD_TARGET)) \
|
---|
589 | 6 $($(target)_$(type)TOOL) \
|
---|
590 | 7 $($(target)_TOOL.$(BUILD_TARGET)) \
|
---|
591 | 8 $($(target)_TOOL) \
|
---|
592 | 9 $($(source)_$(type)TOOL.$(BUILD_TARGET)) \
|
---|
593 | 10 $($(source)_$(type)TOOL) \
|
---|
594 | 11 $($(source)_TOOL.$(BUILD_TARGET)) \
|
---|
595 | 12 $($(source)_TOOL) \
|
---|
596 | 13 $($(type)TOOL.$(BUILD_TARGET)) \
|
---|
597 | 14 $($(type)TOOL) \
|
---|
598 | 15 $(TOOL.$(BUILD_TARGET)) \
|
---|
599 | 16 $(TOOL) )
|
---|
600 | endif
|
---|
601 | $(eval $(TOOL_$(tool)_COMPILE_$(type)))
|
---|
602 |
|
---|
603 | $(eval _OBJS_$(target) += $(obj))
|
---|
604 | $(eval _DEPFILES += $(dep))
|
---|
605 |
|
---|
606 | endef
|
---|
607 |
|
---|
608 | ## Generic macro for processing all target sources.
|
---|
609 | # @param $(target) Normalized target name.
|
---|
610 | define def_target_sources
|
---|
611 | #$ (warning def_target_sources)
|
---|
612 | # C sources
|
---|
613 | $(foreach type,C,$(foreach source, $(filter %.c, $($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_MODE)))\
|
---|
614 | ,$(eval $(def_target_source_c_cpp_asm)) ))
|
---|
615 |
|
---|
616 | # C++ sources
|
---|
617 | $(foreach type,CXX,$(foreach source, $(filter %.cpp %.cxx %.xx, $($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_MODE)))\
|
---|
618 | ,$(eval $(def_target_source_c_cpp_asm)) ))
|
---|
619 |
|
---|
620 | # ASM sources
|
---|
621 | $(foreach type,AS,$(foreach source, $(filter %.asm %.s %.S, $($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_MODE)))\
|
---|
622 | ,$(eval $(def_target_source_c_cpp_asm)) ))
|
---|
623 | endef
|
---|
624 |
|
---|
625 |
|
---|
626 | #
|
---|
627 | # LIBRARIES
|
---|
628 | #
|
---|
629 |
|
---|
630 | ## Library (one).
|
---|
631 | # @param $(target) Normalized library (target) name.
|
---|
632 | define def_lib
|
---|
633 | # library basics
|
---|
634 | $(eval tool := $(call _TARGET_TOOL,$(target),AR))
|
---|
635 | ifeq ($(tool),)
|
---|
636 | $$(error kBuild: Library target $(target) doesn't have a tool defined!)
|
---|
637 | endif
|
---|
638 | ## @todo prefix
|
---|
639 | $(eval outbase := $(call _TARGET_BASE,$(target),$(target)))
|
---|
640 | $(eval PATH_$(target) := $(patsubst %/,%,$(dir $(outbase))))
|
---|
641 | $(eval libsuff := $(firstword\
|
---|
642 | $($(target)_LIBSUFF.$(BUILD_TARGET))\
|
---|
643 | $($(target)_LIBSUFF)\
|
---|
644 | $(TOOL_$(tool)_ARLIBSUFF.$(BUILD_TARGET))\
|
---|
645 | $(TOOL_$(tool)_ARLIBSUFF)\
|
---|
646 | $(SUFF_LIB)\
|
---|
647 | ))
|
---|
648 | $(eval lib := $(outbase)$(libsuff))
|
---|
649 |
|
---|
650 | # source -> object
|
---|
651 | $(eval $(def_target_sources))
|
---|
652 |
|
---|
653 | # library linking
|
---|
654 | $(eval tool := $(call _TARGET_TOOL,$(target),AR))
|
---|
655 | $(eval outbase := $(call _TARGET_BASE,$(target),$(target)))
|
---|
656 | $(eval flags :=\
|
---|
657 | $(TOOL_$(tool)_ARFLAGS)\
|
---|
658 | $(TOOL_$(tool)_ARFLAGS.$(BUILD_TYPE))\
|
---|
659 | $(ARFLAGS)\
|
---|
660 | $(ARFLAGS.$(BUILD_TYPE))\
|
---|
661 | $($(target)_ARFLAGS)\
|
---|
662 | $($(target)_ARFLAGS.$(BUILD_TYPE))\
|
---|
663 | )
|
---|
664 | $(eval objs = $(_OBJS_$(target)))
|
---|
665 | $(eval othersrc := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm,$($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_MODE))))
|
---|
666 | $(eval dirdep := $(dir $(lib)).dir_created)
|
---|
667 | ## @todo fix dependencies on makefiles an such
|
---|
668 | $(eval deps := )
|
---|
669 |
|
---|
670 | $(eval $(TOOL_$(tool)_LINK_LIBRARY))
|
---|
671 |
|
---|
672 | # publish rule (still need work)
|
---|
673 | ifndef $(target)_NOINST
|
---|
674 | $(eval publib := $(PATH_LIB)/$(notdir $(lib)))
|
---|
675 | $(publib) : $(lib) $(dir $(publib)).dir_created
|
---|
676 | $(CP) $(lib) $(publib)
|
---|
677 |
|
---|
678 | _LIBS += $(publib)
|
---|
679 | _OUT_FILES += $(lib) $(publib)
|
---|
680 | else
|
---|
681 | _LIBS += $(lib)
|
---|
682 | _OUT_FILES += $(lib)
|
---|
683 | endif
|
---|
684 | _OBJS += $(_OBJS_$(target))
|
---|
685 | endef
|
---|
686 |
|
---|
687 | # Process libraries
|
---|
688 | $(foreach target, $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)), $(eval $(def_lib)))
|
---|
689 |
|
---|
690 |
|
---|
691 |
|
---|
692 | #
|
---|
693 | # PROGRAMS
|
---|
694 | #
|
---|
695 |
|
---|
696 | ## Program (one).
|
---|
697 | # @param $(target) Normalized target (program) name.
|
---|
698 | define def_program
|
---|
699 | # basics
|
---|
700 | $(eval tool := $(call _TARGET_TOOL,$(target),LD))
|
---|
701 | $(eval outbase := $(call _TARGET_BASE,$(target),$(target)))
|
---|
702 | $(eval PATH_$(target) := $(patsubst %/,%,$(dir $(outbase))))
|
---|
703 | $(eval exesuff := $(firstword $($(target)_EXESUFF) $($(target)_EXESUFF) $(TOOL_$(tool)_LDEXESUFF) $(SUFF_EXE)))
|
---|
704 | $(eval exe := $(outbase)$(exesuff))
|
---|
705 |
|
---|
706 | # source -> object
|
---|
707 | $(eval $(def_target_sources))
|
---|
708 |
|
---|
709 | # more library stuff.
|
---|
710 | $(eval tool := $(call _TARGET_TOOL,$(target),LD))
|
---|
711 | $(eval outbase := $(call _TARGET_BASE,$(target),$(target)))
|
---|
712 | $(eval objs = $(_OBJS_$(target)))
|
---|
713 | $(eval flags :=\
|
---|
714 | $(TOOL_$(tool)_LDFLAGS)\
|
---|
715 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TYPE))\
|
---|
716 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET))\
|
---|
717 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET_ARCH))\
|
---|
718 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET_CPU))\
|
---|
719 | $(LDFLAGS)\
|
---|
720 | $(LDFLAGS.$(BUILD_TYPE))\
|
---|
721 | $(LDFLAGS.$(BUILD_TARGET))\
|
---|
722 | $(LDFLAGS.$(BUILD_TARGET_ARCH))\
|
---|
723 | $(LDFLAGS.$(BUILD_TARGET_CPU))\
|
---|
724 | $($(target)_LDFLAGS)\
|
---|
725 | $($(target)_LDFLAGS.$(BUILD_TYPE))\
|
---|
726 | $($(target)_LDFLAGS.$(BUILD_TARGET))\
|
---|
727 | $($(target)_LDFLAGS.$(BUILD_TARGET_ARCH))\
|
---|
728 | $($(target)_LDFLAGS.$(BUILD_TARGET_CPU))\
|
---|
729 | )
|
---|
730 | $(eval libs :=\
|
---|
731 | $($(target)_LIBS.$(BUILD_TARGET_CPU))\
|
---|
732 | $($(target)_LIBS.$(BUILD_TARGET_ARCH))\
|
---|
733 | $($(target)_LIBS.$(BUILD_TARGET))\
|
---|
734 | $($(target)_LIBS.$(BUILD_TYPE))\
|
---|
735 | $($(target)_LIBS)\
|
---|
736 | $(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
|
---|
737 | $($(target)_SDKS.$(BUILD_TYPE)) \
|
---|
738 | $($(target)_SDKS),\
|
---|
739 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_CPU))\
|
---|
740 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_ARCH))\
|
---|
741 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET))\
|
---|
742 | $(SDK_$(sdk)_LIBS.$(BUILD_TYPE))\
|
---|
743 | $(SDK_$(sdk)_LIBS))\
|
---|
744 | $(LIBS.$(BUILD_TARGET_CPU))\
|
---|
745 | $(LIBS.$(BUILD_TARGET_ARCH))\
|
---|
746 | $(LIBS.$(BUILD_TARGET))\
|
---|
747 | $(LIBS.$(BUILD_TYPE))\
|
---|
748 | $(LIBS)\
|
---|
749 | $(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
|
---|
750 | $(SDKS.$(BUILD_TYPE)) \
|
---|
751 | $(SDKS),\
|
---|
752 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_CPU))\
|
---|
753 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_ARCH))\
|
---|
754 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET))\
|
---|
755 | $(SDK_$(sdk)_LIBS.$(BUILD_TYPE))\
|
---|
756 | $(SDK_$(sdk)_LIBS))\
|
---|
757 | $(TOOL_$(tool)_LIBS.$(BUILD_TARGET_CPU))\
|
---|
758 | $(TOOL_$(tool)_LIBS.$(BUILD_TARGET_ARCH))\
|
---|
759 | $(TOOL_$(tool)_LIBS.$(BUILD_TARGET))\
|
---|
760 | $(TOOL_$(tool)_LIBS.$(BUILD_TYPE))\
|
---|
761 | $(TOOL_$(tool)_LIBS)\
|
---|
762 | )
|
---|
763 | $(eval libpath :=\
|
---|
764 | $($(target)_LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
765 | $($(target)_LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
766 | $($(target)_LIBPATH.$(BUILD_TARGET))\
|
---|
767 | $($(target)_LIBPATH.$(BUILD_TYPE))\
|
---|
768 | $($(target)_LIBPATH)\
|
---|
769 | $(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
|
---|
770 | $($(target)_SDKS.$(BUILD_TYPE)) \
|
---|
771 | $($(target)_SDKS),\
|
---|
772 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
773 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
774 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET))\
|
---|
775 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TYPE))\
|
---|
776 | $(SDK_$(sdk)_LIBPATH))\
|
---|
777 | $(LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
778 | $(LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
779 | $(LIBPATH.$(BUILD_TARGET))\
|
---|
780 | $(LIBPATH.$(BUILD_TYPE))\
|
---|
781 | $(LIBPATH)\
|
---|
782 | $(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
|
---|
783 | $(SDKS.$(BUILD_TYPE)) \
|
---|
784 | $(SDKS),\
|
---|
785 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
786 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
787 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET))\
|
---|
788 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TYPE))\
|
---|
789 | $(SDK_$(sdk)_LIBPATH))\
|
---|
790 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
791 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
792 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET))\
|
---|
793 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TYPE))\
|
---|
794 | $(TOOL_$(tool)_LIBPATH)\
|
---|
795 | )
|
---|
796 | $(eval dirdep := $(dir $(exe)).dir_created)
|
---|
797 | ## @todo fix dependencies
|
---|
798 | $(eval deps := )
|
---|
799 | #
|
---|
800 | $(eval custom_pre := $(strip $(firstword
|
---|
801 | $($(target)_CUSTOM_PRE.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
802 | $($(target)_CUSTOM_PRE.$(BUILD_TARGET))\
|
---|
803 | $($(target)_CUSTOM_PRE.$(BUILD_TYPE))\
|
---|
804 | $($(target)_CUSTOM_PRE)\
|
---|
805 | $(CUSTOM_PRE.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
806 | $(CUSTOM_PRE.$(BUILD_TARGET))\
|
---|
807 | $(CUSTOM_PRE.$(BUILD_TYPE))\
|
---|
808 | $(CUSTOM_PRE)\
|
---|
809 | )))
|
---|
810 | $(eval custom_post := $(strip $(firstword
|
---|
811 | $($(target)_CUSTOM_POST.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
812 | $($(target)_CUSTOM_POST.$(BUILD_TARGET))\
|
---|
813 | $($(target)_CUSTOM_POST.$(BUILD_TYPE))\
|
---|
814 | $($(target)_CUSTOM_POST)\
|
---|
815 | $(CUSTOM_POST.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
816 | $(CUSTOM_POST.$(BUILD_TARGET))\
|
---|
817 | $(CUSTOM_POST.$(BUILD_TYPE))\
|
---|
818 | $(CUSTOM_POST)\
|
---|
819 | )))
|
---|
820 | $(eval othersrc := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm,$($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_MODE))))
|
---|
821 |
|
---|
822 | $(eval $(TOOL_$(tool)_LINK_PROGRAM))
|
---|
823 | # publish rule (still need work)
|
---|
824 | ifndef $(target)_NOINST
|
---|
825 | $(eval pubexe := $(PATH_BIN)/$(notdir $(exe)))
|
---|
826 | $(pubexe) : $(exe) $(dir $(pubexe)).dir_created
|
---|
827 | $(CP) $(exe) $(pubexe)
|
---|
828 |
|
---|
829 | _DLLS += $(pubexe)
|
---|
830 | _OUT_FILES += $(exe) $(pubexe)
|
---|
831 | else
|
---|
832 | _DLLS += $(exe)
|
---|
833 | _OUT_FILES += $(exe)
|
---|
834 | endif
|
---|
835 | _OBJS += $(_OBJS_$(target))
|
---|
836 | endef
|
---|
837 |
|
---|
838 | # Process libraries
|
---|
839 | $(foreach target, $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)), $(eval $(def_program)))
|
---|
840 |
|
---|
841 |
|
---|
842 |
|
---|
843 | #
|
---|
844 | # DLLS
|
---|
845 | #
|
---|
846 |
|
---|
847 | ## DLL (one).
|
---|
848 | # @param $(target) Normalized target (program) name.
|
---|
849 | define def_dll
|
---|
850 | # dllmod basics
|
---|
851 | $(eval tool := $(call _TARGET_TOOL,$(target),LD))
|
---|
852 | $(eval outbase := $(call _TARGET_BASE,$(target),$(target)))
|
---|
853 | $(eval PATH_$(target) := $(patsubst %/,%,$(dir $(outbase))))
|
---|
854 | $(eval dllsuff := $(firstword $($(target)_DLLSUFF) $($(target)_DLLSUFF) $(TOOL_$(tool)_LDDLLSUFF) $(SUFF_DLL)))
|
---|
855 | $(eval dll := $(outbase)$(dllsuff))
|
---|
856 |
|
---|
857 | # source -> object
|
---|
858 | $(eval $(def_target_sources))
|
---|
859 |
|
---|
860 | # dllmod linking.
|
---|
861 | $(eval tool := $(call _TARGET_TOOL,$(target),LD))
|
---|
862 | $(eval outbase := $(call _TARGET_BASE,$(target),$(target)))
|
---|
863 | $(eval objs = $(_OBJS_$(target)))
|
---|
864 | $(eval flags :=\
|
---|
865 | $(TOOL_$(tool)_LDFLAGS)\
|
---|
866 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TYPE))\
|
---|
867 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET))\
|
---|
868 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET_ARCH))\
|
---|
869 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET_CPU))\
|
---|
870 | $(LDFLAGS)\
|
---|
871 | $(LDFLAGS.$(BUILD_TYPE))\
|
---|
872 | $(LDFLAGS.$(BUILD_TARGET))\
|
---|
873 | $(LDFLAGS.$(BUILD_TARGET_ARCH))\
|
---|
874 | $(LDFLAGS.$(BUILD_TARGET_CPU))\
|
---|
875 | $($(target)_LDFLAGS)\
|
---|
876 | $($(target)_LDFLAGS.$(BUILD_TYPE))\
|
---|
877 | $($(target)_LDFLAGS.$(BUILD_TARGET))\
|
---|
878 | $($(target)_LDFLAGS.$(BUILD_TARGET_ARCH))\
|
---|
879 | $($(target)_LDFLAGS.$(BUILD_TARGET_CPU))\
|
---|
880 | )
|
---|
881 | $(eval libs :=\
|
---|
882 | $($(target)_LIBS.$(BUILD_TARGET_CPU))\
|
---|
883 | $($(target)_LIBS.$(BUILD_TARGET_ARCH))\
|
---|
884 | $($(target)_LIBS.$(BUILD_TARGET))\
|
---|
885 | $($(target)_LIBS.$(BUILD_TYPE))\
|
---|
886 | $($(target)_LIBS)\
|
---|
887 | $(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
|
---|
888 | $($(target)_SDKS.$(BUILD_TYPE)) \
|
---|
889 | $($(target)_SDKS),\
|
---|
890 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_CPU))\
|
---|
891 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_ARCH))\
|
---|
892 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET))\
|
---|
893 | $(SDK_$(sdk)_LIBS.$(BUILD_TYPE))\
|
---|
894 | $(SDK_$(sdk)_LIBS))\
|
---|
895 | $(LIBS.$(BUILD_TARGET_CPU))\
|
---|
896 | $(LIBS.$(BUILD_TARGET_ARCH))\
|
---|
897 | $(LIBS.$(BUILD_TARGET))\
|
---|
898 | $(LIBS.$(BUILD_TYPE))\
|
---|
899 | $(LIBS)\
|
---|
900 | $(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
|
---|
901 | $(SDKS.$(BUILD_TYPE)) \
|
---|
902 | $(SDKS),\
|
---|
903 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_CPU))\
|
---|
904 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_ARCH))\
|
---|
905 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET))\
|
---|
906 | $(SDK_$(sdk)_LIBS.$(BUILD_TYPE))\
|
---|
907 | $(SDK_$(sdk)_LIBS))\
|
---|
908 | $(TOOL_$(tool)_LIBS.$(BUILD_TARGET_CPU))\
|
---|
909 | $(TOOL_$(tool)_LIBS.$(BUILD_TARGET_ARCH))\
|
---|
910 | $(TOOL_$(tool)_LIBS.$(BUILD_TARGET))\
|
---|
911 | $(TOOL_$(tool)_LIBS.$(BUILD_TYPE))\
|
---|
912 | $(TOOL_$(tool)_LIBS)\
|
---|
913 | )
|
---|
914 | $(eval libpath :=\
|
---|
915 | $($(target)_LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
916 | $($(target)_LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
917 | $($(target)_LIBPATH.$(BUILD_TARGET))\
|
---|
918 | $($(target)_LIBPATH.$(BUILD_TYPE))\
|
---|
919 | $($(target)_LIBPATH)\
|
---|
920 | $(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
|
---|
921 | $($(target)_SDKS.$(BUILD_TYPE)) \
|
---|
922 | $($(target)_SDKS),\
|
---|
923 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
924 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
925 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET))\
|
---|
926 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TYPE))\
|
---|
927 | $(SDK_$(sdk)_LIBPATH))\
|
---|
928 | $(LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
929 | $(LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
930 | $(LIBPATH.$(BUILD_TARGET))\
|
---|
931 | $(LIBPATH.$(BUILD_TYPE))\
|
---|
932 | $(LIBPATH)\
|
---|
933 | $(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
|
---|
934 | $(SDKS.$(BUILD_TYPE)) \
|
---|
935 | $(SDKS),\
|
---|
936 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
937 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
938 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET))\
|
---|
939 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TYPE))\
|
---|
940 | $(SDK_$(sdk)_LIBPATH))\
|
---|
941 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
942 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
943 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET))\
|
---|
944 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TYPE))\
|
---|
945 | $(TOOL_$(tool)_LIBPATH)\
|
---|
946 | )
|
---|
947 | $(eval dirdep := $(dir $(dll)).dir_created)
|
---|
948 | ## @todo fix dependencies
|
---|
949 | $(eval deps := )
|
---|
950 | #
|
---|
951 | $(eval custom_pre := $(strip $(firstword
|
---|
952 | $($(target)_CUSTOM_PRE.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
953 | $($(target)_CUSTOM_PRE.$(BUILD_TARGET))\
|
---|
954 | $($(target)_CUSTOM_PRE.$(BUILD_TYPE))\
|
---|
955 | $($(target)_CUSTOM_PRE)\
|
---|
956 | $(CUSTOM_PRE.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
957 | $(CUSTOM_PRE.$(BUILD_TARGET))\
|
---|
958 | $(CUSTOM_PRE.$(BUILD_TYPE))\
|
---|
959 | $(CUSTOM_PRE)\
|
---|
960 | )))
|
---|
961 | $(eval custom_post := $(strip $(firstword
|
---|
962 | $($(target)_CUSTOM_POST.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
963 | $($(target)_CUSTOM_POST.$(BUILD_TARGET))\
|
---|
964 | $($(target)_CUSTOM_POST.$(BUILD_TYPE))\
|
---|
965 | $($(target)_CUSTOM_POST)\
|
---|
966 | $(CUSTOM_POST.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
967 | $(CUSTOM_POST.$(BUILD_TARGET))\
|
---|
968 | $(CUSTOM_POST.$(BUILD_TYPE))\
|
---|
969 | $(CUSTOM_POST)\
|
---|
970 | )))
|
---|
971 | $(eval othersrc := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm,$($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_MODE))))
|
---|
972 |
|
---|
973 | ifndef TOOL_$(tool)_LINK_DLL
|
---|
974 | $$(warning kBuild: TOOL_$(tool)_LINK_DLL is not defined. target=$(target) )
|
---|
975 | $$(warning kBuild: tools: \
|
---|
976 | 1 $($(target)_$(source)TOOL.$(BUILD_TARGET)) \
|
---|
977 | 2 $($(target)_$(source)TOOL) \
|
---|
978 | 3 $($(target)_TOOL.$(BUILD_TARGET)) \
|
---|
979 | 4 $($(target)_TOOL) \
|
---|
980 | 5 $($(source)TOOL) \
|
---|
981 | 6 $($(source)TOOL.$(BUILD_TARGET)) \
|
---|
982 | 7 $(TOOL.$(BUILD_TARGET)) \
|
---|
983 | 8 $(TOOL) )
|
---|
984 | endif
|
---|
985 |
|
---|
986 | $(eval $(TOOL_$(tool)_LINK_DLL))
|
---|
987 |
|
---|
988 |
|
---|
989 | # publish rule (still need work)
|
---|
990 | ifndef $(target)_NOINST
|
---|
991 | $(eval pubdll := $(PATH_BIN)/$(notdir $(dll)))
|
---|
992 | $(pubdll) : $(dll) $(dir $(pubdll)).dir_created
|
---|
993 | $(CP) $(dll) $(pubdll)
|
---|
994 |
|
---|
995 | _DLLS += $(pubdll)
|
---|
996 | _OUT_FILES += $(dll) $(pubdll)
|
---|
997 | else
|
---|
998 | _DLLS += $(dll)
|
---|
999 | _OUT_FILES += $(dll)
|
---|
1000 | endif
|
---|
1001 | _OBJS += $(_OBJS_$(target))
|
---|
1002 | endef
|
---|
1003 |
|
---|
1004 | # Process dlls
|
---|
1005 | $(foreach target, $(DLLS) $(DLLS.$(BUILD_TARGET)), $(eval $(def_dll)))
|
---|
1006 |
|
---|
1007 |
|
---|
1008 | #
|
---|
1009 | # SYSMODS
|
---|
1010 | #
|
---|
1011 |
|
---|
1012 | ## System module (one).
|
---|
1013 | # @param $(target) Normalized target (program) name.
|
---|
1014 | define def_sysmod
|
---|
1015 | # sysmod basics
|
---|
1016 | $(eval tool := $(call _TARGET_TOOL,$(target),LD))
|
---|
1017 | $(eval outbase := $(call _TARGET_BASE,$(target),$(target)))
|
---|
1018 | $(eval PATH_$(target) := $(patsubst %/,%,$(dir $(outbase))))
|
---|
1019 | $(eval syssuff := $(firstword $($(target)_SYSSUFF) $($(target)_SYSSUFF) $(TOOL_$(tool)_LDSYSSUFF) $(SUFF_SYS)))
|
---|
1020 | $(eval sys := $(outbase)$(syssuff))
|
---|
1021 |
|
---|
1022 | # source -> object
|
---|
1023 | $(eval $(def_target_sources))
|
---|
1024 |
|
---|
1025 | # sysmod linking
|
---|
1026 | $(eval tool := $(call _TARGET_TOOL,$(target),LD))
|
---|
1027 | $(eval outbase := $(call _TARGET_BASE,$(target),$(target)))
|
---|
1028 | $(eval objs = $(_OBJS_$(target)))
|
---|
1029 | $(eval flags :=\
|
---|
1030 | $(TOOL_$(tool)_LDFLAGS)\
|
---|
1031 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TYPE))\
|
---|
1032 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET))\
|
---|
1033 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET_ARCH))\
|
---|
1034 | $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET_CPU))\
|
---|
1035 | $(LDFLAGS)\
|
---|
1036 | $(LDFLAGS.$(BUILD_TYPE))\
|
---|
1037 | $(LDFLAGS.$(BUILD_TARGET))\
|
---|
1038 | $(LDFLAGS.$(BUILD_TARGET_ARCH))\
|
---|
1039 | $(LDFLAGS.$(BUILD_TARGET_CPU))\
|
---|
1040 | $($(target)_LDFLAGS)\
|
---|
1041 | $($(target)_LDFLAGS.$(BUILD_TYPE))\
|
---|
1042 | $($(target)_LDFLAGS.$(BUILD_TARGET))\
|
---|
1043 | $($(target)_LDFLAGS.$(BUILD_TARGET_ARCH))\
|
---|
1044 | $($(target)_LDFLAGS.$(BUILD_TARGET_CPU))\
|
---|
1045 | )
|
---|
1046 | $(eval libs :=\
|
---|
1047 | $($(target)_LIBS.$(BUILD_TARGET_CPU))\
|
---|
1048 | $($(target)_LIBS.$(BUILD_TARGET_ARCH))\
|
---|
1049 | $($(target)_LIBS.$(BUILD_TARGET))\
|
---|
1050 | $($(target)_LIBS.$(BUILD_TYPE))\
|
---|
1051 | $($(target)_LIBS)\
|
---|
1052 | $(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
|
---|
1053 | $($(target)_SDKS.$(BUILD_TYPE)) \
|
---|
1054 | $($(target)_SDKS),\
|
---|
1055 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_CPU))\
|
---|
1056 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_ARCH))\
|
---|
1057 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET))\
|
---|
1058 | $(SDK_$(sdk)_LIBS.$(BUILD_TYPE))\
|
---|
1059 | $(SDK_$(sdk)_LIBS))\
|
---|
1060 | $(LIBS.$(BUILD_TARGET_CPU))\
|
---|
1061 | $(LIBS.$(BUILD_TARGET_ARCH))\
|
---|
1062 | $(LIBS.$(BUILD_TARGET))\
|
---|
1063 | $(LIBS.$(BUILD_TYPE))\
|
---|
1064 | $(LIBS)\
|
---|
1065 | $(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
|
---|
1066 | $(SDKS.$(BUILD_TYPE)) \
|
---|
1067 | $(SDKS),\
|
---|
1068 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_CPU))\
|
---|
1069 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_ARCH))\
|
---|
1070 | $(SDK_$(sdk)_LIBS.$(BUILD_TARGET))\
|
---|
1071 | $(SDK_$(sdk)_LIBS.$(BUILD_TYPE))\
|
---|
1072 | $(SDK_$(sdk)_LIBS))\
|
---|
1073 | $(TOOL_$(tool)_LIBS.$(BUILD_TARGET_CPU))\
|
---|
1074 | $(TOOL_$(tool)_LIBS.$(BUILD_TARGET_ARCH))\
|
---|
1075 | $(TOOL_$(tool)_LIBS.$(BUILD_TARGET))\
|
---|
1076 | $(TOOL_$(tool)_LIBS.$(BUILD_TYPE))\
|
---|
1077 | $(TOOL_$(tool)_LIBS)\
|
---|
1078 | )
|
---|
1079 | $(eval libpath :=\
|
---|
1080 | $($(target)_LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
1081 | $($(target)_LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
1082 | $($(target)_LIBPATH.$(BUILD_TARGET))\
|
---|
1083 | $($(target)_LIBPATH.$(BUILD_TYPE))\
|
---|
1084 | $($(target)_LIBPATH)\
|
---|
1085 | $(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
|
---|
1086 | $($(target)_SDKS.$(BUILD_TYPE)) \
|
---|
1087 | $($(target)_SDKS),\
|
---|
1088 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
1089 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
1090 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET))\
|
---|
1091 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TYPE))\
|
---|
1092 | $(SDK_$(sdk)_LIBPATH))\
|
---|
1093 | $(LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
1094 | $(LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
1095 | $(LIBPATH.$(BUILD_TARGET))\
|
---|
1096 | $(LIBPATH.$(BUILD_TYPE))\
|
---|
1097 | $(LIBPATH)\
|
---|
1098 | $(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
|
---|
1099 | $(SDKS.$(BUILD_TYPE)) \
|
---|
1100 | $(SDKS),\
|
---|
1101 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
1102 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
1103 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET))\
|
---|
1104 | $(SDK_$(sdk)_LIBPATH.$(BUILD_TYPE))\
|
---|
1105 | $(SDK_$(sdk)_LIBPATH))\
|
---|
1106 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET_CPU))\
|
---|
1107 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET_ARCH))\
|
---|
1108 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET))\
|
---|
1109 | $(TOOL_$(tool)_LIBPATH.$(BUILD_TYPE))\
|
---|
1110 | $(TOOL_$(tool)_LIBPATH)\
|
---|
1111 | )
|
---|
1112 | $(eval dirdep := $(dir $(sys)).dir_created)
|
---|
1113 | ## @todo fix dependencies
|
---|
1114 | $(eval deps := )
|
---|
1115 | #
|
---|
1116 | $(eval custom_pre := $(strip $(firstword
|
---|
1117 | $($(target)_CUSTOM_PRE.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
1118 | $($(target)_CUSTOM_PRE.$(BUILD_TARGET))\
|
---|
1119 | $($(target)_CUSTOM_PRE.$(BUILD_TYPE))\
|
---|
1120 | $($(target)_CUSTOM_PRE)\
|
---|
1121 | $(CUSTOM_PRE.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
1122 | $(CUSTOM_PRE.$(BUILD_TARGET))\
|
---|
1123 | $(CUSTOM_PRE.$(BUILD_TYPE))\
|
---|
1124 | $(CUSTOM_PRE)\
|
---|
1125 | )))
|
---|
1126 | $(eval custom_post := $(strip $(firstword
|
---|
1127 | $($(target)_CUSTOM_POST.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
1128 | $($(target)_CUSTOM_POST.$(BUILD_TARGET))\
|
---|
1129 | $($(target)_CUSTOM_POST.$(BUILD_TYPE))\
|
---|
1130 | $($(target)_CUSTOM_POST)\
|
---|
1131 | $(CUSTOM_POST.$(BUILD_TARGET).$(BUILD_TYPE))\
|
---|
1132 | $(CUSTOM_POST.$(BUILD_TARGET))\
|
---|
1133 | $(CUSTOM_POST.$(BUILD_TYPE))\
|
---|
1134 | $(CUSTOM_POST)\
|
---|
1135 | )))
|
---|
1136 | $(eval othersrc := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm,$($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_MODE))))
|
---|
1137 |
|
---|
1138 | ifndef TOOL_$(tool)_LINK_SYSMOD
|
---|
1139 | $$(warning kBuild: TOOL_$(tool)_LINK_SYSMOD is not defined. target=$(target) )
|
---|
1140 | $$(warning kBuild: tools: \
|
---|
1141 | 1 $($(target)_$(source)TOOL.$(BUILD_TARGET)) \
|
---|
1142 | 2 $($(target)_$(source)TOOL) \
|
---|
1143 | 3 $($(target)_TOOL.$(BUILD_TARGET)) \
|
---|
1144 | 4 $($(target)_TOOL) \
|
---|
1145 | 5 $($(source)TOOL) \
|
---|
1146 | 6 $($(source)TOOL.$(BUILD_TARGET)) \
|
---|
1147 | 7 $(TOOL.$(BUILD_TARGET)) \
|
---|
1148 | 8 $(TOOL) )
|
---|
1149 | endif
|
---|
1150 |
|
---|
1151 | $(eval $(TOOL_$(tool)_LINK_SYSMOD))
|
---|
1152 |
|
---|
1153 | # publish rule (still need work)
|
---|
1154 | ifndef $(target)_NOINST
|
---|
1155 | $(eval pubsys := $(PATH_BIN)/$(notdir $(sys)))
|
---|
1156 | $(pubsys): $(sys) $(dir $(pubsys)).dir_created
|
---|
1157 | $(CP) $(sys) $(pubsys)
|
---|
1158 |
|
---|
1159 | $(eval _SYSMODS += $(pubsys))
|
---|
1160 | $(eval _OUT_FILES += $(sys) $(pubsys))
|
---|
1161 | else
|
---|
1162 | $(eval _SYSMODS += $(sys))
|
---|
1163 | $(eval _OUT_FILES += $(sys))
|
---|
1164 | endif
|
---|
1165 | _OBJS += $(_OBJS_$(target))
|
---|
1166 | endef
|
---|
1167 |
|
---|
1168 | # Process sysmods
|
---|
1169 | $(foreach target, $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)), $(eval $(def_sysmod)))
|
---|
1170 |
|
---|
1171 |
|
---|
1172 |
|
---|
1173 | #
|
---|
1174 | # OTHERS
|
---|
1175 | #
|
---|
1176 | _OTHERS = $(OTHERS)
|
---|
1177 |
|
---|
1178 |
|
---|
1179 |
|
---|
1180 | #
|
---|
1181 | # DOCS
|
---|
1182 | #
|
---|
1183 |
|
---|
1184 |
|
---|
1185 | #
|
---|
1186 | # Directories.
|
---|
1187 | #
|
---|
1188 | _DIRFILES := $(sort $(addsuffix /.dir_created,$(_DIRS)) $(addsuffix .dir_created,$(sort $(dir $(_OUT_FILES) $(_OBJS)))))
|
---|
1189 |
|
---|
1190 | define def_createdir
|
---|
1191 | $(dirfile):
|
---|
1192 | $(call MSG_Ltarget,Creating directory $$(@D))
|
---|
1193 | $(MKDIR) -p $$(@D)
|
---|
1194 | @echo dir_created > $$@
|
---|
1195 | endef
|
---|
1196 |
|
---|
1197 | $(foreach dirfile,$(_DIRFILES),$(eval $(def_createdir)))
|
---|
1198 |
|
---|
1199 |
|
---|
1200 | #
|
---|
1201 | # Include dependency files.
|
---|
1202 | #
|
---|
1203 | $(foreach dep,$(wildcard $(_DEPFILES)),$(eval include $(dep)))
|
---|
1204 |
|
---|
1205 |
|
---|
1206 | #
|
---|
1207 | # PASSES (including directory and makefile walking)
|
---|
1208 | #
|
---|
1209 | # Do all the default passes if it's unspecified.
|
---|
1210 |
|
---|
1211 | #PASSES ?= needed libraries binaries others publish
|
---|
1212 | PASSES ?= libraries binaries others
|
---|
1213 |
|
---|
1214 | ## Proritized list of the default makefile when walking subdirectories.
|
---|
1215 | # The user can overload this list.
|
---|
1216 | DEFAULT_MAKEFILE ?= Makefile.kmk makefile.kmk Makefile makefile
|
---|
1217 |
|
---|
1218 | ## Subdir
|
---|
1219 | # @param $(pass) Lowercase pass name.
|
---|
1220 | # @param $(PASS) Uppercase pass name.
|
---|
1221 | # @param $(subdir) Subdirectory
|
---|
1222 | # @param $(tag) tag to attach to the rule name.
|
---|
1223 | define def_pass_subdir
|
---|
1224 | pass_$(pass)$(tag)::
|
---|
1225 | $(QUIET)$$(MAKE) -C $(subdir) -f $$(notdir $$(firstword $$(wildcard $$(addprefix $(subdir)/,$$(DEFAULT_MAKEFILE))))) pass_$(pass)
|
---|
1226 | endef
|
---|
1227 |
|
---|
1228 | ## Submakefile
|
---|
1229 | # @param $(pass) Lowercase pass name.
|
---|
1230 | # @param $(PASS) Uppercase pass name.
|
---|
1231 | # @param $(makefile) Makefile.
|
---|
1232 | # @param $(tag) tag to attach to the rule name.
|
---|
1233 | define def_pass_makefile
|
---|
1234 | pass_$(pass)$(tag)::
|
---|
1235 | $(QUIET)$$(MAKE) -C $(patsubst %/,%,$(dir $(makefile))) -f $(notdir $(makefile)) pass_$(pass)
|
---|
1236 | endef
|
---|
1237 |
|
---|
1238 |
|
---|
1239 | ## Execute a pass.
|
---|
1240 | # @param $(pass) Lowercase pass name.
|
---|
1241 | # @param $(PASS) Uppercase pass name.
|
---|
1242 | define def_pass
|
---|
1243 | $(eval SUBDIRS_$(PASS) ?= $(SUBDIRS))
|
---|
1244 | $(eval SUBDIRS_AFTER_$(PASS) ?= $(SUBDIRS_AFTER))
|
---|
1245 | $(eval MAKEFILES_BEFORE_$(PASS) ?= $(MAKEFILES_BEFORE))
|
---|
1246 | $(eval MAKEFILES_AFTER_$(PASS) ?= $(MAKEFILES_AFTER))
|
---|
1247 |
|
---|
1248 | $(eval tag:=_before)
|
---|
1249 | $(foreach subdir,$(SUBDIRS_$(PASS)),$(eval $(def_pass_subdir)))
|
---|
1250 | $(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)),$(eval $(def_pass_makefile)))
|
---|
1251 |
|
---|
1252 | $(eval tag:=_after)
|
---|
1253 | $(foreach subdir,$(SUBDIRS_AFTER_$(PASS)),$(eval $(def_pass_subdir)))
|
---|
1254 | $(foreach makefile,$(MAKEFILES_AFTER_$(PASS)),$(eval $(def_pass_makefile)))
|
---|
1255 |
|
---|
1256 | .NOTPARALLEL: pass_$(pass)_before pass_$(pass)_after
|
---|
1257 | .PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_doit pass_$(pass)_after
|
---|
1258 | pass_$(pass): \
|
---|
1259 | pass_$(pass)_before \
|
---|
1260 | pass_$(pass)_doit \
|
---|
1261 | pass_$(pass)_after
|
---|
1262 |
|
---|
1263 | endef
|
---|
1264 |
|
---|
1265 |
|
---|
1266 | ## PASS: needed
|
---|
1267 | # This pass builds targets which are required for building the rest.
|
---|
1268 | pass_needed_doit: $(_NEEDEDS)
|
---|
1269 | pass := needed
|
---|
1270 | PASS := NEEDED
|
---|
1271 | $(eval $(def_pass))
|
---|
1272 |
|
---|
1273 | ## PASS: libraries
|
---|
1274 | # This pass builds library targets.
|
---|
1275 | pass_libraries_doit: $(_LIBS) $(_IMPORT_LIBS) $(_OTHER_LIBRARIES)
|
---|
1276 | pass := libraries
|
---|
1277 | PASS := LIBRARIES
|
---|
1278 | $(eval $(def_pass))
|
---|
1279 |
|
---|
1280 | ## PASS: binaries
|
---|
1281 | # This pass builds binary targets, i.e. programs, dlls, system modules and stuff.
|
---|
1282 | pass_binaries_doit: $(_DLLS) $(_EXES) $(_SYSMODS) $(_OTHER_BINARIES)
|
---|
1283 | pass := binaries
|
---|
1284 | PASS := BINARIES
|
---|
1285 | $(eval $(def_pass))
|
---|
1286 |
|
---|
1287 | ## PASS: others
|
---|
1288 | # This pass builds other targets.
|
---|
1289 | pass_others_doit: $(_OTHERS)
|
---|
1290 | pass := others
|
---|
1291 | PASS := OTHERS
|
---|
1292 | $(eval $(def_pass))
|
---|
1293 |
|
---|
1294 | ## PASS: publish
|
---|
1295 | # This pass installs the built entities to a sandbox area.
|
---|
1296 | pass_publish_doit: publish
|
---|
1297 | publish::
|
---|
1298 | pass := publish
|
---|
1299 | PASS := PUBLISH
|
---|
1300 | # $(sort).. not nice.
|
---|
1301 | SUBDIRS_PUBLISH ?= $(sort $(SUBDIRS) $(SUBDIRS_LIBRARIES) $(SUBDIRS_BINARIES) $(SUBDIRS_OTHERS))
|
---|
1302 | SUBDIRS_AFTER_PUBLISH ?= $(sort $(SUBDIRS_AFTER) $(SUBDIRS_AFTER_LIBRARIES) $(SUBDIRS_AFTER_BINARIES) $(SUBDIRS_AFTER_OTHERS))
|
---|
1303 | MAKEFILES_BEFORE_PUBLISH?= $(sort $(MAKEFILES_BEFORE) $(MAKEFILES_BEFORE_LIBRARIES) $(MAKEFILES_BEFORE_BINARIES) $(MAKEFILES_BEFORE_OTHERS))
|
---|
1304 | MAKEFILES_AFTER_PUBLISH ?= $(sort $(MAKEFILES_AFTER) $(MAKEFILES_AFTER_LIBRARIES) $(MAKEFILES_AFTER_BINARIES) $(MAKEFILES_AFTER_OTHERS))
|
---|
1305 | $(eval $(def_pass))
|
---|
1306 |
|
---|
1307 | ## PASS: packing
|
---|
1308 | # This pass processes custom packing rules.
|
---|
1309 | pass_packing_doit: packing
|
---|
1310 | packing::
|
---|
1311 | pass := packing
|
---|
1312 | PASS := PACKING
|
---|
1313 | $(eval $(def_pass))
|
---|
1314 |
|
---|
1315 | ## PASS: clean
|
---|
1316 | # This pass removes all generated files.
|
---|
1317 | pass_clean_doit:
|
---|
1318 | $(RM) -f $(_OUT_FILES) $(_OBJS) $(_DEPFILES) $(_DIRFILES) $(OTHER_CLEAN)
|
---|
1319 | pass := clean
|
---|
1320 | PASS := CLEAN
|
---|
1321 | $(eval $(def_pass))
|
---|
1322 | clean: pass_clean
|
---|
1323 |
|
---|
1324 | ## PASS: nothing
|
---|
1325 | # This pass just walks the tree.
|
---|
1326 | pass_nothing_doit:
|
---|
1327 | $(call MSG_Ltarget,Did nothing in $(CURDIR))
|
---|
1328 | pass := nothing
|
---|
1329 | PASS := NOTHING
|
---|
1330 | $(eval $(def_pass))
|
---|
1331 | nothing: pass_nothing
|
---|
1332 |
|
---|
1333 |
|
---|
1334 |
|
---|
1335 | #
|
---|
1336 | # THE MAIN RULES
|
---|
1337 | #
|
---|
1338 | all_recursive: $(foreach pass,$(PASSES),pass_$(pass))
|
---|
1339 |
|
---|
1340 | rebuild: clean
|
---|
1341 | $(MAKE) -f $(firstword $(MAKEFILE_LIST)) all_recursive
|
---|
1342 |
|
---|
1343 |
|
---|
1344 | # misc shortcuts.
|
---|
1345 | target: needed libraries binaries others
|
---|
1346 | objects: $(_OBJS)
|
---|
1347 | programs: $(_EXES)
|
---|
1348 | dlls: $(_DLLS)
|
---|
1349 | sysmods: $(_SYSMODS)
|
---|
1350 |
|
---|
1351 |
|
---|
1352 | # end-of-file-content
|
---|
1353 | __footer_kmk__ := target
|
---|
1354 | endif # __footer_kmk__
|
---|