source: trunk/kBuild/header.kmk@ 993

Last change on this file since 993 was 992, checked in by bird, 18 years ago

Made env.sh reflect that ARCH is more important than CPU. Added keyword suggestions for a bunch of architecture.

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