source: trunk/kBuild/footer.kmk@ 90

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

..

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 30.7 KB
Line 
1# $Id: footer.kmk 89 2004-06-04 18:21:46Z bird $
2## @file
3#
4# kBuild - File included at top of makefile.
5#
6# Copyright (c) 2004 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 2 of the License, or
14# (at your option) any later version.
15#
16# kBuild is distributed in the hope that it will be useful,
17# but WITHOUT ANY WARRANTY; without even the implied warranty of
18# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19# GNU General Public License for more details.
20#
21# You should have received a copy of the GNU General Public License
22# along with kBuild; if not, write to the Free Software
23# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24#
25#
26
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 := $(LIBRARIES) $(PROGRAMS) $(DLLS) $(SYSMODS) $(OTHERS)
37
38# dependency files.
39_DEPFILES :=
40
41# All kind of output files except for _OBJS and _DEPFILES.
42# Compiling or linking definition outputting other things that $@ and any
43# required dependency file must add those output files to this variable.
44_OUT_FILES :=
45
46# all of a type
47_OBJS :=
48_LIBS :=
49_DLLS :=
50_EXES :=
51_SYSMODS:=
52_DIRS :=
53
54# all objs of a specific target
55define def_objs_var
56_OBJS_$1 :=
57endef
58$(foreach target, $(ALL_TARGETS), $(eval _OBJS_$(target) := ))
59
60
61#
62# Basic macros
63#
64
65## Figure out the tool for a source
66# @param $1 source file
67# @param $2 normalized main target
68# @param $3 tooltype
69_SOURCE_TOOL = $(strip $(firstword \
70 $($1_$2_$(3)TOOL.$(BUILD_TARGET)) $($1_$2_TOOL.$(BUILD_TARGET)) \
71 $($1_$2_$(3)TOOL) $($1_$2_TOOL) \
72 $($1_$(3)TOOL.$(BUILD_TARGET)) $($1_TOOL.$(BUILD_TARGET)) \
73 $($1_$(3)TOOL) $($1_TOOL) \
74 $($2_$(3)TOOL.$(BUILD_TARGET)) $($2_TOOL.$(BUILD_TARGET)) \
75 $($2_$(3)TOOL) $($2_TOOL) \
76 $($(3)TOOL.$(BUILD_TARGET)) $(TOOL.$(BUILD_TARGET)) \
77 $($(3)TOOL) $(TOOL) ))
78
79## Figure out the tool for a target.
80# @param $1 normalized target.
81# @param $2 tooltype.
82_TARGET_TOOL = $(strip $(firstword \
83 $($(1)_$(2)TOOL.$(BUILD_TARGET)) $($(1)_$(2)TOOL) \
84 $($(1)_TOOL.$(BUILD_TARGET)) $($(1)_TOOL) \
85 $($(2)TOOL) $($(2)TOOL.$(BUILD_TARGET)) \
86 $(TOOL.$(BUILD_TARGET)) $(TOOL) \
87 ))
88
89## Figure out where to put object files.
90# @param $1 source file
91# @param $2 normalized main target
92_OBJECT_BASE = $(PATH_TARGET)/$(2)/$(basename $(1))
93
94## Figure out where to put object files.
95# @param $1 real target name.
96# @param $2 normalized main target
97_TARGET_BASE = $(PATH_TARGET)/$(2)/$(basename $(1))
98
99
100#
101# Include templates
102#
103_TEMPLATES := $(TEMPLATE)
104define def_templates
105ifdef $(target)_TEMPLATE
106_TEMPLATES += $($(target)_TEMPLATE)
107endif
108endef
109$(foreach target, $(ALL_TARGETS), $(eval $(def_templates)))
110_TEMPLATES := $(sort $(_TEMPLATES))
111# $ (warning dbg: _TEMPLATES=$(_TEMPLATES))
112
113define def_templates_include
114ifndef TEMPLATE_$(template)
115include $(firstword $(wildcard $(PATH_KBUILD)/templates/$(template).kmk))
116endif
117endef
118$(foreach template, $(_TEMPLATES), $(eval $(def_templates)))
119
120
121#
122# Common Inheritance
123#
124
125## Inherit defaults property
126# @param $(prop) Property name
127# @param $(target) Target name.
128define def_inherit_defaults_one
129ifndef $(target)_$(prop)
130ifdef $(prop)
131$(target)_$(prop) := $($(prop))
132endif
133endif
134endef
135
136## Inherit default properties for one target.
137# A bit tricky this one, but it depends a bit on whether or not TEMPLATE
138# is inherited from the default properties.
139# @param $(target) Target name
140#
141define def_inherit_defaults
142ifdef $(target)_TEMPLATE
143ifndef TEMPLATE_$($(target)_TEMPLATE)_TOOL
144$(foreach prop,TOOL, $(eval $(def_inherit_defaults_one)))
145endif
146ifndef TEMPLATE_$($(target)_TEMPLATE)_SDKS
147$(foreach prop,SDKS, $(eval $(def_inherit_defaults_one)))
148endif
149else
150$(foreach prop,TEMPLATE TOOL SDKS,$(eval $(def_inherit_defaults_one)))
151endif
152endef
153# Inherit default properties.
154$(foreach target, $(ALL_TARGETS), $(eval $(def_inherit_defaults)))
155
156
157## Inherit one template property in a accumulative manner.
158# @param $(prop) Property name
159# @param $(target) Target name
160# @todo fix the precedence order for some properties.
161define def_inherit_template_one
162ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
163ifndef $(target)_$(prop)
164$(eval $(target)_$(prop) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop)))
165endif
166endif
167ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)
168ifndef $(target)_$(prop).$(BUILD_TARGET)
169$(eval $(target)_$(prop).$(BUILD_TARGET) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)))
170endif
171endif
172endef
173
174## Inherit one template property.
175# @param $(prop) Property name
176# @param $(target) Target name
177define def_inherit_template_one_accumulate
178ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
179$(eval $(target)_$(prop) := $($(target)_$(prop)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop)))
180endif
181ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)
182$(eval $(target)_$(prop).$(BUILD_TARGET) := $($(target)_$(prop).$(BUILD_TARGET)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)))
183endif
184ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_CPU)
185$(eval $(target)_$(prop).$(BUILD_TARGET_CPU) := $($(target)_$(prop).$(BUILD_TARGET)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_CPU)))
186endif
187ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_ARCH)
188$(eval $(target)_$(prop).$(BUILD_TARGET_ARCH) := $($(target)_$(prop).$(BUILD_TARGET)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_ARCH)))
189endif
190endef
191
192## Inherit template properties for on target.
193# @param $(target) Target name.
194define def_inherit_template
195$(foreach prop, TOOL ARTOOL CTOOL CXXTOOL ASTOOL LDTOOL\
196 ,$(eval $(def_inherit_template_one)))
197$(foreach prop,SDKS DEFS INCS COPTS CFLAGS CDEFS CINCS CXXOPTS CXXFLAGS CXXDEFS CXXINCS ASOPTS ASFLAGS ASDEFS ASINCS\
198 ,$(eval $(def_inherit_template_one_accumulate)))
199endef
200# Inherit template properties
201$(foreach target, $(ALL_TARGETS), $(eval $(def_inherit_template)))
202
203
204
205#
206# Include tools
207#
208_TOOLS := $(TOOL)
209define def_tools_target_source
210$(foreach tool,\
211 $($(source)_TOOL.$(BUILD_TARGET)) $($(target)_$(source)_TOOL.$(BUILD_TARGET))\
212 $($(source)_TOOL) $($(target)_$(source)_TOOL)\
213 $($(source)_CTOOL.$(BUILD_TARGET)) $($(target)_$(source)_CTOOL.$(BUILD_TARGET))\
214 $($(source)_CTOOL) $($(target)_$(source)_CTOOL)\
215 $($(source)_CXXTOOL.$(BUILD_TARGET)) $($(target)_$(source)_CXXTOOL.$(BUILD_TARGET))\
216 $($(source)_CXXTOOL) $($(target)_$(source)_CXXTOOL)\
217 $($(source)_ASTOOL.$(BUILD_TARGET)) $($(target)_$(source)_ASTOOL.$(BUILD_TARGET))\
218 $($(source)_ASTOOL) $($(target)_$(source)_ASTOOL)\
219 $($(source)_ARTOOL.$(BUILD_TARGET)) $($(target)_$(source)_ARTOOL.$(BUILD_TARGET))\
220 $($(source)_ARTOOL) $($(target)_$(source)_ARTOOL)\
221 $($(source)_LDTOOL.$(BUILD_TARGET)) $($(target)_$(source)_LDTOOL.$(BUILD_TARGET))\
222 $($(source)_LDTOOL) $($(target)_$(source)_LDTOOL)\
223 ,$(eval _TOOLS += $(tool)))
224endef
225define def_tools_target
226$(foreach tool,\
227 $($(target)_TOOL.$(BUILD_TARGET))\
228 $($(target)_TOOL)\
229 $($(target)_CTOOL.$(BUILD_TARGET))\
230 $($(target)_CTOOL)\
231 $($(target)_CXXTOOL.$(BUILD_TARGET))\
232 $($(target)_CXXTOOL)\
233 $($(target)_ASTOOL.$(BUILD_TARGET))\
234 $($(target)_ASTOOL)\
235 $($(target)_ARTOOL.$(BUILD_TARGET))\
236 $($(target)_ARTOOL)\
237 $($(target)_LDTOOL.$(BUILD_TARGET))\
238 $($(target)_LDTOOL)\
239 ,$(eval _TOOLS += $(tool)))
240$(foreach source, $($(target)_SOURCES), $(eval $(def_tools_target_source)))
241endef
242$(foreach target, $(ALL_TARGETS), $(eval $(def_tools_target)))
243_TOOLS := $(sort $(_TOOLS))
244
245define def_tools_include
246ifndef TOOL_$(tool)
247include $(firstword $(wildcard $(PATH_KBUILD)/tools/$(tool).kmk))
248endif
249endef
250$(foreach tool, $(_TOOLS), $(eval $(def_tools_include)))
251
252
253#
254# Include SDKs
255#
256_SDKS := $(SDKS)
257define def_sdks_target_source
258$(foreach sdk, $($(source)_SDKS) $($(target)_$(source)_SDKS), \
259 $(eval _SDKS += $(sdk)))
260endef
261define def_sdks_target
262$(foreach sdk, $($(target)_SDKS), $(eval _SDKS += $(sdk)))
263$(foreach source, $($(target)_SOURCES), $(eval $(def_sdks_target_source)))
264endef
265$(foreach target, $(ALL_TARGETS), $(eval $(def_sdks_target)))
266_SDKS := $(sort $(_SDKS))
267
268define def_sdks_include
269ifndef SDK_$(sdk)
270include $(firstword $(wildcard $(PATH_KBUILD)/sdks/$(sdk).kmk))
271endif
272endef
273$(foreach sdk, $(_SDKS), $(eval $(def_sdk)))
274
275#
276# Object processing.
277#
278
279## Generic macro for processing C, C++ and Assembly sources.
280# @param $(target) Normalized target name.
281# @param $(source) Source file name.
282# @param $(type) Source type. {C,CXX,AS}
283#
284# @remark I've no clue why I've to $(eval ..) everything in this define. MAKE bug?
285define def_target_source_c_cpp_asm
286#$ (warning dbg: def_target_source_c_cpp_asm: source=$(source) target=$(target) type=$(type))
287
288$(eval tool:=$(call _SOURCE_TOOL,$(source),$(target),$(type)))
289$(eval defs :=\
290 $(TOOL_$(tool)_DEFS)\
291 $(TOOL_$(tool)_DEFS.$(BUILD_TYPE))\
292 $(TOOL_$(tool)_DEFS.$(BUILD_TARGET))\
293 $(TOOL_$(tool)_DEFS.$(BUILD_TARGET_ARCH))\
294 $(TOOL_$(tool)_DEFS.$(BUILD_TARGET_CPU))\
295 $(TOOL_$(tool)_$(type)DEFS)\
296 $(TOOL_$(tool)_$(type)DEFS.$(BUILD_TYPE))\
297 $(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
298 $(SDKS.$(BUILD_TYPE)) \
299 $(SDKS),\
300 $(SDK_$(sdk)_DEFS)\
301 $(SDK_$(sdk)_DEFS.$(BUILD_TYPE))\
302 $(SDK_$(sdk)_DEFS.$(BUILD_TARGET))\
303 $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_ARCH))\
304 $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_CPU))
305 $(SDK_$(sdk)_$(type)DEFS)\
306 $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TYPE))\
307 $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET))\
308 $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
309 $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_CPU)))\
310 $(DEFS)\
311 $(DEFS.$(BUILD_TYPE))\
312 $(DEFS.$(BUILD_TARGET))\
313 $(DEFS.$(BUILD_TARGET_ARCH))\
314 $(DEFS.$(BUILD_TARGET_CPU))\
315 $($(type)DEFS)\
316 $($(type)DEFS.$(BUILD_TYPE))\
317 $($(type)DEFS.$(BUILD_TARGET))\
318 $($(type)DEFS.$(BUILD_TARGET_ARCH))\
319 $($(type)DEFS.$(BUILD_TARGET_CPU))\
320 $(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
321 $($(target)_SDKS.$(BUILD_TYPE)) \
322 $($(target)_SDKS),\
323 $(SDK_$(sdk)_DEFS)\
324 $(SDK_$(sdk)_DEFS.$(BUILD_TYPE))\
325 $(SDK_$(sdk)_DEFS.$(BUILD_TARGET))\
326 $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_ARCH))\
327 $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_CPU))
328 $(SDK_$(sdk)_$(type)DEFS)\
329 $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TYPE))\
330 $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET))\
331 $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
332 $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_CPU)))\
333 $($(target)_DEFS)\
334 $($(target)_DEFS.$(BUILD_TYPE))\
335 $($(target)_DEFS.$(BUILD_TARGET))\
336 $($(target)_DEFS.$(BUILD_TARGET_ARCH))\
337 $($(target)_DEFS.$(BUILD_TARGET_CPU))\
338 $($(target)_$(type)DEFS)\
339 $($(target)_$(type)DEFS.$(BUILD_TYPE))\
340 $($(target)_$(type)DEFS.$(BUILD_TARGET))\
341 $($(target)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
342 $($(target)_$(type)DEFS.$(BUILD_TARGET_CPU))\
343 $(foreach sdk, $($(source)_SDKS.$(BUILD_TARGET)) \
344 $($(source)_SDKS.$(BUILD_TYPE)) \
345 $($(source)_SDKS),\
346 $(SDK_$(sdk)_DEFS)\
347 $(SDK_$(sdk)_DEFS.$(BUILD_TYPE))\
348 $(SDK_$(sdk)_DEFS.$(BUILD_TARGET))\
349 $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_ARCH))\
350 $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_CPU))
351 $(SDK_$(sdk)_$(type)DEFS)\
352 $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TYPE))\
353 $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET))\
354 $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
355 $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_CPU)))\
356 $($(source)_DEFS)\
357 $($(source)_DEFS.$(BUILD_TYPE))\
358 $($(source)_DEFS.$(BUILD_TARGET))\
359 $($(source)_DEFS.$(BUILD_TARGET_ARCH))\
360 $($(source)_DEFS.$(BUILD_TARGET_CPU))\
361 $($(source)_$(type)DEFS)\
362 $($(source)_$(type)DEFS.$(BUILD_TYPE))\
363 $($(source)_$(type)DEFS.$(BUILD_TARGET))\
364 $($(source)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
365 $($(source)_$(type)DEFS.$(BUILD_TARGET_CPU))\
366 $(foreach sdk, $($(target)_$(source)_SDKS.$(BUILD_TARGET)) \
367 $($(target)_$(source)_SDKS.$(BUILD_TYPE)) \
368 $($(target)_$(source)_SDKS),\
369 $(SDK_$(sdk)_DEFS)\
370 $(SDK_$(sdk)_DEFS.$(BUILD_TYPE))\
371 $(SDK_$(sdk)_DEFS.$(BUILD_TARGET))\
372 $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_ARCH))\
373 $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_CPU))
374 $(SDK_$(sdk)_$(type)DEFS)\
375 $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TYPE))\
376 $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET))\
377 $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
378 $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_CPU)))\
379 $($(target)_$(source)_DEFS)\
380 $($(target)_$(source)_DEFS.$(BUILD_TYPE))\
381 $($(target)_$(source)_DEFS.$(BUILD_TARGET))\
382 $($(target)_$(source)_DEFS.$(BUILD_TARGET_ARCH))\
383 $($(target)_$(source)_DEFS.$(BUILD_TARGET_CPU))\
384 $($(target)_$(source)_$(type)DEFS)\
385 $($(target)_$(source)_$(type)DEFS.$(BUILD_TYPE))\
386 $($(target)_$(source)_$(type)DEFS.$(BUILD_TARGET))\
387 $($(target)_$(source)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
388 $($(target)_$(source)_$(type)DEFS.$(BUILD_TARGET_CPU))\
389 )
390$(eval incs :=\
391 $($(target)_$(source)_$(type)INCS.$(BUILD_TARGET_CPU))\
392 $($(target)_$(source)_$(type)INCS.$(BUILD_TARGET_ARCH))\
393 $($(target)_$(source)_$(type)INCS.$(BUILD_TARGET))\
394 $($(target)_$(source)_$(type)INCS.$(BUILD_TYPE))\
395 $($(target)_$(source)_$(type)INCS)\
396 $($(target)_$(source)_INCS.$(BUILD_TARGET_CPU))\
397 $($(target)_$(source)_INCS.$(BUILD_TARGET_ARCH))\
398 $($(target)_$(source)_INCS.$(BUILD_TARGET))\
399 $($(target)_$(source)_INCS.$(BUILD_TYPE))\
400 $($(target)_$(source)_INCS)\
401 $(foreach sdk, $($(target)_$(source)_SDKS.$(BUILD_TARGET)) \
402 $($(target)_$(source)_SDKS.$(BUILD_TYPE)) \
403 $($(target)_$(source)_SDKS),
404 $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_CPU))\
405 $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_ARCH))\
406 $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET))\
407 $(SDK_$(sdk)_$(type)INCS.$(BUILD_TYPE))\
408 $(SDK_$(sdk)_$(type)INCS)\
409 $(SDK_$(sdk)_INCS.$(BUILD_TARGET_CPU))\
410 $(SDK_$(sdk)_INCS.$(BUILD_TARGET_ARCH))\
411 $(SDK_$(sdk)_INCS.$(BUILD_TARGET))\
412 $(SDK_$(sdk)_INCS.$(BUILD_TYPE))\
413 $(SDK_$(sdk)_INCS))\
414 $($(source)_$(type)INCS.$(BUILD_TARGET_CPU))\
415 $($(source)_$(type)INCS.$(BUILD_TARGET_ARCH))\
416 $($(source)_$(type)INCS.$(BUILD_TARGET))\
417 $($(source)_$(type)INCS.$(BUILD_TYPE))\
418 $($(source)_$(type)INCS)\
419 $($(source)_INCS.$(BUILD_TARGET_CPU))\
420 $($(source)_INCS.$(BUILD_TARGET_ARCH))\
421 $($(source)_INCS.$(BUILD_TARGET))\
422 $($(source)_INCS.$(BUILD_TYPE))\
423 $($(source)_INCS)\
424 $(foreach sdk, $($(source)_SDKS.$(BUILD_TARGET)) \
425 $($(source)_SDKS.$(BUILD_TYPE)) \
426 $($(source)_SDKS),\
427 $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_CPU))\
428 $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_ARCH))\
429 $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET))\
430 $(SDK_$(sdk)_$(type)INCS.$(BUILD_TYPE))\
431 $(SDK_$(sdk)_$(type)INCS)\
432 $(SDK_$(sdk)_INCS.$(BUILD_TARGET_CPU))\
433 $(SDK_$(sdk)_INCS.$(BUILD_TARGET_ARCH))\
434 $(SDK_$(sdk)_INCS.$(BUILD_TARGET))\
435 $(SDK_$(sdk)_INCS.$(BUILD_TYPE))\
436 $(SDK_$(sdk)_INCS))\
437 $($(target)_$(type)INCS.$(BUILD_TARGET_CPU))\
438 $($(target)_$(type)INCS.$(BUILD_TARGET_ARCH))\
439 $($(target)_$(type)INCS.$(BUILD_TARGET))\
440 $($(target)_$(type)INCS.$(BUILD_TYPE))\
441 $($(target)_$(type)INCS)\
442 $($(target)_INCS.$(BUILD_TARGET_CPU))\
443 $($(target)_INCS.$(BUILD_TARGET_ARCH))\
444 $($(target)_INCS.$(BUILD_TARGET))\
445 $($(target)_INCS.$(BUILD_TYPE))\
446 $($(target)_INCS)\
447 $(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
448 $($(target)_SDKS.$(BUILD_TYPE)) \
449 $($(target)_SDKS),\
450 $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_CPU))\
451 $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_ARCH))\
452 $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET))\
453 $(SDK_$(sdk)_$(type)INCS.$(BUILD_TYPE))\
454 $(SDK_$(sdk)_$(type)INCS)\
455 $(SDK_$(sdk)_INCS.$(BUILD_TARGET_CPU))\
456 $(SDK_$(sdk)_INCS.$(BUILD_TARGET_ARCH))\
457 $(SDK_$(sdk)_INCS.$(BUILD_TARGET))\
458 $(SDK_$(sdk)_INCS.$(BUILD_TYPE))\
459 $(SDK_$(sdk)_INCS))\
460 $(INCS.$(BUILD_TARGET_CPU))\
461 $(INCS.$(BUILD_TARGET_ARCH))\
462 $(INCS.$(BUILD_TARGET))\
463 $(INCS.$(BUILD_TYPE))\
464 $(INCS)\
465 $(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
466 $(SDKS.$(BUILD_TYPE)) \
467 $(SDKS),\
468 $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_CPU))\
469 $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_ARCH))\
470 $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET))\
471 $(SDK_$(sdk)_$(type)INCS.$(BUILD_TYPE))\
472 $(SDK_$(sdk)_$(type)INCS)\
473 $(SDK_$(sdk)_INCS.$(BUILD_TARGET_CPU))\
474 $(SDK_$(sdk)_INCS.$(BUILD_TARGET_ARCH))\
475 $(SDK_$(sdk)_INCS.$(BUILD_TARGET))\
476 $(SDK_$(sdk)_INCS.$(BUILD_TYPE))\
477 $(SDK_$(sdk)_INCS))\
478 $(TOOL_$(tool)_$(type)INCS.$(BUILD_TARGET_CPU))\
479 $(TOOL_$(tool)_$(type)INCS.$(BUILD_TARGET_ARCH))\
480 $(TOOL_$(tool)_$(type)INCS.$(BUILD_TARGET))\
481 $(TOOL_$(tool)_$(type)INCS.$(BUILD_TYPE))\
482 $(TOOL_$(tool)_$(type)INCS)\
483 )
484$(eval flags :=\
485 $(TOOL_$(tool)_$(type)FLAGS)\
486 $(TOOL_$(tool)_$(type)FLAGS.$(BUILD_TYPE))\
487 $(TOOL_$(tool)_$(type)FLAGS.$(BUILD_TARGET))\
488 $(TOOL_$(tool)_$(type)FLAGS.$(BUILD_TARGET_ARCH))\
489 $(TOOL_$(tool)_$(type)FLAGS.$(BUILD_TARGET_CPU))\
490 $($(type)FLAGS)\
491 $($(type)FLAGS.$(BUILD_TYPE))\
492 $($(type)FLAGS.$(BUILD_TARGET))\
493 $($(type)FLAGS.$(BUILD_TARGET_ARCH))\
494 $($(type)FLAGS.$(BUILD_TARGET_CPU))\
495 $($(target)_$(type)FLAGS)\
496 $($(target)_$(type)FLAGS.$(BUILD_TYPE))\
497 $($(target)_$(type)FLAGS.$(BUILD_TARGET))\
498 $($(target)_$(type)FLAGS.$(BUILD_TARGET_ARCH))\
499 $($(target)_$(type)FLAGS.$(BUILD_TARGET_CPU))\
500 $($(source)_$(type)FLAGS)\
501 $($(source)_$(type)FLAGS.$(BUILD_TYPE))\
502 $($(source)_$(type)FLAGS.$(BUILD_TARGET))\
503 $($(source)_$(type)FLAGS.$(BUILD_TARGET_ARCH))\
504 $($(source)_$(type)FLAGS.$(BUILD_TARGET_CPU))\
505 $($(target)_$(source)_$(type)FLAGS)\
506 $($(target)_$(source)_$(type)FLAGS.$(BUILD_TYPE))\
507 $($(target)_$(source)_$(type)FLAGS.$(BUILD_TARGET))\
508 $($(target)_$(source)_$(type)FLAGS.$(BUILD_TARGET_ARCH))\
509 $($(target)_$(source)_$(type)FLAGS.$(BUILD_TARGET_CPU))\
510 )
511$(eval outbase := $(call _OBJECT_BASE,$(source),$(target)))
512$(eval dirdep := $(dir $(outbase)).dir_created)
513$(eval objsuff := $(firstword \
514 $($(target)_$(source)_OBJSUFF.$(BUILD_TARGET))\
515 $($(target)_$(source)_OBJSUFF)\
516 $($(source)_OBJSUFF.$(BUILD_TARGET))\
517 $($(source)_OBJSUFF)\
518 $($(target)_OBJSUFF.$(BUILD_TARGET))\
519 $($(target)_OBJSUFF)\
520 $(TOOL_$(tool)_$(type)OBJSUFF.$(BUILD_TARGET))\
521 $(TOOL_$(tool)_$(type)OBJSUFF)\
522 $(SUFF_OBJ)\
523 ))
524$(eval obj := $(outbase)$(objsuff))
525$(eval dep := $(outbase)$(SUFF_DEP))
526
527#$ (warning dbg: target=$(target) source=$(source) tool=$(tool) obj=$(obj) dep=$(dep) flags=$(flags) defs=$(defs) incs=$(incs) dirdep=$(dirdep) outbase=$(outbase) objsuff=$(objsuff))
528$(eval $(TOOL_$(tool)_COMPILE_$(type)))
529
530$(eval _OBJS_$(target) += $(obj))
531$(eval _DEPFILES += $(dep))
532
533endef
534
535## Generic macro for processing all target sources.
536# @param $(target) Normalized target name.
537define def_target_sources
538#$ (warning def_target_sources)
539# C sources
540$(foreach type,C,$(foreach source, $(filter %.c, $($(target)_SOURCES))\
541 ,$(eval $(def_target_source_c_cpp_asm)) ))
542
543# C++ sources
544$(foreach type,CXX,$(foreach source, $(filter %.cpp, $($(target)_SOURCES)) $(filter %.cxx, $($(target)_SOURCES)) $(filter %.cc, $($(target)_SOURCES))\
545 ,$(eval $(def_target_source_c_cpp_asm)) ))
546
547# ASM sources
548$(foreach type,AS,$(foreach source, $(filter %.asm, $($(target)_SOURCES)) $(filter %.s, $($(target)_SOURCES)) $(filter %.S, $($(target)_SOURCES))\
549 ,$(eval $(def_target_source_c_cpp_asm)) ))
550endef
551
552
553#
554# LIBRARIES
555#
556
557## Library (one).
558# @param $(target) Normalized library (target) name.
559define def_lib
560# source -> object
561$(eval $(def_target_sources))
562
563# library
564$(eval tool := $(call _TARGET_TOOL,$(target),AR))
565ifeq ($(tool),)
566$$(error kBuild: Library target $(target) doesn't have a tool defined!)
567endif
568$(eval flags :=\
569 $(TOOL_$(tool)_ARFLAGS)\
570 $(TOOL_$(tool)_ARFLAGS.$(BUILD_TYPE))\
571 $(ARFLAGS)\
572 $(ARFLAGS.$(BUILD_TYPE))\
573 $($(target)_ARFLAGS)\
574 $($(target)_ARFLAGS.$(BUILD_TYPE))\
575 )
576$(eval libsuff := $(firstword\
577 $($(target)_LIBSUFF.$(BUILD_TARGET))\
578 $($(target)_LIBSUFF)\
579 $(TOOL_$(tool)_ARLIBSUFF.$(BUILD_TARGET))\
580 $(TOOL_$(tool)_ARLIBSUFF)\
581 $(SUFF_LIB)\
582))
583## @todo prefix
584$(eval outbase := $(call _TARGET_BASE,$(target),$(target)))
585$(eval lib := $(outbase)$(libsuff))
586$(eval objs = $(_OBJS_$(target)))
587$(eval dirdep := $(dir $(lib)).dir_created)
588## @todo fix dependencies on makefiles an such
589$(eval deps := )
590
591$(eval $(TOOL_$(tool)_LINK_LIBRARY))
592
593_OBJS += $(_OBJS_$(target))
594_LIBS += $(lib)
595_OUT_FILES += $(lib)
596endef
597
598# Process libraries
599$(foreach target, $(LIBRARIES), $(eval $(def_lib)))
600
601
602
603#
604# PROGRAMS
605#
606
607## Program (one).
608# @param $(target) Normalized target (program) name.
609define def_program
610# source -> object
611$(eval $(def_target_sources))
612
613# library
614$(eval tool := $(call _TARGET_TOOL,$(target),LD))
615$(eval flags :=\
616 $(TOOL_$(tool)_LDFLAGS)\
617 $(TOOL_$(tool)_LDFLAGS.$(BUILD_TYPE))\
618 $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET))\
619 $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET_ARCH))\
620 $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET_CPU))\
621 $(LDFLAGS)\
622 $(LDFLAGS.$(BUILD_TYPE))\
623 $(LDFLAGS.$(BUILD_TARGET))\
624 $(LDFLAGS.$(BUILD_TARGET_ARCH))\
625 $(LDFLAGS.$(BUILD_TARGET_CPU))\
626 $($(target)_LDFLAGS)\
627 $($(target)_LDFLAGS.$(BUILD_TYPE))\
628 $($(target)_LDFLAGS.$(BUILD_TARGET))\
629 $($(target)_LDFLAGS.$(BUILD_TARGET_ARCH))\
630 $($(target)_LDFLAGS.$(BUILD_TARGET_CPU))\
631)
632$(eval exesuff := $(firstword $($(target)_EXESUFF) $($(target)_EXESUFF) $(TOOL_$(tool)_LDEXESUFF) $(SUFF_EXE)))
633$(eval outbase := $(call _TARGET_BASE,$(target),$(target)))
634$(eval exe := $(outbase)$(exesuff))
635$(eval objs = $(_OBJS_$(target)))
636$(eval libs :=\
637 $($(target)_LIBS.$(BUILD_TARGET_CPU))\
638 $($(target)_LIBS.$(BUILD_TARGET_ARCH))\
639 $($(target)_LIBS.$(BUILD_TARGET))\
640 $($(target)_LIBS.$(BUILD_TYPE))\
641 $($(target)_LIBS)\
642 $(LIBS.$(BUILD_TARGET_CPU))\
643 $(LIBS.$(BUILD_TARGET_ARCH))\
644 $(LIBS.$(BUILD_TARGET))\
645 $(LIBS.$(BUILD_TYPE))\
646 $(LIBS)\
647 $(TOOL_$(tool)_LIBS.$(BUILD_TYPE))\
648 $(TOOL_$(tool)_LIBS)\
649)
650$(eval libpath :=\
651 $($(target)_LIBPATH.$(BUILD_TARGET_CPU))\
652 $($(target)_LIBPATH.$(BUILD_TARGET_ARCH))\
653 $($(target)_LIBPATH.$(BUILD_TARGET))\
654 $($(target)_LIBPATH.$(BUILD_TYPE))\
655 $($(target)_LIBPATH)\
656 $(LIBPATH.$(BUILD_TARGET_CPU))\
657 $(LIBPATH.$(BUILD_TARGET_ARCH))\
658 $(LIBPATH.$(BUILD_TARGET))\
659 $(LIBPATH.$(BUILD_TYPE))\
660 $(LIBPATH)\
661 $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET_CPU))\
662 $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET_ARCH))\
663 $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET))\
664 $(TOOL_$(tool)_LIBPATH.$(BUILD_TYPE))\
665 $(TOOL_$(tool)_LIBPATH)\
666)
667$(eval dirdep := $(dir $(exe)).dir_created)
668## @todo fix dependencies
669$(eval deps := )
670#
671$(eval deffile := $(strip $(firstword
672 $($(target)_DEFFILE.$(BUILD_TARGET).$(BUILD_TYPE))\
673 $($(target)_DEFFILE.$(BUILD_TARGET))\
674 $($(target)_DEFFILE.$(BUILD_TYPE))\
675 $($(target)_DEFFILE)\
676 $(DEFFILE.$(BUILD_TARGET).$(BUILD_TYPE))\
677 $(DEFFILE.$(BUILD_TARGET))\
678 $(DEFFILE.$(BUILD_TYPE))\
679 $(DEFFILE)\
680)))
681$(eval custom_pre := $(strip $(firstword
682 $($(target)_CUSTOM_PRE.$(BUILD_TARGET).$(BUILD_TYPE))\
683 $($(target)_CUSTOM_PRE.$(BUILD_TARGET))\
684 $($(target)_CUSTOM_PRE.$(BUILD_TYPE))\
685 $($(target)_CUSTOM_PRE)\
686 $(CUSTOM_PRE.$(BUILD_TARGET).$(BUILD_TYPE))\
687 $(CUSTOM_PRE.$(BUILD_TARGET))\
688 $(CUSTOM_PRE.$(BUILD_TYPE))\
689 $(CUSTOM_PRE)\
690)))
691$(eval custom_post := $(strip $(firstword
692 $($(target)_CUSTOM_POST.$(BUILD_TARGET).$(BUILD_TYPE))\
693 $($(target)_CUSTOM_POST.$(BUILD_TARGET))\
694 $($(target)_CUSTOM_POST.$(BUILD_TYPE))\
695 $($(target)_CUSTOM_POST)\
696 $(CUSTOM_POST.$(BUILD_TARGET).$(BUILD_TYPE))\
697 $(CUSTOM_POST.$(BUILD_TARGET))\
698 $(CUSTOM_POST.$(BUILD_TYPE))\
699 $(CUSTOM_POST)\
700)))
701
702$(eval $(TOOL_$(tool)_LINK_PROGRAM))
703
704_OBJS += $(_OBJS_$(target))
705_EXES += $(exe)
706_OUT_FILES += $(exe)
707endef
708
709# Process libraries
710$(foreach target, $(PROGRAMS), $(eval $(def_program)))
711
712
713
714#
715# DLLS
716#
717
718
719
720#
721# SYSMODS
722#
723
724## System moduler (one).
725# @param $(target) Normalized target (program) name.
726define def_sysmod
727# source -> object
728$(eval $(def_target_sources))
729
730# library
731$(eval tool := $(call _TARGET_TOOL,$(target),LD))
732$(eval flags :=\
733 $(TOOL_$(tool)_LDFLAGS)\
734 $(TOOL_$(tool)_LDFLAGS.$(BUILD_TYPE))\
735 $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET))\
736 $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET_ARCH))\
737 $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET_CPU))\
738 $(LDFLAGS)\
739 $(LDFLAGS.$(BUILD_TYPE))\
740 $(LDFLAGS.$(BUILD_TARGET))\
741 $(LDFLAGS.$(BUILD_TARGET_ARCH))\
742 $(LDFLAGS.$(BUILD_TARGET_CPU))\
743 $($(target)_LDFLAGS)\
744 $($(target)_LDFLAGS.$(BUILD_TYPE))\
745 $($(target)_LDFLAGS.$(BUILD_TARGET))\
746 $($(target)_LDFLAGS.$(BUILD_TARGET_ARCH))\
747 $($(target)_LDFLAGS.$(BUILD_TARGET_CPU))\
748)
749$(eval syssuff := $(firstword $($(target)_SYSSUFF) $($(target)_SYSSUFF) $(TOOL_$(tool)_LDSYSSUFF) $(SUFF_SYS)))
750$(eval outbase := $(call _TARGET_BASE,$(target),$(target)))
751$(eval sys := $(outbase)$(syssuff))
752$(eval objs = $(_OBJS_$(target)))
753$(eval libs :=\
754 $($(target)_LIBS.$(BUILD_TARGET_CPU))\
755 $($(target)_LIBS.$(BUILD_TARGET_ARCH))\
756 $($(target)_LIBS.$(BUILD_TARGET))\
757 $($(target)_LIBS.$(BUILD_TYPE))\
758 $($(target)_LIBS)\
759 $(LIBS.$(BUILD_TARGET_CPU))\
760 $(LIBS.$(BUILD_TARGET_ARCH))\
761 $(LIBS.$(BUILD_TARGET))\
762 $(LIBS.$(BUILD_TYPE))\
763 $(LIBS)\
764 $(TOOL_$(tool)_LIBS.$(BUILD_TYPE))\
765 $(TOOL_$(tool)_LIBS)\
766)
767$(eval libpath :=\
768 $($(target)_LIBPATH.$(BUILD_TARGET_CPU))\
769 $($(target)_LIBPATH.$(BUILD_TARGET_ARCH))\
770 $($(target)_LIBPATH.$(BUILD_TARGET))\
771 $($(target)_LIBPATH.$(BUILD_TYPE))\
772 $($(target)_LIBPATH)\
773 $(LIBPATH.$(BUILD_TARGET_CPU))\
774 $(LIBPATH.$(BUILD_TARGET_ARCH))\
775 $(LIBPATH.$(BUILD_TARGET))\
776 $(LIBPATH.$(BUILD_TYPE))\
777 $(LIBPATH)\
778 $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET_CPU))\
779 $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET_ARCH))\
780 $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET))\
781 $(TOOL_$(tool)_LIBPATH.$(BUILD_TYPE))\
782 $(TOOL_$(tool)_LIBPATH)\
783)
784$(eval dirdep := $(dir $(sys)).dir_created)
785## @todo fix dependencies
786$(eval deps := )
787#
788$(eval deffile := $(strip $(firstword
789 $($(target)_DEFFILE.$(BUILD_TARGET).$(BUILD_TYPE))\
790 $($(target)_DEFFILE.$(BUILD_TARGET))\
791 $($(target)_DEFFILE.$(BUILD_TYPE))\
792 $($(target)_DEFFILE)\
793 $(DEFFILE.$(BUILD_TARGET).$(BUILD_TYPE))\
794 $(DEFFILE.$(BUILD_TARGET))\
795 $(DEFFILE.$(BUILD_TYPE))\
796 $(DEFFILE)\
797)))
798$(eval custom_pre := $(strip $(firstword
799 $($(target)_CUSTOM_PRE.$(BUILD_TARGET).$(BUILD_TYPE))\
800 $($(target)_CUSTOM_PRE.$(BUILD_TARGET))\
801 $($(target)_CUSTOM_PRE.$(BUILD_TYPE))\
802 $($(target)_CUSTOM_PRE)\
803 $(CUSTOM_PRE.$(BUILD_TARGET).$(BUILD_TYPE))\
804 $(CUSTOM_PRE.$(BUILD_TARGET))\
805 $(CUSTOM_PRE.$(BUILD_TYPE))\
806 $(CUSTOM_PRE)\
807)))
808$(eval custom_post := $(strip $(firstword
809 $($(target)_CUSTOM_POST.$(BUILD_TARGET).$(BUILD_TYPE))\
810 $($(target)_CUSTOM_POST.$(BUILD_TARGET))\
811 $($(target)_CUSTOM_POST.$(BUILD_TYPE))\
812 $($(target)_CUSTOM_POST)\
813 $(CUSTOM_POST.$(BUILD_TARGET).$(BUILD_TYPE))\
814 $(CUSTOM_POST.$(BUILD_TARGET))\
815 $(CUSTOM_POST.$(BUILD_TYPE))\
816 $(CUSTOM_POST)\
817)))
818
819$(eval $(TOOL_$(tool)_LINK_SYSMOD))
820
821_OBJS += $(_OBJS_$(target))
822_SYSMODS += $(sys)
823_OUT_FILES += $(sys)
824endef
825
826# Process libraries
827$(foreach target, $(SYSMODS), $(eval $(def_sysmod)))
828
829
830
831#
832# OTHERS
833#
834
835
836
837#
838# DOCS
839#
840
841
842#
843# Directories.
844#
845_OUTPUT_FILES := $(_OBJS) $(_LIBS) $(_EXES) $(_DLLS) $(_SYSMODS)
846_DIRFILES := $(sort $(addsuffix /.dir_created,$(_DIRS)) $(addsuffix .dir_created,$(dir $(_OUTPUT_FILES))))
847
848define def_createdir
849$(dirfile):
850 $(call MSG_L1,Creating directory $$(@D))
851 $(MKDIR) -p $$(@D)
852 @echo dir_created > $$@
853endef
854
855$(foreach dirfile,$(_DIRFILES),$(eval $(def_createdir)))
856
857
858#
859# Include dependency files.
860#
861$(foreach dep,$(wildcard $(_DEPFILES)),$(eval include $(dep)))
862
863
864#
865# PASSES (including directory and makefile walking)
866#
867# Do all the default passes if it's unspecified.
868PASSES ?= needed libraries binaries others publish
869
870## Proritized list of the default makefile when walking subdirectories.
871# The user can overload this list.
872DEFAULT_MAKEFILE ?= Makefile.kmk makefile.kmk Makefile makefile
873
874## Subdir
875# @param $(pass) Lowercase pass name.
876# @param $(PASS) Uppercase pass name.
877# @param $(subdir) Subdirectory
878# @param $(tag) tag to attach to the rule name.
879define def_pass_subdir
880pass_$(pass)$(tag)::
881 $(QUIET)$$(MAKE) -C $(subdir) -f $$(notdir $$(firstword $$(wildcard $$(addprefix $(subdir)/,$$(DEFAULT_MAKEFILE))))) pass_$(pass)
882endef
883
884## Submakefile
885# @param $(pass) Lowercase pass name.
886# @param $(PASS) Uppercase pass name.
887# @param $(makefile) Makefile.
888# @param $(tag) tag to attach to the rule name.
889define def_pass_makefile
890pass_$(pass)$(tag)::
891 $(QUIET)$$(MAKE) -C $(patsubst %/,%,$(dir $(makefile))) -f $(notdir $(makefile)) pass_$(pass)
892endef
893
894
895## Execute a pass.
896# @param $(pass) Lowercase pass name.
897# @param $(PASS) Uppercase pass name.
898define def_pass
899$(eval SUBDIRS_$(PASS) ?= $(SUBDIRS))
900$(eval SUBDIRS_AFTER_$(PASS) ?= $(SUBDIRS_AFTER))
901$(eval MAKEFILES_BEFORE_$(PASS) ?= $(MAKEFILES_BEFORE))
902$(eval MAKEFILES_AFTER_$(PASS) ?= $(MAKEFILES_AFTER))
903
904$(eval tag:=_before)
905$(foreach subdir,$(SUBDIRS_$(PASS)),$(eval $(def_pass_subdir)))
906$(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)),$(eval $(def_pass_makefile)))
907
908$(eval tag:=_after)
909$(foreach subdir,$(SUBDIRS_AFTER_$(PASS)),$(eval $(def_pass_subdir)))
910$(foreach makefile,$(MAKEFILES_AFTER_$(PASS)),$(eval $(def_pass_makefile)))
911
912.NOTPARALLEL: pass_$(pass)_before pass_$(pass)_after
913.PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_doit pass_$(pass)_after
914pass_$(pass): \
915 pass_$(pass)_before \
916 pass_$(pass)_doit \
917 pass_$(pass)_after
918
919endef
920
921
922## PASS: needed
923# This pass builds targets which are required for building the rest.
924pass_needed_doit: $(_NEEDEDS)
925pass := needed
926PASS := NEEDED
927$(eval $(def_pass))
928
929## PASS: libraries
930# This pass builds library targets.
931pass_libraries_doit: $(_LIBS) $(_IMPORT_LIBS) $(_OTHER_LIBRARIES)
932pass := libraries
933PASS := LIBRARIES
934$(eval $(def_pass))
935
936## PASS: binaries
937# This pass builds binary targets, i.e. programs, dlls, system modules and stuff.
938pass_binaries_doit: $(_DLLS) $(_EXES) $(_SYSMODS) $(_OTHER_BINARIES)
939pass := binaries
940PASS := BINARIES
941$(eval $(def_pass))
942
943## PASS: others
944# This pass builds other targets.
945pass_others_doit: $(_OTHERS)
946pass := others
947PASS := OTHERS
948$(eval $(def_pass))
949
950## PASS: publish
951# This pass installs the built entities to a sandbox area.
952pass_publish_doit: publish
953publish::
954pass := publish
955PASS := PUBLISH
956# $(sort).. not nice.
957SUBDIRS_PUBLISH ?= $(sort $(SUBDIRS) $(SUBDIRS_LIBRARIES) $(SUBDIRS_BINARIES) $(SUBDIRS_OTHERS))
958SUBDIRS_AFTER_PUBLISH ?= $(sort $(SUBDIRS_AFTER) $(SUBDIRS_AFTER_LIBRARIES) $(SUBDIRS_AFTER_BINARIES) $(SUBDIRS_AFTER_OTHERS))
959MAKEFILES_BEFORE_PUBLISH?= $(sort $(MAKEFILES_BEFORE) $(MAKEFILES_BEFORE_LIBRARIES) $(MAKEFILES_BEFORE_BINARIES) $(MAKEFILES_BEFORE_OTHERS))
960MAKEFILES_AFTER_PUBLISH ?= $(sort $(MAKEFILES_AFTER) $(MAKEFILES_AFTER_LIBRARIES) $(MAKEFILES_AFTER_BINARIES) $(MAKEFILES_AFTER_OTHERS))
961$(eval $(def_pass))
962
963## PASS: packing
964# This pass processes custom packing rules.
965pass_packing_doit: packing
966packing::
967pass := packing
968PASS := PACKING
969$(eval $(def_pass))
970
971## PASS: clean
972# This pass removes all generated files.
973pass_clean_doit:
974 $(RM) -f $(_OUT_FILES) $(_OBJS) $(_DEPFILES) $(_DIRFILES)
975pass := clean
976PASS := CLEAN
977$(eval $(def_pass))
978clean: pass_clean
979
980## PASS: nothing
981# This pass just walks the tree.
982pass_nothing_doit:
983 $(call MSG_L1,Did nothing in $(CURDIR))
984pass := nothing
985PASS := NOTHING
986$(eval $(def_pass))
987nothing: pass_nothing
988
989
990
991#
992# THE MAIN RULES
993#
994all_recursive: $(foreach pass,$(PASSES),pass_$(pass))
995
996rebuild: clean all_recursive
997
998
999# misc shortcuts.
1000target: needed libraries binaries others
1001objects: $(_OBJS)
1002programs: $(_EXES)
1003dlls: $(_DLLS)
1004sysmods: $(_SYSMODS)
1005
1006
1007# end-of-file-content
1008__footer_kmk__ := 1
1009endif # __footer_kmk__
Note: See TracBrowser for help on using the repository browser.