source: trunk/kBuild/footer.kmk@ 184

Last change on this file since 184 was 184, checked in by bird, 21 years ago

Dependencies.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 45.4 KB
Line 
1# $Id: footer.kmk 184 2004-12-04 02:26:54Z 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
27ifndef __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.
36ALL_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
60define def_objs_var
61_OBJS_$target :=
62endef
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
117no-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
121no-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)
138define def_templates
139ifdef $(target)_TEMPLATE
140_TEMPLATES += $($(target)_TEMPLATE)
141endif
142endef
143$(foreach target, $(ALL_TARGETS), $(eval $(def_templates)))
144_TEMPLATES := $(sort $(_TEMPLATES))
145# $ (warning dbg: _TEMPLATES=$(_TEMPLATES))
146
147define def_templates_include
148ifndef TEMPLATE_$(template)
149include $(firstword $(wildcard $(PATH_KBUILD)/templates/$(template).kmk))
150endif
151endef
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.
162define def_inherit_defaults_one
163ifndef $(target)_$(prop)
164ifndef $(target)_$(prop).$(BUILD_TARGET)
165ifdef $(prop)
166$$(eval $(target)_$(prop) := $($(prop)))
167endif
168ifdef $(prop).$(BUILD_TARGET)
169$$(eval $(target)_$(prop).$(BUILD_TARGET) := $($(prop).$(BUILD_TARGET)))
170endif
171endif
172endif
173endef
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#
180define def_inherit_defaults
181ifdef $(target)_TEMPLATE
182ifeq ($(strip $(TEMPLATE_$($(target)_TEMPLATE)_TOOL) $(TEMPLATE_$($(target)_TEMPLATE)_TOOL.$(BUILD_TARGET))),)
183$$(foreach prop,TOOL, $$(eval $$(def_inherit_defaults_one)))
184endif
185ifeq ($(strip $(TEMPLATE_$($(target)_TEMPLATE)_SDKS) $(TEMPLATE_$($(target)_TEMPLATE)_SDKS.$(BUILD_TARGET))),)
186$$(foreach prop,SDKS, $$(eval $$(def_inherit_defaults_one)))
187endif
188else
189$$(foreach prop,TEMPLATE TOOL SDKS, $$(eval $$(def_inherit_defaults_one)))
190endif
191endef
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.
201define def_inherit_template_one
202ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
203ifndef $(target)_$(prop)
204#$$ (warning dbgtarget: $(target)_$(prop):='$(TEMPLATE_$($(target)_TEMPLATE)_$(prop))' TEMPLATE_$($(target)_TEMPLATE)_$(prop))
205$$(target)_$$(prop) := $$(TEMPLATE_$$($$(target)_TEMPLATE)_$$(prop))
206endif
207endif
208ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)
209ifndef $(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))
212endif
213endif
214endef
215
216## Inherit one template property.
217# @param $(prop) Property name
218# @param $(target) Target name
219define def_inherit_template_one_accumulate
220ifdef 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)))
224endif
225ifdef 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)))
228endif
229ifdef 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)))
232endif
233ifdef 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)))
236endif
237endef
238
239
240## Inherit template properties for on target.
241# @param $(target) Target name.
242define 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)))
247endef
248# Inherit template properties
249$(foreach target, $(ALL_TARGETS),$(eval $(def_inherit_template)))
250
251
252#
253# Include tools
254#
255_TOOLS := $(TOOL)
256define 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)))
271endef
272define 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)))
289endef
290$(foreach target, $(ALL_TARGETS), $(eval $(def_tools_target)))
291_TOOLS := $(sort $(_TOOLS))
292
293define def_tools_include
294ifndef TOOL_$(tool)
295include $(firstword $(wildcard $(PATH_KBUILD)/tools/$(tool).kmk))
296endif
297endef
298$(foreach tool, $(_TOOLS), $(eval $(def_tools_include)))
299
300
301#
302# Include SDKs
303#
304_SDKS := $(SDKS)
305define 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)))
309endef
310define 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)))
315endef
316$(foreach target, $(ALL_TARGETS), $(eval $(def_sdks_target)))
317_SDKS := $(sort $(_SDKS))
318
319define def_sdks_include_one
320ifndef SDK_$(sdk)
321include $(firstword $(wildcard $(PATH_KBUILD)/sdks/$(sdk).kmk))
322endif
323endef
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.
337define 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$(eval deps := \
580 $($(target)_$(source)_DEPS)\
581 $($(target)_$(source)_DEPS.$(BUILD_TYPE))\
582 $($(target)_$(source)_DEPS.$(BUILD_TARGET))\
583 $($(target)_$(source)_DEPS.$(BUILD_TARGET_ARCH))\
584 $($(target)_$(source)_DEPS.$(BUILD_TARGET_CPU))\
585 $($(source)_DEPS)\
586 $($(source)_DEPS.$(BUILD_TYPE))\
587 $($(source)_DEPS.$(BUILD_TARGET))\
588 $($(target)_DEPS)\
589 $($(target)_DEPS.$(BUILD_TARGET_ARCH))\
590 $($(target)_DEPS.$(BUILD_TARGET_CPU)))
591
592
593#$ (warning dbg: target=$(target) source=$(source) tool=$(tool) obj=$(obj) dep=$(dep) flags=$(flags) defs=$(defs) incs=$(incs) dirdep=$(dirdep) outbase=$(outbase) objsuff=$(objsuff) deps=$(deps))
594ifndef TOOL_$(tool)_COMPILE_$(type)
595$$(warning kBuild: TOOL_$(tool)_COMPILE_$(type) is not defined. source=$(source) target=$(target) )
596$$(warning kBuild: tools: \
597 1 $($(target)_$(source)_$(type)TOOL.$(BUILD_TARGET)) \
598 2 $($(target)_$(source)_$(type)TOOL) \
599 3 $($(target)_$(source)_TOOL.$(BUILD_TARGET)) \
600 4 $($(target)_$(source)_TOOL) \
601 5 $($(target)_$(type)TOOL.$(BUILD_TARGET)) \
602 6 $($(target)_$(type)TOOL) \
603 7 $($(target)_TOOL.$(BUILD_TARGET)) \
604 8 $($(target)_TOOL) \
605 9 $($(source)_$(type)TOOL.$(BUILD_TARGET)) \
606 10 $($(source)_$(type)TOOL) \
607 11 $($(source)_TOOL.$(BUILD_TARGET)) \
608 12 $($(source)_TOOL) \
609 13 $($(type)TOOL.$(BUILD_TARGET)) \
610 14 $($(type)TOOL) \
611 15 $(TOOL.$(BUILD_TARGET)) \
612 16 $(TOOL) )
613endif
614$(eval $(TOOL_$(tool)_COMPILE_$(type)))
615
616$(eval _OBJS_$(target) += $(obj))
617$(eval _DEPFILES += $(dep))
618
619endef
620
621## Generic macro for processing all target sources.
622# @param $(target) Normalized target name.
623define def_target_sources
624#$ (warning def_target_sources)
625# C sources
626$(foreach type,C,$(foreach source, $(filter %.c, $($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_MODE)))\
627 ,$(eval $(def_target_source_c_cpp_asm)) ))
628
629# C++ sources
630$(foreach type,CXX,$(foreach source, $(filter %.cpp %.cxx %.xx, $($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_MODE)))\
631 ,$(eval $(def_target_source_c_cpp_asm)) ))
632
633# ASM sources
634$(foreach type,AS,$(foreach source, $(filter %.asm %.s %.S, $($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_MODE)))\
635 ,$(eval $(def_target_source_c_cpp_asm)) ))
636endef
637
638
639#
640# LIBRARIES
641#
642
643## Library (one).
644# @param $(target) Normalized library (target) name.
645define def_lib
646# library basics
647$(eval tool := $(call _TARGET_TOOL,$(target),AR))
648ifeq ($(tool),)
649$$(error kBuild: Library target $(target) doesn't have a tool defined!)
650endif
651## @todo prefix
652$(eval outbase := $(call _TARGET_BASE,$(target),$(target)))
653$(eval PATH_$(target) := $(patsubst %/,%,$(dir $(outbase))))
654$(eval libsuff := $(firstword\
655 $($(target)_LIBSUFF.$(BUILD_TARGET))\
656 $($(target)_LIBSUFF)\
657 $(TOOL_$(tool)_ARLIBSUFF.$(BUILD_TARGET))\
658 $(TOOL_$(tool)_ARLIBSUFF)\
659 $(SUFF_LIB)\
660))
661$(eval lib := $(outbase)$(libsuff))
662$(eval TARGET_$(target) := $(lib))
663
664# source -> object
665$(eval $(def_target_sources))
666
667# library linking
668$(eval tool := $(call _TARGET_TOOL,$(target),AR))
669$(eval outbase := $(call _TARGET_BASE,$(target),$(target)))
670$(eval flags :=\
671 $(TOOL_$(tool)_ARFLAGS)\
672 $(TOOL_$(tool)_ARFLAGS.$(BUILD_TYPE))\
673 $(ARFLAGS)\
674 $(ARFLAGS.$(BUILD_TYPE))\
675 $($(target)_ARFLAGS)\
676 $($(target)_ARFLAGS.$(BUILD_TYPE))\
677 )
678$(eval objs = $(_OBJS_$(target)))
679$(eval othersrc := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm,$($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_MODE))))
680$(eval dirdep := $(dir $(lib)).dir_created)
681## @todo fix dependencies on makefiles an such
682$(eval deps := $($(target)_DEPS))
683
684$(eval $(TOOL_$(tool)_LINK_LIBRARY))
685
686# publish rule (still need work)
687ifndef $(target)_NOINST
688$(eval publib := $(PATH_LIB)/$(notdir $(lib)))
689$(publib) : $(lib) $(dir $(publib)).dir_created
690 $(CP) $(lib) $(publib)
691
692_LIBS += $(publib)
693_OUT_FILES += $(lib) $(publib)
694else
695_LIBS += $(lib)
696_OUT_FILES += $(lib)
697endif
698_OBJS += $(_OBJS_$(target))
699endef
700
701# Process libraries
702$(foreach target, $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)), $(eval $(def_lib)))
703
704
705
706#
707# PROGRAMS
708#
709
710## Program (one).
711# @param $(target) Normalized target (program) name.
712define def_program
713# basics
714$(eval tool := $(call _TARGET_TOOL,$(target),LD))
715$(eval outbase := $(call _TARGET_BASE,$(target),$(target)))
716$(eval PATH_$(target) := $(patsubst %/,%,$(dir $(outbase))))
717$(eval exesuff := $(firstword $($(target)_EXESUFF) $($(target)_EXESUFF) $(TOOL_$(tool)_LDEXESUFF) $(SUFF_EXE)))
718$(eval exe := $(outbase)$(exesuff))
719$(eval TARGET_$(target) := $(exe))
720
721# source -> object
722$(eval $(def_target_sources))
723
724# more library stuff.
725$(eval tool := $(call _TARGET_TOOL,$(target),LD))
726$(eval outbase := $(call _TARGET_BASE,$(target),$(target)))
727$(eval objs = $(_OBJS_$(target)))
728$(eval flags :=\
729 $(TOOL_$(tool)_LDFLAGS)\
730 $(TOOL_$(tool)_LDFLAGS.$(BUILD_TYPE))\
731 $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET))\
732 $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET_ARCH))\
733 $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET_CPU))\
734 $(LDFLAGS)\
735 $(LDFLAGS.$(BUILD_TYPE))\
736 $(LDFLAGS.$(BUILD_TARGET))\
737 $(LDFLAGS.$(BUILD_TARGET_ARCH))\
738 $(LDFLAGS.$(BUILD_TARGET_CPU))\
739 $($(target)_LDFLAGS)\
740 $($(target)_LDFLAGS.$(BUILD_TYPE))\
741 $($(target)_LDFLAGS.$(BUILD_TARGET))\
742 $($(target)_LDFLAGS.$(BUILD_TARGET_ARCH))\
743 $($(target)_LDFLAGS.$(BUILD_TARGET_CPU))\
744)
745$(eval libs :=\
746 $($(target)_LIBS.$(BUILD_TARGET_CPU))\
747 $($(target)_LIBS.$(BUILD_TARGET_ARCH))\
748 $($(target)_LIBS.$(BUILD_TARGET))\
749 $($(target)_LIBS.$(BUILD_TYPE))\
750 $($(target)_LIBS)\
751 $(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
752 $($(target)_SDKS.$(BUILD_TYPE)) \
753 $($(target)_SDKS),\
754 $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_CPU))\
755 $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_ARCH))\
756 $(SDK_$(sdk)_LIBS.$(BUILD_TARGET))\
757 $(SDK_$(sdk)_LIBS.$(BUILD_TYPE))\
758 $(SDK_$(sdk)_LIBS))\
759 $(LIBS.$(BUILD_TARGET_CPU))\
760 $(LIBS.$(BUILD_TARGET_ARCH))\
761 $(LIBS.$(BUILD_TARGET))\
762 $(LIBS.$(BUILD_TYPE))\
763 $(LIBS)\
764 $(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
765 $(SDKS.$(BUILD_TYPE)) \
766 $(SDKS),\
767 $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_CPU))\
768 $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_ARCH))\
769 $(SDK_$(sdk)_LIBS.$(BUILD_TARGET))\
770 $(SDK_$(sdk)_LIBS.$(BUILD_TYPE))\
771 $(SDK_$(sdk)_LIBS))\
772 $(TOOL_$(tool)_LIBS.$(BUILD_TARGET_CPU))\
773 $(TOOL_$(tool)_LIBS.$(BUILD_TARGET_ARCH))\
774 $(TOOL_$(tool)_LIBS.$(BUILD_TARGET))\
775 $(TOOL_$(tool)_LIBS.$(BUILD_TYPE))\
776 $(TOOL_$(tool)_LIBS)\
777)
778$(eval libpath :=\
779 $($(target)_LIBPATH.$(BUILD_TARGET_CPU))\
780 $($(target)_LIBPATH.$(BUILD_TARGET_ARCH))\
781 $($(target)_LIBPATH.$(BUILD_TARGET))\
782 $($(target)_LIBPATH.$(BUILD_TYPE))\
783 $($(target)_LIBPATH)\
784 $(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
785 $($(target)_SDKS.$(BUILD_TYPE)) \
786 $($(target)_SDKS),\
787 $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_CPU))\
788 $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_ARCH))\
789 $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET))\
790 $(SDK_$(sdk)_LIBPATH.$(BUILD_TYPE))\
791 $(SDK_$(sdk)_LIBPATH))\
792 $(LIBPATH.$(BUILD_TARGET_CPU))\
793 $(LIBPATH.$(BUILD_TARGET_ARCH))\
794 $(LIBPATH.$(BUILD_TARGET))\
795 $(LIBPATH.$(BUILD_TYPE))\
796 $(LIBPATH)\
797 $(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
798 $(SDKS.$(BUILD_TYPE)) \
799 $(SDKS),\
800 $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_CPU))\
801 $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_ARCH))\
802 $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET))\
803 $(SDK_$(sdk)_LIBPATH.$(BUILD_TYPE))\
804 $(SDK_$(sdk)_LIBPATH))\
805 $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET_CPU))\
806 $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET_ARCH))\
807 $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET))\
808 $(TOOL_$(tool)_LIBPATH.$(BUILD_TYPE))\
809 $(TOOL_$(tool)_LIBPATH)\
810)
811$(eval dirdep := $(dir $(exe)).dir_created)
812## @todo fix dependencies
813$(eval deps := $($(target)_DEPS))
814#
815$(eval custom_pre := $(strip $(firstword
816 $($(target)_CUSTOM_PRE.$(BUILD_TARGET).$(BUILD_TYPE))\
817 $($(target)_CUSTOM_PRE.$(BUILD_TARGET))\
818 $($(target)_CUSTOM_PRE.$(BUILD_TYPE))\
819 $($(target)_CUSTOM_PRE)\
820 $(CUSTOM_PRE.$(BUILD_TARGET).$(BUILD_TYPE))\
821 $(CUSTOM_PRE.$(BUILD_TARGET))\
822 $(CUSTOM_PRE.$(BUILD_TYPE))\
823 $(CUSTOM_PRE)\
824)))
825$(eval custom_post := $(strip $(firstword
826 $($(target)_CUSTOM_POST.$(BUILD_TARGET).$(BUILD_TYPE))\
827 $($(target)_CUSTOM_POST.$(BUILD_TARGET))\
828 $($(target)_CUSTOM_POST.$(BUILD_TYPE))\
829 $($(target)_CUSTOM_POST)\
830 $(CUSTOM_POST.$(BUILD_TARGET).$(BUILD_TYPE))\
831 $(CUSTOM_POST.$(BUILD_TARGET))\
832 $(CUSTOM_POST.$(BUILD_TYPE))\
833 $(CUSTOM_POST)\
834)))
835$(eval othersrc := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm,$($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_MODE))))
836
837$(eval $(TOOL_$(tool)_LINK_PROGRAM))
838# publish rule (still need work)
839ifndef $(target)_NOINST
840$(eval pubexe := $(PATH_BIN)/$(notdir $(exe)))
841$(pubexe) : $(exe) $(dir $(pubexe)).dir_created
842 $(CP) $(exe) $(pubexe)
843
844_DLLS += $(pubexe)
845_OUT_FILES += $(exe) $(pubexe)
846else
847_DLLS += $(exe)
848_OUT_FILES += $(exe)
849endif
850_OBJS += $(_OBJS_$(target))
851endef
852
853# Process libraries
854$(foreach target, $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)), $(eval $(def_program)))
855
856
857
858#
859# DLLS
860#
861
862## DLL (one).
863# @param $(target) Normalized target (program) name.
864define def_dll
865# dllmod basics
866$(eval tool := $(call _TARGET_TOOL,$(target),LD))
867$(eval outbase := $(call _TARGET_BASE,$(target),$(target)))
868$(eval PATH_$(target) := $(patsubst %/,%,$(dir $(outbase))))
869$(eval dllsuff := $(firstword $($(target)_DLLSUFF) $($(target)_DLLSUFF) $(TOOL_$(tool)_LDDLLSUFF) $(SUFF_DLL)))
870$(eval dll := $(outbase)$(dllsuff))
871$(eval TARGET_$(target) := $(dll))
872
873# source -> object
874$(eval $(def_target_sources))
875
876# dllmod linking.
877$(eval tool := $(call _TARGET_TOOL,$(target),LD))
878$(eval outbase := $(call _TARGET_BASE,$(target),$(target)))
879$(eval objs = $(_OBJS_$(target)))
880$(eval flags :=\
881 $(TOOL_$(tool)_LDFLAGS)\
882 $(TOOL_$(tool)_LDFLAGS.$(BUILD_TYPE))\
883 $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET))\
884 $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET_ARCH))\
885 $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET_CPU))\
886 $(LDFLAGS)\
887 $(LDFLAGS.$(BUILD_TYPE))\
888 $(LDFLAGS.$(BUILD_TARGET))\
889 $(LDFLAGS.$(BUILD_TARGET_ARCH))\
890 $(LDFLAGS.$(BUILD_TARGET_CPU))\
891 $($(target)_LDFLAGS)\
892 $($(target)_LDFLAGS.$(BUILD_TYPE))\
893 $($(target)_LDFLAGS.$(BUILD_TARGET))\
894 $($(target)_LDFLAGS.$(BUILD_TARGET_ARCH))\
895 $($(target)_LDFLAGS.$(BUILD_TARGET_CPU))\
896)
897$(eval libs :=\
898 $($(target)_LIBS.$(BUILD_TARGET_CPU))\
899 $($(target)_LIBS.$(BUILD_TARGET_ARCH))\
900 $($(target)_LIBS.$(BUILD_TARGET))\
901 $($(target)_LIBS.$(BUILD_TYPE))\
902 $($(target)_LIBS)\
903 $(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
904 $($(target)_SDKS.$(BUILD_TYPE)) \
905 $($(target)_SDKS),\
906 $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_CPU))\
907 $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_ARCH))\
908 $(SDK_$(sdk)_LIBS.$(BUILD_TARGET))\
909 $(SDK_$(sdk)_LIBS.$(BUILD_TYPE))\
910 $(SDK_$(sdk)_LIBS))\
911 $(LIBS.$(BUILD_TARGET_CPU))\
912 $(LIBS.$(BUILD_TARGET_ARCH))\
913 $(LIBS.$(BUILD_TARGET))\
914 $(LIBS.$(BUILD_TYPE))\
915 $(LIBS)\
916 $(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
917 $(SDKS.$(BUILD_TYPE)) \
918 $(SDKS),\
919 $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_CPU))\
920 $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_ARCH))\
921 $(SDK_$(sdk)_LIBS.$(BUILD_TARGET))\
922 $(SDK_$(sdk)_LIBS.$(BUILD_TYPE))\
923 $(SDK_$(sdk)_LIBS))\
924 $(TOOL_$(tool)_LIBS.$(BUILD_TARGET_CPU))\
925 $(TOOL_$(tool)_LIBS.$(BUILD_TARGET_ARCH))\
926 $(TOOL_$(tool)_LIBS.$(BUILD_TARGET))\
927 $(TOOL_$(tool)_LIBS.$(BUILD_TYPE))\
928 $(TOOL_$(tool)_LIBS)\
929)
930$(eval libpath :=\
931 $($(target)_LIBPATH.$(BUILD_TARGET_CPU))\
932 $($(target)_LIBPATH.$(BUILD_TARGET_ARCH))\
933 $($(target)_LIBPATH.$(BUILD_TARGET))\
934 $($(target)_LIBPATH.$(BUILD_TYPE))\
935 $($(target)_LIBPATH)\
936 $(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
937 $($(target)_SDKS.$(BUILD_TYPE)) \
938 $($(target)_SDKS),\
939 $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_CPU))\
940 $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_ARCH))\
941 $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET))\
942 $(SDK_$(sdk)_LIBPATH.$(BUILD_TYPE))\
943 $(SDK_$(sdk)_LIBPATH))\
944 $(LIBPATH.$(BUILD_TARGET_CPU))\
945 $(LIBPATH.$(BUILD_TARGET_ARCH))\
946 $(LIBPATH.$(BUILD_TARGET))\
947 $(LIBPATH.$(BUILD_TYPE))\
948 $(LIBPATH)\
949 $(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
950 $(SDKS.$(BUILD_TYPE)) \
951 $(SDKS),\
952 $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_CPU))\
953 $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_ARCH))\
954 $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET))\
955 $(SDK_$(sdk)_LIBPATH.$(BUILD_TYPE))\
956 $(SDK_$(sdk)_LIBPATH))\
957 $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET_CPU))\
958 $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET_ARCH))\
959 $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET))\
960 $(TOOL_$(tool)_LIBPATH.$(BUILD_TYPE))\
961 $(TOOL_$(tool)_LIBPATH)\
962)
963$(eval dirdep := $(dir $(dll)).dir_created)
964## @todo fix dependencies
965$(eval deps := $($(target)_DEPS))
966#
967$(eval custom_pre := $(strip $(firstword
968 $($(target)_CUSTOM_PRE.$(BUILD_TARGET).$(BUILD_TYPE))\
969 $($(target)_CUSTOM_PRE.$(BUILD_TARGET))\
970 $($(target)_CUSTOM_PRE.$(BUILD_TYPE))\
971 $($(target)_CUSTOM_PRE)\
972 $(CUSTOM_PRE.$(BUILD_TARGET).$(BUILD_TYPE))\
973 $(CUSTOM_PRE.$(BUILD_TARGET))\
974 $(CUSTOM_PRE.$(BUILD_TYPE))\
975 $(CUSTOM_PRE)\
976)))
977$(eval custom_post := $(strip $(firstword
978 $($(target)_CUSTOM_POST.$(BUILD_TARGET).$(BUILD_TYPE))\
979 $($(target)_CUSTOM_POST.$(BUILD_TARGET))\
980 $($(target)_CUSTOM_POST.$(BUILD_TYPE))\
981 $($(target)_CUSTOM_POST)\
982 $(CUSTOM_POST.$(BUILD_TARGET).$(BUILD_TYPE))\
983 $(CUSTOM_POST.$(BUILD_TARGET))\
984 $(CUSTOM_POST.$(BUILD_TYPE))\
985 $(CUSTOM_POST)\
986)))
987$(eval othersrc := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm,$($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_MODE))))
988
989ifndef TOOL_$(tool)_LINK_DLL
990$$(warning kBuild: TOOL_$(tool)_LINK_DLL is not defined. target=$(target) )
991$$(warning kBuild: tools: \
992 1 $($(target)_$(source)TOOL.$(BUILD_TARGET)) \
993 2 $($(target)_$(source)TOOL) \
994 3 $($(target)_TOOL.$(BUILD_TARGET)) \
995 4 $($(target)_TOOL) \
996 5 $($(source)TOOL) \
997 6 $($(source)TOOL.$(BUILD_TARGET)) \
998 7 $(TOOL.$(BUILD_TARGET)) \
999 8 $(TOOL) )
1000endif
1001
1002$(eval $(TOOL_$(tool)_LINK_DLL))
1003
1004
1005# publish rule (still need work)
1006ifndef $(target)_NOINST
1007$(eval pubdll := $(PATH_BIN)/$(notdir $(dll)))
1008$(pubdll) : $(dll) $(dir $(pubdll)).dir_created
1009 $(CP) $(dll) $(pubdll)
1010
1011_DLLS += $(pubdll)
1012_OUT_FILES += $(dll) $(pubdll)
1013else
1014_DLLS += $(dll)
1015_OUT_FILES += $(dll)
1016endif
1017_OBJS += $(_OBJS_$(target))
1018endef
1019
1020# Process dlls
1021$(foreach target, $(DLLS) $(DLLS.$(BUILD_TARGET)), $(eval $(def_dll)))
1022
1023
1024#
1025# SYSMODS
1026#
1027
1028## System module (one).
1029# @param $(target) Normalized target (program) name.
1030define def_sysmod
1031# sysmod basics
1032$(eval tool := $(call _TARGET_TOOL,$(target),LD))
1033$(eval outbase := $(call _TARGET_BASE,$(target),$(target)))
1034$(eval PATH_$(target) := $(patsubst %/,%,$(dir $(outbase))))
1035$(eval syssuff := $(firstword $($(target)_SYSSUFF) $($(target)_SYSSUFF) $(TOOL_$(tool)_LDSYSSUFF) $(SUFF_SYS)))
1036$(eval sys := $(outbase)$(syssuff))
1037$(eval TARGET_$(target) := $(sys))
1038
1039# source -> object
1040$(eval $(def_target_sources))
1041
1042# sysmod linking
1043$(eval tool := $(call _TARGET_TOOL,$(target),LD))
1044$(eval outbase := $(call _TARGET_BASE,$(target),$(target)))
1045$(eval objs = $(_OBJS_$(target)))
1046$(eval flags :=\
1047 $(TOOL_$(tool)_LDFLAGS)\
1048 $(TOOL_$(tool)_LDFLAGS.$(BUILD_TYPE))\
1049 $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET))\
1050 $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET_ARCH))\
1051 $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET_CPU))\
1052 $(LDFLAGS)\
1053 $(LDFLAGS.$(BUILD_TYPE))\
1054 $(LDFLAGS.$(BUILD_TARGET))\
1055 $(LDFLAGS.$(BUILD_TARGET_ARCH))\
1056 $(LDFLAGS.$(BUILD_TARGET_CPU))\
1057 $($(target)_LDFLAGS)\
1058 $($(target)_LDFLAGS.$(BUILD_TYPE))\
1059 $($(target)_LDFLAGS.$(BUILD_TARGET))\
1060 $($(target)_LDFLAGS.$(BUILD_TARGET_ARCH))\
1061 $($(target)_LDFLAGS.$(BUILD_TARGET_CPU))\
1062)
1063$(eval libs :=\
1064 $($(target)_LIBS.$(BUILD_TARGET_CPU))\
1065 $($(target)_LIBS.$(BUILD_TARGET_ARCH))\
1066 $($(target)_LIBS.$(BUILD_TARGET))\
1067 $($(target)_LIBS.$(BUILD_TYPE))\
1068 $($(target)_LIBS)\
1069 $(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
1070 $($(target)_SDKS.$(BUILD_TYPE)) \
1071 $($(target)_SDKS),\
1072 $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_CPU))\
1073 $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_ARCH))\
1074 $(SDK_$(sdk)_LIBS.$(BUILD_TARGET))\
1075 $(SDK_$(sdk)_LIBS.$(BUILD_TYPE))\
1076 $(SDK_$(sdk)_LIBS))\
1077 $(LIBS.$(BUILD_TARGET_CPU))\
1078 $(LIBS.$(BUILD_TARGET_ARCH))\
1079 $(LIBS.$(BUILD_TARGET))\
1080 $(LIBS.$(BUILD_TYPE))\
1081 $(LIBS)\
1082 $(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
1083 $(SDKS.$(BUILD_TYPE)) \
1084 $(SDKS),\
1085 $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_CPU))\
1086 $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_ARCH))\
1087 $(SDK_$(sdk)_LIBS.$(BUILD_TARGET))\
1088 $(SDK_$(sdk)_LIBS.$(BUILD_TYPE))\
1089 $(SDK_$(sdk)_LIBS))\
1090 $(TOOL_$(tool)_LIBS.$(BUILD_TARGET_CPU))\
1091 $(TOOL_$(tool)_LIBS.$(BUILD_TARGET_ARCH))\
1092 $(TOOL_$(tool)_LIBS.$(BUILD_TARGET))\
1093 $(TOOL_$(tool)_LIBS.$(BUILD_TYPE))\
1094 $(TOOL_$(tool)_LIBS)\
1095)
1096$(eval libpath :=\
1097 $($(target)_LIBPATH.$(BUILD_TARGET_CPU))\
1098 $($(target)_LIBPATH.$(BUILD_TARGET_ARCH))\
1099 $($(target)_LIBPATH.$(BUILD_TARGET))\
1100 $($(target)_LIBPATH.$(BUILD_TYPE))\
1101 $($(target)_LIBPATH)\
1102 $(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
1103 $($(target)_SDKS.$(BUILD_TYPE)) \
1104 $($(target)_SDKS),\
1105 $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_CPU))\
1106 $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_ARCH))\
1107 $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET))\
1108 $(SDK_$(sdk)_LIBPATH.$(BUILD_TYPE))\
1109 $(SDK_$(sdk)_LIBPATH))\
1110 $(LIBPATH.$(BUILD_TARGET_CPU))\
1111 $(LIBPATH.$(BUILD_TARGET_ARCH))\
1112 $(LIBPATH.$(BUILD_TARGET))\
1113 $(LIBPATH.$(BUILD_TYPE))\
1114 $(LIBPATH)\
1115 $(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
1116 $(SDKS.$(BUILD_TYPE)) \
1117 $(SDKS),\
1118 $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_CPU))\
1119 $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_ARCH))\
1120 $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET))\
1121 $(SDK_$(sdk)_LIBPATH.$(BUILD_TYPE))\
1122 $(SDK_$(sdk)_LIBPATH))\
1123 $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET_CPU))\
1124 $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET_ARCH))\
1125 $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET))\
1126 $(TOOL_$(tool)_LIBPATH.$(BUILD_TYPE))\
1127 $(TOOL_$(tool)_LIBPATH)\
1128)
1129$(eval dirdep := $(dir $(sys)).dir_created)
1130## @todo fix dependencies
1131$(eval deps := $($(target)_DEPS))
1132#
1133$(eval custom_pre := $(strip $(firstword
1134 $($(target)_CUSTOM_PRE.$(BUILD_TARGET).$(BUILD_TYPE))\
1135 $($(target)_CUSTOM_PRE.$(BUILD_TARGET))\
1136 $($(target)_CUSTOM_PRE.$(BUILD_TYPE))\
1137 $($(target)_CUSTOM_PRE)\
1138 $(CUSTOM_PRE.$(BUILD_TARGET).$(BUILD_TYPE))\
1139 $(CUSTOM_PRE.$(BUILD_TARGET))\
1140 $(CUSTOM_PRE.$(BUILD_TYPE))\
1141 $(CUSTOM_PRE)\
1142)))
1143$(eval custom_post := $(strip $(firstword
1144 $($(target)_CUSTOM_POST.$(BUILD_TARGET).$(BUILD_TYPE))\
1145 $($(target)_CUSTOM_POST.$(BUILD_TARGET))\
1146 $($(target)_CUSTOM_POST.$(BUILD_TYPE))\
1147 $($(target)_CUSTOM_POST)\
1148 $(CUSTOM_POST.$(BUILD_TARGET).$(BUILD_TYPE))\
1149 $(CUSTOM_POST.$(BUILD_TARGET))\
1150 $(CUSTOM_POST.$(BUILD_TYPE))\
1151 $(CUSTOM_POST)\
1152)))
1153$(eval othersrc := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm,$($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_MODE))))
1154
1155ifndef TOOL_$(tool)_LINK_SYSMOD
1156$$(warning kBuild: TOOL_$(tool)_LINK_SYSMOD is not defined. target=$(target) )
1157$$(warning kBuild: tools: \
1158 1 $($(target)_$(source)TOOL.$(BUILD_TARGET)) \
1159 2 $($(target)_$(source)TOOL) \
1160 3 $($(target)_TOOL.$(BUILD_TARGET)) \
1161 4 $($(target)_TOOL) \
1162 5 $($(source)TOOL) \
1163 6 $($(source)TOOL.$(BUILD_TARGET)) \
1164 7 $(TOOL.$(BUILD_TARGET)) \
1165 8 $(TOOL) )
1166endif
1167
1168$(eval $(TOOL_$(tool)_LINK_SYSMOD))
1169
1170# publish rule (still need work)
1171ifndef $(target)_NOINST
1172$(eval pubsys := $(PATH_BIN)/$(notdir $(sys)))
1173$(pubsys): $(sys) $(dir $(pubsys)).dir_created
1174 $(CP) $(sys) $(pubsys)
1175
1176$(eval _SYSMODS += $(pubsys))
1177$(eval _OUT_FILES += $(sys) $(pubsys))
1178else
1179$(eval _SYSMODS += $(sys))
1180$(eval _OUT_FILES += $(sys))
1181endif
1182_OBJS += $(_OBJS_$(target))
1183endef
1184
1185# Process sysmods
1186$(foreach target, $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)), $(eval $(def_sysmod)))
1187
1188
1189
1190#
1191# OTHERS
1192#
1193_OTHERS = $(OTHERS)
1194
1195
1196
1197#
1198# DOCS
1199#
1200
1201
1202#
1203# Directories.
1204#
1205_DIRFILES := $(sort $(addsuffix /.dir_created,$(_DIRS)) $(addsuffix .dir_created,$(sort $(dir $(_OUT_FILES) $(_OBJS)))))
1206
1207define def_createdir
1208$(dirfile):
1209 $(call MSG_Ltarget,Creating directory $$(@D))
1210 $(MKDIR) -p $$(@D)
1211 @echo dir_created > $$@
1212endef
1213
1214$(foreach dirfile,$(_DIRFILES),$(eval $(def_createdir)))
1215
1216
1217#
1218# Include dependency files.
1219#
1220$(foreach dep,$(wildcard $(_DEPFILES)),$(eval include $(dep)))
1221
1222
1223#
1224# PASSES (including directory and makefile walking)
1225#
1226# Do all the default passes if it's unspecified.
1227
1228#PASSES ?= needed libraries binaries others publish
1229PASSES ?= libraries binaries others
1230
1231## Proritized list of the default makefile when walking subdirectories.
1232# The user can overload this list.
1233DEFAULT_MAKEFILE ?= Makefile.kmk makefile.kmk Makefile makefile
1234
1235## Subdir
1236# @param $(pass) Lowercase pass name.
1237# @param $(PASS) Uppercase pass name.
1238# @param $(subdir) Subdirectory
1239# @param $(tag) tag to attach to the rule name.
1240define def_pass_subdir
1241pass_$(pass)$(tag)::
1242 $(QUIET)$$(MAKE) -C $(subdir) -f $$(notdir $$(firstword $$(wildcard $$(addprefix $(subdir)/,$$(DEFAULT_MAKEFILE))))) pass_$(pass)
1243endef
1244
1245## Submakefile
1246# @param $(pass) Lowercase pass name.
1247# @param $(PASS) Uppercase pass name.
1248# @param $(makefile) Makefile.
1249# @param $(tag) tag to attach to the rule name.
1250define def_pass_makefile
1251pass_$(pass)$(tag)::
1252 $(QUIET)$$(MAKE) -C $(patsubst %/,%,$(dir $(makefile))) -f $(notdir $(makefile)) pass_$(pass)
1253endef
1254
1255
1256## Execute a pass.
1257# @param $(pass) Lowercase pass name.
1258# @param $(PASS) Uppercase pass name.
1259define def_pass
1260$(eval SUBDIRS_$(PASS) ?= $(SUBDIRS) $(SUBDIRS.$(BUILD_TARGET)))
1261$(eval SUBDIRS_AFTER_$(PASS) ?= $(SUBDIRS_AFTER) $(SUBDIRS_AFTER.$(BUILD_TARGET)))
1262$(eval MAKEFILES_BEFORE_$(PASS) ?= $(MAKEFILES_BEFORE) $(MAKEFILES_BEFORE.$(BUILD_TARGET)))
1263$(eval MAKEFILES_AFTER_$(PASS) ?= $(MAKEFILES_AFTER) $(MAKEFILES_AFTER.$(BUILD_TARGET)))
1264
1265$(eval tag:=_before)
1266$(foreach subdir,$(SUBDIRS_$(PASS)) $(SUBDIRS_$(PASS).$(BUILD_TARGET)) ,$(eval $(def_pass_subdir)))
1267$(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(BUILD_TARGET)),$(eval $(def_pass_makefile)))
1268
1269$(eval tag:=_after)
1270$(foreach subdir,$(SUBDIRS_AFTER_$(PASS)) $(SUBDIRS_AFTER_$(PASS).$(BUILD_TARGET)) ,$(eval $(def_pass_subdir)))
1271$(foreach makefile,$(MAKEFILES_AFTER_$(PASS)) $(MAKEFILES_AFTER_$(PASS).$(BUILD_TARGET)) ,$(eval $(def_pass_makefile)))
1272
1273.NOTPARALLEL: pass_$(pass)_before pass_$(pass)_after
1274.PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_doit pass_$(pass)_after
1275pass_$(pass): \
1276 pass_$(pass)_before \
1277 pass_$(pass)_doit \
1278 pass_$(pass)_after
1279
1280endef
1281
1282
1283## PASS: needed
1284# This pass builds targets which are required for building the rest.
1285pass_needed_doit: $(_NEEDEDS)
1286pass := needed
1287PASS := NEEDED
1288$(eval $(def_pass))
1289
1290## PASS: libraries
1291# This pass builds library targets.
1292pass_libraries_doit: $(_LIBS) $(_IMPORT_LIBS) $(_OTHER_LIBRARIES)
1293pass := libraries
1294PASS := LIBRARIES
1295$(eval $(def_pass))
1296
1297## PASS: binaries
1298# This pass builds binary targets, i.e. programs, dlls, system modules and stuff.
1299pass_binaries_doit: $(_DLLS) $(_EXES) $(_SYSMODS) $(_OTHER_BINARIES)
1300pass := binaries
1301PASS := BINARIES
1302$(eval $(def_pass))
1303
1304## PASS: others
1305# This pass builds other targets.
1306pass_others_doit: $(_OTHERS)
1307pass := others
1308PASS := OTHERS
1309$(eval $(def_pass))
1310
1311## PASS: publish
1312# This pass installs the built entities to a sandbox area.
1313pass_publish_doit: publish
1314publish::
1315pass := publish
1316PASS := PUBLISH
1317# $(sort).. not nice.
1318SUBDIRS_PUBLISH ?= $(sort $(SUBDIRS) $(SUBDIRS.$(BUILD_TARGET)) $(SUBDIRS_LIBRARIES) $(SUBDIRS_LIBRARIES.$(BUILD_TARGET)) $(SUBDIRS_BINARIES) $(SUBDIRS_BINARIES.$(BUILD_TARGET)) $(SUBDIRS_OTHERS) $(SUBDIRS_OTHERS.$(BUILD_TARGET)))
1319SUBDIRS_AFTER_PUBLISH ?= $(sort $(SUBDIRS_AFTER) $(SUBDIRS_AFTER.$(BUILD_TARGET)) $(SUBDIRS_AFTER_LIBRARIES) $(SUBDIRS_AFTER_LIBRARIES.$(BUILD_TARGET)) $(SUBDIRS_AFTER_BINARIES) $(SUBDIRS_AFTER_BINARIES.$(BUILD_TARGET)) $(SUBDIRS_AFTER_OTHERS) $(SUBDIRS_AFTER_OTHERS.$(BUILD_TARGET)))
1320MAKEFILES_BEFORE_PUBLISH?= $(sort $(MAKEFILES_BEFORE) $(MAKEFILES_BEFORE.$(BUILD_TARGET)) $(MAKEFILES_BEFORE_LIBRARIES) $(MAKEFILES_BEFORE_LIBRARIES.$(BUILD_TARGET)) $(MAKEFILES_BEFORE_BINARIES) $(MAKEFILES_BEFORE_BINARIES.$(BUILD_TARGET)) $(MAKEFILES_BEFORE_OTHERS) $(MAKEFILES_BEFORE_OTHERS.$(BUILD_TARGET)))
1321MAKEFILES_AFTER_PUBLISH ?= $(sort $(MAKEFILES_AFTER) $(MAKEFILES_AFTER.$(BUILD_TARGET)) $(MAKEFILES_AFTER_LIBRARIES) $(MAKEFILES_AFTER_LIBRARIES.$(BUILD_TARGET)) $(MAKEFILES_AFTER_BINARIES) $(MAKEFILES_AFTER_BINARIES.$(BUILD_TARGET)) $(MAKEFILES_AFTER_OTHERS) $(MAKEFILES_AFTER_OTHERS.$(BUILD_TARGET)))
1322$(eval $(def_pass))
1323
1324## PASS: packing
1325# This pass processes custom packing rules.
1326pass_packing_doit: packing
1327packing::
1328pass := packing
1329PASS := PACKING
1330$(eval $(def_pass))
1331
1332## PASS: clean
1333# This pass removes all generated files.
1334pass_clean_doit:
1335 $(RM) -f $(_OUT_FILES) $(_OBJS) $(_DEPFILES) $(_DIRFILES) $(OTHER_CLEAN)
1336pass := clean
1337PASS := CLEAN
1338$(eval $(def_pass))
1339clean: pass_clean
1340
1341## PASS: nothing
1342# This pass just walks the tree.
1343pass_nothing_doit:
1344 $(call MSG_Ltarget,Did nothing in $(CURDIR))
1345pass := nothing
1346PASS := NOTHING
1347$(eval $(def_pass))
1348nothing: pass_nothing
1349
1350
1351
1352#
1353# THE MAIN RULES
1354#
1355all_recursive: $(foreach pass,$(PASSES),pass_$(pass))
1356
1357rebuild: clean
1358 $(MAKE) -f $(firstword $(MAKEFILE_LIST)) all_recursive
1359
1360
1361# misc shortcuts.
1362target: needed libraries binaries others
1363objects: $(_OBJS)
1364programs: $(_EXES)
1365dlls: $(_DLLS)
1366sysmods: $(_SYSMODS)
1367
1368
1369# end-of-file-content
1370__footer_kmk__ := target
1371endif # __footer_kmk__
Note: See TracBrowser for help on using the repository browser.