source: trunk/kBuild/header.kmk@ 3036

Last change on this file since 3036 was 3035, checked in by bird, 8 years ago

header.kmk: Added HOST_PATH_SEP.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 53.5 KB
Line 
1# $Id: header.kmk 3035 2017-05-09 15:57:48Z bird $
2## @file
3# kBuild - File included at top of a makefile.
4#
5
6#
7# Copyright (c) 2004-2015 knut st. osmundsen <bird-kBuild-spam-xiv@anduin.net>
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# As a special exception you are granted permission to include this file, via
27# the kmk include directive, as you wish without this in itself causing the
28# resulting makefile, program or whatever to be covered by the GPL license.
29# This exception does not however invalidate any other reasons why the makefile,
30# program, whatever should not be covered the GPL.
31#
32#
33
34ifndef __header_kmk__
35# start-of-file-content
36ifdef KBUILD_PROFILE_SELF
37 _KBUILD_TS_HEADER_START := $(nanots ) # just a dummy warm up query
38 $(info prof: since start - since previous -- event description)
39 ifeq ($(KBUILD_PROFILE_SELF),2)
40 $(info stat: $(make-stats ))
41 endif
42 _KBUILD_TS_HEADER_START := $(nanots )
43 _KBUILD_TS_PREV := $(_KBUILD_TS_HEADER_START)
44
45 _KBUILD_FMT_ELAPSED_EX = $(int-div $(int-add $(int-sub $1, $2),500000),1000000)ms
46 _KBUILD_FMT_ELAPSED = $(call _KBUILD_FMT_ELAPSED_EX,$(_KBUILD_TS_NOW),$1)
47
48define def_profile_self
49 _KBUILD_TS_NOW := $(nanots )
50 $(info prof: $(call _KBUILD_FMT_ELAPSED,$(_KBUILD_TS_HEADER_START)) - $(call _KBUILD_FMT_ELAPSED, $(_KBUILD_TS_PREV)) -- $(strip $1))
51 ifeq ($(KBUILD_PROFILE_SELF),2)
52 $(info stat: $(make-stats ))
53 endif
54 _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
55endef
56
57endif
58
59
60#
61# Check make version before we do anything else.
62#
63ifndef KMK_VERSION
64 $(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)
65endif
66ifneq ($(KBUILD_VERSION_MAJOR).$(KBUILD_VERSION_MINOR),0.1)
67 ifneq ($(KBUILD_VERSION_MAJOR),0)
68 $(warning kBuild: kmk major version mismatch! Expected '0' but found '$(KBUILD_VERSION_MAJOR)'!)
69 else
70 $(warning kBuild: kmk minor version mismatch! Expected '1' but found '$(KBUILD_VERSION_MINOR)'!)
71 endif
72else
73 if $(KBUILD_VERSION_PATCH) < 999
74 $(error kBuild: kmk version mismatch! Expected 0.1.999 or later. Actual version is $(KBUILD_VERSION).)
75 endif
76endif
77
78#
79# The revision in which this file was last modified.
80# This can be useful when using development versions of kBuild.
81#
82KMK_REVISION := $(patsubst %:,, $Rev: 3035 $ )
83
84
85#
86# Define the default goal.
87#
88.PHONY: all all_recursive
89all: all_recursive
90
91#
92# The phony FORCE target.
93#
94.PHONY: FORCE
95FORCE:
96
97
98#
99# Enable delete on error and second expansion of prerequisites and targets.
100#
101.DELETE_ON_ERROR:
102
103.SECONDEXPANSION:
104
105.SECONDTARGETEXPANSION:
106
107
108#
109# General purpose macros.
110#
111
112##
113# Newline character(s).
114define NL
115
116
117endef
118
119##
120# Tab character.
121TAB := $(subst ., ,.)
122
123##
124# Newline + tab characters (for generating commands).
125NLTAB = $(NL)$(TAB)
126
127##
128# Space character.
129SP := $(subst ., ,.)
130
131##
132# Hash character.
133define HASH
134#
135endef
136
137##
138# Colon character.
139COLON := :
140
141##
142# Semicolon character.
143SEMICOLON := ;
144
145##
146# Comma character.
147COMMA := ,
148
149##
150# Dot character.
151DOT := .
152
153##
154# Dollar character.
155DOLLAR := $$
156
157##
158# Equal character.
159EQUAL := =
160
161##
162# Percent character.
163PERCENT := %
164
165##
166# Single quote character.
167SQUOTE := '
168
169##
170# Double quote character.
171DQUOTE := "
172
173
174#
175# The list of standard build types in kBuild.
176#
177# This list can be extended in Config.kmk and it's possible to extend
178# (inherit) another build type.
179#
180KBUILD_BLD_TYPES := release profile debug
181
182
183#
184# The OSes, Architectures and CPUs that kBuild recognizes.
185#
186# When kBuild is ported to a new OS or architecture a unique keyword needs
187# to be assigned to it and added here. This strictness is required because
188# this keyword namespace is shared between OSes, architectures, cpus and
189# build types. (PORTME)
190#
191KBUILD_OSES := darwin dos dragonfly freebsd haiku l4 linux netbsd nt openbsd os2 solaris win os-agnostic
192KBUILD_ARCHES := x86 amd64 sparc32 sparc64 s390 s390x ppc32 ppc64 mips32 mips64 ia64 hppa32 hppa64 arm alpha noarch
193KBUILD_ARCHES_64 := amd64 sparc64 s390x ppc64 mips64 ia64 hppa64 alpha
194KBUILD_ARCHES_32 := x86 sparc32 s390 ppc32 mips32 hppa32 arm
195
196
197#
198# Mapping of kBuild OS + ARCH to GNU system type wildcards.
199# For use with the foreach/append/prepend and wildcard functions.
200#
201KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.darwin.x86 = i?86-apple-darwin*
202KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.darwin.amd64 = x86_64-apple-darwin* amd64-apple-darwin*
203KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.freebsd.x86 = i?86-*freebsd*
204KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.freebsd.amd64 = x86_64-*freebsd* amd64-*freebsd*
205KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.linux.x86 = i?86-*linux-gnu
206KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.linux.amd64 = x86_64-*linux-gnu amd64-*linux-gnu
207KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.netbsd.x86 = i?86-*netbsd*
208KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.netbsd.amd64 = x86_64-*netbsd* amd64-*netbsd*
209KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.os2.x86 = i?86-*os2*
210KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.solaris.x86 = i?86-*solaris2*
211KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.solaris.amd64 = amd64-*solaris2* x86_64-*solaris2*
212KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.solaris.sparc32 = sparc-*solaris2*
213KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.solaris.sparc64 = sparc64-*solaris2* sparcv9-*solaris2*
214KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.win.x86 = i?86-*mingw32* i?86-*msys* i?86-*cygwin*
215KBUILD_OSARCH_2_GNU_SYSTEM_TYPES.win.amd64 = x86_64-*mingw64* amd64-*mingw64* x86_64-*msys* amd64-*msys* x86_64-*cygwin* amd64-*cygwin*
216
217
218#
219# Set default build type.
220#
221ifndef KBUILD_TYPE
222 ifdef BUILD_TYPE
223 KBUILD_TYPE := $(BUILD_TYPE)
224 endif
225else ifdef BUILD_TYPE
226 ifneq ($(KBUILD_TYPE),$(BUILD_TYPE))
227 ifeq ($(origin KBUILD_TYPE):$(origin BUILD_TYPE),environment:command line)
228 KBUILD_TYPE := $(BUILD_TYPE)
229 else ifneq ($(origin KBUILD_TYPE):$(origin BUILD_TYPE),command line:environment)
230 $(error kBuild: KBUILD_TYPE and BUILD_TYPE disagree.)
231 endif
232 endif
233endif
234override BUILD_TYPE = $(KBUILD_TYPE)
235
236ifndef KBUILD_TYPE
237 KBUILD_TYPE := release
238else
239 if1of ($(KBUILD_TYPE), $(KBUILD_OSES) $(KBUILD_ARCHES))
240 $(error kBuild: The KBUILD_TYPE value '$(KBUILD_TYPE)' is an OS or architecture!)
241 endif
242 ifneq (.$(words $(KBUILD_TYPE)).$(KBUILD_TYPE).,.1.$(strip $(KBUILD_TYPE)).)
243 $(error kBuild: The KBUILD_TYPE value '$(KBUILD_TYPE)' contains spaces/tabs!)
244 endif
245endif
246
247
248#
249# Host platform legacy
250# kmk deals with this, so this is only temporary until I've rebuilt everything.
251#
252ifndef KBUILD_HOST
253 KBUILD_HOST := $(BUILD_PLATFORM)
254endif
255ifndef KBUILD_HOST_ARCH
256 KBUILD_HOST_ARCH := $(BUILD_PLATFORM_ARCH)
257endif
258ifndef KBUILD_HOST_CPU
259 KBUILD_HOST_CPU := $(BUILD_PLATFORM_CPU)
260endif
261
262
263#
264# Assert valid build platform variables.
265#
266# All these are set by kmk so they shouldn't be any trouble
267# unless the user starts messing about with environment variables.
268#
269ifneq (.$(words $(KBUILD_HOST)).$(KBUILD_HOST).,.1.$(strip $(KBUILD_HOST)).)
270 $(error kBuild: The KBUILD_HOST value '$(KBUILD_HOST)' contains spaces/tabs!)
271endif
272ifneq ($(words $(filter $(KBUILD_HOST),$(KBUILD_OSES))),1)
273 $(error kBuild: KBUILD_HOST value '$(KBUILD_HOST)' is not recognized (valid: $(KBUILD_OSES)))
274endif
275
276ifneq (.$(words $(KBUILD_HOST_ARCH)).$(KBUILD_HOST_ARCH).,.1.$(strip $(KBUILD_HOST_ARCH)).)
277 $(error kBuild: The KBUILD_HOST_ARCH value '$(KBUILD_HOST_ARCH)' contains spaces/tabs!)
278endif
279ifneq ($(words $(filter $(KBUILD_HOST_ARCH),$(KBUILD_ARCHES))),1)
280 $(error kBuild: KBUILD_HOST_ARCH value '$(KBUILD_HOST_ARCH)' is not recognized (valid: $(KBUILD_ARCHES)))
281endif
282
283ifeq ($(strip $(KBUILD_HOST_CPU)),)
284 KBUILD_HOST_CPU := blend
285else
286 ifneq (.$(words $(KBUILD_HOST_CPU)).$(KBUILD_HOST_CPU).,.1.$(strip $(KBUILD_HOST_CPU)).)
287 $(error kBuild: The KBUILD_HOST_CPU value '$(KBUILD_HOST_CPU)' contains spaces/tabs!)
288 endif
289 if1of ($(KBUILD_HOST_CPU), $(KBUILD_OSES) $(KBUILD_ARCHES))
290 $(error kBuild: The KBUILD_HOST_CPU value '$(KBUILD_HOST_CPU)' was found in the OS or architecture keywords!)
291 endif
292 ifeq ($(KBUILD_HOST_CPU),$(KBUILD_TYPE))
293 $(error kBuild: The KBUILD_HOST_CPU value '$(KBUILD_HOST_CPU)' is the same as the KBUILD_TYPE!)
294 endif
295endif
296
297
298#
299# Deal with target platform legacy.
300#
301ifndef KBUILD_TARGET
302 ifdef BUILD_TARGET
303 KBUILD_TARGET := $(BUILD_TARGET)
304 endif
305else ifdef BUILD_TARGET
306 ifneq ($(KBUILD_TARGET),$(BUILD_TARGET))
307 ifeq ($(origin KBUILD_TARGET):$(origin BUILD_TARGET),environment:command line)
308 KBUILD_TARGET := $(BUILD_TARGET)
309 else ifneq ($(origin KBUILD_TARGET):$(origin BUILD_TARGET),command line:environment)
310 $(error kBuild: KBUILD_TARGET and BUILD_TARGET disagree)
311 endif
312 endif
313endif
314override BUILD_TARGET = $(KBUILD_TARGET)
315
316ifndef KBUILD_TARGET_ARCH
317 ifdef BUILD_TARGET_ARCH
318 KBUILD_TARGET_ARCH := $(BUILD_TARGET_ARCH)
319 endif
320else ifdef BUILD_TARGET_ARCH
321 ifneq ($(KBUILD_TARGET_ARCH),$(BUILD_TARGET_ARCH))
322 ifeq ($(origin KBUILD_TARGET_ARCH):$(origin BUILD_TARGET_ARCH),environment:command line)
323 KBUILD_TARGET_ARCH := $(BUILD_TARGET_ARCH)
324 else ifneq ($(origin KBUILD_TARGET_ARCH):$(origin BUILD_TARGET_ARCH),command line:environment)
325 $(error kBuild: KBUILD_TARGET_ARCH and BUILD_TARGET_ARCH disagree)
326 endif
327 endif
328endif
329override BUILD_TARGET_ARCH = $(KBUILD_TARGET_ARCH)
330
331ifndef KBUILD_TARGET_CPU
332 ifdef BUILD_TARGET_CPU
333 KBUILD_TARGET_CPU := $(BUILD_TARGET_CPU)
334 endif
335else ifdef BUILD_TARGET_CPU
336 ifneq ($(KBUILD_TARGET_CPU),$(BUILD_TARGET_CPU))
337 ifeq ($(origin KBUILD_TARGET_CPU):$(origin BUILD_TARGET_CPU),environment:command line)
338 KBUILD_TARGET_CPU := $(BUILD_TARGET_CPU)
339 else ifneq ($(origin KBUILD_TARGET_CPU):$(origin BUILD_TARGET_CPU),command line:environment)
340 $(error kBuild: KBUILD_TARGET_CPU and BUILD_TARGET_CPU disagree)
341 endif
342 endif
343endif
344override BUILD_TARGET_CPU = $(KBUILD_TARGET_CPU)
345
346
347#
348# Assert or set default target platform.
349# When not defined use the corresponding KBUILD_HOST value.
350#
351ifndef KBUILD_TARGET
352 KBUILD_TARGET := $(KBUILD_HOST)
353else
354 ifneq (.$(words $(KBUILD_TARGET)).$(KBUILD_TARGET).,.1.$(strip $(KBUILD_TARGET)).)
355 $(error kBuild: The KBUILD_TARGET value '$(KBUILD_TARGET)' contains spaces/tabs!)
356 endif
357 ifneq ($(words $(filter $(KBUILD_TARGET),$(KBUILD_OSES))),1)
358 $(error kBuild: KBUILD_TARGET value '$(KBUILD_TARGET)' is not recognized (valid: $(KBUILD_OSES)))
359 endif
360endif
361
362ifndef KBUILD_TARGET_ARCH
363 KBUILD_TARGET_ARCH := $(KBUILD_HOST_ARCH)
364else
365 ifneq (.$(words $(KBUILD_TARGET_ARCH)).$(KBUILD_TARGET_ARCH).,.1.$(strip $(KBUILD_TARGET_ARCH)).)
366 $(error kBuild: The KBUILD_TARGET_ARCH value '$(KBUILD_TARGET_ARCH)' contains spaces/tabs!)
367 endif
368 ifneq ($(words $(filter $(KBUILD_TARGET_ARCH),$(KBUILD_ARCHES))),1)
369 $(error kBuild: KBUILD_TARGET_ARCH value '$(KBUILD_TARGET_ARCH)' is not recognized (valid: $(KBUILD_ARCHES)))
370 endif
371endif
372
373ifndef KBUILD_TARGET_CPU
374 KBUILD_TARGET_CPU := $(KBUILD_HOST_CPU)
375else ifeq ($(strip $(KBUILD_TARGET_CPU)),)
376 ifeq ($(KBUILD_TARGET_ARCH),$(KBUILD_HOST_ARCH))
377 KBUILD_TARGET_CPU := $(KBUILD_HOST_CPU)
378 else
379 KBUILD_TARGET_CPU := blend
380 endif
381else
382 ifneq (.$(words $(KBUILD_TARGET_CPU)).$(KBUILD_TARGET_CPU).,.1.$(strip $(KBUILD_TARGET_CPU)).)
383 $(error kBuild: The KBUILD_TARGET_CPU value '$(KBUILD_TARGET_CPU)' contains spaces/tabs!)
384 endif
385 if1of ($(KBUILD_TARGET_CPU), $(KBUILD_OSES) $(KBUILD_ARCHES))
386 $(error kBuild: The KBUILD_TARGET_CPU value was found in the OS or architecture keywords!)
387 endif
388 ifeq ($(KBUILD_TARGET_CPU),$(KBUILD_TYPE))
389 $(error kBuild: The KBUILD_TARGET_CPU value '$(KBUILD_TARGET_CPU)' is the same as the KBUILD_TYPE!)
390 endif
391endif
392
393# Short hand for $(KBUILD_TARGET).$(KBUILD_TARGET_ARCH).
394KBUILD_TARGET_DOT_ARCH = $(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)
395KBUILD_HOST_DOT_ARCH = $(KBUILD_HOST).$(KBUILD_TARGET_ARCH)
396
397
398#
399# Paths and stuff.
400#
401
402# Adjust DEPTH first.
403DEPTH := $(strip $(DEPTH))
404ifeq ($(DEPTH),)
405 DEPTH := .
406endif
407
408## PATH_CURRENT is the current directory (getcwd).
409PATH_CURRENT := $(abspath $(CURDIR))
410## PATH_SUB_CURRENT points to current directory of the current makefile.
411# Meaning that it will change value as we enter and exit sub-makefiles.
412PATH_SUB_CURRENT := $(PATH_CURRENT)
413## PATH_ROOT points to the project root directory.
414PATH_ROOT := $(abspath $(PATH_CURRENT)/$(DEPTH))
415## PATH_SUB_ROOT points to the directory of the top-level makefile.
416ifneq ($(strip $(SUB_DEPTH)),)
417 SUB_DEPTH := $(strip $(SUB_DEPTH))
418 PATH_SUB_ROOT := $(abspath $(PATH_CURRENT)/$(SUB_DEPTH))
419else
420 PATH_SUB_ROOT := $(PATH_CURRENT)
421endif
422
423## CURSUBDIR is PATH_SUB_ROOT described relative to PATH_ROOT.
424# This variable is used to determin where the object files and other output goes.
425ifneq ($(PATH_ROOT),$(PATH_SUB_ROOT))
426 CURSUBDIR := $(patsubst $(PATH_ROOT)/%,%,$(PATH_SUB_ROOT))
427else
428 CURSUBDIR := .
429endif
430
431# Install directory layout. Relative to PATH_INS.
432KBUILD_INST_PATHS := BIN DLL SYS LIB DOC DEBUG SBIN LIBEXEC SHARE
433INST_BIN = bin/
434if1of ($(KBUILD_TARGET), win)
435INST_DLL = bin/
436else
437INST_DLL = lib/
438endif
439if1of ($(KBUILD_TARGET), os2 win)
440INST_SYS = drivers/
441else
442INST_SYS = kernel/
443endif
444INST_LIB = lib/
445INST_DOC = share/doc/
446INST_DEBUG = debug/
447INST_SBIN = sbin/
448INST_LIBEXEC = libexec/
449INST_SHARE = share/
450
451# Staging directory layout. Relative to PATH_STAGE.
452STAGE_BIN = $(INST_BIN)
453STAGE_DLL = $(INST_DLL)
454STAGE_SYS = $(INST_SYS)
455STAGE_LIB = $(INST_LIB)
456STAGE_DOC = $(INST_DOC)
457STAGE_DEBUG = $(INST_DEBUG)
458STAGE_SBIN = $(INST_SBIN)
459STAGE_LIBEXEC = $(INST_LIBEXEC)
460STAGE_SHARE = $(INST_SHARE)
461
462# Install and staging directory paths.
463$(foreach path, $(KBUILD_INST_PATHS), \
464 $(eval PATH_STAGE_$(path) = $$(patsubst %/,%,$$(PATH_STAGE)/$$(STAGE_$(path)))) \
465 $(eval PATH_INST_$(path) = $$(patsubst %/,%,$$(PATH_INS)/$$(INST_$(path)))) \
466)
467
468# Output directories.
469ifndef PATH_OUT_BASE
470 PATH_OUT_BASE := $(PATH_ROOT)/out
471endif
472ifndef PATH_OUT
473 ifdef BUILD_TARGET_SUB # (BUILD_TARGET_SUB is not currently recognized by kBuild in any other places - obsolete)
474 PATH_OUT = $(PATH_OUT_BASE)/$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH).$(BUILD_TARGET_SUB)/$(KBUILD_TYPE)
475 else
476 PATH_OUT = $(PATH_OUT_BASE)/$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)/$(KBUILD_TYPE)
477 endif
478endif # !define PATH_OUT
479PATH_OBJCACHE = $(PATH_OUT_BASE)/kObjCache
480PATH_OBJ = $(PATH_OUT)/obj
481PATH_TARGET = $(PATH_OBJ)/$(CURSUBDIR)
482PATH_STAGE = $(PATH_OUT)/stage
483ifndef PATH_INS
484 ifdef DESTROOT
485PATH_INS = $(DESTROOT)
486 else
487PATH_INS = $(PATH_OUT)/dist
488 endif
489endif
490
491# Tripwire obsolete PATH defines.
492PATH_BIN = $(error kBuild: PATH_BIN is obsoleted in kBuild 0.1.2. Use PATH_STAGE_BIN or PATH_INST_BIN instead)
493PATH_DLL = $(error kBuild: PATH_LIB is obsoleted in kBuild 0.1.2. Use PATH_STAGE_DLL or PATH_INST_DLL instead)
494PATH_LIB = $(error kBuild: PATH_LIB is obsoleted in kBuild 0.1.2. Use PATH_STAGE_LIB or PATH_INST_LIB instead)
495PATH_SYS = $(error kBuild: PATH_SYS is obsoleted in kBuild 0.1.2. Use PATH_STAGE_SYS or PATH_INST_SYS instead)
496PATH_DOC = $(error kBuild: PATH_DOC is obsoleted in kBuild 0.1.2. Use PATH_STAGE_DOC or PATH_INST_DOC instead)
497
498# Development tool tree.
499ifndef KBUILD_DEVTOOLS
500 ifeq ($(PATH_DEVTOOLS),)
501 KBUILD_DEVTOOLS = $(PATH_ROOT)/tools
502 else
503 KBUILD_DEVTOOLS := $(PATH_DEVTOOLS)
504 endif
505endif
506KBUILD_DEVTOOLS_TRG ?= $(KBUILD_DEVTOOLS)/$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)
507KBUILD_DEVTOOLS_HST ?= $(KBUILD_DEVTOOLS)/$(KBUILD_HOST).$(KBUILD_HOST_ARCH)
508
509if1of ($(KBUILD_TARGET_ARCH), amd64 hppa64 mips64 ppc64 s390x sparc64)
510 ifeq ($(KBUILD_TARGET_ARCH),amd64)
511 KBUILD_DEVTOOLS_TRG_ALT ?= $(KBUILD_DEVTOOLS)/$(KBUILD_TARGET).x86
512 else ifeq ($(KBUILD_TARGET_ARCH),hppa64)
513 KBUILD_DEVTOOLS_TRG_ALT ?= $(KBUILD_DEVTOOLS)/$(KBUILD_TARGET).hppa32
514 else ifeq ($(KBUILD_TARGET_ARCH),mips64)
515 KBUILD_DEVTOOLS_TRG_ALT ?= $(KBUILD_DEVTOOLS)/$(KBUILD_TARGET).mips32
516 else ifeq ($(KBUILD_TARGET_ARCH),ppc64)
517 KBUILD_DEVTOOLS_TRG_ALT ?= $(KBUILD_DEVTOOLS)/$(KBUILD_TARGET).ppc32
518 else ifeq ($(KBUILD_TARGET_ARCH),s390x)
519 KBUILD_DEVTOOLS_TRG_ALT ?= $(KBUILD_DEVTOOLS)/$(KBUILD_TARGET).s390
520 else ifeq ($(KBUILD_TARGET_ARCH),sparc64)
521 KBUILD_DEVTOOLS_TRG_ALT ?= $(KBUILD_DEVTOOLS)/$(KBUILD_TARGET).sparc32
522 endif
523endif
524
525if1of ($(KBUILD_HOST_ARCH), amd64 hppa64 mips64 ppc64 s390x sparc64)
526 ifeq ($(KBUILD_HOST_ARCH),amd64)
527 KBUILD_DEVTOOLS_HST_ALT ?= $(KBUILD_DEVTOOLS)/$(KBUILD_HOST).x86
528 else ifeq ($(KBUILD_HOST_ARCH),hppa64)
529 KBUILD_DEVTOOLS_HST_ALT ?= $(KBUILD_DEVTOOLS)/$(KBUILD_HOST).hppa32
530 else ifeq ($(KBUILD_HOST_ARCH),mips64)
531 KBUILD_DEVTOOLS_HST_ALT ?= $(KBUILD_DEVTOOLS)/$(KBUILD_HOST).mips32
532 else ifeq ($(KBUILD_HOST_ARCH),ppc64)
533 KBUILD_DEVTOOLS_HST_ALT ?= $(KBUILD_DEVTOOLS)/$(KBUILD_HOST).ppc32
534 else ifeq ($(KBUILD_HOST_ARCH),s390x)
535 KBUILD_DEVTOOLS_HST_ALT ?= $(KBUILD_DEVTOOLS)/$(KBUILD_HOST).s390
536 else ifeq ($(KBUILD_HOST_ARCH),sparc64)
537 KBUILD_DEVTOOLS_HST_ALT ?= $(KBUILD_DEVTOOLS)/$(KBUILD_HOST).sparc32
538 endif
539endif
540
541# Deprecated legacy names.
542PATH_DEVTOOLS ?= $(KBUILD_DEVTOOLS)
543PATH_DEVTOOLS_TRG ?= $(KBUILD_DEVTOOLS_TRG)
544PATH_DEVTOOLS_BLD ?= $(KBUILD_DEVTOOLS_TRG)
545PATH_DEVTOOLS_TRG_ALT ?= $(KBUILD_DEVTOOLS_TRG_ALT)
546PATH_DEVTOOLS_HST ?= $(KBUILD_DEVTOOLS_HST)
547PATH_DEVTOOLS_HST_ALT ?= $(KBUILD_DEVTOOLS_HST_ALT)
548
549# KBUILD_PATH / PATH_KBUILD is determined by kmk.
550ifndef KBUILD_PATH
551 KBUILD_PATH := $(PATH_KBUILD)
552endif
553ifeq ($(strip $(KBUILD_PATH)),)
554 $(error kBuild: KBUILD_PATH is missing or empty! kmk is supposed to set it.)
555endif
556# KBUILD_BIN_PATH / PATH_KBUILD_BIN is determined by kmk.
557ifndef KBUILD_BIN_PATH
558 KBUILD_BIN_PATH := $(PATH_KBUILD_BIN)
559endif
560ifeq ($(strip $(KBUILD_BIN_PATH)),)
561 $(error kBuild: KBUILD_BIN_PATH is missing or empty! kmk is supposed to set it.)
562endif
563
564# kBuild files which might be of interest.
565FILE_KBUILD_HEADER := $(KBUILD_PATH)/header.kmk
566#FILE_KBUILD_CONFIG := $(KBUILD_PATH)/config.kmk
567FILE_KBUILD_FOOTER := $(KBUILD_PATH)/footer.kmk
568FILE_KBUILD_SUB_HEADER := $(KBUILD_PATH)/subheader.kmk
569FILE_KBUILD_SUB_FOOTER := $(KBUILD_PATH)/subfooter.kmk
570
571## MAKEFILE is the name of the main makefile.
572MAKEFILE := $(firstword $(MAKEFILE_LIST))
573## MAKEFILE_CURRENT is the name of the current makefile.
574# This is updated everything a sub-makefile is included.
575MAKEFILE_CURRENT := $(MAKEFILE)
576
577
578## @todo this should be done via SUFF_XYZ.target/host...
579
580#
581# Build platform setup.
582# (PORTME)
583#
584if1of ($(KBUILD_HOST), win nt)
585# Win, Win32, Win64, NT.
586EXEC_X86_WIN32 :=
587HOSTSUFF_EXE := .exe
588HOST_PATH_SEP := $(SEMICOLON)
589
590# OS/2.
591else ifeq ($(KBUILD_HOST),os2)
592EXEC_X86_WIN32 := innopec.exe
593HOSTSUFF_EXE := .exe
594HOST_PATH_SEP := $(SEMICOLON)
595
596else if1of ($(KBUILD_HOST), freebsd dragonfly linux openbsd netbsd)
597# Unix (like) systems with wine.
598EXEC_X86_WIN32 := wine
599HOSTSUFF_EXE :=
600HOST_PATH_SEP := $(COLON)
601
602else
603# Unix (like) systems without wine.
604EXEC_X86_WIN32 := false
605HOSTSUFF_EXE :=
606HOST_PATH_SEP := $(COLON)
607endif
608
609
610#
611# Build target setup.
612# (PORTME)
613#
614SUFF_DEP := .dep
615SUFF_BIN :=
616if1of ($(KBUILD_TARGET), win nt os2)
617SUFF_OBJ := .obj
618SUFF_LIB := .lib
619SUFF_DLL := .dll
620SUFF_EXE := .exe
621SUFF_SYS := .sys
622SUFF_RES := .res
623else ifeq ($(KBUILD_TARGET),l4)
624SUFF_OBJ := .o
625SUFF_LIB := .a
626SUFF_DLL := .s.so
627SUFF_EXE :=
628SUFF_SYS := .a
629SUFF_RES :=
630else ifeq ($(KBUILD_TARGET),darwin)
631SUFF_OBJ := .o
632SUFF_LIB := .a
633SUFF_DLL := .dylib
634SUFF_EXE :=
635SUFF_SYS :=
636SUFF_RES :=
637else
638SUFF_OBJ := .o
639SUFF_LIB := .a
640SUFF_DLL := .so
641SUFF_EXE :=
642 if1of ($(KBUILD_TARGET), dragonfly freebsd linux netbsd openbsd) ## @todo check netbsd and openbsd.
643SUFF_SYS := .ko
644 else
645SUFF_SYS :=
646 endif
647SUFF_RES :=
648endif
649
650#
651# Standard kBuild tools.
652#
653ifeq ($(KMK),kmk)
654KMK := $(KBUILD_BIN_PATH)/kmk$(HOSTSUFF_EXE)
655endif
656MAKE := $(KMK)
657
658GMAKE := $(KBUILD_BIN_PATH)/kmk_gmake$(HOSTSUFF_EXE)
659
660#DEP_EXT := $(KBUILD_BIN_PATH)/kDep$(HOSTSUFF_EXE)
661#DEP_INT := $(KBUILD_BIN_PATH)/kDep$(HOSTSUFF_EXE)
662#DEP := $(DEP_INT)
663
664DEP_IDB_EXT := $(KBUILD_BIN_PATH)/kDepIDB$(HOSTSUFF_EXE)
665DEP_IDB_INT := kmk_builtin_kDepIDB
666DEP_IDB := $(DEP_IDB_INT)
667
668DEP_OBJ_EXT := $(KBUILD_BIN_PATH)/kDepObj$(HOSTSUFF_EXE)
669DEP_OBJ_INT := kmk_builtin_kDepObj
670DEP_OBJ := $(DEP_OBJ_INT)
671
672DEP_PRE := $(KBUILD_BIN_PATH)/kDepPre$(HOSTSUFF_EXE)
673
674KOBJCACHE_EXT := $(KBUILD_BIN_PATH)/kObjCache$(HOSTSUFF_EXE)
675KOBJCACHE := $(KOBJCACHE_EXT)
676
677KLIBTWEAKER_EXT := $(KBUILD_BIN_PATH)/kLibTweaker$(HOSTSUFF_EXE)
678KLIBTWEAKER := $(KLIBTWEAKER_EXT)
679
680APPEND_EXT := $(KBUILD_BIN_PATH)/kmk_append$(HOSTSUFF_EXE)
681APPEND_INT := kmk_builtin_append
682APPEND := $(APPEND_INT)
683
684CAT_EXT := $(KBUILD_BIN_PATH)/kmk_cat$(HOSTSUFF_EXE)
685CAT_INT := kmk_builtin_cat
686CAT := $(CAT_INT)
687
688CHMOD_EXT := $(KBUILD_BIN_PATH)/kmk_chmod$(HOSTSUFF_EXE)
689CHMOD_INT := kmk_builtin_chmod
690CHMOD := $(CHMOD_INT)
691
692CMP_EXT := $(KBUILD_BIN_PATH)/kmk_cmp$(HOSTSUFF_EXE)
693CMP_INT := kmk_builtin_cmp
694CMP := $(CMP_INT)
695
696CP_EXT := $(KBUILD_BIN_PATH)/kmk_cp$(HOSTSUFF_EXE)
697CP_INT := kmk_builtin_cp
698CP := $(CP_INT)
699
700ECHO_EXT := $(KBUILD_BIN_PATH)/kmk_echo$(HOSTSUFF_EXE)
701ECHO_INT := kmk_builtin_echo
702ECHO := $(ECHO_INT)
703
704EXPR_EXT := $(KBUILD_BIN_PATH)/kmk_expr$(HOSTSUFF_EXE)
705EXPR_INT := kmk_builtin_expr
706EXPR := $(EXPR_INT)
707
708INSTALL_EXT := $(KBUILD_BIN_PATH)/kmk_install$(HOSTSUFF_EXE)
709INSTALL_INT := kmk_builtin_install
710INSTALL := $(INSTALL_INT)
711
712LN_EXT := $(KBUILD_BIN_PATH)/kmk_ln$(HOSTSUFF_EXE)
713LN_INT := kmk_builtin_ln
714LN := $(LN_INT)
715
716MD5SUM_EXT := $(KBUILD_BIN_PATH)/kmk_md5sum$(HOSTSUFF_EXE)
717MD5SUM_INT := kmk_builtin_md5sum
718MD5SUM := $(MD5SUM_INT)
719
720MKDIR_EXT := $(KBUILD_BIN_PATH)/kmk_mkdir$(HOSTSUFF_EXE)
721MKDIR_INT := kmk_builtin_mkdir
722MKDIR := $(MKDIR_INT)
723
724MV_EXT := $(KBUILD_BIN_PATH)/kmk_mv$(HOSTSUFF_EXE)
725MV_INT := kmk_builtin_mv
726MV := $(MV_INT)
727
728PRINTF_EXT := $(KBUILD_BIN_PATH)/kmk_printf$(HOSTSUFF_EXE)
729PRINTF_INT := kmk_builtin_printf
730PRINTF := $(PRINTF_INT)
731
732REDIRECT_EXT:= $(KBUILD_BIN_PATH)/kmk_redirect$(HOSTSUFF_EXE)
733if $(KBUILD_KMK_REVISION) > 2911
734REDIRECT_INT:= kmk_builtin_redirect
735else
736REDIRECT_INT:= $(REDIRECT_EXT)
737endif
738REDIRECT := $(REDIRECT_INT)
739
740RM_EXT := $(KBUILD_BIN_PATH)/kmk_rm$(HOSTSUFF_EXE)
741RM_INT := kmk_builtin_rm
742RM := $(RM_INT)
743
744RMDIR_EXT := $(KBUILD_BIN_PATH)/kmk_rmdir$(HOSTSUFF_EXE)
745RMDIR_INT := kmk_builtin_rmdir
746RMDIR := $(RMDIR_INT)
747
748SED_EXT := $(KBUILD_BIN_PATH)/kmk_sed$(HOSTSUFF_EXE)
749SED_INT := $(SED_EXT)
750SED := $(SED_EXT)
751
752SLEEP_INT := kmk_builtin_sleep
753SLEEP_EXT := $(KBUILD_BIN_PATH)/kmk_sleep$(HOSTSUFF_EXE)
754SLEEP := $(SLEEP_EXT)
755
756TEST_EXT := $(KBUILD_BIN_PATH)/kmk_test$(HOSTSUFF_EXE)
757TEST_INT := kmk_builtin_test
758TEST := $(TEST_INT)
759
760TIME_EXT := $(KBUILD_BIN_PATH)/kmk_time$(HOSTSUFF_EXE)
761TIME_INT := $(TIME_EXT)
762TIME := $(TIME_INT)
763
764# Our default shell is the Almquist shell from *BSD.
765ASH := $(KBUILD_BIN_PATH)/kmk_ash$(HOSTSUFF_EXE)
766MAKESHELL := $(ASH)
767SHELL := $(ASH)
768export SHELL MAKESHELL
769
770# Symlinking is problematic on some platforms...
771LN_SYMLINK := $(LN) -s
772
773# When copying to the staging area, use hard links to save time and space.
774ifndef KBUILD_NO_HARD_LINKING
775 INSTALL_STAGING := $(INSTALL) --hard-link-files-when-possible
776else
777 INSTALL_STAGING := $(INSTALL)
778endif
779
780
781#
782# Some Functions.
783# The lower cased ones are either fallbacks or candidates for functions.c.
784#
785
786## ABSPATH - make paths absolute.
787# This implementation is clumsy and doesn't resolve '..' and '.' components.
788#
789# @param $1 The paths to make absolute.
790# @obsolete Use the GNU make function $(abspath) directly now.
791ABSPATH = $(abspath $(1))$(warning ABSPATH is deprecated, use abspath directly!)
792
793## DIRDEP - make create directory dependencies.
794#
795# @param $1 The paths to the directories which must be created.
796DIRDEP = $(foreach path,$(patsubst %/,%,$(1)),$(path)/)
797
798## Cygwin kludge.
799# This converts /cygdrive/x/% to x:%.
800#
801# @param $1 The paths to make native.
802# @remark This macro is pretty much obsolete since we don't use cygwin base make.
803ifneq ($(patsubst /cygdrive/%,%,$(CURDIR)),$(CURDIR))
804 CYGPATHMIXED = $(foreach path,$(1)\
805 ,$(if $(patsubst /cygdrive/%,,$(path)),$(path),$(patsubst $(strip $(firstword $(subst /, ,$(patsubst /cygdrive/%,%,$(path)))))/%,$(strip $(firstword $(subst /, ,$(patsubst /cygdrive/%,%,$(path))))):/%,$(patsubst /cygdrive/%,%,$(path)))))
806else
807 CYGPATHMIXED = $(1)
808endif
809
810## Removes the drive letter from a path (if it has one)
811# @param $1 the path
812no-drive = $(word $(words $(subst :, ,$(1))),$(subst :, ,$(1)))
813
814## Removes the root slash from a path (if it has one)
815# @param $1 the path
816no-root-slash = $(patsubst /%,%,$(1))
817
818##
819# Similar to firstword, except it returns the value of first defined variable.
820# @param $1 list of variables to probe.
821define FIRST-DEFINED-VAR
822local .RETURN := $(strip $(firstdefined $1, value))
823endef
824
825## Figure out where to put object files.
826# @param $1 real target name.
827# @param $2 normalized main target
828TARGET_BASE = $(PATH_TARGET)/$(2)/$(call no-root-slash,$(call no-drive,$(1)))
829
830## Figure out where to put object files.
831# @param $1 normalized main target
832TARGET_PATH = $(PATH_TARGET)/$(1)
833
834##
835# Checks if the specified short option ($1) is found in the flags ($2),
836# assuming getopt style options.
837#
838# @returns $3 if present, $4 not.
839#
840# @param $1 The option (single char!).
841# @param $2 The option arguments.
842# @param $3 Eval and return if present.
843# @param $4 Eval and return if not present.
844#
845# @todo May confuse option values starting with '-' for options.
846# @remarks Invoke like this: $(evalcall KB_FN_OPT_TEST_SHORT,d,$(flags),present,not-present)
847#
848define KB_FN_OPT_TEST_SHORT
849local options := $(translate $(strip $(filter -%,$(filter-out --%,$2))),$(SP)-,)
850local .RETURN := $(if-expr $(pos $1,$(options)) != 0,$3,$4)
851endef
852
853##
854# Checks if the specified long option ($1) is found in the flags ($2),
855# assuming getopt style options.
856#
857# @returns $3 if present, $4 not.
858#
859# @param $1 The long option, dashes included. No % chars.
860# @param $2 The option arguments.
861# @param $3 Eval and return if present.
862# @param $4 Eval and return if not present.
863#
864# @todo May confuse option values starting with '--' for options.
865# @remarks Invoke like this: $(evalcall KBFN_OPT_TEST_SHORT,--defined,$(flags),present,not-present)
866#
867define KB_FN_OPT_TEST_LONG
868local options := $(filter-out =delete=%,$(subst :, =delete=,$(subst =, =delete=,$2)))
869local .RETURN := $(if-expr "$(filter $1,$(options))" != "",$3,$4)
870endef
871
872##
873# Checks if the specified short ($1) or long ($2) option is found in the flags ($2),
874# assuming getopt style options.
875#
876# @returns $4 if present, $5 not.
877#
878# @param $1 The short option (single char!).
879# @param $2 The long option, dashes included. No % chars.
880# @param $3 The option arguments.
881# @param $4 Eval and return if present.
882# @param $5 Eval and return if not present.
883#
884# @todo May confuse option values starting with '--' for options.
885# @remarks Invoke like this: $(evalcall KB_FN_OPT_TEST_SHORT_LONG,d,--defined,$(flags),present,not-present)
886#
887define KB_FN_OPT_TEST_SHORT_LONG
888local short_options := $(translate $(strip $(filter -%,$(filter-out --%,$3))),$(SP)-,)
889local long_options := $(filter-out =delete=%,$(subst :, =delete=,$(subst =, =delete=,$3)))
890local .RETURN := $(if-expr $(pos $1,$(short_options)) != 0 || "$(filter $2,$(long_options))" != "",$4,$5)
891endef
892
893##
894# Make an assignment to a deprecated variable.
895#
896# @param $1 The variable name.
897# @param $2 The value.
898# @param $3 The variable to use instead.
899#
900ifdef KBUILD_WITH_DEPREATED_AS_ERROR
901 KB_FN_ASSIGN_DEPRECATED = $(eval $(subst :,$$(COLON),$1) = $2$$(error $1 is deprecated, use $3 instead))
902else
903 KB_FN_ASSIGN_DEPRECATED = $(eval $(subst :,$$(COLON),$1) = $2$$(warning $1 is deprecated, use $3 instead))
904endif
905
906##
907# Show an assertion message.
908#
909# @param $1 The assertion name.
910# @param $2 The details.
911#
912define KB_FN_ASSERT_MSG
913$(info !! kBuild $1 Assertion Failed !!)
914ifdef target
915 $(info !! target: $(target))
916 local varloc := $(where $(target))
917 if "$(varloc)" == "undefined"
918 local varloc := $(where $(target)_TEMPLATE)
919 endif
920 if "$(varloc)" == "undefined"
921 local varloc := $(where $(target)_SOURCES)
922 endif
923 if "$(varloc)" == "undefined"
924 local varloc := $(where $(target)_EXTENDS)
925 endif
926 if "$(varloc)" == "undefined"
927 local varloc := $(where target)
928 endif
929 ifneq ($(varloc),)
930 $(info !! location: $(varloc))
931 else
932 $(info !! probable location: $($(target)_DEFPATH)/Makefile.kmk)
933 endif
934endif
935$(info !! $2)
936$(error fixme)
937endef
938
939##
940# Throw an error if the given path $1 isn't absolute and assertions are enabled.
941#
942# @param $1 The name of the path variable to check.
943#
944ifdef KBUILD_INTERNAL_STRICT
945 KB_FN_ASSERT_ABSPATH = $(if-expr "$(abspath $($(strip $1)))" != "$(strip $($(strip $1)))",\
946 $(evalcall KB_FN_ASSERT_MSG,abspath,$1 is:$(NLTAB)'$($(strip $1))'$(NLTAB)expected:$(NLTAB)'$(abspath $($(strip $1)))'))
947else
948 KB_FN_ASSERT_ABSPATH :=
949endif
950
951
952#
953# Somewhat simple solution for automatic command dependencies.
954#
955
956##
957# Advanced version of KB_FN_AUTO_CMD_DEPS_COMMANDS_EX where you set
958# the dependency file name yourself.
959#
960# After or before the recipe do $(call KB_FN_AUTO_CMD_DEPS_EX,<recipe-target>,<dep-file>).
961#
962# @param 1 dep file.
963define KB_FN_AUTO_CMD_DEPS_COMMANDS_EX
964 %$(QUIET2)$(RM) -f -- "$1"
965 %$(QUIET2)$(APPEND) "$1" 'define AUTO_CMD_DEP_$(translate $@,:,_)_PREV_CMDS'
966 %$(QUIET2)$(APPEND) -c "$1" '$@'
967 %$(QUIET2)$(APPEND) "$1" 'endef'
968endef
969
970##
971# Advanced version of KB_FN_AUTO_CMD_DEPS
972#
973# @param 1 recipe name
974# @param 2 dep file.
975KB_FN_AUTO_CMD_DEPS_EX = $(eval includedep $2)$(eval _DEPFILES_INCLUDED += $2)$1: .MUST_MAKE = $$(comp-cmds-ex $$(AUTO_CMD_DEP_$(translate $1,:,_)_PREV_CMDS),$$(commands $1),FORCE)
976
977##
978# $(call KB_FN_AUTO_CMD_DEPS_COMMANDS) as the first command in a recipe to
979# automatically generate command dependencies.
980# After or before the recipe do $(call KB_FN_AUTO_CMD_DEPS,<recipe-target>).
981define KB_FN_AUTO_CMD_DEPS_COMMANDS
982 %$(QUIET2)$(RM) -f -- "$@.auto-dep"
983 %$(QUIET2)$(APPEND) "$@.auto-dep" 'define AUTO_CMD_DEP_$(translate $@,:,_)_PREV_CMDS'
984 %$(QUIET2)$(APPEND) -c "$@.auto-dep" '$@'
985 %$(QUIET2)$(APPEND) "$@.auto-dep" 'endef'
986endef
987
988##
989# Call before or after defining a recipe that you want automatic command
990# dependencies on. The recipe must start off by $(call KB_FN_AUTO_CMD_DEPS_COMMANDS).
991#
992# @param 1 recipe name
993KB_FN_AUTO_CMD_DEPS = $(call KB_FN_AUTO_CMD_DEPS_EX,$1,$1.auto-dep)
994
995
996#
997# Initialize some of the globals which the Config.kmk and
998# others can add stuff to if they like for processing in the footer.
999#
1000
1001## KBUILD_TEMPLATE_PATHS
1002# List a paths (separated by space) where templates can be found.
1003KBUILD_TEMPLATE_PATHS :=
1004
1005## KBUILD_TOOL_PATHS
1006# List of paths (separated by space) where tools can be found.
1007KBUILD_TOOL_PATHS :=
1008
1009## KBUILD_SDK_PATHS
1010# List of paths (separated by space) where SDKs can be found.
1011KBUILD_SDK_PATHS :=
1012
1013## KBUILD_UNIT_PATHS
1014# List of paths (separated by space) where units (USES) can be found.
1015KBUILD_UNIT_PATHS :=
1016
1017## KBUILD_DEFAULT_PATHS
1018# List of paths (separated by space) to search for stuff as a last resort.
1019KBUILD_DEFAULT_PATHS :=
1020
1021## Proritized list of the default makefile when walking subdirectories.
1022# The user can overload this list.
1023DEFAULT_MAKEFILE := Makefile.kmk makefile.kmk Makefile makefile
1024
1025## KBUILD_SRC_HANDLERS
1026# The list of source handlers, pair of extension and handler.
1027# The user can overload this list to provide additional or custom
1028# handlers. On a per-target/template see SRC_HANDLERS.
1029KBUILD_SRC_HANDLERS := \
1030 .c:def_src_handler_c \
1031 .C:def_src_handler_c \
1032.cxx:def_src_handler_cxx \
1033.CXX:def_src_handler_cxx \
1034.cpp:def_src_handler_cxx \
1035.CPP:def_src_handler_cxx \
1036 .cc:def_src_handler_cxx \
1037 .CC:def_src_handler_cxx \
1038 .m:def_src_handler_objc \
1039 .M:def_src_handler_objcxx \
1040 .mm:def_src_handler_objcxx \
1041.asm:def_src_handler_asm \
1042.ASM:def_src_handler_asm \
1043 .s:def_src_handler_asm \
1044 .S:def_src_handler_asm \
1045 .rc:def_src_handler_rc \
1046.obj:def_src_handler_obj \
1047 .o:def_src_handler_obj \
1048.res:def_src_handler_obj
1049
1050## PROPS_TOOLS
1051# This is a subset of PROPS_SINGLE.
1052PROPS_TOOLS := TOOL CTOOL CXXTOOL OBJCTOOL OBJCXXTOOL ASTOOL RCTOOL ARTOOL LDTOOL FETCHTOOL UNPACKTOOL PATCHTOOL
1053
1054## PROPS_SINGLE
1055# The list of non-accumulative target properties.
1056# A Config.kmk file can add it's own properties to this list and kBuild
1057# will do the necessary inheritance for templates, sdks, tools and targets.
1058PROPS_SINGLE := $(PROPS_TOOLS) TEMPLATE INSTTYPE INST STAGE NOINST BLD_TYPE BLD_TRG BLD_TRG_ARCH BLD_TRG_CPU FETCHDIR \
1059 OBJSUFF COBJSUFF CXXOBJSUFF OBJCOBJSUFF OBJCXXOBJSUFF ASOBJSUFF RCOBJSUFF SYSSUFF BINSUFF EXESUFF DLLSUFF LIBSUFF ARLIBSUFF \
1060 MODE UID GID LD_DEBUG DEBUG_INSTTYPE DEBUG_INST DEBUG_STAGE
1061## PROPS_SINGLE_LNK
1062# Subset of PROPS_SINGLE which applies to all linkable targets.
1063PROPS_SINGLE_LNK := $(filter-out FETCHTOOL UNPACKTOOL PATCHTOOL FETCHDIR, $(PROPS_SINGLE))
1064
1065## PROPS_DEFERRED
1066# This list of non-accumulative target properties which are or may be
1067# functions, and thus should not be expanded until the very last moment.
1068PROPS_DEFERRED := INSTFUN INSTALLER PRE_CMDS POST_CMDS PRE_INST_CMDS POST_INST_CMDS \
1069 PRE_FILE_CMDS POST_FILE_CMDS PRE_SYMLINK_CMDS POST_SYMLINK_CMDS PRE_DIRECTORY_CMDS POST_DIRECTORY_CMDS \
1070 NAME SONAME
1071
1072## PROPS_ACCUMULATE_R
1073# The list of accumulative target properties where the right most value/flag
1074# is the 'most significant'.
1075# A Config.kmk file can add it's own properties to this list and kBuild
1076# will do the necessary inheritance from templates to targets.
1077PROPS_ACCUMULATE_R := \
1078 DEPS LNK_DEPS ORDERDEPS LNK_ORDERDEPS DEFS \
1079 ARFLAGS \
1080 CFLAGS CDEFS \
1081 CXXFLAGS CXXDEFS \
1082 OBJCFLAGS OBJCDEFS \
1083 OBJCXXFLAGS OBJCXXDEFS \
1084 ASFLAGS ASDEFS \
1085 RCFLAGS RCDEFS \
1086 LDFLAGS \
1087 IDFLAGS IFFLAGS EXEC_IFFLAGS ISFLAGS \
1088 FETCHFLAGS UNPACKFLAGS PATCHFLAGS
1089## PROPS_ACCUMULATE_R_LNK
1090# Subset of PROPS_ACCUMULATE_R which applies to all linkable targets.
1091PROPS_ACCUMULATE_R_LNK := $(filter-out ARFLAGS LDFLAGS EXEC_IFFLAGS FETCHFLAGS UNPACKFLAGS PATCHFLAGS, $(PROPS_ACCUMULATE_R))
1092
1093## PROPS_ACCUMULATE
1094# The list of accumulative target properties where the left most value/flag
1095# is the 'most significant'.
1096# A Config.kmk file can add it's own properties to this list and kBuild
1097# will do the necessary inheritance from templates to targets.
1098PROPS_ACCUMULATE_L := \
1099 SDKS USES SOURCES EXEC_SOURCES SRC_HANDLERS INTERMEDIATES \
1100 INCS CINCS CXXINCS OBJCINCS OBJCXXINCS ASINCS RCINCS \
1101 LIBS LIBPATH \
1102 DIRS BLDDIRS CLEAN
1103## PROPS_ACCUMULATE_L_LNK
1104# Subset of PROPS_ACCUMULATE_L which applies to all linkable targets.
1105PROPS_ACCUMULATE_L_LNK := $(filter-out LIBS LIBPATH EXEC_SOURCES DIRS, $(PROPS_ACCUMULATE_L))
1106
1107## PROPS_ALL
1108# List of all the properties.
1109PROPS_ALL = $(PROPS_SINGLE) $(PROPS_DEFERRED) $(PROPS_ACCUMULATE_L) $(PROPS_ACCUMULATE_R)
1110
1111## @name Properties valid on programs (BLDPROGS and PROGRAMS)
1112## @{
1113PROPS_PROGRAMS_SINGLE := $(PROPS_SINGLE_LNK) LDTOOL EXESUFF
1114PROPS_PROGRAMS_DEFERRED := $(PROPS_DEFERRED)
1115PROPS_PROGRAMS_ACCUMULATE_R := $(PROPS_ACCUMULATE_R_LNK) LDFLAGS
1116PROPS_PROGRAMS_ACCUMULATE_L := $(PROPS_ACCUMULATE_L_LNK) LIBS LIBPATH
1117## @}
1118
1119## @name Properties valid on libraries (LIBRARIES and IMPORT_LIBS)
1120## @{
1121PROPS_LIBRARIES_SINGLE := $(PROPS_SINGLE_LNK) ARTOOL LIBSUFF ARLIBSUFF LIBSUFF
1122PROPS_LIBRARIES_DEFERRED := $(filter-out SONAME,$(PROPS_DEFERRED))
1123PROPS_LIBRARIES_ACCUMULATE_R := $(PROPS_ACCUMULATE_R_LNK) ARFLAGS
1124PROPS_LIBRARIES_ACCUMULATE_L := $(PROPS_ACCUMULATE_L_LNK)
1125## @}
1126
1127## @name Properties valid on dlls (DLLS)
1128## @{
1129PROPS_DLLS_SINGLE := $(PROPS_SINGLE_LNK) LDTOOL DLLSUFF LIBSUFF
1130PROPS_DLLS_DEFERRED := $(PROPS_DEFERRED)
1131PROPS_DLLS_ACCUMULATE_R := $(PROPS_ACCUMULATE_R_LNK) LDFLAGS
1132PROPS_DLLS_ACCUMULATE_L := $(PROPS_ACCUMULATE_L_LNK) LIBS LIBPATH
1133## @}
1134
1135## @name Properties valid on system modules (SYSMODS)
1136## @{
1137PROPS_SYSMODS_SINGLE := $(PROPS_SINGLE_LNK) LDTOOL SYSSUFF
1138PROPS_SYSMODS_DEFERRED := $(PROPS_DEFERRED)
1139PROPS_SYSMODS_ACCUMULATE_R := $(PROPS_ACCUMULATE_R_LNK) LDFLAGS
1140PROPS_SYSMODS_ACCUMULATE_L := $(PROPS_ACCUMULATE_L_LNK) LIBS LIBPATH
1141## @}
1142
1143## @name Properties valid on misc binaries (MISCBINS)
1144## @{
1145PROPS_MISCBINS_SINGLE := $(PROPS_SINGLE_LNK) LDTOOL BINSUFF
1146PROPS_MISCBINS_DEFERRED := $(PROPS_DEFERRED)
1147PROPS_MISCBINS_ACCUMULATE_R := $(PROPS_ACCUMULATE_R_LNK) LDFLAGS
1148PROPS_MISCBINS_ACCUMULATE_L := $(PROPS_ACCUMULATE_L_LNK) LIBS LIBPATH
1149## @}
1150
1151## @name Properties valid on installs (INSTALLS)
1152## @{
1153PROPS_INSTALLS_SINGLE := TOOL TEMPLATE INSTTYPE INST STAGE NOINST BLD_TYPE BLD_TRG BLD_TRG_ARCH BLD_TRG_CPU MODE UID GID
1154PROPS_INSTALLS_DEFERRED := INSTFUN INSTALLER PRE_FILE_CMDS POST_FILE_CMDS PRE_SYMLINK_CMDS POST_SYMLINK_CMDS \
1155 PRE_DIRECTORY_CMDS POST_DIRECTORY_CMDS
1156PROPS_INSTALLS_ACCUMULATE_R := DEPS ORDERDEPS GOALS INST_ONLY_GOALS STAGE_ONLY_GOALS IFFLAGS EXEC_IFFLAGS
1157PROPS_INSTALLS_ACCUMULATE_L := SOURCES EXEC_SOURCES DIRS CLEAN
1158## @}
1159
1160## @name Properties valid on fetches (FETCHES)
1161## @{
1162PROPS_FETCHES_SINGLE := TOOL TEMPLATE FETCHTOOL UNPACKTOOL PATCHTOOL INST FETCHDIR
1163PROPS_FETCHES_DEFERRED :=
1164PROPS_FETCHES_ACCUMULATE_R := FETCHFLAGS UNPACKFLAGS PATCHFLAGS
1165PROPS_FETCHES_ACCUMULATE_L := SOURCES CLEAN
1166## @}
1167
1168## KBUILD_COMPILE_CATEGTORIES
1169# Tools categories for compiling.
1170KBUILD_COMPILE_CATEGTORIES := AS C CXX OBJC OBJCXX RC
1171
1172## KBUILD_GENERIC_CATEGORIES
1173# Generic tool categories.
1174KBUILD_GENERIC_CATEGORIES := FETCH UNPACK PATCH $(addprefix LINK_,LIBRARY PROGRAM DLL SYSMOD MISCBIN)
1175
1176## PROPS_TOOLS_ONLY
1177# Properties found only on tools.
1178# This is expanded in a deferred manner, so it will pick up changes made to
1179# KBUILD_COMPILE_CATEGTORIES and KBUILD_GENERIC_CATEGORIES made by units.
1180PROPS_TOOLS_ONLY = \
1181 $(foreach cat, $(KBUILD_COMPILE_CATEGTORIES), \
1182 COMPILE_$(cat)_CMDS \
1183 COMPILE_$(cat)_OUTPUT \
1184 COMPILE_$(cat)_OUTPUT_MAYBE \
1185 COMPILE_$(cat)_DEPEND \
1186 COMPILE_$(cat)_DEPORD \
1187 COMPILE_$(cat)_USES_KOBJCACHE ) \
1188 $(foreach cat, $(KBUILD_GENERIC_CATEGORIES), \
1189 $(cat)_CMDS \
1190 $(cat)_OUTPUT \
1191 $(cat)_OUTPUT_MAYBE \
1192 $(cat)_DEPEND \
1193 $(cat)_DEPORD ))
1194
1195
1196#
1197# Here is a special 'hack' to prevent innocent environment variables being
1198# picked up and treated as properties. (The most annoying example of why
1199# this is necessary is the Visual C++ commandline with it's LIBPATH.)
1200#
1201# Define KBUILD_DONT_KILL_ENV_PROPS in the env. or on the commandline to
1202# disable this 'hack'.
1203#
1204ifndef KBUILD_DONT_KILL_ENV_PROPS
1205
1206define def_nuke_environment_prop
1207ifeq ($(origin $(prop)),environment)
1208$(prop) =
1209endif
1210endef
1211$(foreach prop, $(PROPS_ALL) \
1212 FETCHES PATCHES BLDPROGS LIBRARIES IMPORT_LIBS DLLS PROGRAMS SYSMODS MISCBINS INSTALLS OTHERS \
1213 SUBDIRS MAKEFILES BLDDIRS \
1214 ,$(eval $(value def_nuke_environment_prop)))
1215
1216endif # KBUILD_DONT_KILL_ENV_PROPS
1217
1218
1219#
1220# Pass configuration.
1221#
1222# The PASS_<passname>_trgs variable is listing the targets.
1223# The PASS_<passname>_vars variable is listing the target variables.
1224# The PASS_<passname>_pass variable is the lowercased passname.
1225#
1226
1227## PASS: fetches
1228# This pass fetches and unpacks things needed to complete the build.
1229PASS_FETCHES := Fetches
1230PASS_FETCHES_trgs :=
1231PASS_FETCHES_vars := _FETCHES
1232PASS_FETCHES_pass := fetches
1233
1234## PASS: patches
1235# This pass applies patches.
1236PASS_PATCHES := Patches
1237PASS_PATCHES_trgs :=
1238PASS_PATCHES_vars := _PATCHES
1239PASS_PATCHES_pass := patches
1240
1241## PASS: bldprogs
1242# This pass builds targets which are required for building the rest.
1243PASS_BLDPROGS := Build Programs
1244PASS_BLDPROGS_trgs :=
1245PASS_BLDPROGS_vars := _BLDPROGS
1246PASS_BLDPROGS_pass := bldprogs
1247
1248## PASS: libraries
1249# This pass builds library targets.
1250PASS_LIBRARIES := Libraries
1251PASS_LIBRARIES_trgs :=
1252PASS_LIBRARIES_vars := _LIBS _IMPORT_LIBS _OTHER_LIBRARIES
1253PASS_LIBRARIES_pass := libraries
1254
1255## PASS: binaries
1256# This pass builds dll targets.
1257PASS_DLLS := DLLs
1258PASS_DLLS_trgs :=
1259PASS_DLLS_vars := _DLLS _OTHER_DLLS
1260PASS_DLLS_pass := dlls
1261
1262## PASS: binaries
1263# This pass builds binary targets, i.e. programs, system modules and stuff.
1264PASS_BINARIES := Programs
1265PASS_BINARIES_trgs :=
1266PASS_BINARIES_vars := _PROGRAMS _SYSMODS _MISC_BINS _OTHER_BINARIES
1267PASS_BINARIES_pass := binaries
1268
1269## PASS: others
1270# This pass builds other targets.
1271PASS_OTHERS := Other Stuff
1272PASS_OTHERS_trgs :=
1273PASS_OTHERS_vars := _OTHERS
1274PASS_OTHERS_pass := others
1275
1276## PASS: staging
1277# This pass installs the built entities to a sandbox area.
1278## @todo split this up into build install (to sandbox) and real installation.
1279PASS_STAGING := Staging
1280PASS_STAGING_trgs :=
1281PASS_STAGING_vars := _STAGE_DIRS _INSTALLS _STAGE_FILES _DEBUG_STAGE_DIRS _DEBUG_STAGE_FILES
1282PASS_STAGING_pass := staging
1283
1284## PASS: install
1285# This pass installs the built entities to where they will be used (using
1286# DESTROOT or PATH_INS to indicate where this is).
1287PASS_INSTALLS := Install
1288PASS_INSTALLS_trgs :=
1289PASS_INSTALLS_vars := _INSTALLS_DIRS _INSTALLS_FILES _DEBUG_INSTALL_DIRS _DEBUG_INSTALL_FILES
1290PASS_INSTALLS_pass := installs
1291
1292## PASS: testing
1293# This pass processes custom rules for executing tests.
1294PASS_TESTING := Tests
1295PASS_TESTING_trgs :=
1296PASS_TESTING_vars := _TESTING
1297PASS_TESTING_pass := testing
1298
1299## PASS: packing
1300# This pass processes custom packing rules.
1301PASS_PACKING := Packing
1302PASS_PACKING_trgs :=
1303PASS_PACKING_vars := _PACKING
1304PASS_PACKING_pass := packing
1305
1306## PASS: clean
1307# This pass removes all generated files.
1308PASS_CLEAN := Clean
1309PASS_CLEAN_trgs := do-clean
1310PASS_CLEAN_vars :=
1311PASS_CLEAN_pass := clean
1312
1313## PASS: nothing
1314# This pass just walks the tree.
1315PASS_NOTHING := Nothing
1316PASS_NOTHING_trgs := do-nothing
1317PASS_NOTHING_vars :=
1318PASS_NOTHING_pass := nothing
1319
1320## DEFAULT_PASSES
1321# The default passes and their order.
1322DEFAULT_PASSES := BLDPROGS LIBRARIES DLLS BINARIES OTHERS STAGING
1323
1324## PASSES
1325# The passes that should be defined. This must include
1326# all passes mentioned by DEFAULT_PASSES.
1327PASSES := FETCHES PATCHES $(DEFAULT_PASSES) INSTALLS TESTING PACKING CLEAN NOTHING
1328
1329
1330#
1331# Check for --pretty-command-printing before including the Config.kmk
1332# so that anyone overriding the message macros can take the implied
1333# verbosity level change into account.
1334#
1335ifndef KBUILD_VERBOSE
1336 ifndef KBUILD_QUIET
1337 ifeq ($(KMK_OPTS_PRETTY_COMMAND_PRINTING),1)
1338 export KBUILD_VERBOSE := 2
1339 endif
1340 endif
1341endif
1342
1343
1344#
1345# Legacy variable translation.
1346# These will be eliminated when switching to the next version.
1347#
1348ifdef USE_KOBJCACHE
1349 ifndef KBUILD_USE_KOBJCACHE
1350 export KBUILD_USE_KOBJCACHE := $(USE_KOBJCACHE)
1351 endif
1352endif
1353
1354
1355#
1356# Library path searching hints (target OS + arch).
1357#
1358# KBUILD_LIB_SEARCH_SUBS - Subdirs typically containing the right libraries.
1359# KBUILD_LIB_SEARCH_ROOTS - Roots to search for library subdirs.
1360# KBUILD_LIB_SEARCH_PATHS - ROOTS + SUBS.
1361#
1362ifeq ($(KBUILD_TARGET),darwin)
1363 KBUILD_LIB_SEARCH_ROOTS := \
1364 /usr/ \
1365 /Developer/usr/
1366 KBUILD_LIB_SEARCH_SUBS := lib/
1367
1368else if1of ($(KBUILD_TARGET), freebsd netbsd openbsd dragonfly)
1369 KBUILD_LIB_SEARCH_ROOTS := \
1370 / \
1371 /usr/ \
1372 /usr/local/
1373 KBUILD_LIB_SEARCH_SUBS := lib/
1374
1375else ifeq ($(KBUILD_TARGET),linux)
1376 ifeq ($(realpath /bin),/usr/bin)
1377 KBUILD_LIB_SEARCH_ROOTS := \
1378 /usr/ \
1379 / \
1380 /usr/local/
1381 else
1382 KBUILD_LIB_SEARCH_ROOTS := \
1383 / \
1384 /usr/ \
1385 /usr/local/
1386 endif
1387 ifeq ($(KBUILD_TARGET_ARCH),amd64)
1388 KBUILD_LIB_SEARCH_SUBS := \
1389 lib/x86_64-linux-gnu/ \
1390 lib64/ \
1391 lib/
1392 else ifeq ($(KBUILD_TARGET_ARCH),x86)
1393 KBUILD_LIB_SEARCH_SUBS := \
1394 lib/i686-linux-gnu/ \
1395 lib/i386-linux-gnu/ \
1396 lib32/ \
1397 lib/
1398 else
1399 KBUILD_LIB_SEARCH_SUBS := lib/
1400 endif
1401
1402else ifeq ($(KBUILD_TARGET),solaris)
1403 KBUILD_LIB_SEARCH_ROOTS := \
1404 / \
1405 /usr/ \
1406 /usr/sfw/ \
1407 /usr/local/ \
1408 /sw/
1409 ifeq ($(KBUILD_TARGET_ARCH),amd64)
1410 KBUILD_LIB_SEARCH_SUBS := lib/amd64/ lib/
1411 else ifeq ($(KBUILD_TARGET_ARCH),sparc64)
1412 KBUILD_LIB_SEARCH_SUBS := lib/sparcv9/ lib/
1413 else
1414 KBUILD_LIB_SEARCH_SUBS := lib/
1415 endif
1416
1417else
1418 KBUILD_LIB_SEARCH_SUBS :=
1419 KBUILD_LIB_SEARCH_ROOTS :=
1420endif
1421KBUILD_LIB_SEARCH_PATHS := $(foreach root, $(KBUILD_LIB_SEARCH_ROOTS), $(addprefix $(root),$(KBUILD_LIB_SEARCH_SUBS)))
1422
1423
1424#
1425# This is how we find the closest config.kmk.
1426# It's a little hacky but I think it works fine.
1427#
1428_CFGDIR := .
1429_CFGFILES := ./Config.kmk ./config.kmk
1430define def_include_config
1431$(eval _CFGDIR := $(_CFGDIR)/$(dir))
1432_CFGFILES += $(_CFGDIR)/Config.kmk $(_CFGDIR)/config.kmk
1433endef
1434# walk down the _RELATIVE_ path specified by DEPTH.
1435$(foreach dir,$(subst /, ,$(DEPTH)), $(eval $(def_include_config)) )
1436# add the default config file.
1437_CFGFILE := $(firstword $(wildcard $(_CFGFILES) $(FILE_KBUILD_CONFIG)))
1438_CFGFILES :=
1439_CFGDIR :=
1440ifeq ($(_CFGFILE),)
1441$(error kBuild: no Config.kmk file found! Check the DEPTH: DEPTH='$(DEPTH)' PATH_CURRENT='$(PATH_CURRENT)')
1442endif
1443
1444# Include the config.kmk we found file (or the default one).
1445ifdef KBUILD_PROFILE_SELF
1446 $(evalcall def_profile_self, including $(_CFGFILE))
1447 include $(_CFGFILE)
1448 $(evalcall def_profile_self, included $(_CFGFILE))
1449else
1450 include $(_CFGFILE)
1451endif
1452
1453
1454
1455#
1456# Finalize a the central path variables now that we've included the Config.kmk file.
1457#
1458# This prevents some trouble when users override the defaults for these
1459# variables and uses relative paths or paths with incorrect case.
1460#
1461PATH_OUT_BASE := $(abspath $(PATH_OUT_BASE))
1462PATH_OUT := $(abspath $(PATH_OUT))
1463PATH_OBJ := $(abspath $(PATH_OBJ))
1464PATH_TARGET := $(abspath $(PATH_TARGET))
1465PATH_INS := $(abspath $(PATH_INS))
1466PATH_STAGE := $(abspath $(PATH_STAGE))
1467
1468# Finalize the install and staging directory layouts.
1469define def_kbuild_finalize_inst
1470local val := $(strip $($(y)_$(x)))
1471ifeq ($(val),)
1472 $(error kBuild: '$(y)_$(x)' is set to an empty value.)
1473endif
1474ifneq ($(words $(val)),1)
1475 $(error kBuild: The '$(y)_$(x)' value '$(val)' should not contain spaces.)
1476endif
1477ifneq ($(pos \,$(val)), 0)
1478 $(error kBuild: The '$(y)_$(x)' value '$(val)' contains DOS slashes: not allowed.)
1479endif
1480ifneq ($(pos $(COLON),$(val)), 0)
1481 $(error kBuild: The '$(y)_$(x)' value '$(val)' contains colon: not allowed.)
1482endif
1483ifneq ($(substr $(val),-1), /)
1484 $(error kBuild: The '$(y)_$(x)' value '$(val)' has no trailing slash.)
1485endif
1486if $(pos /../,$(val)) != 0 || "$(substr $(val), 3)" == "../"
1487 $(error kBuild: The '$(y)_$(x)' value '$(val)' contains dot-dot escape.)
1488endif
1489$($(y)_$(x) := $(val)
1490
1491local val := $(strip $(PATH_$(y)_$(x)))
1492ifeq ($(val),)
1493 $(error kBuild: 'PATH_$(y)_$(x)' is set to an empty value.)
1494endif
1495PATH_$(y)_$(x) := $(val)
1496endef
1497$(foreach y, INST STAGE, $(foreach x, $(KBUILD_INST_PATHS), $(evalcall def_kbuild_finalize_inst)))
1498
1499# No abspath for devtools since they might've been referenced already and we
1500# don't want conflicting variable expansions.
1501KBUILD_DEVTOOLS := $(KBUILD_DEVTOOLS)
1502KBUILD_DEVTOOLS_TRG := $(KBUILD_DEVTOOLS_TRG)
1503KBUILD_DEVTOOLS_TRG_ALT := $(KBUILD_DEVTOOLS_TRG_ALT)
1504KBUILD_DEVTOOLS_HST := $(KBUILD_DEVTOOLS_HST)
1505KBUILD_DEVTOOLS_HST_ALT := $(KBUILD_DEVTOOLS_HST_ALT)
1506
1507
1508#
1509# Setup the message style. The default one is inlined.
1510#
1511# See kBuild/msgstyles for more styles or use KBUILD_MSG_STYLE_PATHS
1512# to create your own message style.
1513#
1514KBUILD_MSG_STYLE ?= default
1515ifeq ($(KBUILD_MSG_STYLE),default)
1516 #
1517 # The 'default' style.
1518 #
1519
1520 ## Fetch starting.
1521 # @param 1 Target name.
1522 MSG_FETCH ?= $(call MSG_L1,Fetching $1...)
1523 ## Re-fetch starting.
1524 # @param 1 Target name.
1525 MSG_REFETCH ?= $(call MSG_L1,Re-fetching $1...)
1526 ## Downloading a fetch component.
1527 # @param 1 Target name.
1528 # @param 2 The source URL.
1529 # @param 3 The destination file name.
1530 MSG_FETCH_DL ?= $(call MSG_L1,Downloading $1 - $2,=> $3)
1531 ## Checking a fetch component.
1532 # @param 1 Target name.
1533 # @param 2 The source URL.
1534 # @param 3 The destination file name.
1535 MSG_FETCH_CHK?= $(call MSG_L1,Checking $1 - $3, ($2))
1536 ## Unpacking a fetch component.
1537 # @param 1 Target name.
1538 # @param 2 The archive file name.
1539 # @param 3 The target directory.
1540 MSG_FETCH_UP ?= $(call MSG_L1,Unpacking $1 - $2 => $3)
1541 ## Fetch completed.
1542 # @param 1 Target name.
1543 MSG_FETCH_OK ?= $(call MSG_L1,Successfully fetched $1)
1544 ## Unfetch a fetch target.
1545 # @param 1 Target name.
1546 MSG_UNFETCH ?= $(call MSG_L1,Unfetching $1...)
1547 ## Compiling a source file.
1548 # @param 1 Target name.
1549 # @param 2 The source filename.
1550 # @param 3 The primary link output file name.
1551 # @param 4 The source type (C,CXX,OBJC,AS,RC,++).
1552 MSG_COMPILE ?= $(call MSG_L1,Compiling $1 - $2,=> $3)
1553 ## Tool
1554 # @param 1 The tool name (bin2c,...)
1555 # @param 2 Target name.
1556 # @param 3 The source filename.
1557 # @param 4 The primary output file name.
1558 MSG_TOOL ?= $(call MSG_L1,$1 $2 - $3,=> $4)
1559 ## Generate a file, typically a source file.
1560 # @param 1 Target name if applicable.
1561 # @param 2 Output file name.
1562 # @param 3 What it's generated from
1563 MSG_GENERATE ?= $(call MSG_L1,Generating $(if $1,$1 - )$2,$(if $3,from $3))
1564 ## Linking a bldprog/dll/program/sysmod target.
1565 # @param 1 Target name.
1566 # @param 2 The primary link output file name.
1567 # @param 3 The link tool operation (LINK_LIBRARY,LINK_PROGRAM,LINK_DLL,LINK_SYSMOD,++).
1568 MSG_LINK ?= $(call MSG_L1,Linking $1,=> $2)
1569 ## Merging a library into the target (during library linking).
1570 # @param 1 Target name.
1571 # @param 2 The output library name.
1572 # @param 3 The input library name.
1573 MSG_AR_MERGE ?= $(call MSG_L1,Merging $3 into $1, ($2))
1574 ## Creating a directory (build).
1575 # @param 1 Directory name.
1576 MSG_MKDIR ?= $(call MSG_L2,Creating directory $1)
1577 ## Cleaning.
1578 MSG_CLEAN ?= $(call MSG_L1,Cleaning...)
1579 ## Nothing.
1580 MSG_NOTHING ?= $(call MSG_L1,Did nothing in $(CURDIR))
1581 ## Pass
1582 # @param 1 The pass name.
1583 MSG_PASS ?= $(call MSG_L1,Pass - $1)
1584 ## Installing a bldprog/lib/dll/program/sysmod target.
1585 # @param 1 Target name.
1586 # @param 2 The source filename.
1587 # @param 3 The destination file name.
1588 MSG_INST_TRG ?= $(call MSG_L1,Installing $1 => $3)
1589 ## Installing a file (install target).
1590 # @param 1 The source filename.
1591 # @param 2 The destination filename.
1592 MSG_INST_FILE?= $(call MSG_L1,Installing $2,(<= $1))
1593 ## Installing a symlink.
1594 # @param 1 Symlink
1595 # @param 2 Link target
1596 MSG_INST_SYM ?= $(call MSG_L1,Installing symlink $1,=> $2)
1597 ## Installing a directory.
1598 # @param 1 Directory name.
1599 MSG_INST_DIR ?= $(call MSG_L1,Installing directory $1)
1600
1601else
1602 _KBUILD_MSG_STYLE_FILE := $(firstword $(foreach path, $(KBUILD_MSG_STYLE_PATHS) $(KBUILD_PATH)/msgstyles, $(wildcard $(path)/$(KBUILD_MSG_STYLE).kmk)))
1603 ifneq ($(_KBUILD_MSG_STYLE_FILE),)
1604 include $(_KBUILD_MSG_STYLE_FILE)
1605 else
1606 $(error kBuild: Can't find the style setup file for KBUILD_MSG_STYLE '$(KBUILD_MSG_STYLE)')
1607 endif
1608endif
1609
1610
1611#
1612# Message macros.
1613#
1614# This is done after including Config.kmk as to allow for
1615# KBUILD_QUIET and KBUILD_VERBOSE to be configurable.
1616#
1617ifdef KBUILD_QUIET
1618 # No output
1619 QUIET := @
1620 QUIET2:= @
1621 MSG_L1 =
1622 MSG_L2 =
1623else
1624 ifndef KBUILD_VERBOSE
1625 # Default output level.
1626 QUIET := @
1627 QUIET2 := @
1628 MSG_L1 ?= %@$(ECHO) "kBuild: $1"
1629 MSG_L2 =
1630 else ifeq ($(KBUILD_VERBOSE),1)
1631 # A bit more output
1632 QUIET := @
1633 QUIET2 := @
1634 MSG_L1 ?= %@$(ECHO) "kBuild: $1 $2"
1635 MSG_L2 =
1636 else ifeq ($(KBUILD_VERBOSE),2)
1637 # Lot more output
1638 QUIET :=
1639 QUIET2 := @
1640 MSG_L1 ?= %@$(ECHO) "kBuild: $1 $2"
1641 MSG_L2 ?= %@$(ECHO) "kBuild: $1"
1642 else
1643 # maximal output.
1644 QUIET :=
1645 QUIET2 :=
1646 MSG_L1 ?= %@$(ECHO) "kBuild: $1 $2"
1647 MSG_L2 ?= %@$(ECHO) "kBuild: $1"
1648 endif
1649endif
1650
1651
1652##
1653# An internal define used by subheader.kmk, subfooter.kmk, and
1654# KB_FN_PASS_0_ON_TARGET.
1655#
1656# @param target The target to process.
1657#
1658define def_subfooter_header_target_pass
1659 ifndef $(target)_PATH
1660 ifndef $(target)_DEFPATH
1661 $(target)_DEFPATH := $(PATH_SUB_CURRENT)
1662 endif
1663 $(call KB_FN_ASSIGN_DEPRECATED,$(target)_PATH,$($(target)_DEFPATH), $(target)_DEFPATH)
1664 else ifndef $(target)_DEFPATH
1665 $(target)_DEFPATH := $($(target)_PATH)
1666 endif
1667 ifndef $(target)_MAKEFILE
1668 $(target)_MAKEFILE := $(MAKEFILE_CURRENT)
1669 endif
1670 ifndef $(target)_0_OUTDIR
1671 $(target)_0_OUTDIR := $(call TARGET_PATH,$(target))
1672 $(call KB_FN_ASSIGN_DEPRECATED,PATH_$(target),$($(target)_0_OUTDIR), $(target)_0_OUTDIR)
1673 endif
1674endef
1675
1676##
1677# Function to call to set _0_OUTDIR, _DEFPATH, and _MAKEFILE earlier than subfooter.
1678# Can be used to avoid exploiting double expansion.
1679#
1680# @param 1 The target name.
1681KB_FN_DO_PASS0_ON_TARGET = $(foreach target,$1,$(if-expr defined($(target)_0_OUTDIR),,$(evalval def_subfooter_header_target_pass)))
1682
1683
1684#
1685# Validate any KBUILD_BLD_TYPES additions and finally the KBUILD_TYPE.
1686#
1687if1of ($(KBUILD_BLD_TYPES), $(KBUILD_OSES))
1688 $(error kBuild: found KBUILD_BLD_TYPES in KBUILD_OSES!)
1689endif
1690if1of ($(KBUILD_BLD_TYPES), $(KBUILD_ARCHES))
1691 $(error kBuild: found KBUILD_BLD_TYPES in KBUILD_ARCHES!)
1692endif
1693if1of ($(KBUILD_OSES), $(KBUILD_ARCHES))
1694 $(error kBuild: found KBUILD_OSES in KBUILD_ARCHES!)
1695endif
1696ifn1of ($(KBUILD_TYPE), $(KBUILD_BLD_TYPES))
1697 $(error kBuild: KBUILD_TYPE(=$(KBUILD_TYPE)) is not found in KBUILD_BLD_TYPES(=$(KBUILD_BLD_TYPES))!)
1698endif
1699
1700
1701#
1702# Mark the output and temporary directories as volatile on windows.
1703#
1704# This automatically means the directories not listed here are considered
1705# static and won't be invalidated once we start running compile jobs.
1706#
1707ifeq ($(KBUILD_HOST),win)
1708 if $(KBUILD_KMK_REVISION) >= 2886
1709 $(dircache-ctl volatile, $(PATH_OUT_BASE), $(PATH_OUT), $(TEMP), $(TMP), $(TMPDIR), $(TMP))
1710 endif
1711endif
1712
1713
1714ifdef KBUILD_PROFILE_SELF
1715 $(evalcall def_profile_self, end of header.kmk)
1716 _KBUILD_TS_HEADER_END := $(_KBUILD_TS_PREV)
1717endif
1718
1719# end-of-file-content
1720__header_kmk__ := 1
1721endif # !__header_kmk__
1722
Note: See TracBrowser for help on using the repository browser.