source: trunk/kBuild/header.kmk@ 2144

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

footer/header: moving the pass aliases (more bustage).

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