source: trunk/kBuild/header.kmk@ 2172

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

header.kmk: added some missing tools and cleaned up the existing.

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