source: trunk/kBuild/header.kmk@ 828

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

Added fake xargs implementation. Retired abspathex to gnumake-header.kmk.

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