source: trunk/kBuild/header.kmk@ 886

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

Moved the PATH_* finalizing to header.kmk and applied abspath to all of them.

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