source: trunk/kBuild/header.kmk@ 904

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

Recognize the CLEAN attribute. header.kmk

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