source: trunk/kBuild/header.kmk@ 742

Last change on this file since 742 was 742, checked in by bird, 19 years ago

Fixed the sub-makefile bustage and added two sanitychecks.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 19.4 KB
RevLine 
[69]1# $Id: header.kmk 742 2006-12-17 07:41:22Z bird $
2## @file
3#
4# kBuild - File included at top of makefile.
5#
[353]6# Copyright (c) 2004-2005 knut st. osmundsen <bird-srcspam@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))
[557]99 ifneq ($(words $(BUILD_PLATFORM))$(filter-out darwin freebsd l4 linux nt os2 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))
[557]133 ifneq ($(words $(BUILD_TARGET))$(filter-out darwin freebsd l4 linux nt os2 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
[725]172## CURSUBDIR is PATH_SUB_ROOT described relative to PATH_ROOT.
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))
[725]213## MAKEFILE_CURRENT is the name of the current makefile.
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
226 $(warning kBuild: kmk minor version mismatch, expected '1' found '$(KBUILD_VERSION_MINOR)'!)
227 endif
228 endif
229else
[723]230 include $(PATH_KBUILD)/gnumake-header.kmk
[216]231endif
[673]232
233
234#
235# The revision in which this file was last modified.
236# This can be useful when using development versions of kBuild.
237#
[672]238KMK_REVISION := $(patsubst %:,, $Rev: 742 $ )
[69]239
[576]240
[69]241#
[72]242# Build platform setup.
[69]243#
244# OS/2
[72]245ifeq ($(BUILD_PLATFORM),os2)
[83]246EXEC_X86_WIN32 := innopec.exe
[69]247HOSTSUFF_EXE := .exe
248endif
249
250# Linux
[72]251ifeq ($(BUILD_PLATFORM),linux)
[135]252EXEC_X86_WIN32 := wine
[69]253HOSTSUFF_EXE :=
254endif
[70]255
[547]256# Win, Win32, Win64, NT.
257ifeq ($(filter-out win32 win64 win nt,$(BUILD_PLATFORM)),)
[69]258EXEC_X86_WIN32 :=
259HOSTSUFF_EXE := .exe
260endif
261
[299]262# FreeBSD
263ifeq ($(BUILD_PLATFORM),freebsd)
264EXEC_X86_WIN32 := wine
265HOSTSUFF_EXE :=
266endif
[125]267
[557]268# Darwin / Mac OS X
269ifeq ($(BUILD_PLATFORM),darwin)
270EXEC_X86_WIN32 := false
271HOSTSUFF_EXE :=
272endif
273
[578]274ifndef PATH_KBUILD_BIN
[731]275 PATH_KBUILD_BIN := $(PATH_KBUILD)/bin/$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)
[578]276 ifeq ($(wildcard $(PATH_KBUILD_BIN)/kmk_ash$(HOSTSUFF_EXE)),)
277 ifeq ($(BUILD_TARGET_ARCH),amd64)
[731]278 PATH_KBUILD_BIN := $(PATH_KBUILD)/bin/$(BUILD_PLATFORM).x86
[478]279 endif
[578]280 ifeq ($(wildcard $(PATH_KBUILD_BIN)/kmk_ash$(HOSTSUFF_EXE)),)
[653]281 ifeq ($(filter-out win64 win32 win nt ,$(BUILD_PLATFORM)),)
[731]282 PATH_KBUILD_BIN := $(PATH_KBUILD)/bin/win.x86
[578]283 endif
284 endif
285 ifeq ($(wildcard $(PATH_KBUILD_BIN)/kmk_ash$(HOSTSUFF_EXE)),)
286 # give up
[731]287 PATH_KBUILD_BIN := $(PATH_KBUILD)/bin/$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)
[578]288 endif
[478]289 endif
290endif
[299]291
[478]292
[73]293#
294# Build target setup.
295#
[480]296ifeq ($(filter-out win32 win64 win nt os2,$(BUILD_TARGET)),)
[73]297SUFF_OBJ := .obj
298SUFF_LIB := .lib
299SUFF_DLL := .dll
300SUFF_EXE := .exe
[86]301SUFF_SYS := .sys
[73]302SUFF_RES := .res
303endif
[480]304ifeq ($(BUILD_TARGET),l4)
[73]305SUFF_OBJ := .o
306SUFF_LIB := .a
[480]307SUFF_DLL := .s.so
[73]308SUFF_EXE :=
[86]309SUFF_SYS := .a
[73]310SUFF_RES :=
311endif
[557]312ifeq ($(BUILD_TARGET),darwin)
313SUFF_OBJ := .o
314SUFF_LIB := .a
315SUFF_DLL := .dylib
316SUFF_EXE :=
317SUFF_SYS := .a
318SUFF_RES :=
319endif
[480]320ifndef SUFF_OBJ
[296]321SUFF_OBJ := .o
322SUFF_LIB := .a
[480]323SUFF_DLL := .so
[296]324SUFF_EXE :=
325SUFF_SYS := .a
326SUFF_RES :=
327endif
[69]328
329#
330# Standard kBuild tools.
331#
[233]332ifeq ($(MAKE),kmk)
[578]333MAKE := $(PATH_KBUILD_BIN)/kmk$(HOSTSUFF_EXE)
[233]334endif
335
[578]336DEP_EXT := $(PATH_KBUILD_BIN)/kDep$(HOSTSUFF_EXE)
[380]337ifeq ($(filter kDep,$(KMK_BUILTIN)),kDep)
[397]338DEP := kmk_builtin_kDep
[230]339else
[380]340DEP := $(DEP_EXT)
[230]341endif
[69]342
[578]343DEP_IDB_EXT := $(PATH_KBUILD_BIN)/kDepIDB$(HOSTSUFF_EXE)
[397]344ifeq ($(filter kDepPre,$(KMK_BUILTIN)),kDepIDB)
345DEP_IDB := $(if kmk_builtin_kDepIDB
346else
347DEP_IDB := $(DEP_IDB_EXT)
348endif
349
[578]350DEP_PRE_EXT := $(PATH_KBUILD_BIN)/kDepPre$(HOSTSUFF_EXE)
[380]351ifeq ($(filter kDepPre,$(KMK_BUILTIN)),kDepPre)
352DEP_PRE := $(if kmk_builtin_kDepPre
353else
354DEP_PRE := $(DEP_PRE_EXT)
355endif
356
[578]357APPEND_EXT := $(PATH_KBUILD_BIN)/kmk_append$(HOSTSUFF_EXE)
[353]358ifeq ($(filter append,$(KMK_BUILTIN)),append)
[380]359APPEND := kmk_builtin_append
[353]360else
[380]361APPEND := $(APPEND_EXT)
[353]362endif
[69]363
[578]364CAT_EXT := $(PATH_KBUILD_BIN)/kmk_cat$(HOSTSUFF_EXE)
[380]365ifeq ($(filter cat,$(KMK_BUILTIN)),cat)
366CAT := kmk_builtin_cat
367else
368CAT := $(CAT_EXT)
369endif
[353]370
[578]371CP_EXT := $(PATH_KBUILD_BIN)/kmk_cp$(HOSTSUFF_EXE)
[380]372ifeq ($(filter cp,$(KMK_BUILTIN)),cp)
373CP := kmk_builtin_cp
374else
375CP := $(CP_EXT)
376endif
377
[578]378ECHO_EXT := $(PATH_KBUILD_BIN)/kmk_echo$(HOSTSUFF_EXE)
[380]379ifeq ($(filter echo,$(KMK_BUILTIN)),echo)
380ECHO := kmk_builtin_echo
381else
382ECHO := $(ECHO_EXT)
383endif
384
[578]385INSTALL_EXT := $(PATH_KBUILD_BIN)/kmk_install$(HOSTSUFF_EXE)
[380]386ifeq ($(filter install,$(KMK_BUILTIN)),install)
387INSTALL := kmk_builtin_install
388else
389INSTALL := $(INSTALL_EXT)
390endif
391
[578]392LN_EXT := $(PATH_KBUILD_BIN)/kmk_ln$(HOSTSUFF_EXE)
[380]393ifeq ($(filter ln,$(KMK_BUILTIN)),ln)
394LN := kmk_builtin_ln
395else
396LN := $(LN_EXT)
397endif
398
[578]399MKDIR_EXT := $(PATH_KBUILD_BIN)/kmk_mkdir$(HOSTSUFF_EXE)
[380]400ifeq ($(filter mkdir,$(KMK_BUILTIN)),mkdir)
401MKDIR := kmk_builtin_mkdir
402else
403MKDIR := $(MKDIR_EXT)
404endif
405
[578]406MV_EXT := $(PATH_KBUILD_BIN)/kmk_mv$(HOSTSUFF_EXE)
[380]407ifeq ($(filter mv,$(KMK_BUILTIN)),mv)
408MV := kmk_builtin_mv
409else
410MV := $(MV_EXT)
411endif
412
[578]413RM_EXT := $(PATH_KBUILD_BIN)/kmk_rm$(HOSTSUFF_EXE)
[380]414ifeq ($(filter rm,$(KMK_BUILTIN)),rm)
415RM := kmk_builtin_rm
416else
417RM := $(RM_EXT)
418endif
419
[601]420RMDIR_EXT := $(PATH_KBUILD_BIN)/kmk_rmdir$(HOSTSUFF_EXE)
421ifeq ($(filter rmdir,$(KMK_BUILTIN)),rmdir)
422RMDIR := kmk_builtin_rmdir
423else
424RMDIR := $(RMDIR_EXT)
425endif
426
[578]427SED_EXT := $(PATH_KBUILD_BIN)/kmk_sed$(HOSTSUFF_EXE)
[380]428ifeq ($(filter sed,$(KMK_BUILTIN)),sed)
429SED := kmk_builtin_sed
430else
431SED := $(SED_EXT)
432endif
433
434# Our default shell is the Almquist shell from *BSD.
[578]435ASH := $(PATH_KBUILD_BIN)/kmk_ash$(HOSTSUFF_EXE)
[380]436MAKESHELL := $(ASH)
437SHELL := $(ASH)
438export SHELL MAKESHELL
439
[414]440# Symlinking is problematic on some platforms...
[380]441LN_SYMLINK := $(LN) -s
442
[130]443## ABSPATH - make paths absolute.
[129]444# This implementation is clumsy and doesn't resolve '..' and '.' components.
[73]445#
[129]446# @param $1 The paths to make absolute.
[696]447# @obsolete Use the GNU make function $(abspath) directly now.
[306]448ABSPATH = $(abspath $(1))
[353]449
[130]450## DIRDEP - make create directory dependencies.
451#
452# @param $1 The paths to the directories which must be created.
[353]453DIRDEP = $(foreach path,$(patsubst %/,%,$(1)),$(path)/)
[129]454
[204]455
[129]456## Cygwin kludge.
457# This converts /cygdrive/x/% to x:%.
458#
459# @param $1 The paths to make native.
460# @remark This macro is pretty much obsolete since we don't use cygwin base make.
461ifneq ($(patsubst /cygdrive/%,%,$(CURDIR)),$(CURDIR))
462CYGPATHMIXED = $(foreach path,$(1)\
463 ,$(if $(patsubst /cygdrive/%,,$(path)),$(path),$(patsubst $(strip $(firstword $(subst /, ,$(patsubst /cygdrive/%,%,$(path)))))/%,$(strip $(firstword $(subst /, ,$(patsubst /cygdrive/%,%,$(path))))):/%,$(patsubst /cygdrive/%,%,$(path)))))
464else
465CYGPATHMIXED = $(1)
466endif
467
[723]468
469ifneq ($(filter stack,$(KMK_FEATURES)),stack) ## @todo retire this to gnumake-header.kmk when all the programs have been recompiled.
470##
471# Pushes an item onto a 'stack' variable.
472# @param $1 The stack variable name
473# @param $2 What to push.
474stack-push = $(eval $1 +=$2)
475
476##
477# Removes the top element from a 'stack' variable.
478# @returns The popped element
479# @param $1 The stack variable name
480stack-pop = $(call stack-top,$1)$(call stack-popv,$1)
481
482##
483# Removes the top element from a 'stack' variable.
484# This does *NOT* return the top element, use
485# @param $1 The stack variable name
486# @remark This ain't very fast (that's why it's implemented in functions.c in kmk).
[724]487stack-popv = $(eval $1:=$(wordlist 1,$(words $(wordlist 2,9999,$($1))),$($1)))
[723]488
489##
490# Retrieves the top element from the 'stack' variable.
491# @param $1 The stack variable name
492stack-top = $(lastword $($1))
493endif
494
495
[129]496#
[353]497# Initialize some of the globals which the Config.kmk and
498# others can add stuff to if they like for processing in the footer.
499#
500
501## ALL_TARGET
502# This is the list of all targets.
503ALL_TARGETS :=
504
505## TEMPLATE_PATHS
506# List a paths (separated by space) where templates can be found.
507TEMPLATE_PATHS :=
508
509## TOOL_PATHS
510# List of paths (separated by space) where tools can be found.
511TOOL_PATHS :=
512
513## SDK_PATHS
514# List of paths (separated by space) where SDKs can be found.
515SDK_PATHS :=
516
517## Proritized list of the default makefile when walking subdirectories.
518# The user can overload this list.
519DEFAULT_MAKEFILE := Makefile.kmk makefile.kmk Makefile makefile
520
[640]521## PROPS_TOOLS
522# This is a subset of the other PROPS
[641]523PROPS_TOOLS := TOOL CTOOL CXXTOOL ASTOOL RCTOOL ARTOOL LDTOOL FETCHTOOL UNPACKTOOL PATCHTOOL
[640]524
[353]525## PROPS_SINGLE
526# The list of non-accumulative target properties.
527# A Config.kmk file can add it's own properties to this list and kBuild
528# will do the necessary inheritance from templates to targets.
[641]529PROPS_SINGLE := $(PROPS_TOOLS) INST NOINST BLD_TYPE BLD_TRG BLD_TRG_ARCH BLD_TRG_CPU FETCHDIR \
530 OBJSUFF COBJSUFF CXXOBJSUFF ASOBJSUFF RCOBJSUFF SYSSUFF EXESUFF DLLSUFF LIBSUFF ARLIBSUFF
[353]531
532## PROPS_DEFERRED
533# This list of non-accumulative target properties which are functions,
534# and thus should not be expanded until the very last moment.
535PROPS_DEFERRED := INSTFUN INSTALLER
536
[660]537## PROPS_ACCUMULATE_R
538# The list of accumulative target properties where the right most value/flag
539# is the 'most significant'.
[353]540# A Config.kmk file can add it's own properties to this list and kBuild
541# will do the necessary inheritance from templates to targets.
[660]542PROPS_ACCUMULATE_R := \
543 DEFS DEPS \
544 CFLAGS CDEFS \
545 CXXFLAGS CXXDEFS \
546 ASFLAGS ASDEFS \
547 RCFLAGS RCDEFS \
548 LDFLAGS \
[640]549 FETCHFLAGS UNPACKFLAGS PATCHFLAGS
[353]550
[660]551## PROPS_ACCUMULATE
552# The list of accumulative target properties where the left most value/flag
553# is the 'most significant'.
554# A Config.kmk file can add it's own properties to this list and kBuild
555# will do the necessary inheritance from templates to targets.
556PROPS_ACCUMULATE_L := \
557 SDKS SOURCES \
558 INCS CINCS CXXINCX ASINCS RCINCS \
559 LIBS LIBPATH
[353]560
[662]561## PROPS_ALL
562# List of all the properties.
563PROPS_ALL = $(PROPS_SINGLE) $(PROPS_DEFERRED) $(PROPS_ACCUMULATE_L) $(PROPS_ACCUMULATE_R)
[660]564
[662]565
[353]566#
[662]567# Here is a special 'hack' to prevent innocent environment variables being
568# picked up and treated as properties. (The most annoying example of why
569# this is necessary is the Visual C++ commandline with it's LIBPATH.)
570#
571# Define KBUILD_DONT_KILL_ENV_PROPS in the env. or on the commandline to
572# disable this 'hack'.
573#
574ifndef KBUILD_DONT_KILL_ENV_PROPS
575
576define def_nuke_environment_prop
577ifeq ($(origin $(prop)),environment)
578$(prop) =
579endif
580endef
581$(foreach prop,$(PROPS_ALL),$(eval $(value def_nuke_environment_prop)))
582
583endif
584
585
586#
[353]587# Pass configuration.
588#
589# The PASS_<passname>_trgs variable is listing the targets.
590# The PASS_<passname>_vars variable is listing the target variables.
591# The PASS_<passname>_pass variable is the lowercased passname.
592#
593
[640]594## PASS: fetches
595# This pass fetches and unpacks things needed to complete the build.
596PASS_FETCHES := Fetches
597PASS_FETCHES_trgs :=
598PASS_FETCHES_vars := _FETCHES
599PASS_FETCHES_pass := fetches
600
601## PASS: patches
602# This pass applies patches.
603PASS_PATCHES := Patches
604PASS_PATCHES_trgs :=
605PASS_PATCHES_vars := _PATCHES
606PASS_PATCHES_pass := patches
607
[353]608## PASS: bldprogs
609# This pass builds targets which are required for building the rest.
610PASS_BLDPROGS := Build Programs
611PASS_BLDPROGS_trgs :=
612PASS_BLDPROGS_vars := _BLDPROGS
613PASS_BLDPROGS_pass := bldprogs
614
615## PASS: libraries
616# This pass builds library targets.
617PASS_LIBRARIES := Libraries
618PASS_LIBRARIES_trgs :=
619PASS_LIBRARIES_vars := _LIBS _IMPORT_LIBS _OTHER_LIBRARIES
620PASS_LIBRARIES_pass := libraries
621
622## PASS: binaries
623# This pass builds dll targets.
624PASS_DLLS := DLLs
625PASS_DLLS_trgs :=
626PASS_DLLS_vars := _DLLS _OTHER_DLLS
627PASS_DLLS_pass := dlls
628
629## PASS: binaries
630# This pass builds binary targets, i.e. programs, system modules and stuff.
631PASS_BINARIES := Programs
632PASS_BINARIES_trgs :=
633PASS_BINARIES_vars := _PROGRAMS _SYSMODS _OTHER_BINARIES
634PASS_BINARIES_pass := binaries
635
636## PASS: others
637# This pass builds other targets.
638PASS_OTHERS := Other Stuff
639PASS_OTHERS_trgs :=
640PASS_OTHERS_vars := _OTHERS
641PASS_OTHERS_pass := others
642
643## PASS: install
644# This pass installs the built entities to a sandbox area.
645PASS_INSTALLS := Install
646PASS_INSTALLS_trgs :=
[380]647PASS_INSTALLS_vars := _INSTALLS_DIRS _INSTALLS
[353]648PASS_INSTALLS_pass := installs
649
650## PASS: packing
651# This pass processes custom packing rules.
652PASS_PACKING := Packing
[414]653PASS_PACKING_trgs :=
[417]654PASS_PACKING_vars := _PACKING
[353]655PASS_PACKING_pass := packing
[414]656#alias
657packing: pass_packing
[353]658
659## PASS: clean
660# This pass removes all generated files.
661PASS_CLEAN := Clean
662PASS_CLEAN_trgs := do-clean
663PASS_CLEAN_vars :=
664PASS_CLEAN_pass := clean
665# alias
666clean: pass_clean
667
668## PASS: nothing
669# This pass just walks the tree.
670PASS_NOTHING := Nothing
671PASS_NOTHING_trgs := do-nothing
672PASS_NOTHING_vars :=
673PASS_NOTHING_pass := nothing
674# alias
675nothing: pass_nothing
676
677## DEFAULT_PASSES
678# The default passes and their order.
679DEFAULT_PASSES := BLDPROGS LIBRARIES DLLS BINARIES OTHERS INSTALLS
680
681## PASSES
682# The passes that should be defined. This must include
683# all passes mentioned by DEFAULT_PASSES.
[723]684PASSES := FETCHES PATCHES $(DEFAULT_PASSES) NOTHING CLEAN
[353]685
686
687#
[69]688# This is how we find the closest config.kmk.
689# It's a little hacky but I think it works fine.
[70]690#
691_CFGDIR := .
[78]692_CFGFILES := ./Config.kmk ./config.kmk
[69]693define def_include_config
[78]694$(eval _CFGDIR := $(_CFGDIR)/$(dir))
695_CFGFILES += $(_CFGDIR)/Config.kmk $(_CFGDIR)/config.kmk
[69]696endef
697# walk down the _RELATIVE_ path specified by DEPTH.
[78]698$(foreach dir,$(subst /, ,$(DEPTH)), $(eval $(def_include_config)) )
[69]699# add the default config file.
[78]700_CFGFILE := $(firstword $(wildcard $(_CFGFILES) $(FILE_KBUILD_CONFIG)))
[69]701_CFGFILES :=
702_CFGDIR :=
[416]703ifeq ($(_CFGFILE),)
704$(error kBuild: no Config.kmk file found! Check the DEPTH: DEPTH='$(DEPTH)' PATH_CURRENT='$(PATH_CURRENT)')
705endif
[69]706
707# Include the config.kmk we found file (or the default one).
708include $(_CFGFILE)
709
710
[696]711#
712# Message macros.
713#
714# This is done after including Config.kmk as to allow for
715# KBUILD_QUIET and KBUILD_VERBOSE to be configurable.
716#
717ifdef KBUILD_QUIET
718 # minimal output.
719 QUIET := @
720 QUIET2:= @
721 MSG_L1 =
722 MSG_L2 =
723 MSG_L3 =
724else
725 ifndef KBUILD_VERBOSE
[700]726 ifneq ($(filter --pretty-command-printing,$(MAKEFLAGS)),)
727 export KBUILD_VERBOSE := 1
728 endif
729 endif
730 ifndef KBUILD_VERBOSE
[696]731 QUIET := @
732 QUIET2:= @
733 MSG_L1 = @$(ECHO) "kBuild: $1"
734 MSG_L2 =
735 MSG_L3 =
736 else
737 # maximal output.
738 QUIET :=
739 MSG_L1 = @$(ECHO) "kBuild: $1 $2"
740 MSG_L2 = @$(ECHO) "kBuild: $1"
[699]741 ifneq ($(KBUILD_VERBOSE),all)
[696]742 QUIET2:= @
743 else
744 QUIET2:=
745 endif
746 endif
747endif
748
[69]749# end-of-file-content
[72]750__header_kmk__ := 1
[69]751endif # __header_kmk__
[479]752
[742]753
Note: See TracBrowser for help on using the repository browser.