source: trunk/kBuild/header.kmk@ 895

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

DOLLAR, EQUAL, DOT, COMMA, SEMICOLON and COLON.

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