source: trunk/kBuild/footer.kmk@ 72

Last change on this file since 72 was 72, 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: 6.3 KB
Line 
1# $Id: footer.kmk 72 2004-05-30 06:16:41Z 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#
33
34# all targets.
35ALL_TARGETS := $(LIBRARIES) $(PROGRAMS) $(DLLS) $(DRIVERS) $(OTHERS)
36
37# all of a type
38_OBJS :=
39_LIBS :=
40_DLLS :=
41_EXES :=
42_DIRS :=
43
44# all objs of a specific target
45define def_objs_var
46_OBJS_$1 :=
47endef
48$(foreach target, $(ALL_TARGETS), $(eval _OBJS_$(target) := ))
49
50#
51# Include templates
52#
53_TEMPLATES := $(TEMPLATE)
54define def_templates
55ifdef $(target)_TEMPLATE
56_TEMPLATES += $($(target)_TEMPLATE)
57endif
58endef
59$(foreach target, $(ALL_TARGETS), $(eval $(def_templates)))
60_TEMPLATES := $(sort $(_TEMPLATES))
61# $ (warning dbg: _TEMPLATES=$(_TEMPLATES))
62
63define def_templates_include
64ifndef TEMPLATE_$(template)
65include $(firstword $(wildcard $(PATH_KBUILD)/templates/$(template).kmk))
66endif
67endef
68$(foreach template, $(_TEMPLATES), $(eval $(def_templates)))
69
70
71#
72# Common Inheritance
73#
74
75## Inherit defaults property
76# @param $(prop) Property name
77# @param $(target) Target name.
78define def_inherit_defaults_one
79ifndef $1_$(prop)
80ifdef $(prop)
81$1_$(prop) := $($(prop))
82endif
83endif
84endef
85
86## Inherit default properties for one target.
87# A bit tricky this one, but it depends a bit on whether or not TEMPLATE
88# is inherited from the default properties.
89# @param $(target) Target name
90define def_inherit_defaults
91ifdef $(target)_TEMPLATE
92ifndef TEMPLATE_$($(target)_TEMPLATE)_TOOL
93$(foreach prop, TOOL, $(eval $(def_inherit_defaults_one)))
94endif
95ifndef TEMPLATE_$($(target)_TEMPLATE)_SDKS
96$(foreach prop, SDKS, $(eval $(def_inherit_defaults_one)))
97endif
98else
99$(foreach prop, TEMPLATE TOOL SDKS, $(eval $(def_inherit_defaults_one)))
100endif
101endef
102# Inherit default properties.
103$(foreach target, $(ALL_TARGETS), $(eval $(def_inherit_defaults)))
104
105
106## Inherit one template property.
107# @param $(prop) Property name
108# @param $(target) Target name
109define def_inherit_template_one
110ifndef $(target)_$(prop)
111ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
112$(target)_$(prop) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop))
113endif
114endif
115endef
116
117## Inherit template properties for on target.
118# @param $(target) Target name.
119define def_inherit_template
120$(foreach prop,TOOL SDKS DEFS INCS COPTS CFLAGS CDEFS CINCS CXXOPTS CXXFLAGS CXXDEFS CXXINCS ASOPTS ASFLAGS ASDEFS ASINCS, \
121 $(eval $(def_inherit_template_one)))
122endef
123# Inherit template properties
124$(foreach target, $(ALL_TARGETS), $(eval $(def_inherit_template)))
125
126
127
128#
129# Include tools
130#
131_TOOLS := $(TOOL)
132define def_tools_target_source
133#$ (warning dbg: src=$(source))
134$(foreach tool,$($(source)_TOOL) $($(target)_$(source)_TOOL),\
135 $(eval _TOOLS += $(tool)))
136endef
137define def_tools_target
138#$ (warning dbg: trg=$(target))
139$(foreach tool, $($(target)_TOOL), $(eval _TOOLS += $(tool)))
140$(foreach source, $($(target)_SOURCES), $(eval $(def_tools_target_source)))
141endef
142$(foreach target, $(ALL_TARGETS), $(eval $(def_tools_target)))
143_TOOLS := $(sort $(_TOOLS))
144#$ (warning dbg: _TOOLS=$(_TOOLS))
145
146define def_tools_include
147ifndef TOOL_$(tool)
148include $(firstword $(wildcard $(PATH_KBUILD)/tools/$(tool).kmk))
149endif
150endef
151$(foreach tool, $(_TOOLS), $(eval $(def_tools_include)))
152
153
154#
155# Include SDKs
156#
157_SDKS := $(SDKS)
158define def_sdks_target_source
159$(foreach sdk, $($(source)_SDKS) $($(target)_$(source)_SDKS), \
160 $(eval _SDKS += $(sdk)))
161endef
162define def_sdks_target
163$(foreach sdk, $($(target)_SDKS), $(eval _SDKS += $(sdk)))
164$(foreach source, $($(target)_SOURCES), $(eval $(def_sdks_target_source)))
165endef
166$(foreach target, $(ALL_TARGETS), $(eval $(def_sdks_target)))
167_SDKS := $(sort $(_SDKS))
168#$ (warning dbg: _SDKS=$(_SDKS))
169
170define def_sdks_include
171ifndef SDK_$(sdk)
172include $(firstword $(wildcard $(PATH_KBUILD)/sdks/$(sdk).kmk))
173endif
174endef
175$(foreach sdk, $(_SDKS), $(eval $(def_sdk)))
176
177
178#
179# LIBRARIES
180#
181
182## Figure out the tool for a source
183# @param $1 source file
184# @param $2 normalized main target
185_SOURCE_TOOL = $(firstword $($1_$2_TOOL) $($1_TOOL) $($2_TOOL))
186## Figure out where to put object files.
187# @param $1 source file
188# @param $2 normalized main target
189_OBJECT_BASE = $(PATH_TARGET)/$(2)/$(basename $1)
190
191## Library (one).
192# @param $(lib) Library name
193define def_lib
194#$ (warning dbg: Processing library $(target))
195
196# C++ sources
197#$(foreach o, $(filter %.cpp,$($1_SOURCES)), $(eval $(call def_lib_cxx,$1,$o)))
198#$(foreach o, $(filter %.cxx,$($1_SOURCES)), $(eval $(call def_lib_cxx,$1,$o)))
199#$(foreach o, $(filter %.cc, $($1_SOURCES)), $(eval $(call def_lib_cxx,$1,$o)))
200
201# C sources
202$(foreach source, $(filter %.c, $($(target)_SOURCES)), \
203 $(eval $(call TOOL_$(call _SOURCE_TOOL,$(source),$(target))_COMPILE_C,$(call _OBJECT_BASE,$(source),$(target)),$(source),$(target)) ) )
204
205## ASM sources
206#$(foreach o, $(filter %.asm,$($1_SOURCES)), $(eval $(call def_lib_asm,$1,$o)))
207
208# library
209#$$(PATH_TARGET)/$1$(SUFF_LIB): \
210# $$(PATH_TARGET) \
211# $$(_OBJS_$1)
212# $$(AR) $($1_ARFLAGS) $(ARFLAGS) $(AROUT)$$(@:/=\) $$(_OBJS_$1)
213#
214_OBJS += $(_OBJS_$(target))
215_LIBS += $(PATH_TARGET)/$1$(SUFF_LIB)
216endef
217
218# Process libraries
219$(foreach target, $(LIBRARIES), $(eval $(def_lib)))
220
221
222
223#
224# PROGRAMS
225#
226
227
228
229#
230# DLLS
231#
232
233
234
235#
236# DRIVERS
237#
238
239
240
241#
242# OTHERS
243#
244
245
246
247#
248# DOCS
249#
250
251
252#
253# Directories.
254#
255_DIRFILES := $(sort $(addsuffix /.dir_created,$(_DIRS)) $(addsuffix .dir_created,$(dir $(_OBJS) $(_LIBS) $(_EXES) $(_DLLS))))
256
257define def_createdir
258$(dirfile):
259 $(MKDIR) -p $$(@D)
260 echo dir_created > $$@
261endef
262
263$(foreach dirfile,$(_DIRFILES),$(eval $(def_createdir)))
264
265#
266# THE MAIN RULES
267#
268all_recursive:
269
270
271objs: $(_OBJS)
272
273
274# end-of-file-content
275__footer_kmk__ := 1
276endif # __footer_kmk__
Note: See TracBrowser for help on using the repository browser.