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
RevLine 
[69]1# $Id: header.kmk 1504 2008-04-09 00:04:42Z bird $
2## @file
3#
[978]4# kBuild - File included at top of a makefile.
[69]5#
[1504]6# Copyright (c) 2004-2008 knut st. osmundsen <bird-kBuild-spam@anduin.net>
[69]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
[988]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)
[1441]32 $(info stat: $(make-stats ))
[988]33 _KBUILD_TS_HEADER_START := $(nanots )
34 _KBUILD_TS_PREV := $(_KBUILD_TS_HEADER_START)
35endif
[69]36
[978]37
[69]38#
[978]39# Check make version before we do anything else.
[69]40#
[978]41ifndef KMK_VERSION
[984]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)
[978]43endif
44ifneq ($(KBUILD_VERSION_MAJOR).$(KBUILD_VERSION_MINOR),0.1)
45 ifneq ($(KBUILD_VERSION_MAJOR),0)
[1348]46 $(warning kBuild: kmk major version mismatch! Expected '0' but found '$(KBUILD_VERSION_MAJOR)'!)
[978]47 else
[1348]48 $(warning kBuild: kmk minor version mismatch! Expected '1' but found '$(KBUILD_VERSION_MINOR)'!)
[978]49 endif
[1348]50else
[1504]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).)
[1348]53 endif
[978]54endif
[69]55
56#
[978]57# The revision in which this file was last modified.
58# This can be useful when using development versions of kBuild.
[380]59#
[978]60KMK_REVISION := $(patsubst %:,, $Rev: 1504 $ )
[414]61
[978]62
[380]63#
[978]64# Define the default goal.
[69]65#
[1501]66.PHONY: all all_recursive
[978]67all: all_recursive
[69]68
[894]69#
[978]70# The phony FORCE target.
[894]71#
[1501]72.PHONY: FORCE
[978]73FORCE:
[72]74
[978]75
[69]76#
[978]77# Enable delete on error and second expansion of prerequisites.
[894]78#
[978]79.DELETE_ON_ERROR:
80
[894]81.SECONDEXPANSION:
82
83
84#
[95]85# General purpose macros.
86#
[204]87
[380]88##
89# Newline character(s).
90define NL
[95]91
[380]92
93endef
94
95##
96# Tab character.
97TAB := $(subst ., ,.)
98
99##
[896]100# Newline + tab characters (for generating commands).
101NLTAB = $(NL)$(TAB)
102
103##
[380]104# Space character.
105SP := $(subst ., ,.)
106
107##
[895]108# Hash character.
109define HASH
110#
111endef
[380]112
[895]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
[95]138#
[1403]139# The list of standard build types in kBuild.
140#
[1416]141# This list can be extended in Config.kmk and it's possible to extend
[1403]142# (inherit) another build type.
143#
[1420]144KBUILD_BLD_TYPES := release profile debug
[1403]145
146
147#
[985]148# The OSes, Architectures and CPUs that kBuild recognizes.
[978]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
[984]153# build types. (PORTME)
[978]154#
[985]155KBUILD_OSES := darwin freebsd l4 linux netbsd nt openbsd os2 solaris win
[1381]156KBUILD_ARCHES := x86 amd64 sparc32 sparc64 s390 s390x ppc32 ppc64 mips32 mips64 ia64 hppa32 hppa64 arm alpha
[978]157
158
159#
[585]160# Set default build type.
[69]161#
[1504]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
[978]179else
[1504]180 if1of ($(KBUILD_TYPE), $(KBUILD_OSES) $(KBUILD_ARCHES))
181 $(error kBuild: The KBUILD_TYPE value '$(KBUILD_TYPE)' is an OS or architecture!)
[585]182 endif
[1504]183 ifneq (.$(words $(KBUILD_TYPE)).$(KBUILD_TYPE).,.1.$(strip $(KBUILD_TYPE)).)
184 $(error kBuild: The KBUILD_TYPE value '$(KBUILD_TYPE)' contains spaces/tabs!)
[978]185 endif
[72]186endif
[69]187
188
189#
[1504]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#
[978]205# Assert valid build platform variables.
[70]206#
[978]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#
[1504]210ifneq (.$(words $(KBUILD_HOST)).$(KBUILD_HOST).,.1.$(strip $(KBUILD_HOST)).)
211 $(error kBuild: The KBUILD_HOST value '$(KBUILD_HOST)' contains spaces/tabs!)
[72]212endif
[1504]213ifneq ($(words $(filter $(KBUILD_HOST),$(KBUILD_OSES))),1)
214 $(error kBuild: KBUILD_HOST value '$(KBUILD_HOST)' is not recognized (valid: $(KBUILD_OSES)))
[978]215endif
[70]216
[1504]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!)
[329]219endif
[1504]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)))
[329]222endif
[72]223
[1504]224ifeq ($(strip $(KBUILD_HOST_CPU)),)
225 KBUILD_HOST_CPU := blend
[994]226else
[1504]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!)
[994]229 endif
[1504]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!)
[994]232 endif
[1504]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!)
[994]235 endif
[978]236endif
[72]237
[978]238
[70]239#
[1504]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#
[978]289# Assert or set default target platform.
[1504]290# When not defined use the corresponding KBUILD_HOST value.
[72]291#
[1504]292ifndef KBUILD_TARGET
293 KBUILD_TARGET := $(KBUILD_HOST)
[72]294else
[1504]295 ifneq (.$(words $(KBUILD_TARGET)).$(KBUILD_TARGET).,.1.$(strip $(KBUILD_TARGET)).)
296 $(error kBuild: The KBUILD_TARGET value '$(KBUILD_TARGET)' contains spaces/tabs!)
[478]297 endif
[1504]298 ifneq ($(words $(filter $(KBUILD_TARGET),$(KBUILD_OSES))),1)
299 $(error kBuild: KBUILD_TARGET value '$(KBUILD_TARGET)' is not recognized (valid: $(KBUILD_OSES)))
[978]300 endif
[72]301endif
302
[1504]303ifndef KBUILD_TARGET_ARCH
304 KBUILD_TARGET_ARCH := $(KBUILD_HOST_ARCH)
[978]305else
[1504]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!)
[978]308 endif
[1504]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)))
[978]311 endif
[329]312endif
[978]313
[1504]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)
[994]319 else
[1504]320 KBUILD_TARGET_CPU := blend
[994]321 endif
[978]322else
[1504]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!)
[978]325 endif
[1504]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!)
[978]328 endif
[1504]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!)
[978]331 endif
[329]332endif
[72]333
334
335#
[978]336# Paths and stuff.
[69]337#
[978]338
339# Adjust DEPTH first.
340DEPTH := $(strip $(DEPTH))
341ifeq ($(DEPTH),)
342 DEPTH := .
343endif
344
[725]345## PATH_CURRENT is the current directory (getcwd).
[306]346PATH_CURRENT := $(abspath $(CURDIR))
[725]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.
[472]353ifneq ($(strip $(SUB_DEPTH)),)
[978]354 SUB_DEPTH := $(strip $(SUB_DEPTH))
[725]355 PATH_SUB_ROOT := $(abspath $(PATH_CURRENT)/$(SUB_DEPTH))
[472]356else
[725]357 PATH_SUB_ROOT := $(PATH_CURRENT)
[472]358endif
[306]359
[748]360## CURSUBDIR is PATH_SUB_ROOT described relative to PATH_ROOT.
[725]361# This variable is used to determin where the object files and other output goes.
[1390]362ifneq ($(PATH_ROOT),$(PATH_SUB_ROOT))
363 CURSUBDIR := $(patsubst $(PATH_ROOT)/%,%,$(PATH_SUB_ROOT))
[266]364else
[1390]365 CURSUBDIR := .
[266]366endif
[306]367
[70]368# Output directories.
[242]369ifndef PATH_OUT_BASE
[725]370 PATH_OUT_BASE := $(PATH_ROOT)/out
[242]371endif
[240]372ifndef PATH_OUT
[1504]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)
[725]375 else
[1504]376 PATH_OUT := $(PATH_OUT_BASE)/$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)/$(KBUILD_TYPE)
[725]377 endif
[329]378endif # !define PATH_OUT
[1051]379PATH_OBJCACHE = $(PATH_OUT_BASE)/kObjCache
[353]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
[70]388
[1504]389# KBUILD_PATH / PATH_KBUILD is determined by kmk.
390ifndef KBUILD_PATH
391 KBUILD_PATH := $(PATH_KBUILD)
[70]392endif
[1504]393ifeq ($(strip $(KBUILD_PATH)),)
394 $(error kBuild: KBUILD_PATH is missing or empty! kmk is supposed to set it.)
[978]395endif
[1504]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
[978]403
[69]404# kBuild files which might be of interest.
[1504]405FILE_KBUILD_HEADER := $(KBUILD_PATH)/header.kmk
406#FILE_KBUILD_CONFIG := $(KBUILD_PATH)/config.kmk
407FILE_KBUILD_FOOTER := $(KBUILD_PATH)/footer.kmk
[69]408
[725]409## MAKEFILE is the name of the main makefile.
[204]410MAKEFILE := $(firstword $(MAKEFILE_LIST))
[748]411## MAKEFILE_CURRENT is the name of the current makefile.
[725]412# This is updated everything a sub-makefile is included.
413MAKEFILE_CURRENT := $(MAKEFILE)
[69]414
[72]415
[69]416#
[72]417# Build platform setup.
[984]418# (PORTME)
[69]419#
[984]420
[69]421# OS/2
[1504]422ifeq ($(KBUILD_HOST),os2)
[83]423EXEC_X86_WIN32 := innopec.exe
[69]424HOSTSUFF_EXE := .exe
425endif
426
427# Linux
[1504]428ifeq ($(KBUILD_HOST),linux)
[135]429EXEC_X86_WIN32 := wine
[69]430HOSTSUFF_EXE :=
431endif
[70]432
[547]433# Win, Win32, Win64, NT.
[1504]434if1of ($(KBUILD_HOST), win nt)
[69]435EXEC_X86_WIN32 :=
436HOSTSUFF_EXE := .exe
437endif
438
[299]439# FreeBSD
[1504]440ifeq ($(KBUILD_HOST),freebsd)
[299]441EXEC_X86_WIN32 := wine
442HOSTSUFF_EXE :=
443endif
[125]444
[557]445# Darwin / Mac OS X
[1504]446ifeq ($(KBUILD_HOST),darwin)
[557]447EXEC_X86_WIN32 := false
448HOSTSUFF_EXE :=
449endif
450
[811]451# Solaris
[1504]452ifeq ($(KBUILD_HOST),solaris)
[811]453EXEC_X86_WIN32 := false
454HOSTSUFF_EXE :=
455endif
456
[299]457
[73]458#
459# Build target setup.
[984]460# (PORTME)
[73]461#
[1388]462SUFF_DEP := .dep
[1504]463if1of ($(KBUILD_TARGET), win nt os2)
[1388]464SUFF_OBJ := .obj
465SUFF_LIB := .lib
466SUFF_DLL := .dll
467SUFF_EXE := .exe
468SUFF_SYS := .sys
469SUFF_RES := .res
[1504]470else ifeq ($(KBUILD_TARGET),l4)
[1388]471SUFF_OBJ := .o
472SUFF_LIB := .a
473SUFF_DLL := .s.so
474SUFF_EXE :=
475SUFF_SYS := .a
476SUFF_RES :=
[1504]477else ifeq ($(KBUILD_TARGET),darwin)
[1388]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 :=
[1504]489 if1of ($(KBUILD_TARGET), freebsd linux netbsd openbsd) ## @todo check netbsd and openbsd.
[1389]490SUFF_SYS := .ko
[1388]491 else
[1389]492SUFF_SYS :=
493 endif
[1388]494SUFF_RES :=
[73]495endif
[69]496
497#
498# Standard kBuild tools.
499#
[978]500ifeq ($(KMK),kmk)
[1504]501KMK := $(KBUILD_BIN_PATH)/kmk$(HOSTSUFF_EXE)
[233]502endif
[978]503MAKE := $(KMK)
[233]504
[1504]505GMAKE := $(KBUILD_BIN_PATH)/kmk_gmake$(HOSTSUFF_EXE)
[1378]506
[1504]507DEP_EXT := $(KBUILD_BIN_PATH)/kDep$(HOSTSUFF_EXE)
[1388]508if1of (kDep, $(KMK_BUILTIN))
[397]509DEP := kmk_builtin_kDep
[230]510else
[380]511DEP := $(DEP_EXT)
[230]512endif
[69]513
[1504]514DEP_IDB_EXT := $(KBUILD_BIN_PATH)/kDepIDB$(HOSTSUFF_EXE)
[1388]515if1of (kDepIDB, $(KMK_BUILTIN))
[1004]516DEP_IDB := kmk_builtin_kDepIDB
[397]517else
518DEP_IDB := $(DEP_IDB_EXT)
519endif
520
[1504]521DEP_PRE_EXT := $(KBUILD_BIN_PATH)/kDepPre$(HOSTSUFF_EXE)
[1388]522if1of (kDepPre, $(KMK_BUILTIN))
[1004]523DEP_PRE := kmk_builtin_kDepPre
[380]524else
525DEP_PRE := $(DEP_PRE_EXT)
526endif
527
[1504]528KOBJCACHE_EXT := $(KBUILD_BIN_PATH)/kObjCache$(HOSTSUFF_EXE)
[1388]529if1of (kObjCache, $(KMK_BUILTIN))
[1004]530KOBJCACHE := kmk_builtin_kObjCache
531else
532KOBJCACHE := $(KOBJCACHE_EXT)
533endif
534
[1504]535APPEND_EXT := $(KBUILD_BIN_PATH)/kmk_append$(HOSTSUFF_EXE)
[380]536APPEND := kmk_builtin_append
[69]537
[1504]538CAT_EXT := $(KBUILD_BIN_PATH)/kmk_cat$(HOSTSUFF_EXE)
[380]539CAT := kmk_builtin_cat
[353]540
[1504]541CMP_EXT := $(KBUILD_BIN_PATH)/kmk_cmp$(HOSTSUFF_EXE)
[1118]542CMP := kmk_builtin_cmp
543
[1504]544CP_EXT := $(KBUILD_BIN_PATH)/kmk_cp$(HOSTSUFF_EXE)
[1119]545CP := kmk_builtin_cp
546
[1504]547ECHO_EXT := $(KBUILD_BIN_PATH)/kmk_echo$(HOSTSUFF_EXE)
[380]548ECHO := kmk_builtin_echo
549
[1504]550INSTALL_EXT := $(KBUILD_BIN_PATH)/kmk_install$(HOSTSUFF_EXE)
[380]551INSTALL := kmk_builtin_install
552
[1504]553LN_EXT := $(KBUILD_BIN_PATH)/kmk_ln$(HOSTSUFF_EXE)
[380]554LN := kmk_builtin_ln
555
[1504]556MD5SUM_EXT := $(KBUILD_BIN_PATH)/kmk_md5sum$(HOSTSUFF_EXE)
[1118]557MD5SUM := kmk_builtin_md5sum
558
[1504]559MKDIR_EXT := $(KBUILD_BIN_PATH)/kmk_mkdir$(HOSTSUFF_EXE)
[380]560MKDIR := kmk_builtin_mkdir
561
[1504]562MV_EXT := $(KBUILD_BIN_PATH)/kmk_mv$(HOSTSUFF_EXE)
[380]563MV := kmk_builtin_mv
564
[1504]565PRINTF_EXT := $(KBUILD_BIN_PATH)/kmk_printf$(HOSTSUFF_EXE)
[776]566PRINTF := kmk_builtin_printf
567
[1504]568REDIRECT_EXT:= $(KBUILD_BIN_PATH)/kmk_redirect$(HOSTSUFF_EXE)
[1388]569if1of (redirect, $(KMK_BUILTIN))
[1272]570REDIRECT := kmk_builtin_redirect
571else
572REDIRECT := $(REDIRECT_EXT)
573endif
574
[1504]575RM_EXT := $(KBUILD_BIN_PATH)/kmk_rm$(HOSTSUFF_EXE)
[380]576RM := kmk_builtin_rm
577
[1504]578RMDIR_EXT := $(KBUILD_BIN_PATH)/kmk_rmdir$(HOSTSUFF_EXE)
[601]579RMDIR := kmk_builtin_rmdir
580
[1504]581SED_EXT := $(KBUILD_BIN_PATH)/kmk_sed$(HOSTSUFF_EXE)
[1272]582if1of (sed, $(KMK_BUILTIN))
[978]583SED_INT := kmk_builtin_sed
[380]584else
[978]585SED_INT := $(SED_EXT)
586endif
[380]587SED := $(SED_EXT)
588
[1504]589TEST_EXT := $(KBUILD_BIN_PATH)/kmk_test$(HOSTSUFF_EXE)
[1296]590TEST := kmk_builtin_test
591
[380]592# Our default shell is the Almquist shell from *BSD.
[1504]593ASH := $(KBUILD_BIN_PATH)/kmk_ash$(HOSTSUFF_EXE)
[380]594MAKESHELL := $(ASH)
595SHELL := $(ASH)
596export SHELL MAKESHELL
597
[414]598# Symlinking is problematic on some platforms...
[380]599LN_SYMLINK := $(LN) -s
600
[743]601
602#
603# Some Functions.
[748]604# The lower cased ones are either fallbacks or candidates for functions.c.
[743]605#
606
[130]607## ABSPATH - make paths absolute.
[129]608# This implementation is clumsy and doesn't resolve '..' and '.' components.
[73]609#
[129]610# @param $1 The paths to make absolute.
[696]611# @obsolete Use the GNU make function $(abspath) directly now.
[984]612ABSPATH = $(abspath $(1))$(warning ABSPATH is deprecated, use abspath directly!)
[353]613
[130]614## DIRDEP - make create directory dependencies.
615#
616# @param $1 The paths to the directories which must be created.
[353]617DIRDEP = $(foreach path,$(patsubst %/,%,$(1)),$(path)/)
[129]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))
[743]625 CYGPATHMIXED = $(foreach path,$(1)\
[129]626 ,$(if $(patsubst /cygdrive/%,,$(path)),$(path),$(patsubst $(strip $(firstword $(subst /, ,$(patsubst /cygdrive/%,%,$(path)))))/%,$(strip $(firstword $(subst /, ,$(patsubst /cygdrive/%,%,$(path))))):/%,$(patsubst /cygdrive/%,%,$(path)))))
627else
[743]628 CYGPATHMIXED = $(1)
[129]629endif
630
[743]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)))
[723]634
[743]635## Removes the root slash from a path (if it has one)
636# @param $1 the path
637no-root-slash = $(patsubst /%,%,$(1))
[723]638
[743]639## Figure out where to put object files.
640# @param $1 real target name.
641# @param $2 normalized main target
[748]642TARGET_BASE = $(PATH_TARGET)/$(2)/$(call no-root-slash,$(call no-drive,$(1)))
[723]643
[743]644## Figure out where to put object files.
645# @param $1 normalized main target
646TARGET_PATH = $(PATH_TARGET)/$(1)
[723]647
648
[129]649#
[353]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
[1416]654## KBUILD_TEMPLATE_PATHS
[353]655# List a paths (separated by space) where templates can be found.
[1416]656KBUILD_TEMPLATE_PATHS :=
[353]657
[1416]658## KBUILD_TOOL_PATHS
[353]659# List of paths (separated by space) where tools can be found.
[1416]660KBUILD_TOOL_PATHS :=
[353]661
[1416]662## KBUILD_SDK_PATHS
[353]663# List of paths (separated by space) where SDKs can be found.
[1416]664KBUILD_SDK_PATHS :=
[353]665
[1416]666## KBUILD_DEFAULT_PATHS
667# List of paths (separated by space) to search for stuff as a last resort.
668KBUILD_DEFAULT_PATHS :=
669
[353]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
[1424]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 \
[1435]695.res:def_src_handler_obj
[980]696
[640]697## PROPS_TOOLS
[985]698# This is a subset of PROPS_SINGLE.
[1256]699PROPS_TOOLS := TOOL CTOOL CXXTOOL OBJCTOOL ASTOOL RCTOOL ARTOOL LDTOOL FETCHTOOL UNPACKTOOL PATCHTOOL
[640]700
[353]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
[1400]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 \
[1256]706 OBJSUFF COBJSUFF CXXOBJSUFF OBJCOBJSUFF ASOBJSUFF RCOBJSUFF SYSSUFF EXESUFF DLLSUFF LIBSUFF ARLIBSUFF
[985]707## PROPS_SINGLE_LNK
708# Subset of PROPS_SINGLE which applies to all linkable targets.
[1400]709PROPS_SINGLE_LNK := TOOL TEMPLATE CTOOL CXXTOOL OBJCTOOL ASTOOL RCTOOL \
[985]710 INST NOINST BLD_TYPE BLD_TRG BLD_TRG_ARCH BLD_TRG_CPU \
[1256]711 OBJSUFF COBJSUFF CXXOBJSUFF OBJCOBJSUFF ASOBJSUFF RCOBJSUFF
[353]712
713## PROPS_DEFERRED
[889]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.
[985]716PROPS_DEFERRED := INSTFUN INSTALLER PRE_CMDS POST_CMDS NAME SONAME
[353]717
[660]718## PROPS_ACCUMULATE_R
[748]719# The list of accumulative target properties where the right most value/flag
[660]720# is the 'most significant'.
[353]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.
[660]723PROPS_ACCUMULATE_R := \
[985]724 DEPS ORDERDEPS DEFS \
725 ARFLAGS \
[660]726 CFLAGS CDEFS \
727 CXXFLAGS CXXDEFS \
[1256]728 OBJCFLAGS OBJCDEFS \
[660]729 ASFLAGS ASDEFS \
730 RCFLAGS RCDEFS \
731 LDFLAGS \
[830]732 IDFLAGS IFDLAGS ISFLAGS \
[640]733 FETCHFLAGS UNPACKFLAGS PATCHFLAGS
[985]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 \
[1256]740 OBJCFLAGS OBJCDEFS \
[985]741 ASFLAGS ASDEFS \
742 RCFLAGS RCDEFS \
743 IDFLAGS IFDLAGS ISFLAGS
[353]744
[660]745## PROPS_ACCUMULATE
[748]746# The list of accumulative target properties where the left most value/flag
[660]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 := \
[1426]751 SDKS SOURCES SRC_HANDLERS INTERMEDIATES \
[1256]752 INCS CINCS CXXINCS OBJCINCS ASINCS RCINCS \
[897]753 LIBS LIBPATH \
[985]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 := \
[1424]758 SDKS SOURCES SRC_HANDLERS \
[1256]759 INCS CINCS CXXINCS OBJCINCS ASINCS RCINCS \
[985]760 BLDDIRS CLEAN
[353]761
[662]762## PROPS_ALL
763# List of all the properties.
764PROPS_ALL = $(PROPS_SINGLE) $(PROPS_DEFERRED) $(PROPS_ACCUMULATE_L) $(PROPS_ACCUMULATE_R)
[660]765
[662]766
[985]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## @{
[989]777PROPS_LIBRARIES_SINGLE := $(PROPS_SINGLE_LNK) ARTOOL LIBSUFF ARLIBSUFF LIBSUFF
[985]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
[989]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
[985]799## @name Properties valid on installs (INSTALLS)
800## @{
[1400]801PROPS_INSTALLS_SINGLE := TOOL TEMPLATE INST NOINST
[985]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## @{
[1400]809PROPS_FETCHES_SINGLE := TOOL TEMPLATE FETCHTOOL UNPACKTOOL PATCHTOOL INST FETCHDIR
[985]810PROPS_FETCHES_DEFERRED :=
811PROPS_FETCHES_ACCUMULATE_R := FETCHFLAGS UNPACKFLAGS PATCHFLAGS
812PROPS_FETCHES_ACCUMULATE_L := SOURCES
813## @}
814
815
[353]816#
[748]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
[662]819# this is necessary is the Visual C++ commandline with it's LIBPATH.)
820#
[748]821# Define KBUILD_DONT_KILL_ENV_PROPS in the env. or on the commandline to
[662]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
[762]831$(foreach prop, $(PROPS_ALL) \
832 FETCHES PATCHES BLDPROGS LIBRARIES IMPORT_LIBS DLLS PROGRAMS SYSMODS INSTALLS OTHERS \
[897]833 SUBDIRS MAKEFILES BLDDIRS \
[762]834 ,$(eval $(value def_nuke_environment_prop)))
[662]835
[897]836endif # KBUILD_DONT_KILL_ENV_PROPS
[662]837
838
839#
[353]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
[640]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
[353]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 :=
[854]900PASS_INSTALLS_vars := _INSTALLS_DIRS _INSTALLS _INSTALLS_FILES
[353]901PASS_INSTALLS_pass := installs
902
903## PASS: packing
904# This pass processes custom packing rules.
905PASS_PACKING := Packing
[414]906PASS_PACKING_trgs :=
[417]907PASS_PACKING_vars := _PACKING
[353]908PASS_PACKING_pass := packing
[414]909#alias
910packing: pass_packing
[353]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.
[723]937PASSES := FETCHES PATCHES $(DEFAULT_PASSES) NOTHING CLEAN
[353]938
939
940#
[984]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#
[1418]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#
[69]966# This is how we find the closest config.kmk.
967# It's a little hacky but I think it works fine.
[70]968#
969_CFGDIR := .
[78]970_CFGFILES := ./Config.kmk ./config.kmk
[69]971define def_include_config
[78]972$(eval _CFGDIR := $(_CFGDIR)/$(dir))
973_CFGFILES += $(_CFGDIR)/Config.kmk $(_CFGDIR)/config.kmk
[69]974endef
975# walk down the _RELATIVE_ path specified by DEPTH.
[78]976$(foreach dir,$(subst /, ,$(DEPTH)), $(eval $(def_include_config)) )
[69]977# add the default config file.
[78]978_CFGFILE := $(firstword $(wildcard $(_CFGFILES) $(FILE_KBUILD_CONFIG)))
[69]979_CFGFILES :=
980_CFGDIR :=
[416]981ifeq ($(_CFGFILE),)
982$(error kBuild: no Config.kmk file found! Check the DEPTH: DEPTH='$(DEPTH)' PATH_CURRENT='$(PATH_CURRENT)')
983endif
[69]984
985# Include the config.kmk we found file (or the default one).
[988]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))
[1441]989 $(info stat: $(make-stats ))
[988]990 _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
[69]991
[988]992 include $(_CFGFILE)
[69]993
[988]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))
[1441]996 $(info stat: $(make-stats ))
[988]997 _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
998else
999 include $(_CFGFILE)
1000endif
1001
1002
1003
[696]1004#
[874]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#
[788]1022# Setup the message style. The default one is inlined.
[776]1023#
[788]1024# See kBuild/msgstyles for more styles or use KBUILD_MSG_STYLE_PATHS
1025# to create your own message style.
1026#
[776]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.
[1256]1064 # @param 4 The source type (C,CXX,OBJC,AS,RC,++).
[776]1065 MSG_COMPILE ?= $(call MSG_L1,Compiling $1 - $2,=> $3)
[890]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))
[776]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)
[844]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.
[845]1086 MSG_AR_MERGE ?= $(call MSG_L1,Merging $3 into $1, ($2))
[776]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
[788]1114else
[1504]1115 _KBUILD_MSG_STYLE_FILE := $(firstword $(foreach path, $(KBUILD_MSG_STYLE_PATHS) $(KBUILD_PATH)/msgstyles, $(wildcard $(path)/$(KBUILD_MSG_STYLE).kmk)))
[788]1116 ifneq ($(_KBUILD_MSG_STYLE_FILE),)
1117 include $(_KBUILD_MSG_STYLE_FILE)
[776]1118 else
[788]1119 $(error kBuild: Can't find the style setup file for KBUILD_MSG_STYLE '$(KBUILD_MSG_STYLE)')
[776]1120 endif
1121endif
1122
1123
1124#
[696]1125# Message macros.
1126#
[748]1127# This is done after including Config.kmk as to allow for
[696]1128# KBUILD_QUIET and KBUILD_VERBOSE to be configurable.
1129#
1130ifdef KBUILD_QUIET
[776]1131 # No output
[696]1132 QUIET := @
1133 QUIET2:= @
1134 MSG_L1 =
1135 MSG_L2 =
1136else
1137 ifndef KBUILD_VERBOSE
[776]1138 # Default output level.
1139 QUIET := @
1140 QUIET2 := @
[1496]1141 MSG_L1 ?= %@$(ECHO) "kBuild: $1"
[776]1142 MSG_L2 =
1143 else ifeq ($(KBUILD_VERBOSE),1)
1144 # A bit more output
1145 QUIET := @
1146 QUIET2 := @
[1496]1147 MSG_L1 ?= %@$(ECHO) "kBuild: $1 $2"
[776]1148 MSG_L2 =
1149 else ifeq ($(KBUILD_VERBOSE),2)
1150 # Lot more output
1151 QUIET :=
1152 QUIET2 := @
[1496]1153 MSG_L1 ?= %@$(ECHO) "kBuild: $1 $2"
1154 MSG_L2 ?= %@$(ECHO) "kBuild: $1"
[696]1155 else
1156 # maximal output.
[776]1157 QUIET :=
1158 QUIET2 :=
[1496]1159 MSG_L1 ?= %@$(ECHO) "kBuild: $1 $2"
1160 MSG_L2 ?= %@$(ECHO) "kBuild: $1"
[696]1161 endif
1162endif
1163
[776]1164
[1403]1165#
[1504]1166# Validate any KBUILD_BLD_TYPES additions and finally the KBUILD_TYPE.
[1403]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
[1504]1177ifn1of ($(KBUILD_TYPE), $(KBUILD_BLD_TYPES))
1178 $(error kBuild: KBUILD_TYPE(=$(KBUILD_TYPE)) is not found in KBUILD_BLD_TYPES(=$(KBUILD_BLD_TYPES))!)
[1403]1179endif
1180
1181
1182
[988]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)
[1441]1186 $(info stat: $(make-stats ))
[988]1187 _KBUILD_TS_PREV := $(_KBUILD_TS_HEADER_END)
1188endif
1189
[69]1190# end-of-file-content
[72]1191__header_kmk__ := 1
[69]1192endif # __header_kmk__
[479]1193
Note: See TracBrowser for help on using the repository browser.