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
Line 
1# $Id: header.kmk 894 2007-05-05 04:44:10Z bird $
2## @file
3#
4# kBuild - File included at top of makefile.
5#
6# Copyright (c) 2004-2007 knut st. osmundsen <bird-kBuild-spam@anduin.net>
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#
36# The FORCE rule.
37#
38FORCE:
39
40#
41# Try avoid inference rules.
42#
43.SUFFIXES:
44SUFFIXES :=
45
46#
47# Enable delete (targets) on error.
48#
49.DELETE_ON_ERROR:
50
51#
52# Enable second expansion of prerequisites.
53#
54.SECONDEXPANSION:
55
56
57#
58# General purpose macros.
59#
60
61## get last word in a list.
62# @returns last word in $1.
63# @param $1 Word list.
64lastword = $(word $(words $(1)), $(1))
65
66##
67# Newline character(s).
68define NL
69
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
87STRCMP = $( todo )
88
89#
90# Set default build type.
91#
92ifndef BUILD_TYPE
93 ifdef BUILD_MODE
94 # BUILD_MODE is legacy from the OS/2 build system. :)
95BUILD_TYPE := $(tolower $(BUILD_MODE))
96 else
97BUILD_TYPE := release
98 endif
99endif
100
101
102#
103# Assert build platform.
104#
105ifndef BUILD_PLATFORM
106 $(error kBuild: BUILD_PLATFORM is undefined!)
107else
108 BUILD_PLATFORM := $(strip $(BUILD_PLATFORM))
109 ifneq ($(words $(BUILD_PLATFORM))$(filter-out darwin freebsd l4 linux nt os2 solaris win win32 win64,$(BUILD_PLATFORM)),1)
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
116endif
117
118# Fill in defaults if needed.
119ifndef BUILD_PLATFORM_ARCH
120 ifeq ($(filter-out win64,$(BUILD_PLATFORM)),)
121 BUILD_PLATFORM_ARCH := amd64
122 else
123 BUILD_PLATFORM_ARCH := x86
124 endif
125endif
126ifndef BUILD_PLATFORM_CPU
127 ifeq ($(filter-out amd64,$(BUILD_PLATFORM_ARCH)),)
128 BUILD_PLATFORM_CPU:= k8
129 else
130 BUILD_PLATFORM_CPU:= i586
131 endif
132endif
133
134
135#
136# Assert target platform.
137#
138ifndef BUILD_TARGET
139# not defined, set to the same as build platform
140BUILD_TARGET := $(BUILD_PLATFORM)
141else
142 BUILD_TARGET := $(strip $(BUILD_TARGET))
143 ifneq ($(words $(BUILD_TARGET))$(filter-out darwin freebsd l4 linux nt os2 solaris win win32 win64,$(BUILD_TARGET)),1)
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
150endif
151
152# Fill in defaults if needed.
153ifndef BUILD_TARGET_ARCH
154 BUILD_TARGET_ARCH := x86
155endif
156ifndef BUILD_TARGET_CPU
157 BUILD_TARGET_CPU := i586
158endif
159
160# Adjust the DEPTH definition first
161ifeq ($(strip $(DEPTH)),)
162DEPTH := .
163endif
164
165#
166# Common definitions.
167#
168## PATH_CURRENT is the current directory (getcwd).
169PATH_CURRENT := $(abspath $(CURDIR))
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.
176ifneq ($(strip $(SUB_DEPTH)),)
177 PATH_SUB_ROOT := $(abspath $(PATH_CURRENT)/$(SUB_DEPTH))
178else
179 PATH_SUB_ROOT := $(PATH_CURRENT)
180endif
181
182## CURSUBDIR is PATH_SUB_ROOT described relative to PATH_ROOT.
183# This variable is used to determin where the object files and other output goes.
184ifneq ($(PATH_ROOT),$(PATH_CURRENT))
185CURSUBDIR := $(patsubst $(PATH_ROOT)/%,%,$(PATH_SUB_ROOT))
186else
187CURSUBDIR := .
188endif
189
190# Output directories.
191ifndef PATH_OUT_BASE
192 PATH_OUT_BASE := $(PATH_ROOT)/out
193endif
194ifndef PATH_OUT
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
200endif # !define PATH_OUT
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
209
210# Usually kBuild is external to the source tree.
211ifndef PATH_KBUILD
212 PATH_KBUILD := $(PATH_ROOT)/kBuild
213endif
214PATH_KBUILD := $(abspath $(PATH_KBUILD))
215# kBuild files which might be of interest.
216FILE_KBUILD_HEADER := $(PATH_KBUILD)/header.kmk
217#FILE_KBUILD_CONFIG := $(PATH_KBUILD)/config.kmk
218FILE_KBUILD_FOOTER := $(PATH_KBUILD)/footer.kmk
219
220SUFF_DEP := .dep
221## MAKEFILE is the name of the main makefile.
222MAKEFILE := $(firstword $(MAKEFILE_LIST))
223## MAKEFILE_CURRENT is the name of the current makefile.
224# This is updated everything a sub-makefile is included.
225MAKEFILE_CURRENT := $(MAKEFILE)
226
227
228#
229# Check make version.
230#
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
236 $(warning kBuild: kmk minor version mismatch, expected '1' found '$(KBUILD_VERSION_MINOR)'!)
237 endif
238 endif
239endif
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#
246KMK_REVISION := $(patsubst %:,, $Rev: 894 $ )
247
248
249#
250# Build platform setup.
251#
252# OS/2
253ifeq ($(BUILD_PLATFORM),os2)
254EXEC_X86_WIN32 := innopec.exe
255HOSTSUFF_EXE := .exe
256endif
257
258# Linux
259ifeq ($(BUILD_PLATFORM),linux)
260EXEC_X86_WIN32 := wine
261HOSTSUFF_EXE :=
262endif
263
264# Win, Win32, Win64, NT.
265ifeq ($(filter-out win32 win64 win nt,$(BUILD_PLATFORM)),)
266EXEC_X86_WIN32 :=
267HOSTSUFF_EXE := .exe
268endif
269
270# FreeBSD
271ifeq ($(BUILD_PLATFORM),freebsd)
272EXEC_X86_WIN32 := wine
273HOSTSUFF_EXE :=
274endif
275
276# Darwin / Mac OS X
277ifeq ($(BUILD_PLATFORM),darwin)
278EXEC_X86_WIN32 := false
279HOSTSUFF_EXE :=
280endif
281
282# Solaris
283ifeq ($(BUILD_PLATFORM),solaris)
284EXEC_X86_WIN32 := false
285HOSTSUFF_EXE :=
286endif
287
288ifndef PATH_KBUILD_BIN
289 PATH_KBUILD_BIN := $(PATH_KBUILD)/bin/$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)
290 ifeq ($(wildcard $(PATH_KBUILD_BIN)/kmk_ash$(HOSTSUFF_EXE)),)
291 ifeq ($(BUILD_TARGET_ARCH),amd64)
292 PATH_KBUILD_BIN := $(PATH_KBUILD)/bin/$(BUILD_PLATFORM).x86
293 endif
294 ifeq ($(wildcard $(PATH_KBUILD_BIN)/kmk_ash$(HOSTSUFF_EXE)),)
295 ifeq ($(filter-out win64 win32 win nt ,$(BUILD_PLATFORM)),)
296 PATH_KBUILD_BIN := $(PATH_KBUILD)/bin/win.x86
297 endif
298 endif
299 ifeq ($(wildcard $(PATH_KBUILD_BIN)/kmk_ash$(HOSTSUFF_EXE)),)
300 # give up
301 PATH_KBUILD_BIN := $(PATH_KBUILD)/bin/$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)
302 endif
303 endif
304endif
305
306
307#
308# Build target setup.
309#
310ifeq ($(filter-out win32 win64 win nt os2,$(BUILD_TARGET)),)
311SUFF_OBJ := .obj
312SUFF_LIB := .lib
313SUFF_DLL := .dll
314SUFF_EXE := .exe
315SUFF_SYS := .sys
316SUFF_RES := .res
317endif
318ifeq ($(BUILD_TARGET),l4)
319SUFF_OBJ := .o
320SUFF_LIB := .a
321SUFF_DLL := .s.so
322SUFF_EXE :=
323SUFF_SYS := .a
324SUFF_RES :=
325endif
326ifeq ($(BUILD_TARGET),darwin)
327SUFF_OBJ := .o
328SUFF_LIB := .a
329SUFF_DLL := .dylib
330SUFF_EXE :=
331SUFF_SYS :=
332SUFF_RES :=
333endif
334ifndef SUFF_OBJ
335SUFF_OBJ := .o
336SUFF_LIB := .a
337SUFF_DLL := .so
338SUFF_EXE :=
339SUFF_SYS := .a
340SUFF_RES :=
341endif
342
343#
344# Standard kBuild tools.
345#
346ifeq ($(MAKE),kmk)
347MAKE := $(PATH_KBUILD_BIN)/kmk$(HOSTSUFF_EXE)
348endif
349
350DEP_EXT := $(PATH_KBUILD_BIN)/kDep$(HOSTSUFF_EXE)
351ifeq ($(filter kDep,$(KMK_BUILTIN)),kDep)
352DEP := kmk_builtin_kDep
353else
354DEP := $(DEP_EXT)
355endif
356
357DEP_IDB_EXT := $(PATH_KBUILD_BIN)/kDepIDB$(HOSTSUFF_EXE)
358ifeq ($(filter kDepPre,$(KMK_BUILTIN)),kDepIDB)
359DEP_IDB := $(if kmk_builtin_kDepIDB
360else
361DEP_IDB := $(DEP_IDB_EXT)
362endif
363
364DEP_PRE_EXT := $(PATH_KBUILD_BIN)/kDepPre$(HOSTSUFF_EXE)
365ifeq ($(filter kDepPre,$(KMK_BUILTIN)),kDepPre)
366DEP_PRE := $(if kmk_builtin_kDepPre
367else
368DEP_PRE := $(DEP_PRE_EXT)
369endif
370
371APPEND_EXT := $(PATH_KBUILD_BIN)/kmk_append$(HOSTSUFF_EXE)
372ifeq ($(filter append,$(KMK_BUILTIN)),append)
373APPEND := kmk_builtin_append
374else
375APPEND := $(APPEND_EXT)
376endif
377
378CAT_EXT := $(PATH_KBUILD_BIN)/kmk_cat$(HOSTSUFF_EXE)
379ifeq ($(filter cat,$(KMK_BUILTIN)),cat)
380CAT := kmk_builtin_cat
381else
382CAT := $(CAT_EXT)
383endif
384
385CP_EXT := $(PATH_KBUILD_BIN)/kmk_cp$(HOSTSUFF_EXE)
386ifeq ($(filter cp,$(KMK_BUILTIN)),cp)
387CP := kmk_builtin_cp
388else
389CP := $(CP_EXT)
390endif
391
392ECHO_EXT := $(PATH_KBUILD_BIN)/kmk_echo$(HOSTSUFF_EXE)
393ifeq ($(filter echo,$(KMK_BUILTIN)),echo)
394ECHO := kmk_builtin_echo
395else
396ECHO := $(ECHO_EXT)
397endif
398
399INSTALL_EXT := $(PATH_KBUILD_BIN)/kmk_install$(HOSTSUFF_EXE)
400ifeq ($(filter install,$(KMK_BUILTIN)),install)
401INSTALL := kmk_builtin_install
402else
403INSTALL := $(INSTALL_EXT)
404endif
405
406LN_EXT := $(PATH_KBUILD_BIN)/kmk_ln$(HOSTSUFF_EXE)
407ifeq ($(filter ln,$(KMK_BUILTIN)),ln)
408LN := kmk_builtin_ln
409else
410LN := $(LN_EXT)
411endif
412
413MKDIR_EXT := $(PATH_KBUILD_BIN)/kmk_mkdir$(HOSTSUFF_EXE)
414ifeq ($(filter mkdir,$(KMK_BUILTIN)),mkdir)
415MKDIR := kmk_builtin_mkdir
416else
417MKDIR := $(MKDIR_EXT)
418endif
419
420MV_EXT := $(PATH_KBUILD_BIN)/kmk_mv$(HOSTSUFF_EXE)
421ifeq ($(filter mv,$(KMK_BUILTIN)),mv)
422MV := kmk_builtin_mv
423else
424MV := $(MV_EXT)
425endif
426
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
434RM_EXT := $(PATH_KBUILD_BIN)/kmk_rm$(HOSTSUFF_EXE)
435ifeq ($(filter rm,$(KMK_BUILTIN)),rm)
436RM := kmk_builtin_rm
437else
438RM := $(RM_EXT)
439endif
440
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
448SED_EXT := $(PATH_KBUILD_BIN)/kmk_sed$(HOSTSUFF_EXE)
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.
456ASH := $(PATH_KBUILD_BIN)/kmk_ash$(HOSTSUFF_EXE)
457MAKESHELL := $(ASH)
458SHELL := $(ASH)
459export SHELL MAKESHELL
460
461# Symlinking is problematic on some platforms...
462LN_SYMLINK := $(LN) -s
463
464
465#
466# Some Functions.
467# The lower cased ones are either fallbacks or candidates for functions.c.
468#
469
470## ABSPATH - make paths absolute.
471# This implementation is clumsy and doesn't resolve '..' and '.' components.
472#
473# @param $1 The paths to make absolute.
474# @obsolete Use the GNU make function $(abspath) directly now.
475ABSPATH = $(abspath $(1))
476
477## DIRDEP - make create directory dependencies.
478#
479# @param $1 The paths to the directories which must be created.
480DIRDEP = $(foreach path,$(patsubst %/,%,$(1)),$(path)/)
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))
488 CYGPATHMIXED = $(foreach path,$(1)\
489 ,$(if $(patsubst /cygdrive/%,,$(path)),$(path),$(patsubst $(strip $(firstword $(subst /, ,$(patsubst /cygdrive/%,%,$(path)))))/%,$(strip $(firstword $(subst /, ,$(patsubst /cygdrive/%,%,$(path))))):/%,$(patsubst /cygdrive/%,%,$(path)))))
490else
491 CYGPATHMIXED = $(1)
492endif
493
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)))
502endif
503
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)))
507
508## Removes the root slash from a path (if it has one)
509# @param $1 the path
510no-root-slash = $(patsubst /%,%,$(1))
511
512## Figure out where to put object files.
513# @param $1 real target name.
514# @param $2 normalized main target
515TARGET_BASE = $(PATH_TARGET)/$(2)/$(call no-root-slash,$(call no-drive,$(1)))
516
517## Figure out where to put object files.
518# @param $1 normalized main target
519TARGET_PATH = $(PATH_TARGET)/$(1)
520
521
522#
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
547## PROPS_TOOLS
548# This is a subset of the other PROPS
549PROPS_TOOLS := TOOL CTOOL CXXTOOL ASTOOL RCTOOL ARTOOL LDTOOL FETCHTOOL UNPACKTOOL PATCHTOOL
550
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.
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
557
558## PROPS_DEFERRED
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
562
563## PROPS_ACCUMULATE_R
564# The list of accumulative target properties where the right most value/flag
565# is the 'most significant'.
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.
568PROPS_ACCUMULATE_R := \
569 DEFS DEPS ORDERDEPS \
570 CFLAGS CDEFS \
571 CXXFLAGS CXXDEFS \
572 ASFLAGS ASDEFS \
573 RCFLAGS RCDEFS \
574 LDFLAGS \
575 IDFLAGS IFDLAGS ISFLAGS \
576 FETCHFLAGS UNPACKFLAGS PATCHFLAGS
577
578## PROPS_ACCUMULATE
579# The list of accumulative target properties where the left most value/flag
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
587
588## PROPS_ALL
589# List of all the properties.
590PROPS_ALL = $(PROPS_SINGLE) $(PROPS_DEFERRED) $(PROPS_ACCUMULATE_L) $(PROPS_ACCUMULATE_R)
591
592
593#
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
596# this is necessary is the Visual C++ commandline with it's LIBPATH.)
597#
598# Define KBUILD_DONT_KILL_ENV_PROPS in the env. or on the commandline to
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
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)))
612
613endif
614
615
616#
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
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
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 :=
677PASS_INSTALLS_vars := _INSTALLS_DIRS _INSTALLS _INSTALLS_FILES
678PASS_INSTALLS_pass := installs
679
680## PASS: packing
681# This pass processes custom packing rules.
682PASS_PACKING := Packing
683PASS_PACKING_trgs :=
684PASS_PACKING_vars := _PACKING
685PASS_PACKING_pass := packing
686#alias
687packing: pass_packing
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.
714PASSES := FETCHES PATCHES $(DEFAULT_PASSES) NOTHING CLEAN
715
716
717#
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#
726# This is how we find the closest config.kmk.
727# It's a little hacky but I think it works fine.
728#
729_CFGDIR := .
730_CFGFILES := ./Config.kmk ./config.kmk
731define def_include_config
732$(eval _CFGDIR := $(_CFGDIR)/$(dir))
733_CFGFILES += $(_CFGDIR)/Config.kmk $(_CFGDIR)/config.kmk
734endef
735# walk down the _RELATIVE_ path specified by DEPTH.
736$(foreach dir,$(subst /, ,$(DEPTH)), $(eval $(def_include_config)) )
737# add the default config file.
738_CFGFILE := $(firstword $(wildcard $(_CFGFILES) $(FILE_KBUILD_CONFIG)))
739_CFGFILES :=
740_CFGDIR :=
741ifeq ($(_CFGFILE),)
742$(error kBuild: no Config.kmk file found! Check the DEPTH: DEPTH='$(DEPTH)' PATH_CURRENT='$(PATH_CURRENT)')
743endif
744
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)),)
753 export KBUILD_VERBOSE := 2
754 endif
755 endif
756endif
757
758
759# Include the config.kmk we found file (or the default one).
760include $(_CFGFILE)
761
762
763#
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#
781# Setup the message style. The default one is inlined.
782#
783# See kBuild/msgstyles for more styles or use KBUILD_MSG_STYLE_PATHS
784# to create your own message style.
785#
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)
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))
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)
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 MSG_AR_MERGE ?= $(call MSG_L1,Merging $3 into $1, ($2))
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
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)
877 else
878 $(error kBuild: Can't find the style setup file for KBUILD_MSG_STYLE '$(KBUILD_MSG_STYLE)')
879 endif
880endif
881
882
883#
884# Message macros.
885#
886# This is done after including Config.kmk as to allow for
887# KBUILD_QUIET and KBUILD_VERBOSE to be configurable.
888#
889ifdef KBUILD_QUIET
890 # No output
891 QUIET := @
892 QUIET2:= @
893 MSG_L1 =
894 MSG_L2 =
895else
896 ifndef KBUILD_VERBOSE
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"
914 else
915 # maximal output.
916 QUIET :=
917 QUIET2 :=
918 MSG_L1 ?= @$(ECHO) "kBuild: $1 $2"
919 MSG_L2 ?= @$(ECHO) "kBuild: $1"
920 endif
921endif
922
923
924# end-of-file-content
925__header_kmk__ := 1
926endif # __header_kmk__
927
Note: See TracBrowser for help on using the repository browser.