source: trunk/kBuild/footer.kmk@ 144

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

others.

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