source: trunk/kBuild/header.kmk@ 1520

Last change on this file since 1520 was 1504, checked in by bird, 17 years ago

Environment / global variable policy changes. Renamed the following but will continue to check for the old ones:
BUILD_TYPE -> KBUILD_TYPE
BUILD_TARGET -> KBUILD_TARGET
BUILD_TARGET_ARCH -> KBUILD_TARGET_ARCH
BUILD_TARGET_CPU -> KBUILD_TARGET_CPU
BUILD_PLATFORM -> KBUILD_HOST
BUILD_PLATFORM_ARCH -> KBUILD_HOST_ARCH
BUILD_PLATFORM_CPU -> KBUILD_HOST_CPU
PATH_KBUILD -> KBUILD_PATH
PATH_KBUILD_BIN -> KBUILD_BIN_PATH

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 34.5 KB
Line 
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
27ifndef __header_kmk__
28# start-of-file-content
29ifdef 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)
35endif
36
37
38#
39# Check make version before we do anything else.
40#
41ifndef 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)
43endif
44ifneq ($(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
50else
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
54endif
55
56#
57# The revision in which this file was last modified.
58# This can be useful when using development versions of kBuild.
59#
60KMK_REVISION := $(patsubst %:,, $Rev: 1504 $ )
61
62
63#
64# Define the default goal.
65#
66.PHONY: all all_recursive
67all: all_recursive
68
69#
70# The phony FORCE target.
71#
72.PHONY: FORCE
73FORCE:
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).
90define NL
91
92
93endef
94
95##
96# Tab character.
97TAB := $(subst ., ,.)
98
99##
100# Newline + tab characters (for generating commands).
101NLTAB = $(NL)$(TAB)
102
103##
104# Space character.
105SP := $(subst ., ,.)
106
107##
108# Hash character.
109define HASH
110#
111endef
112
113##
114# Colon character.
115COLON := :
116
117##
118# Semicolon character.
119SEMICOLON := ;
120
121##
122# Comma character.
123COMMA := ,
124
125##
126# Dot character.
127DOT := .
128
129##
130# Dollar character.
131DOLLAR := $$
132
133##
134# Equal character.
135EQUAL := =
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#
144KBUILD_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#
155KBUILD_OSES := darwin freebsd l4 linux netbsd nt openbsd os2 solaris win
156KBUILD_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#
162ifndef KBUILD_TYPE
163 ifdef BUILD_TYPE
164 KBUILD_TYPE := $(BUILD_TYPE)
165 endif
166else 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
174endif
175override BUILD_TYPE = $(KBUILD_TYPE)
176
177ifndef KBUILD_TYPE
178 KBUILD_TYPE := release
179else
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
186endif
187
188
189#
190# Host platform legacy
191# kmk deals with this, so this is only temporary until I've rebuilt everything.
192#
193ifndef KBUILD_HOST
194 KBUILD_HOST := $(BUILD_PLATFORM)
195endif
196ifndef KBUILD_HOST_ARCH
197 KBUILD_HOST_ARCH := $(BUILD_PLATFORM_ARCH)
198endif
199ifndef KBUILD_HOST_CPU
200 KBUILD_HOST_CPU := $(BUILD_PLATFORM_CPU)
201endif
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#
210ifneq (.$(words $(KBUILD_HOST)).$(KBUILD_HOST).,.1.$(strip $(KBUILD_HOST)).)
211 $(error kBuild: The KBUILD_HOST value '$(KBUILD_HOST)' contains spaces/tabs!)
212endif
213ifneq ($(words $(filter $(KBUILD_HOST),$(KBUILD_OSES))),1)
214 $(error kBuild: KBUILD_HOST value '$(KBUILD_HOST)' is not recognized (valid: $(KBUILD_OSES)))
215endif
216
217ifneq (.$(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!)
219endif
220ifneq ($(words $(filter $(KBUILD_HOST_ARCH),$(KBUILD_ARCHES))),1)
221 $(error kBuild: KBUILD_HOST_ARCH value '$(KBUILD_HOST_ARCH)' is not recognized (valid: $(KBUILD_ARCHES)))
222endif
223
224ifeq ($(strip $(KBUILD_HOST_CPU)),)
225 KBUILD_HOST_CPU := blend
226else
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
236endif
237
238
239#
240# Deal with target platform legacy.
241#
242ifndef KBUILD_TARGET
243 ifdef BUILD_TARGET
244 KBUILD_TARGET := $(BUILD_TARGET)
245 endif
246else 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
254endif
255override BUILD_TARGET = $(KBUILD_TARGET)
256
257ifndef KBUILD_TARGET_ARCH
258 ifdef BUILD_TARGET_ARCH
259 KBUILD_TARGET_ARCH := $(BUILD_TARGET_ARCH)
260 endif
261else 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
269endif
270override BUILD_TARGET_ARCH = $(KBUILD_TARGET_ARCH)
271
272ifndef KBUILD_TARGET_CPU
273 ifdef BUILD_TARGET_CPU
274 KBUILD_TARGET_CPU := $(BUILD_TARGET_CPU)
275 endif
276else 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
284endif
285override 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#
292ifndef KBUILD_TARGET
293 KBUILD_TARGET := $(KBUILD_HOST)
294else
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
301endif
302
303ifndef KBUILD_TARGET_ARCH
304 KBUILD_TARGET_ARCH := $(KBUILD_HOST_ARCH)
305else
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
312endif
313
314ifndef KBUILD_TARGET_CPU
315 KBUILD_TARGET_CPU := $(KBUILD_HOST_CPU)
316else 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
322else
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
332endif
333
334
335#
336# Paths and stuff.
337#
338
339# Adjust DEPTH first.
340DEPTH := $(strip $(DEPTH))
341ifeq ($(DEPTH),)
342 DEPTH := .
343endif
344
345## PATH_CURRENT is the current directory (getcwd).
346PATH_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.
349PATH_SUB_CURRENT := $(PATH_CURRENT)
350## PATH_ROOT points to the project root directory.
351PATH_ROOT := $(abspath $(PATH_CURRENT)/$(DEPTH))
352## PATH_SUB_ROOT points to the directory of the top-level makefile.
353ifneq ($(strip $(SUB_DEPTH)),)
354 SUB_DEPTH := $(strip $(SUB_DEPTH))
355 PATH_SUB_ROOT := $(abspath $(PATH_CURRENT)/$(SUB_DEPTH))
356else
357 PATH_SUB_ROOT := $(PATH_CURRENT)
358endif
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.
362ifneq ($(PATH_ROOT),$(PATH_SUB_ROOT))
363 CURSUBDIR := $(patsubst $(PATH_ROOT)/%,%,$(PATH_SUB_ROOT))
364else
365 CURSUBDIR := .
366endif
367
368# Output directories.
369ifndef PATH_OUT_BASE
370 PATH_OUT_BASE := $(PATH_ROOT)/out
371endif
372ifndef 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
378endif # !define PATH_OUT
379PATH_OBJCACHE = $(PATH_OUT_BASE)/kObjCache
380PATH_OBJ = $(PATH_OUT)/obj
381PATH_TARGET = $(PATH_OBJ)/$(CURSUBDIR)
382PATH_INS = $(PATH_OUT)
383PATH_BIN = $(PATH_INS)/bin
384PATH_DLL = $(PATH_INS)/bin
385PATH_SYS = $(PATH_INS)/bin
386PATH_LIB = $(PATH_INS)/lib
387PATH_DOC = $(PATH_INS)/doc
388
389# KBUILD_PATH / PATH_KBUILD is determined by kmk.
390ifndef KBUILD_PATH
391 KBUILD_PATH := $(PATH_KBUILD)
392endif
393ifeq ($(strip $(KBUILD_PATH)),)
394 $(error kBuild: KBUILD_PATH is missing or empty! kmk is supposed to set it.)
395endif
396# KBUILD_BIN_PATH / PATH_KBUILD_BIN is determined by kmk.
397ifndef KBUILD_BIN_PATH
398 KBUILD_BIN_PATH := $(PATH_KBUILD_BIN)
399endif
400ifeq ($(strip $(KBUILD_BIN_PATH)),)
401 $(error kBuild: KBUILD_BIN_PATH is missing or empty! kmk is supposed to set it.)
402endif
403
404# kBuild files which might be of interest.
405FILE_KBUILD_HEADER := $(KBUILD_PATH)/header.kmk
406#FILE_KBUILD_CONFIG := $(KBUILD_PATH)/config.kmk
407FILE_KBUILD_FOOTER := $(KBUILD_PATH)/footer.kmk
408
409## MAKEFILE is the name of the main makefile.
410MAKEFILE := $(firstword $(MAKEFILE_LIST))
411## MAKEFILE_CURRENT is the name of the current makefile.
412# This is updated everything a sub-makefile is included.
413MAKEFILE_CURRENT := $(MAKEFILE)
414
415
416#
417# Build platform setup.
418# (PORTME)
419#
420
421# OS/2
422ifeq ($(KBUILD_HOST),os2)
423EXEC_X86_WIN32 := innopec.exe
424HOSTSUFF_EXE := .exe
425endif
426
427# Linux
428ifeq ($(KBUILD_HOST),linux)
429EXEC_X86_WIN32 := wine
430HOSTSUFF_EXE :=
431endif
432
433# Win, Win32, Win64, NT.
434if1of ($(KBUILD_HOST), win nt)
435EXEC_X86_WIN32 :=
436HOSTSUFF_EXE := .exe
437endif
438
439# FreeBSD
440ifeq ($(KBUILD_HOST),freebsd)
441EXEC_X86_WIN32 := wine
442HOSTSUFF_EXE :=
443endif
444
445# Darwin / Mac OS X
446ifeq ($(KBUILD_HOST),darwin)
447EXEC_X86_WIN32 := false
448HOSTSUFF_EXE :=
449endif
450
451# Solaris
452ifeq ($(KBUILD_HOST),solaris)
453EXEC_X86_WIN32 := false
454HOSTSUFF_EXE :=
455endif
456
457
458#
459# Build target setup.
460# (PORTME)
461#
462SUFF_DEP := .dep
463if1of ($(KBUILD_TARGET), win nt os2)
464SUFF_OBJ := .obj
465SUFF_LIB := .lib
466SUFF_DLL := .dll
467SUFF_EXE := .exe
468SUFF_SYS := .sys
469SUFF_RES := .res
470else ifeq ($(KBUILD_TARGET),l4)
471SUFF_OBJ := .o
472SUFF_LIB := .a
473SUFF_DLL := .s.so
474SUFF_EXE :=
475SUFF_SYS := .a
476SUFF_RES :=
477else ifeq ($(KBUILD_TARGET),darwin)
478SUFF_OBJ := .o
479SUFF_LIB := .a
480SUFF_DLL := .dylib
481SUFF_EXE :=
482SUFF_SYS :=
483SUFF_RES :=
484else
485SUFF_OBJ := .o
486SUFF_LIB := .a
487SUFF_DLL := .so
488SUFF_EXE :=
489 if1of ($(KBUILD_TARGET), freebsd linux netbsd openbsd) ## @todo check netbsd and openbsd.
490SUFF_SYS := .ko
491 else
492SUFF_SYS :=
493 endif
494SUFF_RES :=
495endif
496
497#
498# Standard kBuild tools.
499#
500ifeq ($(KMK),kmk)
501KMK := $(KBUILD_BIN_PATH)/kmk$(HOSTSUFF_EXE)
502endif
503MAKE := $(KMK)
504
505GMAKE := $(KBUILD_BIN_PATH)/kmk_gmake$(HOSTSUFF_EXE)
506
507DEP_EXT := $(KBUILD_BIN_PATH)/kDep$(HOSTSUFF_EXE)
508if1of (kDep, $(KMK_BUILTIN))
509DEP := kmk_builtin_kDep
510else
511DEP := $(DEP_EXT)
512endif
513
514DEP_IDB_EXT := $(KBUILD_BIN_PATH)/kDepIDB$(HOSTSUFF_EXE)
515if1of (kDepIDB, $(KMK_BUILTIN))
516DEP_IDB := kmk_builtin_kDepIDB
517else
518DEP_IDB := $(DEP_IDB_EXT)
519endif
520
521DEP_PRE_EXT := $(KBUILD_BIN_PATH)/kDepPre$(HOSTSUFF_EXE)
522if1of (kDepPre, $(KMK_BUILTIN))
523DEP_PRE := kmk_builtin_kDepPre
524else
525DEP_PRE := $(DEP_PRE_EXT)
526endif
527
528KOBJCACHE_EXT := $(KBUILD_BIN_PATH)/kObjCache$(HOSTSUFF_EXE)
529if1of (kObjCache, $(KMK_BUILTIN))
530KOBJCACHE := kmk_builtin_kObjCache
531else
532KOBJCACHE := $(KOBJCACHE_EXT)
533endif
534
535APPEND_EXT := $(KBUILD_BIN_PATH)/kmk_append$(HOSTSUFF_EXE)
536APPEND := kmk_builtin_append
537
538CAT_EXT := $(KBUILD_BIN_PATH)/kmk_cat$(HOSTSUFF_EXE)
539CAT := kmk_builtin_cat
540
541CMP_EXT := $(KBUILD_BIN_PATH)/kmk_cmp$(HOSTSUFF_EXE)
542CMP := kmk_builtin_cmp
543
544CP_EXT := $(KBUILD_BIN_PATH)/kmk_cp$(HOSTSUFF_EXE)
545CP := kmk_builtin_cp
546
547ECHO_EXT := $(KBUILD_BIN_PATH)/kmk_echo$(HOSTSUFF_EXE)
548ECHO := kmk_builtin_echo
549
550INSTALL_EXT := $(KBUILD_BIN_PATH)/kmk_install$(HOSTSUFF_EXE)
551INSTALL := kmk_builtin_install
552
553LN_EXT := $(KBUILD_BIN_PATH)/kmk_ln$(HOSTSUFF_EXE)
554LN := kmk_builtin_ln
555
556MD5SUM_EXT := $(KBUILD_BIN_PATH)/kmk_md5sum$(HOSTSUFF_EXE)
557MD5SUM := kmk_builtin_md5sum
558
559MKDIR_EXT := $(KBUILD_BIN_PATH)/kmk_mkdir$(HOSTSUFF_EXE)
560MKDIR := kmk_builtin_mkdir
561
562MV_EXT := $(KBUILD_BIN_PATH)/kmk_mv$(HOSTSUFF_EXE)
563MV := kmk_builtin_mv
564
565PRINTF_EXT := $(KBUILD_BIN_PATH)/kmk_printf$(HOSTSUFF_EXE)
566PRINTF := kmk_builtin_printf
567
568REDIRECT_EXT:= $(KBUILD_BIN_PATH)/kmk_redirect$(HOSTSUFF_EXE)
569if1of (redirect, $(KMK_BUILTIN))
570REDIRECT := kmk_builtin_redirect
571else
572REDIRECT := $(REDIRECT_EXT)
573endif
574
575RM_EXT := $(KBUILD_BIN_PATH)/kmk_rm$(HOSTSUFF_EXE)
576RM := kmk_builtin_rm
577
578RMDIR_EXT := $(KBUILD_BIN_PATH)/kmk_rmdir$(HOSTSUFF_EXE)
579RMDIR := kmk_builtin_rmdir
580
581SED_EXT := $(KBUILD_BIN_PATH)/kmk_sed$(HOSTSUFF_EXE)
582if1of (sed, $(KMK_BUILTIN))
583SED_INT := kmk_builtin_sed
584else
585SED_INT := $(SED_EXT)
586endif
587SED := $(SED_EXT)
588
589TEST_EXT := $(KBUILD_BIN_PATH)/kmk_test$(HOSTSUFF_EXE)
590TEST := kmk_builtin_test
591
592# Our default shell is the Almquist shell from *BSD.
593ASH := $(KBUILD_BIN_PATH)/kmk_ash$(HOSTSUFF_EXE)
594MAKESHELL := $(ASH)
595SHELL := $(ASH)
596export SHELL MAKESHELL
597
598# Symlinking is problematic on some platforms...
599LN_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.
612ABSPATH = $(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.
617DIRDEP = $(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.
624ifneq ($(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)))))
627else
628 CYGPATHMIXED = $(1)
629endif
630
631## Removes the drive letter from a path (if it has one)
632# @param $1 the path
633no-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
637no-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
642TARGET_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
646TARGET_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.
656KBUILD_TEMPLATE_PATHS :=
657
658## KBUILD_TOOL_PATHS
659# List of paths (separated by space) where tools can be found.
660KBUILD_TOOL_PATHS :=
661
662## KBUILD_SDK_PATHS
663# List of paths (separated by space) where SDKs can be found.
664KBUILD_SDK_PATHS :=
665
666## KBUILD_DEFAULT_PATHS
667# List of paths (separated by space) to search for stuff as a last resort.
668KBUILD_DEFAULT_PATHS :=
669
670## Proritized list of the default makefile when walking subdirectories.
671# The user can overload this list.
672DEFAULT_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.
678KBUILD_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.
699PROPS_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.
705PROPS_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.
709PROPS_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.
716PROPS_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.
723PROPS_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.
736PROPS_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.
750PROPS_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.
757PROPS_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.
764PROPS_ALL = $(PROPS_SINGLE) $(PROPS_DEFERRED) $(PROPS_ACCUMULATE_L) $(PROPS_ACCUMULATE_R)
765
766
767## @name Properties valid on programs (BLDPROGS and PROGRAMS)
768## @{
769PROPS_PROGRAMS_SINGLE := $(PROPS_SINGLE_LNK) LDTOOL EXESUFF
770PROPS_PROGRAMS_DEFERRED := $(PROPS_DEFERRED)
771PROPS_PROGRAMS_ACCUMULATE_R := $(PROPS_ACCUMULATE_R_LNK) LDFLAGS
772PROPS_PROGRAMS_ACCUMULATE_L := $(PROPS_ACCUMULATE_L_LNK) LIBS LIBPATH
773## @}
774
775## @name Properties valid on libraries (LIBRARIES and IMPORT_LIBS)
776## @{
777PROPS_LIBRARIES_SINGLE := $(PROPS_SINGLE_LNK) ARTOOL LIBSUFF ARLIBSUFF LIBSUFF
778PROPS_LIBRARIES_DEFERRED := $(filter-out SONAME,$(PROPS_DEFERRED))
779PROPS_LIBRARIES_ACCUMULATE_R := $(PROPS_ACCUMULATE_R_LNK) ARFLAGS
780PROPS_LIBRARIES_ACCUMULATE_L := $(PROPS_ACCUMULATE_L_LNK)
781## @}
782
783## @name Properties valid on dlls (DLLS)
784## @{
785PROPS_DLLS_SINGLE := $(PROPS_SINGLE_LNK) LDTOOL DLLSUFF LIBSUFF
786PROPS_DLLS_DEFERRED := $(PROPS_DEFERRED)
787PROPS_DLLS_ACCUMULATE_R := $(PROPS_ACCUMULATE_R_LNK) LDFLAGS
788PROPS_DLLS_ACCUMULATE_L := $(PROPS_ACCUMULATE_L_LNK) LIBS LIBPATH
789## @}
790
791## @name Properties valid on system modules (SYSMODS)
792## @{
793PROPS_SYSMODS_SINGLE := $(PROPS_SINGLE_LNK) LDTOOL SYSSUFF
794PROPS_SYSMODS_DEFERRED := $(PROPS_DEFERRED)
795PROPS_SYSMODS_ACCUMULATE_R := $(PROPS_ACCUMULATE_R_LNK) LDFLAGS
796PROPS_SYSMODS_ACCUMULATE_L := $(PROPS_ACCUMULATE_L_LNK) LIBS LIBPATH
797## @}
798
799## @name Properties valid on installs (INSTALLS)
800## @{
801PROPS_INSTALLS_SINGLE := TOOL TEMPLATE INST NOINST
802PROPS_INSTALLS_DEFERRED := INSTFUN INSTALLER
803PROPS_INSTALLS_ACCUMULATE_R := DEPS ORDERDEPS
804PROPS_INSTALLS_ACCUMULATE_L := SOURCES DIRS CLEAN
805## @}
806
807## @name Properties valid on fetches (INSTALLS)
808## @{
809PROPS_FETCHES_SINGLE := TOOL TEMPLATE FETCHTOOL UNPACKTOOL PATCHTOOL INST FETCHDIR
810PROPS_FETCHES_DEFERRED :=
811PROPS_FETCHES_ACCUMULATE_R := FETCHFLAGS UNPACKFLAGS PATCHFLAGS
812PROPS_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#
824ifndef KBUILD_DONT_KILL_ENV_PROPS
825
826define def_nuke_environment_prop
827ifeq ($(origin $(prop)),environment)
828$(prop) =
829endif
830endef
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
836endif # 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.
849PASS_FETCHES := Fetches
850PASS_FETCHES_trgs :=
851PASS_FETCHES_vars := _FETCHES
852PASS_FETCHES_pass := fetches
853
854## PASS: patches
855# This pass applies patches.
856PASS_PATCHES := Patches
857PASS_PATCHES_trgs :=
858PASS_PATCHES_vars := _PATCHES
859PASS_PATCHES_pass := patches
860
861## PASS: bldprogs
862# This pass builds targets which are required for building the rest.
863PASS_BLDPROGS := Build Programs
864PASS_BLDPROGS_trgs :=
865PASS_BLDPROGS_vars := _BLDPROGS
866PASS_BLDPROGS_pass := bldprogs
867
868## PASS: libraries
869# This pass builds library targets.
870PASS_LIBRARIES := Libraries
871PASS_LIBRARIES_trgs :=
872PASS_LIBRARIES_vars := _LIBS _IMPORT_LIBS _OTHER_LIBRARIES
873PASS_LIBRARIES_pass := libraries
874
875## PASS: binaries
876# This pass builds dll targets.
877PASS_DLLS := DLLs
878PASS_DLLS_trgs :=
879PASS_DLLS_vars := _DLLS _OTHER_DLLS
880PASS_DLLS_pass := dlls
881
882## PASS: binaries
883# This pass builds binary targets, i.e. programs, system modules and stuff.
884PASS_BINARIES := Programs
885PASS_BINARIES_trgs :=
886PASS_BINARIES_vars := _PROGRAMS _SYSMODS _OTHER_BINARIES
887PASS_BINARIES_pass := binaries
888
889## PASS: others
890# This pass builds other targets.
891PASS_OTHERS := Other Stuff
892PASS_OTHERS_trgs :=
893PASS_OTHERS_vars := _OTHERS
894PASS_OTHERS_pass := others
895
896## PASS: install
897# This pass installs the built entities to a sandbox area.
898PASS_INSTALLS := Install
899PASS_INSTALLS_trgs :=
900PASS_INSTALLS_vars := _INSTALLS_DIRS _INSTALLS _INSTALLS_FILES
901PASS_INSTALLS_pass := installs
902
903## PASS: packing
904# This pass processes custom packing rules.
905PASS_PACKING := Packing
906PASS_PACKING_trgs :=
907PASS_PACKING_vars := _PACKING
908PASS_PACKING_pass := packing
909#alias
910packing: pass_packing
911
912## PASS: clean
913# This pass removes all generated files.
914PASS_CLEAN := Clean
915PASS_CLEAN_trgs := do-clean
916PASS_CLEAN_vars :=
917PASS_CLEAN_pass := clean
918# alias
919clean: pass_clean
920
921## PASS: nothing
922# This pass just walks the tree.
923PASS_NOTHING := Nothing
924PASS_NOTHING_trgs := do-nothing
925PASS_NOTHING_vars :=
926PASS_NOTHING_pass := nothing
927# alias
928nothing: pass_nothing
929
930## DEFAULT_PASSES
931# The default passes and their order.
932DEFAULT_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.
937PASSES := 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#
945ifndef KBUILD_VERBOSE
946 ifndef KBUILD_QUIET
947 ifneq ($(filter --pretty-command-printing,$(MAKEFLAGS)),)
948 export KBUILD_VERBOSE := 2
949 endif
950 endif
951endif
952
953
954#
955# Legacy variable translation.
956# These will be eliminated when switching to the next version.
957#
958ifdef USE_KOBJCACHE
959 ifndef KBUILD_USE_KOBJCACHE
960 export KBUILD_USE_KOBJCACHE := $(USE_KOBJCACHE)
961 endif
962endif
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
971define def_include_config
972$(eval _CFGDIR := $(_CFGDIR)/$(dir))
973_CFGFILES += $(_CFGDIR)/Config.kmk $(_CFGDIR)/config.kmk
974endef
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 :=
981ifeq ($(_CFGFILE),)
982$(error kBuild: no Config.kmk file found! Check the DEPTH: DEPTH='$(DEPTH)' PATH_CURRENT='$(PATH_CURRENT)')
983endif
984
985# Include the config.kmk we found file (or the default one).
986ifdef 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)
998else
999 include $(_CFGFILE)
1000endif
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#
1010PATH_OUT := $(abspath $(PATH_OUT))
1011PATH_OBJ := $(abspath $(PATH_OBJ))
1012PATH_TARGET := $(abspath $(PATH_TARGET))
1013PATH_INS := $(abspath $(PATH_INS))
1014PATH_BIN := $(abspath $(PATH_BIN))
1015PATH_DLL := $(abspath $(PATH_DLL))
1016PATH_SYS := $(abspath $(PATH_SYS))
1017PATH_LIB := $(abspath $(PATH_LIB))
1018PATH_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#
1027KBUILD_MSG_STYLE ?= default
1028ifeq ($(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
1114else
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
1121endif
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#
1130ifdef KBUILD_QUIET
1131 # No output
1132 QUIET := @
1133 QUIET2:= @
1134 MSG_L1 =
1135 MSG_L2 =
1136else
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
1162endif
1163
1164
1165#
1166# Validate any KBUILD_BLD_TYPES additions and finally the KBUILD_TYPE.
1167#
1168if1of ($(KBUILD_BLD_TYPES), $(KBUILD_OSES))
1169 $(error kBuild: found KBUILD_BLD_TYPES in KBUILD_OSES!)
1170endif
1171if1of ($(KBUILD_BLD_TYPES), $(KBUILD_ARCHES))
1172 $(error kBuild: found KBUILD_BLD_TYPES in KBUILD_ARCHES!)
1173endif
1174if1of ($(KBUILD_OSES), $(KBUILD_ARCHES))
1175 $(error kBuild: found KBUILD_OSES in KBUILD_ARCHES!)
1176endif
1177ifn1of ($(KBUILD_TYPE), $(KBUILD_BLD_TYPES))
1178 $(error kBuild: KBUILD_TYPE(=$(KBUILD_TYPE)) is not found in KBUILD_BLD_TYPES(=$(KBUILD_BLD_TYPES))!)
1179endif
1180
1181
1182
1183ifdef 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)
1188endif
1189
1190# end-of-file-content
1191__header_kmk__ := 1
1192endif # __header_kmk__
1193
Note: See TracBrowser for help on using the repository browser.