source: trunk/kBuild/header.kmk@ 897

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

Added _CLEAN to install targets and BLDDIR to all targets (but not sources).

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