source: trunk/kBuild/header.kmk@ 1645

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

Introduce the concept of units to prevent footer.kmk from growing beyond proportions. Features that are rarely used are put into units and dragged in via the USES property when needed. The first example of this is how lex (.l files) is handled.

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