source: trunk/kBuild/header.kmk@ 984

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

enabled the multi target rules. added some PORTME hints.

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