1 | # $Id: header.kmk 1504 2008-04-09 00:04:42Z bird $
|
---|
2 | ## @file
|
---|
3 | #
|
---|
4 | # kBuild - File included at top of a makefile.
|
---|
5 | #
|
---|
6 | # Copyright (c) 2004-2008 knut st. osmundsen <bird-kBuild-spam@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 |
|
---|
27 | ifndef __header_kmk__
|
---|
28 | # start-of-file-content
|
---|
29 | ifdef KBUILD_PROFILE_SELF
|
---|
30 | _KBUILD_TS_HEADER_START := $(nanots ) # just a dummy warm up query
|
---|
31 | $(info prof: since start - since previous - event description)
|
---|
32 | $(info stat: $(make-stats ))
|
---|
33 | _KBUILD_TS_HEADER_START := $(nanots )
|
---|
34 | _KBUILD_TS_PREV := $(_KBUILD_TS_HEADER_START)
|
---|
35 | endif
|
---|
36 |
|
---|
37 |
|
---|
38 | #
|
---|
39 | # Check make version before we do anything else.
|
---|
40 | #
|
---|
41 | ifndef KMK_VERSION
|
---|
42 | $(error kBuild: The kmk default variable KMK_VERSION isn't defined! Make sure you are using 'kmk' and not 'make', 'gmake', 'kmk_gmake', 'dmake' or any other make program)
|
---|
43 | endif
|
---|
44 | ifneq ($(KBUILD_VERSION_MAJOR).$(KBUILD_VERSION_MINOR),0.1)
|
---|
45 | ifneq ($(KBUILD_VERSION_MAJOR),0)
|
---|
46 | $(warning kBuild: kmk major version mismatch! Expected '0' but found '$(KBUILD_VERSION_MAJOR)'!)
|
---|
47 | else
|
---|
48 | $(warning kBuild: kmk minor version mismatch! Expected '1' but found '$(KBUILD_VERSION_MINOR)'!)
|
---|
49 | endif
|
---|
50 | else
|
---|
51 | ifneq ($(int-ge $(KBUILD_VERSION_PATCH),3),1)
|
---|
52 | $(warning kBuild: kmk version mismatch! Expected 0.1.3 or later. Actual version is $(KBUILD_VERSION_MAJOR).$(KBUILD_VERSION_MINOR).$(KBUILD_VERSION_PATCH).)
|
---|
53 | endif
|
---|
54 | endif
|
---|
55 |
|
---|
56 | #
|
---|
57 | # The revision in which this file was last modified.
|
---|
58 | # This can be useful when using development versions of kBuild.
|
---|
59 | #
|
---|
60 | KMK_REVISION := $(patsubst %:,, $Rev: 1504 $ )
|
---|
61 |
|
---|
62 |
|
---|
63 | #
|
---|
64 | # Define the default goal.
|
---|
65 | #
|
---|
66 | .PHONY: all all_recursive
|
---|
67 | all: all_recursive
|
---|
68 |
|
---|
69 | #
|
---|
70 | # The phony FORCE target.
|
---|
71 | #
|
---|
72 | .PHONY: FORCE
|
---|
73 | FORCE:
|
---|
74 |
|
---|
75 |
|
---|
76 | #
|
---|
77 | # Enable delete on error and second expansion of prerequisites.
|
---|
78 | #
|
---|
79 | .DELETE_ON_ERROR:
|
---|
80 |
|
---|
81 | .SECONDEXPANSION:
|
---|
82 |
|
---|
83 |
|
---|
84 | #
|
---|
85 | # General purpose macros.
|
---|
86 | #
|
---|
87 |
|
---|
88 | ##
|
---|
89 | # Newline character(s).
|
---|
90 | define NL
|
---|
91 |
|
---|
92 |
|
---|
93 | endef
|
---|
94 |
|
---|
95 | ##
|
---|
96 | # Tab character.
|
---|
97 | TAB := $(subst ., ,.)
|
---|
98 |
|
---|
99 | ##
|
---|
100 | # Newline + tab characters (for generating commands).
|
---|
101 | NLTAB = $(NL)$(TAB)
|
---|
102 |
|
---|
103 | ##
|
---|
104 | # Space character.
|
---|
105 | SP := $(subst ., ,.)
|
---|
106 |
|
---|
107 | ##
|
---|
108 | # Hash character.
|
---|
109 | define HASH
|
---|
110 | #
|
---|
111 | endef
|
---|
112 |
|
---|
113 | ##
|
---|
114 | # Colon character.
|
---|
115 | COLON := :
|
---|
116 |
|
---|
117 | ##
|
---|
118 | # Semicolon character.
|
---|
119 | SEMICOLON := ;
|
---|
120 |
|
---|
121 | ##
|
---|
122 | # Comma character.
|
---|
123 | COMMA := ,
|
---|
124 |
|
---|
125 | ##
|
---|
126 | # Dot character.
|
---|
127 | DOT := .
|
---|
128 |
|
---|
129 | ##
|
---|
130 | # Dollar character.
|
---|
131 | DOLLAR := $$
|
---|
132 |
|
---|
133 | ##
|
---|
134 | # Equal character.
|
---|
135 | EQUAL := =
|
---|
136 |
|
---|
137 |
|
---|
138 | #
|
---|
139 | # The list of standard build types in kBuild.
|
---|
140 | #
|
---|
141 | # This list can be extended in Config.kmk and it's possible to extend
|
---|
142 | # (inherit) another build type.
|
---|
143 | #
|
---|
144 | KBUILD_BLD_TYPES := release profile debug
|
---|
145 |
|
---|
146 |
|
---|
147 | #
|
---|
148 | # The OSes, Architectures and CPUs that kBuild recognizes.
|
---|
149 | #
|
---|
150 | # When kBuild is ported to a new OS or architecture a unique keyword needs
|
---|
151 | # to be assigned to it and added here. This strictness is required because
|
---|
152 | # this keyword namespace is shared between OSes, architectures, cpus and
|
---|
153 | # build types. (PORTME)
|
---|
154 | #
|
---|
155 | KBUILD_OSES := darwin freebsd l4 linux netbsd nt openbsd os2 solaris win
|
---|
156 | KBUILD_ARCHES := x86 amd64 sparc32 sparc64 s390 s390x ppc32 ppc64 mips32 mips64 ia64 hppa32 hppa64 arm alpha
|
---|
157 |
|
---|
158 |
|
---|
159 | #
|
---|
160 | # Set default build type.
|
---|
161 | #
|
---|
162 | ifndef KBUILD_TYPE
|
---|
163 | ifdef BUILD_TYPE
|
---|
164 | KBUILD_TYPE := $(BUILD_TYPE)
|
---|
165 | endif
|
---|
166 | else ifdef BUILD_TYPE
|
---|
167 | ifneq ($(KBUILD_TYPE),$(BUILD_TYPE))
|
---|
168 | ifeq ($(origin KBUILD_TYPE):$(origin BUILD_TYPE),environment:command line)
|
---|
169 | KBUILD_TYPE := $(BUILD_TYPE)
|
---|
170 | else ifneq ($(origin KBUILD_TYPE):$(origin BUILD_TYPE),command line:environment)
|
---|
171 | $(error kBuild: KBUILD_TYPE and BUILD_TYPE disagree.)
|
---|
172 | endif
|
---|
173 | endif
|
---|
174 | endif
|
---|
175 | override BUILD_TYPE = $(KBUILD_TYPE)
|
---|
176 |
|
---|
177 | ifndef KBUILD_TYPE
|
---|
178 | KBUILD_TYPE := release
|
---|
179 | else
|
---|
180 | if1of ($(KBUILD_TYPE), $(KBUILD_OSES) $(KBUILD_ARCHES))
|
---|
181 | $(error kBuild: The KBUILD_TYPE value '$(KBUILD_TYPE)' is an OS or architecture!)
|
---|
182 | endif
|
---|
183 | ifneq (.$(words $(KBUILD_TYPE)).$(KBUILD_TYPE).,.1.$(strip $(KBUILD_TYPE)).)
|
---|
184 | $(error kBuild: The KBUILD_TYPE value '$(KBUILD_TYPE)' contains spaces/tabs!)
|
---|
185 | endif
|
---|
186 | endif
|
---|
187 |
|
---|
188 |
|
---|
189 | #
|
---|
190 | # Host platform legacy
|
---|
191 | # kmk deals with this, so this is only temporary until I've rebuilt everything.
|
---|
192 | #
|
---|
193 | ifndef KBUILD_HOST
|
---|
194 | KBUILD_HOST := $(BUILD_PLATFORM)
|
---|
195 | endif
|
---|
196 | ifndef KBUILD_HOST_ARCH
|
---|
197 | KBUILD_HOST_ARCH := $(BUILD_PLATFORM_ARCH)
|
---|
198 | endif
|
---|
199 | ifndef KBUILD_HOST_CPU
|
---|
200 | KBUILD_HOST_CPU := $(BUILD_PLATFORM_CPU)
|
---|
201 | endif
|
---|
202 |
|
---|
203 |
|
---|
204 | #
|
---|
205 | # Assert valid build platform variables.
|
---|
206 | #
|
---|
207 | # All these are set by kmk so they shouldn't be any trouble
|
---|
208 | # unless the user starts messing about with environment variables.
|
---|
209 | #
|
---|
210 | ifneq (.$(words $(KBUILD_HOST)).$(KBUILD_HOST).,.1.$(strip $(KBUILD_HOST)).)
|
---|
211 | $(error kBuild: The KBUILD_HOST value '$(KBUILD_HOST)' contains spaces/tabs!)
|
---|
212 | endif
|
---|
213 | ifneq ($(words $(filter $(KBUILD_HOST),$(KBUILD_OSES))),1)
|
---|
214 | $(error kBuild: KBUILD_HOST value '$(KBUILD_HOST)' is not recognized (valid: $(KBUILD_OSES)))
|
---|
215 | endif
|
---|
216 |
|
---|
217 | ifneq (.$(words $(KBUILD_HOST_ARCH)).$(KBUILD_HOST_ARCH).,.1.$(strip $(KBUILD_HOST_ARCH)).)
|
---|
218 | $(error kBuild: The KBUILD_HOST_ARCH value '$(KBUILD_HOST_ARCH)' contains spaces/tabs!)
|
---|
219 | endif
|
---|
220 | ifneq ($(words $(filter $(KBUILD_HOST_ARCH),$(KBUILD_ARCHES))),1)
|
---|
221 | $(error kBuild: KBUILD_HOST_ARCH value '$(KBUILD_HOST_ARCH)' is not recognized (valid: $(KBUILD_ARCHES)))
|
---|
222 | endif
|
---|
223 |
|
---|
224 | ifeq ($(strip $(KBUILD_HOST_CPU)),)
|
---|
225 | KBUILD_HOST_CPU := blend
|
---|
226 | else
|
---|
227 | ifneq (.$(words $(KBUILD_HOST_CPU)).$(KBUILD_HOST_CPU).,.1.$(strip $(KBUILD_HOST_CPU)).)
|
---|
228 | $(error kBuild: The KBUILD_HOST_CPU value '$(KBUILD_HOST_CPU)' contains spaces/tabs!)
|
---|
229 | endif
|
---|
230 | if1of ($(KBUILD_HOST_CPU), $(KBUILD_OSES) $(BUILD_ARCHES))
|
---|
231 | $(error kBuild: The KBUILD_HOST_CPU value '$(KBUILD_HOST_CPU)' was found in the OS or architecture keywords!)
|
---|
232 | endif
|
---|
233 | ifeq ($(KBUILD_HOST_CPU),$(KBUILD_TYPE))
|
---|
234 | $(error kBuild: The KBUILD_HOST_CPU value '$(KBUILD_HOST_CPU)' is the same as the KBUILD_TYPE!)
|
---|
235 | endif
|
---|
236 | endif
|
---|
237 |
|
---|
238 |
|
---|
239 | #
|
---|
240 | # Deal with target platform legacy.
|
---|
241 | #
|
---|
242 | ifndef KBUILD_TARGET
|
---|
243 | ifdef BUILD_TARGET
|
---|
244 | KBUILD_TARGET := $(BUILD_TARGET)
|
---|
245 | endif
|
---|
246 | else ifdef BUILD_TARGET
|
---|
247 | ifneq ($(KBUILD_TARGET),$(BUILD_TARGET))
|
---|
248 | ifeq ($(origin KBUILD_TARGET):$(origin BUILD_TARGET),environment:command line)
|
---|
249 | KBUILD_TARGET := $(BUILD_TARGET)
|
---|
250 | else ifneq ($(origin KBUILD_TARGET):$(origin BUILD_TARGET),command line:environment)
|
---|
251 | $(error kBuild: KBUILD_TARGET and BUILD_TARGET disagree)
|
---|
252 | endif
|
---|
253 | endif
|
---|
254 | endif
|
---|
255 | override BUILD_TARGET = $(KBUILD_TARGET)
|
---|
256 |
|
---|
257 | ifndef KBUILD_TARGET_ARCH
|
---|
258 | ifdef BUILD_TARGET_ARCH
|
---|
259 | KBUILD_TARGET_ARCH := $(BUILD_TARGET_ARCH)
|
---|
260 | endif
|
---|
261 | else ifdef BUILD_TARGET_ARCH
|
---|
262 | ifneq ($(KBUILD_TARGET_ARCH),$(BUILD_TARGET_ARCH))
|
---|
263 | ifeq ($(origin KBUILD_TARGET_ARCH):$(origin BUILD_TARGET_ARCH),environment:command line)
|
---|
264 | KBUILD_TARGET_ARCH := $(BUILD_TARGET_ARCH)
|
---|
265 | else ifneq ($(origin KBUILD_TARGET_ARCH):$(origin BUILD_TARGET_ARCH),command line:environment)
|
---|
266 | $(error kBuild: KBUILD_TARGET_ARCH and BUILD_TARGET_ARCH disagree)
|
---|
267 | endif
|
---|
268 | endif
|
---|
269 | endif
|
---|
270 | override BUILD_TARGET_ARCH = $(KBUILD_TARGET_ARCH)
|
---|
271 |
|
---|
272 | ifndef KBUILD_TARGET_CPU
|
---|
273 | ifdef BUILD_TARGET_CPU
|
---|
274 | KBUILD_TARGET_CPU := $(BUILD_TARGET_CPU)
|
---|
275 | endif
|
---|
276 | else ifdef BUILD_TARGET_CPU
|
---|
277 | ifneq ($(KBUILD_TARGET_CPU),$(BUILD_TARGET_CPU))
|
---|
278 | ifeq ($(origin KBUILD_TARGET_CPU):$(origin BUILD_TARGET_CPU),environment:command line)
|
---|
279 | KBUILD_TARGET_CPU := $(BUILD_TARGET_CPU)
|
---|
280 | else ifneq ($(origin KBUILD_TARGET_CPU):$(origin BUILD_TARGET_CPU),command line:environment)
|
---|
281 | $(error kBuild: KBUILD_TARGET_CPU and BUILD_TARGET_CPU disagree)
|
---|
282 | endif
|
---|
283 | endif
|
---|
284 | endif
|
---|
285 | override BUILD_TARGET_CPU = $(KBUILD_TARGET_CPU)
|
---|
286 |
|
---|
287 |
|
---|
288 | #
|
---|
289 | # Assert or set default target platform.
|
---|
290 | # When not defined use the corresponding KBUILD_HOST value.
|
---|
291 | #
|
---|
292 | ifndef KBUILD_TARGET
|
---|
293 | KBUILD_TARGET := $(KBUILD_HOST)
|
---|
294 | else
|
---|
295 | ifneq (.$(words $(KBUILD_TARGET)).$(KBUILD_TARGET).,.1.$(strip $(KBUILD_TARGET)).)
|
---|
296 | $(error kBuild: The KBUILD_TARGET value '$(KBUILD_TARGET)' contains spaces/tabs!)
|
---|
297 | endif
|
---|
298 | ifneq ($(words $(filter $(KBUILD_TARGET),$(KBUILD_OSES))),1)
|
---|
299 | $(error kBuild: KBUILD_TARGET value '$(KBUILD_TARGET)' is not recognized (valid: $(KBUILD_OSES)))
|
---|
300 | endif
|
---|
301 | endif
|
---|
302 |
|
---|
303 | ifndef KBUILD_TARGET_ARCH
|
---|
304 | KBUILD_TARGET_ARCH := $(KBUILD_HOST_ARCH)
|
---|
305 | else
|
---|
306 | ifneq (.$(words $(KBUILD_TARGET_ARCH)).$(KBUILD_TARGET_ARCH).,.1.$(strip $(KBUILD_TARGET_ARCH)).)
|
---|
307 | $(error kBuild: The KBUILD_TARGET_ARCH value '$(KBUILD_TARGET_ARCH)' contains spaces/tabs!)
|
---|
308 | endif
|
---|
309 | ifneq ($(words $(filter $(KBUILD_TARGET_ARCH),$(KBUILD_ARCHES))),1)
|
---|
310 | $(error kBuild: KBUILD_TARGET_ARCH value '$(KBUILD_TARGET_ARCH)' is not recognized (valid: $(KBUILD_ARCHES)))
|
---|
311 | endif
|
---|
312 | endif
|
---|
313 |
|
---|
314 | ifndef KBUILD_TARGET_CPU
|
---|
315 | KBUILD_TARGET_CPU := $(KBUILD_HOST_CPU)
|
---|
316 | else ifeq ($(strip $(KBUILD_TARGET_CPU)),)
|
---|
317 | ifeq ($(KBUILD_TARGET_ARCH),$(KBUILD_HOST_ARCH))
|
---|
318 | KBUILD_TARGET_CPU := $(KBUILD_HOST_CPU)
|
---|
319 | else
|
---|
320 | KBUILD_TARGET_CPU := blend
|
---|
321 | endif
|
---|
322 | else
|
---|
323 | ifneq (.$(words $(KBUILD_TARGET_CPU)).$(KBUILD_TARGET_CPU).,.1.$(strip $(KBUILD_TARGET_CPU)).)
|
---|
324 | $(error kBuild: The KBUILD_TARGET_CPU value '$(KBUILD_TARGET_CPU)' contains spaces/tabs!)
|
---|
325 | endif
|
---|
326 | if1of ($(KBUILD_TARGET_CPU), $(KBUILD_OSES) $(BUILD_ARCHES))
|
---|
327 | $(error kBuild: The KBUILD_TARGET_CPU value was found in the OS or architecture keywords!)
|
---|
328 | endif
|
---|
329 | ifeq ($(KBUILD_TARGET_CPU),$(KBUILD_TYPE))
|
---|
330 | $(error kBuild: The KBUILD_TARGET_CPU value '$(KBUILD_TARGET_CPU)' is the same as the KBUILD_TYPE!)
|
---|
331 | endif
|
---|
332 | endif
|
---|
333 |
|
---|
334 |
|
---|
335 | #
|
---|
336 | # Paths and stuff.
|
---|
337 | #
|
---|
338 |
|
---|
339 | # Adjust DEPTH first.
|
---|
340 | DEPTH := $(strip $(DEPTH))
|
---|
341 | ifeq ($(DEPTH),)
|
---|
342 | DEPTH := .
|
---|
343 | endif
|
---|
344 |
|
---|
345 | ## PATH_CURRENT is the current directory (getcwd).
|
---|
346 | PATH_CURRENT := $(abspath $(CURDIR))
|
---|
347 | ## PATH_SUB_CURRENT points to current directory of the current makefile.
|
---|
348 | # Meaning that it will change value as we enter and exit sub-makefiles.
|
---|
349 | PATH_SUB_CURRENT := $(PATH_CURRENT)
|
---|
350 | ## PATH_ROOT points to the project root directory.
|
---|
351 | PATH_ROOT := $(abspath $(PATH_CURRENT)/$(DEPTH))
|
---|
352 | ## PATH_SUB_ROOT points to the directory of the top-level makefile.
|
---|
353 | ifneq ($(strip $(SUB_DEPTH)),)
|
---|
354 | SUB_DEPTH := $(strip $(SUB_DEPTH))
|
---|
355 | PATH_SUB_ROOT := $(abspath $(PATH_CURRENT)/$(SUB_DEPTH))
|
---|
356 | else
|
---|
357 | PATH_SUB_ROOT := $(PATH_CURRENT)
|
---|
358 | endif
|
---|
359 |
|
---|
360 | ## CURSUBDIR is PATH_SUB_ROOT described relative to PATH_ROOT.
|
---|
361 | # This variable is used to determin where the object files and other output goes.
|
---|
362 | ifneq ($(PATH_ROOT),$(PATH_SUB_ROOT))
|
---|
363 | CURSUBDIR := $(patsubst $(PATH_ROOT)/%,%,$(PATH_SUB_ROOT))
|
---|
364 | else
|
---|
365 | CURSUBDIR := .
|
---|
366 | endif
|
---|
367 |
|
---|
368 | # Output directories.
|
---|
369 | ifndef PATH_OUT_BASE
|
---|
370 | PATH_OUT_BASE := $(PATH_ROOT)/out
|
---|
371 | endif
|
---|
372 | ifndef PATH_OUT
|
---|
373 | ifdef BUILD_TARGET_SUB # (BUILD_TARGET_SUB is not currently recognized by kBuild in any other places - obsolete)
|
---|
374 | PATH_OUT := $(PATH_OUT_BASE)/$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH).$(BUILD_TARGET_SUB)/$(KBUILD_TYPE)
|
---|
375 | else
|
---|
376 | PATH_OUT := $(PATH_OUT_BASE)/$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)/$(KBUILD_TYPE)
|
---|
377 | endif
|
---|
378 | endif # !define PATH_OUT
|
---|
379 | PATH_OBJCACHE = $(PATH_OUT_BASE)/kObjCache
|
---|
380 | PATH_OBJ = $(PATH_OUT)/obj
|
---|
381 | PATH_TARGET = $(PATH_OBJ)/$(CURSUBDIR)
|
---|
382 | PATH_INS = $(PATH_OUT)
|
---|
383 | PATH_BIN = $(PATH_INS)/bin
|
---|
384 | PATH_DLL = $(PATH_INS)/bin
|
---|
385 | PATH_SYS = $(PATH_INS)/bin
|
---|
386 | PATH_LIB = $(PATH_INS)/lib
|
---|
387 | PATH_DOC = $(PATH_INS)/doc
|
---|
388 |
|
---|
389 | # KBUILD_PATH / PATH_KBUILD is determined by kmk.
|
---|
390 | ifndef KBUILD_PATH
|
---|
391 | KBUILD_PATH := $(PATH_KBUILD)
|
---|
392 | endif
|
---|
393 | ifeq ($(strip $(KBUILD_PATH)),)
|
---|
394 | $(error kBuild: KBUILD_PATH is missing or empty! kmk is supposed to set it.)
|
---|
395 | endif
|
---|
396 | # KBUILD_BIN_PATH / PATH_KBUILD_BIN is determined by kmk.
|
---|
397 | ifndef KBUILD_BIN_PATH
|
---|
398 | KBUILD_BIN_PATH := $(PATH_KBUILD_BIN)
|
---|
399 | endif
|
---|
400 | ifeq ($(strip $(KBUILD_BIN_PATH)),)
|
---|
401 | $(error kBuild: KBUILD_BIN_PATH is missing or empty! kmk is supposed to set it.)
|
---|
402 | endif
|
---|
403 |
|
---|
404 | # kBuild files which might be of interest.
|
---|
405 | FILE_KBUILD_HEADER := $(KBUILD_PATH)/header.kmk
|
---|
406 | #FILE_KBUILD_CONFIG := $(KBUILD_PATH)/config.kmk
|
---|
407 | FILE_KBUILD_FOOTER := $(KBUILD_PATH)/footer.kmk
|
---|
408 |
|
---|
409 | ## MAKEFILE is the name of the main makefile.
|
---|
410 | MAKEFILE := $(firstword $(MAKEFILE_LIST))
|
---|
411 | ## MAKEFILE_CURRENT is the name of the current makefile.
|
---|
412 | # This is updated everything a sub-makefile is included.
|
---|
413 | MAKEFILE_CURRENT := $(MAKEFILE)
|
---|
414 |
|
---|
415 |
|
---|
416 | #
|
---|
417 | # Build platform setup.
|
---|
418 | # (PORTME)
|
---|
419 | #
|
---|
420 |
|
---|
421 | # OS/2
|
---|
422 | ifeq ($(KBUILD_HOST),os2)
|
---|
423 | EXEC_X86_WIN32 := innopec.exe
|
---|
424 | HOSTSUFF_EXE := .exe
|
---|
425 | endif
|
---|
426 |
|
---|
427 | # Linux
|
---|
428 | ifeq ($(KBUILD_HOST),linux)
|
---|
429 | EXEC_X86_WIN32 := wine
|
---|
430 | HOSTSUFF_EXE :=
|
---|
431 | endif
|
---|
432 |
|
---|
433 | # Win, Win32, Win64, NT.
|
---|
434 | if1of ($(KBUILD_HOST), win nt)
|
---|
435 | EXEC_X86_WIN32 :=
|
---|
436 | HOSTSUFF_EXE := .exe
|
---|
437 | endif
|
---|
438 |
|
---|
439 | # FreeBSD
|
---|
440 | ifeq ($(KBUILD_HOST),freebsd)
|
---|
441 | EXEC_X86_WIN32 := wine
|
---|
442 | HOSTSUFF_EXE :=
|
---|
443 | endif
|
---|
444 |
|
---|
445 | # Darwin / Mac OS X
|
---|
446 | ifeq ($(KBUILD_HOST),darwin)
|
---|
447 | EXEC_X86_WIN32 := false
|
---|
448 | HOSTSUFF_EXE :=
|
---|
449 | endif
|
---|
450 |
|
---|
451 | # Solaris
|
---|
452 | ifeq ($(KBUILD_HOST),solaris)
|
---|
453 | EXEC_X86_WIN32 := false
|
---|
454 | HOSTSUFF_EXE :=
|
---|
455 | endif
|
---|
456 |
|
---|
457 |
|
---|
458 | #
|
---|
459 | # Build target setup.
|
---|
460 | # (PORTME)
|
---|
461 | #
|
---|
462 | SUFF_DEP := .dep
|
---|
463 | if1of ($(KBUILD_TARGET), win nt os2)
|
---|
464 | SUFF_OBJ := .obj
|
---|
465 | SUFF_LIB := .lib
|
---|
466 | SUFF_DLL := .dll
|
---|
467 | SUFF_EXE := .exe
|
---|
468 | SUFF_SYS := .sys
|
---|
469 | SUFF_RES := .res
|
---|
470 | else ifeq ($(KBUILD_TARGET),l4)
|
---|
471 | SUFF_OBJ := .o
|
---|
472 | SUFF_LIB := .a
|
---|
473 | SUFF_DLL := .s.so
|
---|
474 | SUFF_EXE :=
|
---|
475 | SUFF_SYS := .a
|
---|
476 | SUFF_RES :=
|
---|
477 | else ifeq ($(KBUILD_TARGET),darwin)
|
---|
478 | SUFF_OBJ := .o
|
---|
479 | SUFF_LIB := .a
|
---|
480 | SUFF_DLL := .dylib
|
---|
481 | SUFF_EXE :=
|
---|
482 | SUFF_SYS :=
|
---|
483 | SUFF_RES :=
|
---|
484 | else
|
---|
485 | SUFF_OBJ := .o
|
---|
486 | SUFF_LIB := .a
|
---|
487 | SUFF_DLL := .so
|
---|
488 | SUFF_EXE :=
|
---|
489 | if1of ($(KBUILD_TARGET), freebsd linux netbsd openbsd) ## @todo check netbsd and openbsd.
|
---|
490 | SUFF_SYS := .ko
|
---|
491 | else
|
---|
492 | SUFF_SYS :=
|
---|
493 | endif
|
---|
494 | SUFF_RES :=
|
---|
495 | endif
|
---|
496 |
|
---|
497 | #
|
---|
498 | # Standard kBuild tools.
|
---|
499 | #
|
---|
500 | ifeq ($(KMK),kmk)
|
---|
501 | KMK := $(KBUILD_BIN_PATH)/kmk$(HOSTSUFF_EXE)
|
---|
502 | endif
|
---|
503 | MAKE := $(KMK)
|
---|
504 |
|
---|
505 | GMAKE := $(KBUILD_BIN_PATH)/kmk_gmake$(HOSTSUFF_EXE)
|
---|
506 |
|
---|
507 | DEP_EXT := $(KBUILD_BIN_PATH)/kDep$(HOSTSUFF_EXE)
|
---|
508 | if1of (kDep, $(KMK_BUILTIN))
|
---|
509 | DEP := kmk_builtin_kDep
|
---|
510 | else
|
---|
511 | DEP := $(DEP_EXT)
|
---|
512 | endif
|
---|
513 |
|
---|
514 | DEP_IDB_EXT := $(KBUILD_BIN_PATH)/kDepIDB$(HOSTSUFF_EXE)
|
---|
515 | if1of (kDepIDB, $(KMK_BUILTIN))
|
---|
516 | DEP_IDB := kmk_builtin_kDepIDB
|
---|
517 | else
|
---|
518 | DEP_IDB := $(DEP_IDB_EXT)
|
---|
519 | endif
|
---|
520 |
|
---|
521 | DEP_PRE_EXT := $(KBUILD_BIN_PATH)/kDepPre$(HOSTSUFF_EXE)
|
---|
522 | if1of (kDepPre, $(KMK_BUILTIN))
|
---|
523 | DEP_PRE := kmk_builtin_kDepPre
|
---|
524 | else
|
---|
525 | DEP_PRE := $(DEP_PRE_EXT)
|
---|
526 | endif
|
---|
527 |
|
---|
528 | KOBJCACHE_EXT := $(KBUILD_BIN_PATH)/kObjCache$(HOSTSUFF_EXE)
|
---|
529 | if1of (kObjCache, $(KMK_BUILTIN))
|
---|
530 | KOBJCACHE := kmk_builtin_kObjCache
|
---|
531 | else
|
---|
532 | KOBJCACHE := $(KOBJCACHE_EXT)
|
---|
533 | endif
|
---|
534 |
|
---|
535 | APPEND_EXT := $(KBUILD_BIN_PATH)/kmk_append$(HOSTSUFF_EXE)
|
---|
536 | APPEND := kmk_builtin_append
|
---|
537 |
|
---|
538 | CAT_EXT := $(KBUILD_BIN_PATH)/kmk_cat$(HOSTSUFF_EXE)
|
---|
539 | CAT := kmk_builtin_cat
|
---|
540 |
|
---|
541 | CMP_EXT := $(KBUILD_BIN_PATH)/kmk_cmp$(HOSTSUFF_EXE)
|
---|
542 | CMP := kmk_builtin_cmp
|
---|
543 |
|
---|
544 | CP_EXT := $(KBUILD_BIN_PATH)/kmk_cp$(HOSTSUFF_EXE)
|
---|
545 | CP := kmk_builtin_cp
|
---|
546 |
|
---|
547 | ECHO_EXT := $(KBUILD_BIN_PATH)/kmk_echo$(HOSTSUFF_EXE)
|
---|
548 | ECHO := kmk_builtin_echo
|
---|
549 |
|
---|
550 | INSTALL_EXT := $(KBUILD_BIN_PATH)/kmk_install$(HOSTSUFF_EXE)
|
---|
551 | INSTALL := kmk_builtin_install
|
---|
552 |
|
---|
553 | LN_EXT := $(KBUILD_BIN_PATH)/kmk_ln$(HOSTSUFF_EXE)
|
---|
554 | LN := kmk_builtin_ln
|
---|
555 |
|
---|
556 | MD5SUM_EXT := $(KBUILD_BIN_PATH)/kmk_md5sum$(HOSTSUFF_EXE)
|
---|
557 | MD5SUM := kmk_builtin_md5sum
|
---|
558 |
|
---|
559 | MKDIR_EXT := $(KBUILD_BIN_PATH)/kmk_mkdir$(HOSTSUFF_EXE)
|
---|
560 | MKDIR := kmk_builtin_mkdir
|
---|
561 |
|
---|
562 | MV_EXT := $(KBUILD_BIN_PATH)/kmk_mv$(HOSTSUFF_EXE)
|
---|
563 | MV := kmk_builtin_mv
|
---|
564 |
|
---|
565 | PRINTF_EXT := $(KBUILD_BIN_PATH)/kmk_printf$(HOSTSUFF_EXE)
|
---|
566 | PRINTF := kmk_builtin_printf
|
---|
567 |
|
---|
568 | REDIRECT_EXT:= $(KBUILD_BIN_PATH)/kmk_redirect$(HOSTSUFF_EXE)
|
---|
569 | if1of (redirect, $(KMK_BUILTIN))
|
---|
570 | REDIRECT := kmk_builtin_redirect
|
---|
571 | else
|
---|
572 | REDIRECT := $(REDIRECT_EXT)
|
---|
573 | endif
|
---|
574 |
|
---|
575 | RM_EXT := $(KBUILD_BIN_PATH)/kmk_rm$(HOSTSUFF_EXE)
|
---|
576 | RM := kmk_builtin_rm
|
---|
577 |
|
---|
578 | RMDIR_EXT := $(KBUILD_BIN_PATH)/kmk_rmdir$(HOSTSUFF_EXE)
|
---|
579 | RMDIR := kmk_builtin_rmdir
|
---|
580 |
|
---|
581 | SED_EXT := $(KBUILD_BIN_PATH)/kmk_sed$(HOSTSUFF_EXE)
|
---|
582 | if1of (sed, $(KMK_BUILTIN))
|
---|
583 | SED_INT := kmk_builtin_sed
|
---|
584 | else
|
---|
585 | SED_INT := $(SED_EXT)
|
---|
586 | endif
|
---|
587 | SED := $(SED_EXT)
|
---|
588 |
|
---|
589 | TEST_EXT := $(KBUILD_BIN_PATH)/kmk_test$(HOSTSUFF_EXE)
|
---|
590 | TEST := kmk_builtin_test
|
---|
591 |
|
---|
592 | # Our default shell is the Almquist shell from *BSD.
|
---|
593 | ASH := $(KBUILD_BIN_PATH)/kmk_ash$(HOSTSUFF_EXE)
|
---|
594 | MAKESHELL := $(ASH)
|
---|
595 | SHELL := $(ASH)
|
---|
596 | export SHELL MAKESHELL
|
---|
597 |
|
---|
598 | # Symlinking is problematic on some platforms...
|
---|
599 | LN_SYMLINK := $(LN) -s
|
---|
600 |
|
---|
601 |
|
---|
602 | #
|
---|
603 | # Some Functions.
|
---|
604 | # The lower cased ones are either fallbacks or candidates for functions.c.
|
---|
605 | #
|
---|
606 |
|
---|
607 | ## ABSPATH - make paths absolute.
|
---|
608 | # This implementation is clumsy and doesn't resolve '..' and '.' components.
|
---|
609 | #
|
---|
610 | # @param $1 The paths to make absolute.
|
---|
611 | # @obsolete Use the GNU make function $(abspath) directly now.
|
---|
612 | ABSPATH = $(abspath $(1))$(warning ABSPATH is deprecated, use abspath directly!)
|
---|
613 |
|
---|
614 | ## DIRDEP - make create directory dependencies.
|
---|
615 | #
|
---|
616 | # @param $1 The paths to the directories which must be created.
|
---|
617 | DIRDEP = $(foreach path,$(patsubst %/,%,$(1)),$(path)/)
|
---|
618 |
|
---|
619 | ## Cygwin kludge.
|
---|
620 | # This converts /cygdrive/x/% to x:%.
|
---|
621 | #
|
---|
622 | # @param $1 The paths to make native.
|
---|
623 | # @remark This macro is pretty much obsolete since we don't use cygwin base make.
|
---|
624 | ifneq ($(patsubst /cygdrive/%,%,$(CURDIR)),$(CURDIR))
|
---|
625 | CYGPATHMIXED = $(foreach path,$(1)\
|
---|
626 | ,$(if $(patsubst /cygdrive/%,,$(path)),$(path),$(patsubst $(strip $(firstword $(subst /, ,$(patsubst /cygdrive/%,%,$(path)))))/%,$(strip $(firstword $(subst /, ,$(patsubst /cygdrive/%,%,$(path))))):/%,$(patsubst /cygdrive/%,%,$(path)))))
|
---|
627 | else
|
---|
628 | CYGPATHMIXED = $(1)
|
---|
629 | endif
|
---|
630 |
|
---|
631 | ## Removes the drive letter from a path (if it has one)
|
---|
632 | # @param $1 the path
|
---|
633 | no-drive = $(word $(words $(subst :, ,$(1))),$(subst :, ,$(1)))
|
---|
634 |
|
---|
635 | ## Removes the root slash from a path (if it has one)
|
---|
636 | # @param $1 the path
|
---|
637 | no-root-slash = $(patsubst /%,%,$(1))
|
---|
638 |
|
---|
639 | ## Figure out where to put object files.
|
---|
640 | # @param $1 real target name.
|
---|
641 | # @param $2 normalized main target
|
---|
642 | TARGET_BASE = $(PATH_TARGET)/$(2)/$(call no-root-slash,$(call no-drive,$(1)))
|
---|
643 |
|
---|
644 | ## Figure out where to put object files.
|
---|
645 | # @param $1 normalized main target
|
---|
646 | TARGET_PATH = $(PATH_TARGET)/$(1)
|
---|
647 |
|
---|
648 |
|
---|
649 | #
|
---|
650 | # Initialize some of the globals which the Config.kmk and
|
---|
651 | # others can add stuff to if they like for processing in the footer.
|
---|
652 | #
|
---|
653 |
|
---|
654 | ## KBUILD_TEMPLATE_PATHS
|
---|
655 | # List a paths (separated by space) where templates can be found.
|
---|
656 | KBUILD_TEMPLATE_PATHS :=
|
---|
657 |
|
---|
658 | ## KBUILD_TOOL_PATHS
|
---|
659 | # List of paths (separated by space) where tools can be found.
|
---|
660 | KBUILD_TOOL_PATHS :=
|
---|
661 |
|
---|
662 | ## KBUILD_SDK_PATHS
|
---|
663 | # List of paths (separated by space) where SDKs can be found.
|
---|
664 | KBUILD_SDK_PATHS :=
|
---|
665 |
|
---|
666 | ## KBUILD_DEFAULT_PATHS
|
---|
667 | # List of paths (separated by space) to search for stuff as a last resort.
|
---|
668 | KBUILD_DEFAULT_PATHS :=
|
---|
669 |
|
---|
670 | ## Proritized list of the default makefile when walking subdirectories.
|
---|
671 | # The user can overload this list.
|
---|
672 | DEFAULT_MAKEFILE := Makefile.kmk makefile.kmk Makefile makefile
|
---|
673 |
|
---|
674 | ## KBUILD_SRC_HANDLERS
|
---|
675 | # The list of source handlers, pair of extension and handler.
|
---|
676 | # The user can overload this list to provide additional or custom
|
---|
677 | # handlers. On a per-target/template see SRC_HANDLERS.
|
---|
678 | KBUILD_SRC_HANDLERS := \
|
---|
679 | .c:def_src_handler_c \
|
---|
680 | .C:def_src_handler_c \
|
---|
681 | .cxx:def_src_handler_cxx \
|
---|
682 | .CXX:def_src_handler_cxx \
|
---|
683 | .cpp:def_src_handler_cxx \
|
---|
684 | .CPP:def_src_handler_cxx \
|
---|
685 | .cc:def_src_handler_cxx \
|
---|
686 | .CC:def_src_handler_cxx \
|
---|
687 | .m:def_src_handler_objc \
|
---|
688 | .asm:def_src_handler_asm \
|
---|
689 | .ASM:def_src_handler_asm \
|
---|
690 | .s:def_src_handler_asm \
|
---|
691 | .S:def_src_handler_asm \
|
---|
692 | .rc:def_src_handler_rc \
|
---|
693 | .obj:def_src_handler_obj \
|
---|
694 | .o:def_src_handler_obj \
|
---|
695 | .res:def_src_handler_obj
|
---|
696 |
|
---|
697 | ## PROPS_TOOLS
|
---|
698 | # This is a subset of PROPS_SINGLE.
|
---|
699 | PROPS_TOOLS := TOOL CTOOL CXXTOOL OBJCTOOL ASTOOL RCTOOL ARTOOL LDTOOL FETCHTOOL UNPACKTOOL PATCHTOOL
|
---|
700 |
|
---|
701 | ## PROPS_SINGLE
|
---|
702 | # The list of non-accumulative target properties.
|
---|
703 | # A Config.kmk file can add it's own properties to this list and kBuild
|
---|
704 | # will do the necessary inheritance for templates, sdks, tools and targets.
|
---|
705 | PROPS_SINGLE := $(PROPS_TOOLS) TEMPLATE INST NOINST BLD_TYPE BLD_TRG BLD_TRG_ARCH BLD_TRG_CPU FETCHDIR \
|
---|
706 | OBJSUFF COBJSUFF CXXOBJSUFF OBJCOBJSUFF ASOBJSUFF RCOBJSUFF SYSSUFF EXESUFF DLLSUFF LIBSUFF ARLIBSUFF
|
---|
707 | ## PROPS_SINGLE_LNK
|
---|
708 | # Subset of PROPS_SINGLE which applies to all linkable targets.
|
---|
709 | PROPS_SINGLE_LNK := TOOL TEMPLATE CTOOL CXXTOOL OBJCTOOL ASTOOL RCTOOL \
|
---|
710 | INST NOINST BLD_TYPE BLD_TRG BLD_TRG_ARCH BLD_TRG_CPU \
|
---|
711 | OBJSUFF COBJSUFF CXXOBJSUFF OBJCOBJSUFF ASOBJSUFF RCOBJSUFF
|
---|
712 |
|
---|
713 | ## PROPS_DEFERRED
|
---|
714 | # This list of non-accumulative target properties which are or may be
|
---|
715 | # functions, and thus should not be expanded until the very last moment.
|
---|
716 | PROPS_DEFERRED := INSTFUN INSTALLER PRE_CMDS POST_CMDS NAME SONAME
|
---|
717 |
|
---|
718 | ## PROPS_ACCUMULATE_R
|
---|
719 | # The list of accumulative target properties where the right most value/flag
|
---|
720 | # is the 'most significant'.
|
---|
721 | # A Config.kmk file can add it's own properties to this list and kBuild
|
---|
722 | # will do the necessary inheritance from templates to targets.
|
---|
723 | PROPS_ACCUMULATE_R := \
|
---|
724 | DEPS ORDERDEPS DEFS \
|
---|
725 | ARFLAGS \
|
---|
726 | CFLAGS CDEFS \
|
---|
727 | CXXFLAGS CXXDEFS \
|
---|
728 | OBJCFLAGS OBJCDEFS \
|
---|
729 | ASFLAGS ASDEFS \
|
---|
730 | RCFLAGS RCDEFS \
|
---|
731 | LDFLAGS \
|
---|
732 | IDFLAGS IFDLAGS ISFLAGS \
|
---|
733 | FETCHFLAGS UNPACKFLAGS PATCHFLAGS
|
---|
734 | ## PROPS_ACCUMULATE_R_LNK
|
---|
735 | # Subset of PROPS_ACCUMULATE_R which applies to all linkable targets.
|
---|
736 | PROPS_ACCUMULATE_R_LNK := \
|
---|
737 | DEPS ORDERDEPS DEFS \
|
---|
738 | CFLAGS CDEFS \
|
---|
739 | CXXFLAGS CXXDEFS \
|
---|
740 | OBJCFLAGS OBJCDEFS \
|
---|
741 | ASFLAGS ASDEFS \
|
---|
742 | RCFLAGS RCDEFS \
|
---|
743 | IDFLAGS IFDLAGS ISFLAGS
|
---|
744 |
|
---|
745 | ## PROPS_ACCUMULATE
|
---|
746 | # The list of accumulative target properties where the left most value/flag
|
---|
747 | # is the 'most significant'.
|
---|
748 | # A Config.kmk file can add it's own properties to this list and kBuild
|
---|
749 | # will do the necessary inheritance from templates to targets.
|
---|
750 | PROPS_ACCUMULATE_L := \
|
---|
751 | SDKS SOURCES SRC_HANDLERS INTERMEDIATES \
|
---|
752 | INCS CINCS CXXINCS OBJCINCS ASINCS RCINCS \
|
---|
753 | LIBS LIBPATH \
|
---|
754 | DIRS BLDDIRS CLEAN
|
---|
755 | ## PROPS_ACCUMULATE_L_LNK
|
---|
756 | # Subset of PROPS_ACCUMULATE_L which applies to all linkable targets.
|
---|
757 | PROPS_ACCUMULATE_L_LNK := \
|
---|
758 | SDKS SOURCES SRC_HANDLERS \
|
---|
759 | INCS CINCS CXXINCS OBJCINCS ASINCS RCINCS \
|
---|
760 | BLDDIRS CLEAN
|
---|
761 |
|
---|
762 | ## PROPS_ALL
|
---|
763 | # List of all the properties.
|
---|
764 | PROPS_ALL = $(PROPS_SINGLE) $(PROPS_DEFERRED) $(PROPS_ACCUMULATE_L) $(PROPS_ACCUMULATE_R)
|
---|
765 |
|
---|
766 |
|
---|
767 | ## @name Properties valid on programs (BLDPROGS and PROGRAMS)
|
---|
768 | ## @{
|
---|
769 | PROPS_PROGRAMS_SINGLE := $(PROPS_SINGLE_LNK) LDTOOL EXESUFF
|
---|
770 | PROPS_PROGRAMS_DEFERRED := $(PROPS_DEFERRED)
|
---|
771 | PROPS_PROGRAMS_ACCUMULATE_R := $(PROPS_ACCUMULATE_R_LNK) LDFLAGS
|
---|
772 | PROPS_PROGRAMS_ACCUMULATE_L := $(PROPS_ACCUMULATE_L_LNK) LIBS LIBPATH
|
---|
773 | ## @}
|
---|
774 |
|
---|
775 | ## @name Properties valid on libraries (LIBRARIES and IMPORT_LIBS)
|
---|
776 | ## @{
|
---|
777 | PROPS_LIBRARIES_SINGLE := $(PROPS_SINGLE_LNK) ARTOOL LIBSUFF ARLIBSUFF LIBSUFF
|
---|
778 | PROPS_LIBRARIES_DEFERRED := $(filter-out SONAME,$(PROPS_DEFERRED))
|
---|
779 | PROPS_LIBRARIES_ACCUMULATE_R := $(PROPS_ACCUMULATE_R_LNK) ARFLAGS
|
---|
780 | PROPS_LIBRARIES_ACCUMULATE_L := $(PROPS_ACCUMULATE_L_LNK)
|
---|
781 | ## @}
|
---|
782 |
|
---|
783 | ## @name Properties valid on dlls (DLLS)
|
---|
784 | ## @{
|
---|
785 | PROPS_DLLS_SINGLE := $(PROPS_SINGLE_LNK) LDTOOL DLLSUFF LIBSUFF
|
---|
786 | PROPS_DLLS_DEFERRED := $(PROPS_DEFERRED)
|
---|
787 | PROPS_DLLS_ACCUMULATE_R := $(PROPS_ACCUMULATE_R_LNK) LDFLAGS
|
---|
788 | PROPS_DLLS_ACCUMULATE_L := $(PROPS_ACCUMULATE_L_LNK) LIBS LIBPATH
|
---|
789 | ## @}
|
---|
790 |
|
---|
791 | ## @name Properties valid on system modules (SYSMODS)
|
---|
792 | ## @{
|
---|
793 | PROPS_SYSMODS_SINGLE := $(PROPS_SINGLE_LNK) LDTOOL SYSSUFF
|
---|
794 | PROPS_SYSMODS_DEFERRED := $(PROPS_DEFERRED)
|
---|
795 | PROPS_SYSMODS_ACCUMULATE_R := $(PROPS_ACCUMULATE_R_LNK) LDFLAGS
|
---|
796 | PROPS_SYSMODS_ACCUMULATE_L := $(PROPS_ACCUMULATE_L_LNK) LIBS LIBPATH
|
---|
797 | ## @}
|
---|
798 |
|
---|
799 | ## @name Properties valid on installs (INSTALLS)
|
---|
800 | ## @{
|
---|
801 | PROPS_INSTALLS_SINGLE := TOOL TEMPLATE INST NOINST
|
---|
802 | PROPS_INSTALLS_DEFERRED := INSTFUN INSTALLER
|
---|
803 | PROPS_INSTALLS_ACCUMULATE_R := DEPS ORDERDEPS
|
---|
804 | PROPS_INSTALLS_ACCUMULATE_L := SOURCES DIRS CLEAN
|
---|
805 | ## @}
|
---|
806 |
|
---|
807 | ## @name Properties valid on fetches (INSTALLS)
|
---|
808 | ## @{
|
---|
809 | PROPS_FETCHES_SINGLE := TOOL TEMPLATE FETCHTOOL UNPACKTOOL PATCHTOOL INST FETCHDIR
|
---|
810 | PROPS_FETCHES_DEFERRED :=
|
---|
811 | PROPS_FETCHES_ACCUMULATE_R := FETCHFLAGS UNPACKFLAGS PATCHFLAGS
|
---|
812 | PROPS_FETCHES_ACCUMULATE_L := SOURCES
|
---|
813 | ## @}
|
---|
814 |
|
---|
815 |
|
---|
816 | #
|
---|
817 | # Here is a special 'hack' to prevent innocent environment variables being
|
---|
818 | # picked up and treated as properties. (The most annoying example of why
|
---|
819 | # this is necessary is the Visual C++ commandline with it's LIBPATH.)
|
---|
820 | #
|
---|
821 | # Define KBUILD_DONT_KILL_ENV_PROPS in the env. or on the commandline to
|
---|
822 | # disable this 'hack'.
|
---|
823 | #
|
---|
824 | ifndef KBUILD_DONT_KILL_ENV_PROPS
|
---|
825 |
|
---|
826 | define def_nuke_environment_prop
|
---|
827 | ifeq ($(origin $(prop)),environment)
|
---|
828 | $(prop) =
|
---|
829 | endif
|
---|
830 | endef
|
---|
831 | $(foreach prop, $(PROPS_ALL) \
|
---|
832 | FETCHES PATCHES BLDPROGS LIBRARIES IMPORT_LIBS DLLS PROGRAMS SYSMODS INSTALLS OTHERS \
|
---|
833 | SUBDIRS MAKEFILES BLDDIRS \
|
---|
834 | ,$(eval $(value def_nuke_environment_prop)))
|
---|
835 |
|
---|
836 | endif # KBUILD_DONT_KILL_ENV_PROPS
|
---|
837 |
|
---|
838 |
|
---|
839 | #
|
---|
840 | # Pass configuration.
|
---|
841 | #
|
---|
842 | # The PASS_<passname>_trgs variable is listing the targets.
|
---|
843 | # The PASS_<passname>_vars variable is listing the target variables.
|
---|
844 | # The PASS_<passname>_pass variable is the lowercased passname.
|
---|
845 | #
|
---|
846 |
|
---|
847 | ## PASS: fetches
|
---|
848 | # This pass fetches and unpacks things needed to complete the build.
|
---|
849 | PASS_FETCHES := Fetches
|
---|
850 | PASS_FETCHES_trgs :=
|
---|
851 | PASS_FETCHES_vars := _FETCHES
|
---|
852 | PASS_FETCHES_pass := fetches
|
---|
853 |
|
---|
854 | ## PASS: patches
|
---|
855 | # This pass applies patches.
|
---|
856 | PASS_PATCHES := Patches
|
---|
857 | PASS_PATCHES_trgs :=
|
---|
858 | PASS_PATCHES_vars := _PATCHES
|
---|
859 | PASS_PATCHES_pass := patches
|
---|
860 |
|
---|
861 | ## PASS: bldprogs
|
---|
862 | # This pass builds targets which are required for building the rest.
|
---|
863 | PASS_BLDPROGS := Build Programs
|
---|
864 | PASS_BLDPROGS_trgs :=
|
---|
865 | PASS_BLDPROGS_vars := _BLDPROGS
|
---|
866 | PASS_BLDPROGS_pass := bldprogs
|
---|
867 |
|
---|
868 | ## PASS: libraries
|
---|
869 | # This pass builds library targets.
|
---|
870 | PASS_LIBRARIES := Libraries
|
---|
871 | PASS_LIBRARIES_trgs :=
|
---|
872 | PASS_LIBRARIES_vars := _LIBS _IMPORT_LIBS _OTHER_LIBRARIES
|
---|
873 | PASS_LIBRARIES_pass := libraries
|
---|
874 |
|
---|
875 | ## PASS: binaries
|
---|
876 | # This pass builds dll targets.
|
---|
877 | PASS_DLLS := DLLs
|
---|
878 | PASS_DLLS_trgs :=
|
---|
879 | PASS_DLLS_vars := _DLLS _OTHER_DLLS
|
---|
880 | PASS_DLLS_pass := dlls
|
---|
881 |
|
---|
882 | ## PASS: binaries
|
---|
883 | # This pass builds binary targets, i.e. programs, system modules and stuff.
|
---|
884 | PASS_BINARIES := Programs
|
---|
885 | PASS_BINARIES_trgs :=
|
---|
886 | PASS_BINARIES_vars := _PROGRAMS _SYSMODS _OTHER_BINARIES
|
---|
887 | PASS_BINARIES_pass := binaries
|
---|
888 |
|
---|
889 | ## PASS: others
|
---|
890 | # This pass builds other targets.
|
---|
891 | PASS_OTHERS := Other Stuff
|
---|
892 | PASS_OTHERS_trgs :=
|
---|
893 | PASS_OTHERS_vars := _OTHERS
|
---|
894 | PASS_OTHERS_pass := others
|
---|
895 |
|
---|
896 | ## PASS: install
|
---|
897 | # This pass installs the built entities to a sandbox area.
|
---|
898 | PASS_INSTALLS := Install
|
---|
899 | PASS_INSTALLS_trgs :=
|
---|
900 | PASS_INSTALLS_vars := _INSTALLS_DIRS _INSTALLS _INSTALLS_FILES
|
---|
901 | PASS_INSTALLS_pass := installs
|
---|
902 |
|
---|
903 | ## PASS: packing
|
---|
904 | # This pass processes custom packing rules.
|
---|
905 | PASS_PACKING := Packing
|
---|
906 | PASS_PACKING_trgs :=
|
---|
907 | PASS_PACKING_vars := _PACKING
|
---|
908 | PASS_PACKING_pass := packing
|
---|
909 | #alias
|
---|
910 | packing: pass_packing
|
---|
911 |
|
---|
912 | ## PASS: clean
|
---|
913 | # This pass removes all generated files.
|
---|
914 | PASS_CLEAN := Clean
|
---|
915 | PASS_CLEAN_trgs := do-clean
|
---|
916 | PASS_CLEAN_vars :=
|
---|
917 | PASS_CLEAN_pass := clean
|
---|
918 | # alias
|
---|
919 | clean: pass_clean
|
---|
920 |
|
---|
921 | ## PASS: nothing
|
---|
922 | # This pass just walks the tree.
|
---|
923 | PASS_NOTHING := Nothing
|
---|
924 | PASS_NOTHING_trgs := do-nothing
|
---|
925 | PASS_NOTHING_vars :=
|
---|
926 | PASS_NOTHING_pass := nothing
|
---|
927 | # alias
|
---|
928 | nothing: pass_nothing
|
---|
929 |
|
---|
930 | ## DEFAULT_PASSES
|
---|
931 | # The default passes and their order.
|
---|
932 | DEFAULT_PASSES := BLDPROGS LIBRARIES DLLS BINARIES OTHERS INSTALLS
|
---|
933 |
|
---|
934 | ## PASSES
|
---|
935 | # The passes that should be defined. This must include
|
---|
936 | # all passes mentioned by DEFAULT_PASSES.
|
---|
937 | PASSES := FETCHES PATCHES $(DEFAULT_PASSES) NOTHING CLEAN
|
---|
938 |
|
---|
939 |
|
---|
940 | #
|
---|
941 | # Check for --pretty-command-printing before including the Config.kmk
|
---|
942 | # so that anyone overriding the message macros can take the implied
|
---|
943 | # verbosity level change into account.
|
---|
944 | #
|
---|
945 | ifndef KBUILD_VERBOSE
|
---|
946 | ifndef KBUILD_QUIET
|
---|
947 | ifneq ($(filter --pretty-command-printing,$(MAKEFLAGS)),)
|
---|
948 | export KBUILD_VERBOSE := 2
|
---|
949 | endif
|
---|
950 | endif
|
---|
951 | endif
|
---|
952 |
|
---|
953 |
|
---|
954 | #
|
---|
955 | # Legacy variable translation.
|
---|
956 | # These will be eliminated when switching to the next version.
|
---|
957 | #
|
---|
958 | ifdef USE_KOBJCACHE
|
---|
959 | ifndef KBUILD_USE_KOBJCACHE
|
---|
960 | export KBUILD_USE_KOBJCACHE := $(USE_KOBJCACHE)
|
---|
961 | endif
|
---|
962 | endif
|
---|
963 |
|
---|
964 |
|
---|
965 | #
|
---|
966 | # This is how we find the closest config.kmk.
|
---|
967 | # It's a little hacky but I think it works fine.
|
---|
968 | #
|
---|
969 | _CFGDIR := .
|
---|
970 | _CFGFILES := ./Config.kmk ./config.kmk
|
---|
971 | define def_include_config
|
---|
972 | $(eval _CFGDIR := $(_CFGDIR)/$(dir))
|
---|
973 | _CFGFILES += $(_CFGDIR)/Config.kmk $(_CFGDIR)/config.kmk
|
---|
974 | endef
|
---|
975 | # walk down the _RELATIVE_ path specified by DEPTH.
|
---|
976 | $(foreach dir,$(subst /, ,$(DEPTH)), $(eval $(def_include_config)) )
|
---|
977 | # add the default config file.
|
---|
978 | _CFGFILE := $(firstword $(wildcard $(_CFGFILES) $(FILE_KBUILD_CONFIG)))
|
---|
979 | _CFGFILES :=
|
---|
980 | _CFGDIR :=
|
---|
981 | ifeq ($(_CFGFILE),)
|
---|
982 | $(error kBuild: no Config.kmk file found! Check the DEPTH: DEPTH='$(DEPTH)' PATH_CURRENT='$(PATH_CURRENT)')
|
---|
983 | endif
|
---|
984 |
|
---|
985 | # Include the config.kmk we found file (or the default one).
|
---|
986 | ifdef KBUILD_PROFILE_SELF
|
---|
987 | _KBUILD_TS_NOW := $(nanots )
|
---|
988 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - including $(_CFGFILE))
|
---|
989 | $(info stat: $(make-stats ))
|
---|
990 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
991 |
|
---|
992 | include $(_CFGFILE)
|
---|
993 |
|
---|
994 | _KBUILD_TS_NOW := $(nanots )
|
---|
995 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - included $(_CFGFILE))
|
---|
996 | $(info stat: $(make-stats ))
|
---|
997 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
998 | else
|
---|
999 | include $(_CFGFILE)
|
---|
1000 | endif
|
---|
1001 |
|
---|
1002 |
|
---|
1003 |
|
---|
1004 | #
|
---|
1005 | # Finalize a the central path variables now that we've included the Config.kmk file.
|
---|
1006 | #
|
---|
1007 | # This prevents some trouble when users override the defaults for these
|
---|
1008 | # variables and uses relative paths or paths with incorrect case.
|
---|
1009 | #
|
---|
1010 | PATH_OUT := $(abspath $(PATH_OUT))
|
---|
1011 | PATH_OBJ := $(abspath $(PATH_OBJ))
|
---|
1012 | PATH_TARGET := $(abspath $(PATH_TARGET))
|
---|
1013 | PATH_INS := $(abspath $(PATH_INS))
|
---|
1014 | PATH_BIN := $(abspath $(PATH_BIN))
|
---|
1015 | PATH_DLL := $(abspath $(PATH_DLL))
|
---|
1016 | PATH_SYS := $(abspath $(PATH_SYS))
|
---|
1017 | PATH_LIB := $(abspath $(PATH_LIB))
|
---|
1018 | PATH_DOC := $(abspath $(PATH_DOC))
|
---|
1019 |
|
---|
1020 |
|
---|
1021 | #
|
---|
1022 | # Setup the message style. The default one is inlined.
|
---|
1023 | #
|
---|
1024 | # See kBuild/msgstyles for more styles or use KBUILD_MSG_STYLE_PATHS
|
---|
1025 | # to create your own message style.
|
---|
1026 | #
|
---|
1027 | KBUILD_MSG_STYLE ?= default
|
---|
1028 | ifeq ($(KBUILD_MSG_STYLE),default)
|
---|
1029 | #
|
---|
1030 | # The 'default' style.
|
---|
1031 | #
|
---|
1032 |
|
---|
1033 | ## Fetch starting.
|
---|
1034 | # @param 1 Target name.
|
---|
1035 | MSG_FETCH ?= $(call MSG_L1,Fetching $1...)
|
---|
1036 | ## Re-fetch starting.
|
---|
1037 | # @param 1 Target name.
|
---|
1038 | MSG_REFETCH ?= $(call MSG_L1,Re-fetching $1...)
|
---|
1039 | ## Downloading a fetch component.
|
---|
1040 | # @param 1 Target name.
|
---|
1041 | # @param 2 The source URL.
|
---|
1042 | # @param 3 The destination file name.
|
---|
1043 | MSG_FETCH_DL ?= $(call MSG_L1,Downloading $1 - $2,=> $3)
|
---|
1044 | ## Checking a fetch component.
|
---|
1045 | # @param 1 Target name.
|
---|
1046 | # @param 2 The source URL.
|
---|
1047 | # @param 3 The destination file name.
|
---|
1048 | MSG_FETCH_CHK?= $(call MSG_L1,Checking $1 - $3, ($2))
|
---|
1049 | ## Unpacking a fetch component.
|
---|
1050 | # @param 1 Target name.
|
---|
1051 | # @param 2 The archive file name.
|
---|
1052 | # @param 3 The target directory.
|
---|
1053 | MSG_FETCH_UP ?= $(call MSG_L1,Unpacking $1 - $2 => $3)
|
---|
1054 | ## Fetch completed.
|
---|
1055 | # @param 1 Target name.
|
---|
1056 | MSG_FETCH_OK ?= $(call MSG_L1,Successfully fetched $1)
|
---|
1057 | ## Unfetch a fetch target.
|
---|
1058 | # @param 1 Target name.
|
---|
1059 | MSG_UNFETCH ?= $(call MSG_L1,Unfetching $1...)
|
---|
1060 | ## Compiling a source file.
|
---|
1061 | # @param 1 Target name.
|
---|
1062 | # @param 2 The source filename.
|
---|
1063 | # @param 3 The primary link output file name.
|
---|
1064 | # @param 4 The source type (C,CXX,OBJC,AS,RC,++).
|
---|
1065 | MSG_COMPILE ?= $(call MSG_L1,Compiling $1 - $2,=> $3)
|
---|
1066 | ## Tool
|
---|
1067 | # @param 1 The tool name (bin2c,...)
|
---|
1068 | # @param 2 Target name.
|
---|
1069 | # @param 3 The source filename.
|
---|
1070 | # @param 4 The primary output file name.
|
---|
1071 | MSG_TOOL ?= $(call MSG_L1,$1 $2 - $3,=> $4)
|
---|
1072 | ## Generate a file, typically a source file.
|
---|
1073 | # @param 1 Target name if applicable.
|
---|
1074 | # @param 2 Output file name.
|
---|
1075 | # @param 3 What it's generated from
|
---|
1076 | MSG_GENERATE ?= $(call MSG_L1,Generating $(if $1,$1 - )$2,$(if $3,from $3))
|
---|
1077 | ## Linking a bldprog/dll/program/sysmod target.
|
---|
1078 | # @param 1 Target name.
|
---|
1079 | # @param 2 The primary link output file name.
|
---|
1080 | # @param 3 The link tool operation (LINK_LIBRARY,LINK_PROGRAM,LINK_DLL,LINK_SYSMOD,++).
|
---|
1081 | MSG_LINK ?= $(call MSG_L1,Linking $1,=> $2)
|
---|
1082 | ## Merging a library into the target (during library linking).
|
---|
1083 | # @param 1 Target name.
|
---|
1084 | # @param 2 The output library name.
|
---|
1085 | # @param 3 The input library name.
|
---|
1086 | MSG_AR_MERGE ?= $(call MSG_L1,Merging $3 into $1, ($2))
|
---|
1087 | ## Creating a directory (build).
|
---|
1088 | # @param 1 Directory name.
|
---|
1089 | MSG_MKDIR ?= $(call MSG_L2,Creating directory $1)
|
---|
1090 | ## Cleaning.
|
---|
1091 | MSG_CLEAN ?= $(call MSG_L1,Cleaning...)
|
---|
1092 | ## Nothing.
|
---|
1093 | MSG_NOTHING ?= $(call MSG_L1,Did nothing in $(CURDIR))
|
---|
1094 | ## Pass
|
---|
1095 | # @param 1 The pass name.
|
---|
1096 | MSG_PASS ?= $(call MSG_L1,Pass - $1)
|
---|
1097 | ## Installing a bldprog/lib/dll/program/sysmod target.
|
---|
1098 | # @param 1 Target name.
|
---|
1099 | # @param 2 The source filename.
|
---|
1100 | # @param 3 The destination file name.
|
---|
1101 | MSG_INST_TRG ?= $(call MSG_L1,Installing $1 => $3)
|
---|
1102 | ## Installing a file (install target).
|
---|
1103 | # @param 1 The source filename.
|
---|
1104 | # @param 2 The destination filename.
|
---|
1105 | MSG_INST_FILE?= $(call MSG_L1,Installing $2,(<= $1))
|
---|
1106 | ## Installing a symlink.
|
---|
1107 | # @param 1 Symlink
|
---|
1108 | # @param 2 Link target
|
---|
1109 | MSG_INST_SYM ?= $(call MSG_L1,Installing symlink $1,=> $2)
|
---|
1110 | ## Installing a directory.
|
---|
1111 | # @param 1 Directory name.
|
---|
1112 | MSG_INST_DIR ?= $(call MSG_L1,Installing directory $1)
|
---|
1113 |
|
---|
1114 | else
|
---|
1115 | _KBUILD_MSG_STYLE_FILE := $(firstword $(foreach path, $(KBUILD_MSG_STYLE_PATHS) $(KBUILD_PATH)/msgstyles, $(wildcard $(path)/$(KBUILD_MSG_STYLE).kmk)))
|
---|
1116 | ifneq ($(_KBUILD_MSG_STYLE_FILE),)
|
---|
1117 | include $(_KBUILD_MSG_STYLE_FILE)
|
---|
1118 | else
|
---|
1119 | $(error kBuild: Can't find the style setup file for KBUILD_MSG_STYLE '$(KBUILD_MSG_STYLE)')
|
---|
1120 | endif
|
---|
1121 | endif
|
---|
1122 |
|
---|
1123 |
|
---|
1124 | #
|
---|
1125 | # Message macros.
|
---|
1126 | #
|
---|
1127 | # This is done after including Config.kmk as to allow for
|
---|
1128 | # KBUILD_QUIET and KBUILD_VERBOSE to be configurable.
|
---|
1129 | #
|
---|
1130 | ifdef KBUILD_QUIET
|
---|
1131 | # No output
|
---|
1132 | QUIET := @
|
---|
1133 | QUIET2:= @
|
---|
1134 | MSG_L1 =
|
---|
1135 | MSG_L2 =
|
---|
1136 | else
|
---|
1137 | ifndef KBUILD_VERBOSE
|
---|
1138 | # Default output level.
|
---|
1139 | QUIET := @
|
---|
1140 | QUIET2 := @
|
---|
1141 | MSG_L1 ?= %@$(ECHO) "kBuild: $1"
|
---|
1142 | MSG_L2 =
|
---|
1143 | else ifeq ($(KBUILD_VERBOSE),1)
|
---|
1144 | # A bit more output
|
---|
1145 | QUIET := @
|
---|
1146 | QUIET2 := @
|
---|
1147 | MSG_L1 ?= %@$(ECHO) "kBuild: $1 $2"
|
---|
1148 | MSG_L2 =
|
---|
1149 | else ifeq ($(KBUILD_VERBOSE),2)
|
---|
1150 | # Lot more output
|
---|
1151 | QUIET :=
|
---|
1152 | QUIET2 := @
|
---|
1153 | MSG_L1 ?= %@$(ECHO) "kBuild: $1 $2"
|
---|
1154 | MSG_L2 ?= %@$(ECHO) "kBuild: $1"
|
---|
1155 | else
|
---|
1156 | # maximal output.
|
---|
1157 | QUIET :=
|
---|
1158 | QUIET2 :=
|
---|
1159 | MSG_L1 ?= %@$(ECHO) "kBuild: $1 $2"
|
---|
1160 | MSG_L2 ?= %@$(ECHO) "kBuild: $1"
|
---|
1161 | endif
|
---|
1162 | endif
|
---|
1163 |
|
---|
1164 |
|
---|
1165 | #
|
---|
1166 | # Validate any KBUILD_BLD_TYPES additions and finally the KBUILD_TYPE.
|
---|
1167 | #
|
---|
1168 | if1of ($(KBUILD_BLD_TYPES), $(KBUILD_OSES))
|
---|
1169 | $(error kBuild: found KBUILD_BLD_TYPES in KBUILD_OSES!)
|
---|
1170 | endif
|
---|
1171 | if1of ($(KBUILD_BLD_TYPES), $(KBUILD_ARCHES))
|
---|
1172 | $(error kBuild: found KBUILD_BLD_TYPES in KBUILD_ARCHES!)
|
---|
1173 | endif
|
---|
1174 | if1of ($(KBUILD_OSES), $(KBUILD_ARCHES))
|
---|
1175 | $(error kBuild: found KBUILD_OSES in KBUILD_ARCHES!)
|
---|
1176 | endif
|
---|
1177 | ifn1of ($(KBUILD_TYPE), $(KBUILD_BLD_TYPES))
|
---|
1178 | $(error kBuild: KBUILD_TYPE(=$(KBUILD_TYPE)) is not found in KBUILD_BLD_TYPES(=$(KBUILD_BLD_TYPES))!)
|
---|
1179 | endif
|
---|
1180 |
|
---|
1181 |
|
---|
1182 |
|
---|
1183 | ifdef KBUILD_PROFILE_SELF
|
---|
1184 | _KBUILD_TS_HEADER_END := $(nanots )
|
---|
1185 | $(info prof: $(int-sub $(_KBUILD_TS_HEADER_END), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_HEADER_END), $(_KBUILD_TS_PREV)) - end of header.kmk)
|
---|
1186 | $(info stat: $(make-stats ))
|
---|
1187 | _KBUILD_TS_PREV := $(_KBUILD_TS_HEADER_END)
|
---|
1188 | endif
|
---|
1189 |
|
---|
1190 | # end-of-file-content
|
---|
1191 | __header_kmk__ := 1
|
---|
1192 | endif # __header_kmk__
|
---|
1193 |
|
---|