source: trunk/kBuild/header.kmk@ 894

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

Enable DELETE_ON_ERROR and SECONDEXPANSION by default.

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