1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
|
# $Id: footer.kmk 2537 2011-08-02 19:44:43Z bird $
## @file
# kBuild - File included at bottom of a makefile.
#
#
# Copyright (c) 2004-2011 knut st. osmundsen <bird-kBuild-spamx@anduin.net>
#
# This file is part of kBuild.
#
# kBuild is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version source of the License, or
# (at your option) any later version.
#
# kBuild is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with kBuild; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#
# As a special exception you are granted permission to include this file, via
# the kmk include directive, as you wish without this in itself causing the
# resulting makefile, program or whatever to be covered by the GPL license.
# This exception does not however invalidate any other reasons why the makefile,
# program, whatever should not be covered the GPL.
#
#
ifndef __footer_kmk__
# start-of-file-content
ifdef KBUILD_PROFILE_SELF
$(evalcall def_profile_self, start of footer.kmk)
_KBUILD_TS_FOOTER_START := $(_KBUILD_TS_PREV)
endif
#
# Variables.
# (Some of these need initialization before including definitions using them.)
#
# All targets of each types.
_ALL_BLDPROGS := $(BLDPROGS) $(BLDPROGS.$(KBUILD_HOST)) $(BLDPROGS.$(KBUILD_HOST).$(KBUILD_HOST_ARCH)) $(BLDPROGS.$(KBUILD_HOST_ARCH)) $(BLDPROGS.$(KBUILD_HOST_CPU)) $(BLDPROGS.$(KBUILD_TYPE))
_ALL_LIBRARIES := $(LIBRARIES) $(LIBRARIES.$(KBUILD_TARGET)) $(LIBRARIES.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) $(LIBRARIES.$(KBUILD_TARGET_ARCH)) $(LIBRARIES.$(KBUILD_TARGET_CPU)) $(LIBRARIES.$(KBUILD_TYPE))
_ALL_IMPORT_LIBS := $(IMPORT_LIBS) $(IMPORT_LIBS.$(KBUILD_TARGET)) $(IMPORT_LIBS.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) $(IMPORT_LIBS.$(KBUILD_TARGET_ARCH)) $(IMPORT_LIBS.$(KBUILD_TARGET_CPU)) $(IMPORT_LIBS.$(KBUILD_TYPE))
_ALL_DLLS := $(DLLS) $(DLLS.$(KBUILD_TARGET)) $(DLLS.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) $(DLLS.$(KBUILD_TARGET_ARCH)) $(DLLS.$(KBUILD_TARGET_CPU)) $(DLLS.$(KBUILD_TYPE))
_ALL_PROGRAMS := $(PROGRAMS) $(PROGRAMS.$(KBUILD_TARGET)) $(PROGRAMS.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) $(PROGRAMS.$(KBUILD_TARGET_ARCH)) $(PROGRAMS.$(KBUILD_TARGET_CPU)) $(PROGRAMS.$(KBUILD_TYPE))
_ALL_SYSMODS := $(SYSMODS) $(SYSMODS.$(KBUILD_TARGET)) $(SYSMODS.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) $(SYSMODS.$(KBUILD_TARGET_ARCH)) $(SYSMODS.$(KBUILD_TARGET_CPU)) $(SYSMODS.$(KBUILD_TYPE))
_ALL_MISCBINS := $(MISCBINS) $(MISCBINS.$(KBUILD_TARGET)) $(MISCBINS.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) $(MISCBINS.$(KBUILD_TARGET_ARCH)) $(MISCBINS.$(KBUILD_TARGET_CPU)) $(MISCBINS.$(KBUILD_TYPE))
_ALL_OTHERS := $(OTHERS) $(OTHERS.$(KBUILD_TARGET)) $(OTHERS.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) $(OTHERS.$(KBUILD_TARGET_ARCH)) $(OTHERS.$(KBUILD_TARGET_CPU)) $(OTHERS.$(KBUILD_TYPE))
_ALL_INSTALLS := $(INSTALLS) $(INSTALLS.$(KBUILD_TARGET)) $(INSTALLS.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) $(INSTALLS.$(KBUILD_TARGET_ARCH)) $(INSTALLS.$(KBUILD_TARGET_CPU)) $(INSTALLS.$(KBUILD_TYPE))
_ALL_FETCHES := $(FETCHES) $(FETCHES.$(KBUILD_TARGET)) $(FETCHES.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) $(FETCHES.$(KBUILD_TARGET_ARCH)) $(FETCHES.$(KBUILD_TARGET_CPU)) $(FETCHES.$(KBUILD_TYPE))
_ALL_PATCHES := $(PATCHES) $(PATCHES.$(KBUILD_TARGET)) $(PATCHES.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) $(PATCHES.$(KBUILD_TARGET_ARCH)) $(PATCHES.$(KBUILD_TARGET_CPU)) $(PATCHES.$(KBUILD_TYPE))
# all targets.
_ALL_TARGETS = \
$(_ALL_FETCHES) \
$(_ALL_PATCHES) \
$(_ALL_BLDPROGS) \
$(_ALL_LIBRARIES) \
$(_ALL_IMPORT_LIBS) \
$(_ALL_DLLS) \
$(_ALL_PROGRAMS) \
$(_ALL_SYSMODS) \
$(_ALL_MISCBINS) \
$(_ALL_INSTALLS) \
$(_ALL_OTHERS)
# all $(KBUILD_TARGET) targets.
_ALL_TARGET_TARGETS = \
$(_ALL_FETCHES) \
$(_ALL_PATCHES) \
$(_ALL_LIBRARIES) \
$(_ALL_IMPORT_LIBS) \
$(_ALL_DLLS) \
$(_ALL_PROGRAMS) \
$(_ALL_SYSMODS) \
$(_ALL_MISCBINS) \
$(_ALL_INSTALLS) \
$(_ALL_OTHERS)
# all $(KBUILD_HOST) targets.
_ALL_HOST_TARGETS = \
$(_ALL_BLDPROGS)
# all targets making use of srcname.
_ALL_SRCNAME_TARGETS = \
$(_ALL_FETCHES) \
$(_ALL_PATCHES)
# Dependency files. (currently not on target level, only this global stuff)
_DEPFILES := $(DEPFILES) $(DEPFILES.$(KBUILD_TARGET)) $(DEPFILES.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) $(DEPFILES.$(KBUILD_TARGET_ARCH)) $(DEPFILES.$(KBUILD_TARGET_CPU)) $(DEPFILES.$(KBUILD_TYPE))
# included dependency files.
_DEPFILES_INCLUDED :=
# All kind of output files except for _OBJS and _DEPFILES.
# Compiling or linking definition outputting other things that $@ and any
# required dependency file must add those output files to this variable.
_OUT_FILES :=
# Files which only requires cleaning up.
_CLEAN_FILES :=
# all of a type
_OBJS :=
_FETCHES :=
_DOWNLOADS:=
_UNPACKS :=
_PATCHES :=
_UNFETCHES:=
_BLDPROGS :=
_LIBS :=
_DLLS :=
_PROGRAMS :=
_SYSMODS :=
_MISCBINS :=
_STAGE_FILES :=
_STAGE_DIRS :=
_INSTALLS :=
_INSTALLS_FILES :=
_INSTALLS_DIRS :=
_DEBUG_STAGE_FILES :=
_DEBUG_STAGE_DIRS :=
_DEBUG_INSTALL_FILES :=
_DEBUG_INSTALL_DIRS :=
_OTHERS :=
_PACKING :=
_DIRS := $(PATH_TARGET)/ $(PATH_TARGET) $(BLDDIRS)
_IMPORT_LIBS :=
# Implicit targets added while processing other targets (usually by units).
_ALL_INSTALLS_IMPLICIT :=
# misc
pass_prev :=
#
# Footer macros
#
## Figure out the tool for a target.
# @param $1 normalized target.
# @param $2 tooltype.
# @param bld_trg build target.
# @param bld_trg_arch build target architecture.
# @param bld_type build target type.
if 0
_TARGET_TOOL = $(strip $(firstword \
$($(1)_$(2)TOOL.$(bld_trg).$(bld_trg_arch)) \
$($(1)_$(2)TOOL.$(bld_trg)) \
$($(1)_$(2)TOOL) \
$($(1)_TOOL.$(bld_trg).$(bld_trg_arch)) \
$($(1)_TOOL.$(bld_trg)) \
$($(1)_TOOL) \
$($(2)TOOL.$(bld_trg).$(bld_trg_arch)) \
$($(2)TOOL.$(bld_trg)) \
$($(2)TOOL) \
$(TOOL.$(bld_trg).$(bld_trg_arch)) \
$(TOOL.$(bld_trg)) \
$(TOOL) \
))
else
_TARGET_TOOL = $(strip $(firstword \
$($(1)_$(2)TOOL.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
$($(1)_$(2)TOOL.$(bld_trg).$(bld_trg_arch)) \
$($(1)_$(2)TOOL.$(bld_trg).$(bld_type)) \
$($(1)_$(2)TOOL.$(bld_trg_arch)) \
$($(1)_$(2)TOOL.$(bld_trg)) \
$($(1)_$(2)TOOL.$(bld_type)) \
$($(1)_$(2)TOOL) \
$($(1)_TOOL.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
$($(1)_TOOL.$(bld_trg).$(bld_trg_arch)) \
$($(1)_TOOL.$(bld_trg).$(bld_type)) \
$($(1)_TOOL.$(bld_trg_arch)) \
$($(1)_TOOL.$(bld_trg)) \
$($(1)_TOOL.$(bld_type)) \
$($(1)_TOOL) \
$($(2)TOOL.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
$($(2)TOOL.$(bld_trg).$(bld_trg_arch)) \
$($(2)TOOL.$(bld_trg).$(bld_type)) \
$($(2)TOOL.$(bld_trg_arch)) \
$($(2)TOOL.$(bld_trg)) \
$($(2)TOOL.$(bld_type)) \
$($(2)TOOL) \
$(TOOL.$(bld_trg).$(bld_trg_arch).$(bld_type)) \
$(TOOL.$(bld_trg).$(bld_trg_arch)) \
$(TOOL.$(bld_trg).$(bld_type)) \
$(TOOL.$(bld_trg_arch)) \
$(TOOL.$(bld_trg)) \
$(TOOL.$(bld_type)) \
$(TOOL) \
))
endif
## Figure out the actual name of an installed file.
# @param $1 The file to install.
# @param $2 The target name.
# @param $3 The _INST value (can be empty).
# @param $4 The installation root directory.
_INSTALL_FILE = $(patsubst %/,%/$(notdir $(1)),$(if $(3),$(4)/$(3),$(4)/))
##
# Function for getting the first defined propert value.
#
# @param 1 The property name.
# @param 2 The default property name, empty if none.
# @param 3 What to return if all variables are empty. (optional)
# @note Implicit parameters: target, bld_trg, bld_trg_arch, bld_trg_cpu, bld_type.
# @returns Expanded property value.
#
define def_fn_prop_get_first_defined
local .RETURN := $(firstdefined \
$(target)_$(1).$(bld_trg).$(bld_trg_arch).$(bld_type) \
$(target)_$(1).$(bld_trg).$(bld_trg_arch) \
$(target)_$(1).$(bld_trg).$(bld_type) \
$(target)_$(1).$(bld_trg_cpu) \
$(target)_$(1).$(bld_trg_arch) \
$(target)_$(1).$(bld_trg) \
$(target)_$(1).$(bld_type) \
$(target)_$(1) \
)
ifeq ($(.RETURN),)
ifneq ($(2),)
local .RETURN := $(firstdefined \
$(2).$(bld_trg).$(bld_trg_arch).$(bld_type) \
$(2).$(bld_trg).$(bld_trg_arch) \
$(2).$(bld_trg).$(bld_type) \
$(2).$(bld_trg_cpu) \
$(2).$(bld_trg_arch) \
$(2).$(bld_trg) \
$(2).$(bld_type) \
$(2) \
3 \
)
else
local .RETURN := $(firstdefined \
kBuildGlobalDefaults_$(1).$(bld_trg).$(bld_trg_arch).$(bld_type) \
kBuildGlobalDefaults_$(1).$(bld_trg).$(bld_trg_arch) \
kBuildGlobalDefaults_$(1).$(bld_trg).$(bld_type) \
kBuildGlobalDefaults_$(1).$(bld_trg_cpu) \
kBuildGlobalDefaults_$(1).$(bld_trg_arch) \
kBuildGlobalDefaults_$(1).$(bld_trg) \
kBuildGlobalDefaults_$(1).$(bld_type) \
kBuildGlobalDefaults_$(1) \
3 \
)
endif
endif
local .RETURN := $(strip $($(.RETURN)))
endef # def_fn_prop_get_first_defined
##
# Function for getting the first property value (ignoring empty defines).
#
# @param 1 The property name.
# @param 2 The default property name, empty if none.
# @param 3 What to return if all variables are empty. (optional)
# @note Implicit parameters: target, bld_trg, bld_trg_arch, bld_trg_cpu, bld_type.
# @returns First word.
#
define def_fn_prop_get_first_word
local .RETURN := $(firstword \
$($(target)_$(1).$(bld_trg).$(bld_trg_arch).$(bld_type)) \
$($(target)_$(1).$(bld_trg).$(bld_trg_arch)) \
$($(target)_$(1).$(bld_trg).$(bld_type)) \
$($(target)_$(1).$(bld_trg_cpu)) \
$($(target)_$(1).$(bld_trg_arch)) \
$($(target)_$(1).$(bld_trg)) \
$($(target)_$(1).$(bld_type)) \
$($(target)_$(1)) \
)
ifeq ($(.RETURN),)
ifneq ($(2),)
local .RETURN := $(firstword \
$($(2).$(bld_trg).$(bld_trg_arch).$(bld_type)) \
$($(2).$(bld_trg).$(bld_trg_arch)) \
$($(2).$(bld_trg).$(bld_type)) \
$($(2).$(bld_trg_cpu)) \
$($(2).$(bld_trg_arch)) \
$($(2).$(bld_trg)) \
$($(2).$(bld_type)) \
$($(2)) \
$(3) \
)
else
local .RETURN := $(firstword \
$(kBuildGlobalDefaults_$(1).$(bld_trg).$(bld_trg_arch).$(bld_type)) \
$(kBuildGlobalDefaults_$(1).$(bld_trg).$(bld_trg_arch)) \
$(kBuildGlobalDefaults_$(1).$(bld_trg).$(bld_type)) \
$(kBuildGlobalDefaults_$(1).$(bld_trg_cpu)) \
$(kBuildGlobalDefaults_$(1).$(bld_trg_arch)) \
$(kBuildGlobalDefaults_$(1).$(bld_trg)) \
$(kBuildGlobalDefaults_$(1).$(bld_type)) \
$(kBuildGlobalDefaults_$(1)) \
$(3) \
)
endif
endif
endef # def_fn_prop_get_first_word
#
# The main body.
#
include $(KBUILD_PATH)/footer-inherit-uses-tools.kmk
include $(KBUILD_PATH)/footer-pass1.kmk
include $(KBUILD_PATH)/footer-pass2-fetches.kmk
include $(KBUILD_PATH)/footer-pass2-patches.kmk
include $(KBUILD_PATH)/footer-pass2-compiling-targets.kmk
include $(KBUILD_PATH)/footer-pass2-installs.kmk
include $(KBUILD_PATH)/footer-misc.kmk
include $(KBUILD_PATH)/footer-passes.kmk
#
# THE MAIN RULES
#
all_recursive: $(pass_prev)
rebuild: clean
+ $(MAKE) -f $(firstword $(MAKEFILE_LIST)) all_recursive
# @todo make this a non-default pass!
uninstall::
$(RM) -f -- $(_INSTALLS_FILES)
install:: pass_installs
# misc shortcuts (use secondary expansion here to save strcache[file] space).
targets: bldprogs libraries dlls programs sysmods miscbins others installs
objects: $$(_OBJS)
bldprogs: $$(_BLDPROGS)
libraries: $$(_LIBS) $$(_IMPORT_LIBS) $$(_OTHER_LIBRARIES)
dlls: $$(_DLLS)
programs: $$(_PROGRAMS)
sysmods: $$(_SYSMODS)
miscbins: $$(_MISCBINS)
others: $$(_OTHERS)
stagings: $$(_INSTALLS) $$(_STAGE_DIRS) $$(_STAGE_FILES)
installs: $$(_INSTALLS_DIRS) $$(_INSTALLS_FILES)
install-debug: $$(_DEBUG_INSTALL_DIRS) $$(_DEBUG_INSTALL_FILES)
#
# kBuild debugging stuff.
#
## @todo this doesn't work. Move to a debug unit and expand it.
show_targets:
@$(foreach target, $(_ALL_TARGETS),\
@$(ECHO) "target: $(target)" $(NLTAB)\
@$(ECHO) " $(target)_0_OUTDIR=$($(target)_0_OUTDIR)" $(NLTAB)\
@$(ECHO) " $(target)_1_TARGET=$($(target)_1_TARGET)" $(NLTAB)\
@$(ECHO) " INSTARGET_$(target)=$(INSTARGET_$(target))" $(NLTAB)\
$(foreach prop,$(PROPS_SINGLE) $(PROPS_ACCUMULATE_L) $(PROPS_ACCUMULATE_R) 2_OBJS CLEAN, \
$(eval _tmp:=$(firstword $($(target)_BLD_TRG) $(KBUILD_TARGET))) \
$(if $($(target)_$(prop).$(_tmp)),\
@$(ECHO) " $(target)_$(prop).$(_tmp)=$($(target)_$(prop).$(_tmp))" $(NLTAB)) \
$(if $($(target)_$(prop)), $(NLTAB)@$(ECHO) " $(target)_$(prop)=$($(target)_$(prop))" $(NLTAB)) \
)\
$(foreach prop,$(PROPS_DEFERRED), \
$(eval _tmp:=$(firstword $($(target)_BLD_TRG) $(KBUILD_TARGET))) \
$(if $(value $(target)_$(prop).$(_tmp)),\
@$(ECHO) ' $(target)_$(prop).$(_tmp)=$(value $(TARGET)_$(prop).$(_tmp))' $(NLTAB)) \
$(if $(value $(target)_$(prop)), $(NLTAB)@$(ECHO) ' $(target)_$(prop)=$(value $(target)_$(prop))' $(NLTAB)) \
))
#
# Include dependency files.
#
ifdef _DEPFILES
# TODO: first works the second doesn't, provided _KB_INCLUDE_DEPS is undefined:
# if "$(_KB_INCLUDE_DEPS)" == "1"
# if $(_KB_INCLUDE_DEPS) == "1"
ifdef KB_HAVE_INCLUDEDEP_QUEUE
includedep-queue $(_DEPFILES)
else
$(foreach dep, $(_DEPFILES), $(eval includedep $(dep)))
endif
endif
ifdef KBUILD_PROFILE_SELF
$(evalcall def_profile_self, end of footer.kmk)
_KBUILD_TS_FOOTER_END := $(_KBUILD_TS_PREV)
ifneq ($(KBUILD_PROFILE_SELF),0)
$(info prof: ALL=$(words $(_ALL_TARGETS)) BLDPROGS=$(words $(_ALL_BLDPROGS)) LIBRARIES=$(words $(_ALL_LIBRARIES)) IMPORT_LIBS=$(words $(IMPORT_LIBS)) DLLS=$(words $(DLLS)) PROGRAMS=$(words $(_ALL_PROGRAMS)) )
$(info prof: SYSMODS=$(words $(_ALL_SYSMODS)) MISCBINS=$(words $(_ALL_MISCBINS)) OTHERS=$(words $(_ALL_OTHERS)) INSTALLS=$(words $(_ALL_INSTALLS)) FETCHES=$(words $(_ALL_FETCHES)) PACKING=$(words $(_PACKING)) TESTING=$(words $(TESTING)) )
$(info prof: DIRS=$(words $(_DIR_ALL)) TOOLS=$(words $(_TOOLS)) SDKS=$(words $(_SDKS)) USES=$(words $(_USES)) OUT_FILES=$(words $(_OUT_FILES)) OBJS=$(words $(_OBJS)) CLEAN_FILES=$(words $(CLEAN_FILES) $(OTHER_CLEAN)) )
$(info prof: DEPFILES_INCLUDED=$(words $(_DEPFILES_INCLUDED)) DEPFILES=$(words $(_DEPFILES)) MAKEFILES=$(words $(MAKEFILE_LIST)) )
endif
endif
# end-of-file-content
__footer_kmk__ := target
endif # !defined(__footer_kmk__)
|