source: trunk/kBuild/header.kmk@ 1775

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

touch KMK_REVISION

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