source: trunk/kBuild/header.kmk@ 1354

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

Require kmk 0.1.2 or later. Use if1of. Removed test on obsolete targets/platforms win32 and win64.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 30.1 KB
Line 
1# $Id: header.kmk 1348 2007-12-03 00:54:30Z bird $
2## @file
3#
4# kBuild - File included at top of a 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
29ifdef KBUILD_PROFILE_SELF
30 _KBUILD_TS_HEADER_START := $(nanots ) # just a dummy warm up query
31 $(info prof: since start - since previous - event description)
32 _KBUILD_TS_HEADER_START := $(nanots )
33 _KBUILD_TS_PREV := $(_KBUILD_TS_HEADER_START)
34endif
35
36
37#
38# Check make version before we do anything else.
39#
40ifndef KMK_VERSION
41 $(error kBuild: The kmk default variable KMK_VERSION isn't defined! Make sure you are using 'kmk' and not 'make', 'gmake', 'kmk_gmake', 'dmake' or any other make program)
42endif
43ifneq ($(KBUILD_VERSION_MAJOR).$(KBUILD_VERSION_MINOR),0.1)
44 ifneq ($(KBUILD_VERSION_MAJOR),0)
45 $(warning kBuild: kmk major version mismatch! Expected '0' but found '$(KBUILD_VERSION_MAJOR)'!)
46 else
47 $(warning kBuild: kmk minor version mismatch! Expected '1' but found '$(KBUILD_VERSION_MINOR)'!)
48 endif
49else
50 ifneq ($(int-ge $(KBUILD_VERSION_PATCH),2),1)
51 $(warning kBuild: kmk version mismatch! Expected 0.1.2 or later. Actual version is $(KBUILD_VERSION_MAJOR).$(KBUILD_VERSION_MINOR).$(KBUILD_VERSION_PATCH).)
52 endif
53endif
54
55#
56# The revision in which this file was last modified.
57# This can be useful when using development versions of kBuild.
58#
59KMK_REVISION := $(patsubst %:,, $Rev: 1348 $ )
60
61
62#
63# Define the default goal.
64#
65all: all_recursive
66
67#
68# The phony FORCE target.
69#
70FORCE:
71
72
73#
74# Enable delete on error and second expansion of prerequisites.
75#
76.DELETE_ON_ERROR:
77
78.SECONDEXPANSION:
79
80
81#
82# General purpose macros.
83#
84
85##
86# Newline character(s).
87define NL
88
89
90endef
91
92##
93# Tab character.
94TAB := $(subst ., ,.)
95
96##
97# Newline + tab characters (for generating commands).
98NLTAB = $(NL)$(TAB)
99
100##
101# Space character.
102SP := $(subst ., ,.)
103
104##
105# Hash character.
106define HASH
107#
108endef
109
110##
111# Colon character.
112COLON := :
113
114##
115# Semicolon character.
116SEMICOLON := ;
117
118##
119# Comma character.
120COMMA := ,
121
122##
123# Dot character.
124DOT := .
125
126##
127# Dollar character.
128DOLLAR := $$
129
130##
131# Equal character.
132EQUAL := =
133
134
135#
136# The OSes, Architectures and CPUs that kBuild recognizes.
137#
138# When kBuild is ported to a new OS or architecture a unique keyword needs
139# to be assigned to it and added here. This strictness is required because
140# this keyword namespace is shared between OSes, architectures, cpus and
141# build types. (PORTME)
142#
143KBUILD_OSES := darwin freebsd l4 linux netbsd nt openbsd os2 solaris win
144KBUILD_ARCHES := x86 amd64 sparc32 sparc64 s390 ppc32 ppc64 mips32 mips64 ia64 hppa32 hppa64 arm alpha
145
146
147#
148# Set default build type.
149#
150ifndef BUILD_TYPE
151 BUILD_TYPE := release
152else
153 if1of ($(BUILD_TYPE),$(KBUILD_OSES) $(KBUILD_ARCHES))
154 $(error kBuild: The BUILD_TYPE value '$(BUILD_TYPE)' is an OS or architecture!)
155 endif
156 ifneq (.$(words $(BUILD_TYPE)).$(BUILD_TYPE).,.1.$(strip $(BUILD_TYPE)).)
157 $(error kBuild: The BUILD_TYPE value '$(BUILD_TYPE)' contains spaces/tabs!)
158 endif
159endif
160
161
162#
163# Assert valid build platform variables.
164#
165# All these are set by kmk so they shouldn't be any trouble
166# unless the user starts messing about with environment variables.
167#
168ifneq (.$(words $(BUILD_PLATFORM)).$(BUILD_PLATFORM).,.1.$(strip $(BUILD_PLATFORM)).)
169 $(error kBuild: The BUILD_PLATFORM value '$(BUILD_PLATFORM)' contains spaces/tabs!)
170endif
171ifneq ($(words $(filter $(BUILD_PLATFORM),$(KBUILD_OSES))),1)
172 $(error kBuild: BUILD_PLATFORM value '$(BUILD_PLATFORM)' is not recognized (valid: $(KBUILD_OSES)))
173endif
174
175ifneq (.$(words $(BUILD_PLATFORM_ARCH)).$(BUILD_PLATFORM_ARCH).,.1.$(strip $(BUILD_PLATFORM_ARCH)).)
176 $(error kBuild: The BUILD_PLATFORM_ARCH value '$(BUILD_PLATFORM_ARCH)' contains spaces/tabs!)
177endif
178ifneq ($(words $(filter $(BUILD_PLATFORM_ARCH),$(KBUILD_ARCHES))),1)
179 $(error kBuild: BUILD_PLATFORM_ARCH value '$(BUILD_PLATFORM_ARCH)' is not recognized (valid: $(KBUILD_ARCHES)))
180endif
181
182ifeq ($(strip $(BUILD_PLATFORM_CPU)),)
183 BUILD_PLATFORM_CPU := blend
184else
185 ifneq (.$(words $(BUILD_PLATFORM_CPU)).$(BUILD_PLATFORM_CPU).,.1.$(strip $(BUILD_PLATFORM_CPU)).)
186 $(error kBuild: The BUILD_PLATFORM_CPU value '$(BUILD_PLATFORM_CPU)' contains spaces/tabs!)
187 endif
188 if1of ($(BUILD_PLATFORM_CPU), $(KBUILD_OSES) $(BUILD_ARCHES))
189 $(error kBuild: The BUILD_PLATFORM_CPU value '$(BUILD_PLATFORM_CPU)' was found in the OS or architecture keywords!)
190 endif
191 ifeq ($(BUILD_PLATFORM_CPU),$(BUILD_TYPE))
192 $(error kBuild: The BUILD_PLATFORM_CPU value '$(BUILD_PLATFORM_CPU)' is the same as the BUILD_TYPE!)
193 endif
194endif
195
196
197#
198# Assert or set default target platform.
199# When not defined use the corresponding BUILD_PLATFORM value.
200#
201ifndef BUILD_TARGET
202 BUILD_TARGET := $(BUILD_PLATFORM)
203else
204 ifneq (.$(words $(BUILD_TARGET)).$(BUILD_TARGET).,.1.$(strip $(BUILD_TARGET)).)
205 $(error kBuild: The BUILD_TARGET value '$(BUILD_TARGET)' contains spaces/tabs!)
206 endif
207 ifneq ($(words $(filter $(BUILD_TARGET),$(KBUILD_OSES))),1)
208 $(error kBuild: BUILD_TARGET value '$(BUILD_TARGET)' is not recognized (valid: $(KBUILD_OSES)))
209 endif
210endif
211
212ifndef BUILD_TARGET_ARCH
213 BUILD_TARGET_ARCH := $(BUILD_PLATFORM_ARCH)
214else
215 ifneq (.$(words $(BUILD_TARGET_ARCH)).$(BUILD_TARGET_ARCH).,.1.$(strip $(BUILD_TARGET_ARCH)).)
216 $(error kBuild: The BUILD_TARGET_ARCH value '$(BUILD_TARGET_ARCH)' contains spaces/tabs!)
217 endif
218 ifneq ($(words $(filter $(BUILD_TARGET_ARCH),$(KBUILD_ARCHES))),1)
219 $(error kBuild: BUILD_TARGET_ARCH value '$(BUILD_TARGET_ARCH)' is not recognized (valid: $(KBUILD_ARCHES)))
220 endif
221endif
222
223ifndef BUILD_TARGET_CPU
224 BUILD_TARGET_CPU := $(BUILD_PLATFORM_CPU)
225else ifeq ($(strip $(BUILD_TARGET_CPU)),)
226 ifeq ($(BUILD_TARGET_ARCH),$(BUILD_PLATFORM_ARCH))
227 BUILD_TARGET_CPU := $(BUILD_PLATFORM_CPU)
228 else
229 BUILD_TARGET_CPU := blend
230 endif
231else
232 ifneq (.$(words $(BUILD_TARGET_CPU)).$(BUILD_TARGET_CPU).,.1.$(strip $(BUILD_TARGET_CPU)).)
233 $(error kBuild: The BUILD_TARGET_CPU value '$(BUILD_TARGET_CPU)' contains spaces/tabs!)
234 endif
235 if1of ($(BUILD_TARGET_CPU), $(KBUILD_OSES) $(BUILD_ARCHES))
236 $(error kBuild: The BUILD_TARGET_CPU value was found in the OS or architecture keywords!)
237 endif
238 ifeq ($(BUILD_TARGET_CPU),$(BUILD_TYPE))
239 $(error kBuild: The BUILD_TARGET_CPU value '$(BUILD_TARGET_CPU)' is the same as the BUILD_TYPE!)
240 endif
241endif
242
243
244#
245# Paths and stuff.
246#
247
248# Adjust DEPTH first.
249DEPTH := $(strip $(DEPTH))
250ifeq ($(DEPTH),)
251 DEPTH := .
252endif
253
254## PATH_CURRENT is the current directory (getcwd).
255PATH_CURRENT := $(abspath $(CURDIR))
256## PATH_SUB_CURRENT points to current directory of the current makefile.
257# Meaning that it will change value as we enter and exit sub-makefiles.
258PATH_SUB_CURRENT := $(PATH_CURRENT)
259## PATH_ROOT points to the project root directory.
260PATH_ROOT := $(abspath $(PATH_CURRENT)/$(DEPTH))
261## PATH_SUB_ROOT points to the directory of the top-level makefile.
262ifneq ($(strip $(SUB_DEPTH)),)
263 SUB_DEPTH := $(strip $(SUB_DEPTH))
264 PATH_SUB_ROOT := $(abspath $(PATH_CURRENT)/$(SUB_DEPTH))
265else
266 PATH_SUB_ROOT := $(PATH_CURRENT)
267endif
268
269## CURSUBDIR is PATH_SUB_ROOT described relative to PATH_ROOT.
270# This variable is used to determin where the object files and other output goes.
271ifneq ($(PATH_ROOT),$(PATH_CURRENT))
272CURSUBDIR := $(patsubst $(PATH_ROOT)/%,%,$(PATH_SUB_ROOT))
273else
274CURSUBDIR := .
275endif
276
277# Output directories.
278ifndef PATH_OUT_BASE
279 PATH_OUT_BASE := $(PATH_ROOT)/out
280endif
281ifndef PATH_OUT
282 ifdef BUILD_TARGET_SUB # (BUILD_TARGET_SUB is not currently recognized by kBuild in any other places.)
283 PATH_OUT := $(PATH_OUT_BASE)/$(BUILD_TARGET).$(BUILD_TARGET_ARCH).$(BUILD_TARGET_SUB)/$(BUILD_TYPE)
284 else
285 PATH_OUT := $(PATH_OUT_BASE)/$(BUILD_TARGET).$(BUILD_TARGET_ARCH)/$(BUILD_TYPE)
286 endif
287endif # !define PATH_OUT
288PATH_OBJCACHE = $(PATH_OUT_BASE)/kObjCache
289PATH_OBJ = $(PATH_OUT)/obj
290PATH_TARGET = $(PATH_OBJ)/$(CURSUBDIR)
291PATH_INS = $(PATH_OUT)
292PATH_BIN = $(PATH_INS)/bin
293PATH_DLL = $(PATH_INS)/bin
294PATH_SYS = $(PATH_INS)/bin
295PATH_LIB = $(PATH_INS)/lib
296PATH_DOC = $(PATH_INS)/doc
297
298# PATH_KBUILD is determined by kmk.
299ifeq ($(strip $(PATH_KBUILD)),)
300 $(error kBuild: PATH_KBUILD is missing or empty! kmk is supposed to set it.)
301endif
302# PATH_KBUILD_BIN is determined by kmk.
303ifeq ($(strip $(PATH_KBUILD_BIN)),)
304 $(error kBuild: PATH_KBUILD_BIN is missing or empty! kmk is supposed to set it.)
305endif
306
307# kBuild files which might be of interest.
308FILE_KBUILD_HEADER := $(PATH_KBUILD)/header.kmk
309#FILE_KBUILD_CONFIG := $(PATH_KBUILD)/config.kmk
310FILE_KBUILD_FOOTER := $(PATH_KBUILD)/footer.kmk
311
312## MAKEFILE is the name of the main makefile.
313MAKEFILE := $(firstword $(MAKEFILE_LIST))
314## MAKEFILE_CURRENT is the name of the current makefile.
315# This is updated everything a sub-makefile is included.
316MAKEFILE_CURRENT := $(MAKEFILE)
317
318
319#
320# Build platform setup.
321# (PORTME)
322#
323
324# OS/2
325ifeq ($(BUILD_PLATFORM),os2)
326EXEC_X86_WIN32 := innopec.exe
327HOSTSUFF_EXE := .exe
328endif
329
330# Linux
331ifeq ($(BUILD_PLATFORM),linux)
332EXEC_X86_WIN32 := wine
333HOSTSUFF_EXE :=
334endif
335
336# Win, Win32, Win64, NT.
337if1of ($(BUILD_PLATFORM),win nt)
338EXEC_X86_WIN32 :=
339HOSTSUFF_EXE := .exe
340endif
341
342# FreeBSD
343ifeq ($(BUILD_PLATFORM),freebsd)
344EXEC_X86_WIN32 := wine
345HOSTSUFF_EXE :=
346endif
347
348# Darwin / Mac OS X
349ifeq ($(BUILD_PLATFORM),darwin)
350EXEC_X86_WIN32 := false
351HOSTSUFF_EXE :=
352endif
353
354# Solaris
355ifeq ($(BUILD_PLATFORM),solaris)
356EXEC_X86_WIN32 := false
357HOSTSUFF_EXE :=
358endif
359
360
361#
362# Build target setup.
363# (PORTME)
364#
365SUFF_DEP := .dep
366if1of ($(BUILD_TARGET),win nt os2)
367SUFF_OBJ := .obj
368SUFF_LIB := .lib
369SUFF_DLL := .dll
370SUFF_EXE := .exe
371SUFF_SYS := .sys
372SUFF_RES := .res
373endif
374ifeq ($(BUILD_TARGET),l4)
375SUFF_OBJ := .o
376SUFF_LIB := .a
377SUFF_DLL := .s.so
378SUFF_EXE :=
379SUFF_SYS := .a
380SUFF_RES :=
381endif
382ifeq ($(BUILD_TARGET),darwin)
383SUFF_OBJ := .o
384SUFF_LIB := .a
385SUFF_DLL := .dylib
386SUFF_EXE :=
387SUFF_SYS :=
388SUFF_RES :=
389endif
390ifndef SUFF_OBJ
391SUFF_OBJ := .o
392SUFF_LIB := .a
393SUFF_DLL := .so
394SUFF_EXE :=
395SUFF_SYS := .a
396SUFF_RES :=
397endif
398
399#
400# Standard kBuild tools.
401#
402ifeq ($(KMK),kmk)
403KMK := $(PATH_KBUILD_BIN)/kmk$(HOSTSUFF_EXE)
404endif
405MAKE := $(KMK)
406
407DEP_EXT := $(PATH_KBUILD_BIN)/kDep$(HOSTSUFF_EXE)
408if1of (kDep,$(KMK_BUILTIN))
409DEP := kmk_builtin_kDep
410else
411DEP := $(DEP_EXT)
412endif
413
414DEP_IDB_EXT := $(PATH_KBUILD_BIN)/kDepIDB$(HOSTSUFF_EXE)
415if1of (kDepIDB,$(KMK_BUILTIN))
416DEP_IDB := kmk_builtin_kDepIDB
417else
418DEP_IDB := $(DEP_IDB_EXT)
419endif
420
421DEP_PRE_EXT := $(PATH_KBUILD_BIN)/kDepPre$(HOSTSUFF_EXE)
422if1of (kDepPre,$(KMK_BUILTIN))
423DEP_PRE := kmk_builtin_kDepPre
424else
425DEP_PRE := $(DEP_PRE_EXT)
426endif
427
428KOBJCACHE_EXT := $(PATH_KBUILD_BIN)/kObjCache$(HOSTSUFF_EXE)
429if1of (kObjCache,$(KMK_BUILTIN))
430KOBJCACHE := kmk_builtin_kObjCache
431else
432KOBJCACHE := $(KOBJCACHE_EXT)
433endif
434
435APPEND_EXT := $(PATH_KBUILD_BIN)/kmk_append$(HOSTSUFF_EXE)
436APPEND := kmk_builtin_append
437
438CAT_EXT := $(PATH_KBUILD_BIN)/kmk_cat$(HOSTSUFF_EXE)
439CAT := kmk_builtin_cat
440
441CMP_EXT := $(PATH_KBUILD_BIN)/kmk_cmp$(HOSTSUFF_EXE)
442CMP := kmk_builtin_cmp
443
444CP_EXT := $(PATH_KBUILD_BIN)/kmk_cp$(HOSTSUFF_EXE)
445CP := kmk_builtin_cp
446
447ECHO_EXT := $(PATH_KBUILD_BIN)/kmk_echo$(HOSTSUFF_EXE)
448ECHO := kmk_builtin_echo
449
450INSTALL_EXT := $(PATH_KBUILD_BIN)/kmk_install$(HOSTSUFF_EXE)
451INSTALL := kmk_builtin_install
452
453LN_EXT := $(PATH_KBUILD_BIN)/kmk_ln$(HOSTSUFF_EXE)
454LN := kmk_builtin_ln
455
456MD5SUM_EXT := $(PATH_KBUILD_BIN)/kmk_md5sum$(HOSTSUFF_EXE)
457MD5SUM := kmk_builtin_md5sum
458
459MKDIR_EXT := $(PATH_KBUILD_BIN)/kmk_mkdir$(HOSTSUFF_EXE)
460MKDIR := kmk_builtin_mkdir
461
462MV_EXT := $(PATH_KBUILD_BIN)/kmk_mv$(HOSTSUFF_EXE)
463MV := kmk_builtin_mv
464
465PRINTF_EXT := $(PATH_KBUILD_BIN)/kmk_printf$(HOSTSUFF_EXE)
466PRINTF := kmk_builtin_printf
467
468REDIRECT_EXT:= $(PATH_KBUILD_BIN)/kmk_redirect$(HOSTSUFF_EXE)
469if1of (redirect,$(KMK_BUILTIN))
470REDIRECT := kmk_builtin_redirect
471else
472REDIRECT := $(REDIRECT_EXT)
473endif
474
475RM_EXT := $(PATH_KBUILD_BIN)/kmk_rm$(HOSTSUFF_EXE)
476RM := kmk_builtin_rm
477
478RMDIR_EXT := $(PATH_KBUILD_BIN)/kmk_rmdir$(HOSTSUFF_EXE)
479RMDIR := kmk_builtin_rmdir
480
481SED_EXT := $(PATH_KBUILD_BIN)/kmk_sed$(HOSTSUFF_EXE)
482if1of (sed, $(KMK_BUILTIN))
483SED_INT := kmk_builtin_sed
484else
485SED_INT := $(SED_EXT)
486endif
487SED := $(SED_EXT)
488
489TEST_EXT := $(PATH_KBUILD_BIN)/kmk_test$(HOSTSUFF_EXE)
490TEST := kmk_builtin_test
491
492# Our default shell is the Almquist shell from *BSD.
493ASH := $(PATH_KBUILD_BIN)/kmk_ash$(HOSTSUFF_EXE)
494MAKESHELL := $(ASH)
495SHELL := $(ASH)
496export SHELL MAKESHELL
497
498# Symlinking is problematic on some platforms...
499LN_SYMLINK := $(LN) -s
500
501
502#
503# Some Functions.
504# The lower cased ones are either fallbacks or candidates for functions.c.
505#
506
507## ABSPATH - make paths absolute.
508# This implementation is clumsy and doesn't resolve '..' and '.' components.
509#
510# @param $1 The paths to make absolute.
511# @obsolete Use the GNU make function $(abspath) directly now.
512ABSPATH = $(abspath $(1))$(warning ABSPATH is deprecated, use abspath directly!)
513
514## DIRDEP - make create directory dependencies.
515#
516# @param $1 The paths to the directories which must be created.
517DIRDEP = $(foreach path,$(patsubst %/,%,$(1)),$(path)/)
518
519## Cygwin kludge.
520# This converts /cygdrive/x/% to x:%.
521#
522# @param $1 The paths to make native.
523# @remark This macro is pretty much obsolete since we don't use cygwin base make.
524ifneq ($(patsubst /cygdrive/%,%,$(CURDIR)),$(CURDIR))
525 CYGPATHMIXED = $(foreach path,$(1)\
526 ,$(if $(patsubst /cygdrive/%,,$(path)),$(path),$(patsubst $(strip $(firstword $(subst /, ,$(patsubst /cygdrive/%,%,$(path)))))/%,$(strip $(firstword $(subst /, ,$(patsubst /cygdrive/%,%,$(path))))):/%,$(patsubst /cygdrive/%,%,$(path)))))
527else
528 CYGPATHMIXED = $(1)
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## 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
571## PROPS_TOOLS
572# This is a subset of PROPS_SINGLE.
573PROPS_TOOLS := TOOL CTOOL CXXTOOL OBJCTOOL ASTOOL RCTOOL ARTOOL LDTOOL FETCHTOOL UNPACKTOOL PATCHTOOL
574
575## PROPS_SINGLE
576# The list of non-accumulative target properties.
577# A Config.kmk file can add it's own properties to this list and kBuild
578# will do the necessary inheritance from templates to targets.
579PROPS_SINGLE := $(PROPS_TOOLS) INST NOINST BLD_TYPE BLD_TRG BLD_TRG_ARCH BLD_TRG_CPU FETCHDIR \
580 OBJSUFF COBJSUFF CXXOBJSUFF OBJCOBJSUFF ASOBJSUFF RCOBJSUFF SYSSUFF EXESUFF DLLSUFF LIBSUFF ARLIBSUFF
581## PROPS_SINGLE_LNK
582# Subset of PROPS_SINGLE which applies to all linkable targets.
583PROPS_SINGLE_LNK := TOOL CTOOL CXXTOOL OBJCTOOL ASTOOL RCTOOL \
584 INST NOINST BLD_TYPE BLD_TRG BLD_TRG_ARCH BLD_TRG_CPU \
585 OBJSUFF COBJSUFF CXXOBJSUFF OBJCOBJSUFF ASOBJSUFF RCOBJSUFF
586
587## PROPS_DEFERRED
588# This list of non-accumulative target properties which are or may be
589# functions, and thus should not be expanded until the very last moment.
590PROPS_DEFERRED := INSTFUN INSTALLER PRE_CMDS POST_CMDS NAME SONAME
591
592## PROPS_ACCUMULATE_R
593# The list of accumulative target properties where the right most value/flag
594# is the 'most significant'.
595# A Config.kmk file can add it's own properties to this list and kBuild
596# will do the necessary inheritance from templates to targets.
597PROPS_ACCUMULATE_R := \
598 DEPS ORDERDEPS DEFS \
599 ARFLAGS \
600 CFLAGS CDEFS \
601 CXXFLAGS CXXDEFS \
602 OBJCFLAGS OBJCDEFS \
603 ASFLAGS ASDEFS \
604 RCFLAGS RCDEFS \
605 LDFLAGS \
606 IDFLAGS IFDLAGS ISFLAGS \
607 FETCHFLAGS UNPACKFLAGS PATCHFLAGS
608## PROPS_ACCUMULATE_R_LNK
609# Subset of PROPS_ACCUMULATE_R which applies to all linkable targets.
610PROPS_ACCUMULATE_R_LNK := \
611 DEPS ORDERDEPS DEFS \
612 CFLAGS CDEFS \
613 CXXFLAGS CXXDEFS \
614 OBJCFLAGS OBJCDEFS \
615 ASFLAGS ASDEFS \
616 RCFLAGS RCDEFS \
617 IDFLAGS IFDLAGS ISFLAGS
618
619## PROPS_ACCUMULATE
620# The list of accumulative target properties where the left most value/flag
621# is the 'most significant'.
622# A Config.kmk file can add it's own properties to this list and kBuild
623# will do the necessary inheritance from templates to targets.
624PROPS_ACCUMULATE_L := \
625 SDKS SOURCES \
626 INCS CINCS CXXINCS OBJCINCS ASINCS RCINCS \
627 LIBS LIBPATH \
628 DIRS BLDDIRS CLEAN
629## PROPS_ACCUMULATE_L_LNK
630# Subset of PROPS_ACCUMULATE_L which applies to all linkable targets.
631PROPS_ACCUMULATE_L_LNK := \
632 SDKS SOURCES \
633 INCS CINCS CXXINCS OBJCINCS ASINCS RCINCS \
634 BLDDIRS CLEAN
635
636## PROPS_ALL
637# List of all the properties.
638PROPS_ALL = $(PROPS_SINGLE) $(PROPS_DEFERRED) $(PROPS_ACCUMULATE_L) $(PROPS_ACCUMULATE_R)
639
640
641## @name Properties valid on programs (BLDPROGS and PROGRAMS)
642## @{
643PROPS_PROGRAMS_SINGLE := $(PROPS_SINGLE_LNK) LDTOOL EXESUFF
644PROPS_PROGRAMS_DEFERRED := $(PROPS_DEFERRED)
645PROPS_PROGRAMS_ACCUMULATE_R := $(PROPS_ACCUMULATE_R_LNK) LDFLAGS
646PROPS_PROGRAMS_ACCUMULATE_L := $(PROPS_ACCUMULATE_L_LNK) LIBS LIBPATH
647## @}
648
649## @name Properties valid on libraries (LIBRARIES and IMPORT_LIBS)
650## @{
651PROPS_LIBRARIES_SINGLE := $(PROPS_SINGLE_LNK) ARTOOL LIBSUFF ARLIBSUFF LIBSUFF
652PROPS_LIBRARIES_DEFERRED := $(filter-out SONAME,$(PROPS_DEFERRED))
653PROPS_LIBRARIES_ACCUMULATE_R := $(PROPS_ACCUMULATE_R_LNK) ARFLAGS
654PROPS_LIBRARIES_ACCUMULATE_L := $(PROPS_ACCUMULATE_L_LNK)
655## @}
656
657## @name Properties valid on dlls (DLLS)
658## @{
659PROPS_DLLS_SINGLE := $(PROPS_SINGLE_LNK) LDTOOL DLLSUFF LIBSUFF
660PROPS_DLLS_DEFERRED := $(PROPS_DEFERRED)
661PROPS_DLLS_ACCUMULATE_R := $(PROPS_ACCUMULATE_R_LNK) LDFLAGS
662PROPS_DLLS_ACCUMULATE_L := $(PROPS_ACCUMULATE_L_LNK) LIBS LIBPATH
663## @}
664
665## @name Properties valid on system modules (SYSMODS)
666## @{
667PROPS_SYSMODS_SINGLE := $(PROPS_SINGLE_LNK) LDTOOL SYSSUFF
668PROPS_SYSMODS_DEFERRED := $(PROPS_DEFERRED)
669PROPS_SYSMODS_ACCUMULATE_R := $(PROPS_ACCUMULATE_R_LNK) LDFLAGS
670PROPS_SYSMODS_ACCUMULATE_L := $(PROPS_ACCUMULATE_L_LNK) LIBS LIBPATH
671## @}
672
673## @name Properties valid on installs (INSTALLS)
674## @{
675PROPS_INSTALLS_SINGLE := TOOL INST NOINST
676PROPS_INSTALLS_DEFERRED := INSTFUN INSTALLER
677PROPS_INSTALLS_ACCUMULATE_R := DEPS ORDERDEPS
678PROPS_INSTALLS_ACCUMULATE_L := SOURCES DIRS CLEAN
679## @}
680
681## @name Properties valid on fetches (INSTALLS)
682## @{
683PROPS_FETCHES_SINGLE := TOOL FETCHTOOL UNPACKTOOL PATCHTOOL INST FETCHDIR
684PROPS_FETCHES_DEFERRED :=
685PROPS_FETCHES_ACCUMULATE_R := FETCHFLAGS UNPACKFLAGS PATCHFLAGS
686PROPS_FETCHES_ACCUMULATE_L := SOURCES
687## @}
688
689
690#
691# Here is a special 'hack' to prevent innocent environment variables being
692# picked up and treated as properties. (The most annoying example of why
693# this is necessary is the Visual C++ commandline with it's LIBPATH.)
694#
695# Define KBUILD_DONT_KILL_ENV_PROPS in the env. or on the commandline to
696# disable this 'hack'.
697#
698ifndef KBUILD_DONT_KILL_ENV_PROPS
699
700define def_nuke_environment_prop
701ifeq ($(origin $(prop)),environment)
702$(prop) =
703endif
704endef
705$(foreach prop, $(PROPS_ALL) \
706 FETCHES PATCHES BLDPROGS LIBRARIES IMPORT_LIBS DLLS PROGRAMS SYSMODS INSTALLS OTHERS \
707 SUBDIRS MAKEFILES BLDDIRS \
708 ,$(eval $(value def_nuke_environment_prop)))
709
710endif # KBUILD_DONT_KILL_ENV_PROPS
711
712
713#
714# Pass configuration.
715#
716# The PASS_<passname>_trgs variable is listing the targets.
717# The PASS_<passname>_vars variable is listing the target variables.
718# The PASS_<passname>_pass variable is the lowercased passname.
719#
720
721## PASS: fetches
722# This pass fetches and unpacks things needed to complete the build.
723PASS_FETCHES := Fetches
724PASS_FETCHES_trgs :=
725PASS_FETCHES_vars := _FETCHES
726PASS_FETCHES_pass := fetches
727
728## PASS: patches
729# This pass applies patches.
730PASS_PATCHES := Patches
731PASS_PATCHES_trgs :=
732PASS_PATCHES_vars := _PATCHES
733PASS_PATCHES_pass := patches
734
735## PASS: bldprogs
736# This pass builds targets which are required for building the rest.
737PASS_BLDPROGS := Build Programs
738PASS_BLDPROGS_trgs :=
739PASS_BLDPROGS_vars := _BLDPROGS
740PASS_BLDPROGS_pass := bldprogs
741
742## PASS: libraries
743# This pass builds library targets.
744PASS_LIBRARIES := Libraries
745PASS_LIBRARIES_trgs :=
746PASS_LIBRARIES_vars := _LIBS _IMPORT_LIBS _OTHER_LIBRARIES
747PASS_LIBRARIES_pass := libraries
748
749## PASS: binaries
750# This pass builds dll targets.
751PASS_DLLS := DLLs
752PASS_DLLS_trgs :=
753PASS_DLLS_vars := _DLLS _OTHER_DLLS
754PASS_DLLS_pass := dlls
755
756## PASS: binaries
757# This pass builds binary targets, i.e. programs, system modules and stuff.
758PASS_BINARIES := Programs
759PASS_BINARIES_trgs :=
760PASS_BINARIES_vars := _PROGRAMS _SYSMODS _OTHER_BINARIES
761PASS_BINARIES_pass := binaries
762
763## PASS: others
764# This pass builds other targets.
765PASS_OTHERS := Other Stuff
766PASS_OTHERS_trgs :=
767PASS_OTHERS_vars := _OTHERS
768PASS_OTHERS_pass := others
769
770## PASS: install
771# This pass installs the built entities to a sandbox area.
772PASS_INSTALLS := Install
773PASS_INSTALLS_trgs :=
774PASS_INSTALLS_vars := _INSTALLS_DIRS _INSTALLS _INSTALLS_FILES
775PASS_INSTALLS_pass := installs
776
777## PASS: packing
778# This pass processes custom packing rules.
779PASS_PACKING := Packing
780PASS_PACKING_trgs :=
781PASS_PACKING_vars := _PACKING
782PASS_PACKING_pass := packing
783#alias
784packing: pass_packing
785
786## PASS: clean
787# This pass removes all generated files.
788PASS_CLEAN := Clean
789PASS_CLEAN_trgs := do-clean
790PASS_CLEAN_vars :=
791PASS_CLEAN_pass := clean
792# alias
793clean: pass_clean
794
795## PASS: nothing
796# This pass just walks the tree.
797PASS_NOTHING := Nothing
798PASS_NOTHING_trgs := do-nothing
799PASS_NOTHING_vars :=
800PASS_NOTHING_pass := nothing
801# alias
802nothing: pass_nothing
803
804## DEFAULT_PASSES
805# The default passes and their order.
806DEFAULT_PASSES := BLDPROGS LIBRARIES DLLS BINARIES OTHERS INSTALLS
807
808## PASSES
809# The passes that should be defined. This must include
810# all passes mentioned by DEFAULT_PASSES.
811PASSES := FETCHES PATCHES $(DEFAULT_PASSES) NOTHING CLEAN
812
813
814#
815# Check for --pretty-command-printing before including the Config.kmk
816# so that anyone overriding the message macros can take the implied
817# verbosity level change into account.
818#
819ifndef KBUILD_VERBOSE
820 ifndef KBUILD_QUIET
821 ifneq ($(filter --pretty-command-printing,$(MAKEFLAGS)),)
822 export KBUILD_VERBOSE := 2
823 endif
824 endif
825endif
826
827
828#
829# This is how we find the closest config.kmk.
830# It's a little hacky but I think it works fine.
831#
832_CFGDIR := .
833_CFGFILES := ./Config.kmk ./config.kmk
834define def_include_config
835$(eval _CFGDIR := $(_CFGDIR)/$(dir))
836_CFGFILES += $(_CFGDIR)/Config.kmk $(_CFGDIR)/config.kmk
837endef
838# walk down the _RELATIVE_ path specified by DEPTH.
839$(foreach dir,$(subst /, ,$(DEPTH)), $(eval $(def_include_config)) )
840# add the default config file.
841_CFGFILE := $(firstword $(wildcard $(_CFGFILES) $(FILE_KBUILD_CONFIG)))
842_CFGFILES :=
843_CFGDIR :=
844ifeq ($(_CFGFILE),)
845$(error kBuild: no Config.kmk file found! Check the DEPTH: DEPTH='$(DEPTH)' PATH_CURRENT='$(PATH_CURRENT)')
846endif
847
848# Include the config.kmk we found file (or the default one).
849ifdef KBUILD_PROFILE_SELF
850 _KBUILD_TS_NOW := $(nanots )
851 $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - including $(_CFGFILE))
852 _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
853
854 include $(_CFGFILE)
855
856 _KBUILD_TS_NOW := $(nanots )
857 $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - included $(_CFGFILE))
858 _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
859else
860 include $(_CFGFILE)
861endif
862
863
864
865#
866# Finalize a the central path variables now that we've included the Config.kmk file.
867#
868# This prevents some trouble when users override the defaults for these
869# variables and uses relative paths or paths with incorrect case.
870#
871PATH_OUT := $(abspath $(PATH_OUT))
872PATH_OBJ := $(abspath $(PATH_OBJ))
873PATH_TARGET := $(abspath $(PATH_TARGET))
874PATH_INS := $(abspath $(PATH_INS))
875PATH_BIN := $(abspath $(PATH_BIN))
876PATH_DLL := $(abspath $(PATH_DLL))
877PATH_SYS := $(abspath $(PATH_SYS))
878PATH_LIB := $(abspath $(PATH_LIB))
879PATH_DOC := $(abspath $(PATH_DOC))
880
881
882#
883# Setup the message style. The default one is inlined.
884#
885# See kBuild/msgstyles for more styles or use KBUILD_MSG_STYLE_PATHS
886# to create your own message style.
887#
888KBUILD_MSG_STYLE ?= default
889ifeq ($(KBUILD_MSG_STYLE),default)
890 #
891 # The 'default' style.
892 #
893
894 ## Fetch starting.
895 # @param 1 Target name.
896 MSG_FETCH ?= $(call MSG_L1,Fetching $1...)
897 ## Re-fetch starting.
898 # @param 1 Target name.
899 MSG_REFETCH ?= $(call MSG_L1,Re-fetching $1...)
900 ## Downloading a fetch component.
901 # @param 1 Target name.
902 # @param 2 The source URL.
903 # @param 3 The destination file name.
904 MSG_FETCH_DL ?= $(call MSG_L1,Downloading $1 - $2,=> $3)
905 ## Checking a fetch component.
906 # @param 1 Target name.
907 # @param 2 The source URL.
908 # @param 3 The destination file name.
909 MSG_FETCH_CHK?= $(call MSG_L1,Checking $1 - $3, ($2))
910 ## Unpacking a fetch component.
911 # @param 1 Target name.
912 # @param 2 The archive file name.
913 # @param 3 The target directory.
914 MSG_FETCH_UP ?= $(call MSG_L1,Unpacking $1 - $2 => $3)
915 ## Fetch completed.
916 # @param 1 Target name.
917 MSG_FETCH_OK ?= $(call MSG_L1,Successfully fetched $1)
918 ## Unfetch a fetch target.
919 # @param 1 Target name.
920 MSG_UNFETCH ?= $(call MSG_L1,Unfetching $1...)
921 ## Compiling a source file.
922 # @param 1 Target name.
923 # @param 2 The source filename.
924 # @param 3 The primary link output file name.
925 # @param 4 The source type (C,CXX,OBJC,AS,RC,++).
926 MSG_COMPILE ?= $(call MSG_L1,Compiling $1 - $2,=> $3)
927 ## Tool
928 # @param 1 The tool name (bin2c,...)
929 # @param 2 Target name.
930 # @param 3 The source filename.
931 # @param 4 The primary output file name.
932 MSG_TOOL ?= $(call MSG_L1,$1 $2 - $3,=> $4)
933 ## Generate a file, typically a source file.
934 # @param 1 Target name if applicable.
935 # @param 2 Output file name.
936 # @param 3 What it's generated from
937 MSG_GENERATE ?= $(call MSG_L1,Generating $(if $1,$1 - )$2,$(if $3,from $3))
938 ## Linking a bldprog/dll/program/sysmod target.
939 # @param 1 Target name.
940 # @param 2 The primary link output file name.
941 # @param 3 The link tool operation (LINK_LIBRARY,LINK_PROGRAM,LINK_DLL,LINK_SYSMOD,++).
942 MSG_LINK ?= $(call MSG_L1,Linking $1,=> $2)
943 ## Merging a library into the target (during library linking).
944 # @param 1 Target name.
945 # @param 2 The output library name.
946 # @param 3 The input library name.
947 MSG_AR_MERGE ?= $(call MSG_L1,Merging $3 into $1, ($2))
948 ## Creating a directory (build).
949 # @param 1 Directory name.
950 MSG_MKDIR ?= $(call MSG_L2,Creating directory $1)
951 ## Cleaning.
952 MSG_CLEAN ?= $(call MSG_L1,Cleaning...)
953 ## Nothing.
954 MSG_NOTHING ?= $(call MSG_L1,Did nothing in $(CURDIR))
955 ## Pass
956 # @param 1 The pass name.
957 MSG_PASS ?= $(call MSG_L1,Pass - $1)
958 ## Installing a bldprog/lib/dll/program/sysmod target.
959 # @param 1 Target name.
960 # @param 2 The source filename.
961 # @param 3 The destination file name.
962 MSG_INST_TRG ?= $(call MSG_L1,Installing $1 => $3)
963 ## Installing a file (install target).
964 # @param 1 The source filename.
965 # @param 2 The destination filename.
966 MSG_INST_FILE?= $(call MSG_L1,Installing $2,(<= $1))
967 ## Installing a symlink.
968 # @param 1 Symlink
969 # @param 2 Link target
970 MSG_INST_SYM ?= $(call MSG_L1,Installing symlink $1,=> $2)
971 ## Installing a directory.
972 # @param 1 Directory name.
973 MSG_INST_DIR ?= $(call MSG_L1,Installing directory $1)
974
975else
976 _KBUILD_MSG_STYLE_FILE := $(firstword $(foreach path, $(KBUILD_MSG_STYLE_PATHS) $(PATH_KBUILD)/msgstyles, $(wildcard $(path)/$(KBUILD_MSG_STYLE).kmk)))
977 ifneq ($(_KBUILD_MSG_STYLE_FILE),)
978 include $(_KBUILD_MSG_STYLE_FILE)
979 else
980 $(error kBuild: Can't find the style setup file for KBUILD_MSG_STYLE '$(KBUILD_MSG_STYLE)')
981 endif
982endif
983
984
985#
986# Message macros.
987#
988# This is done after including Config.kmk as to allow for
989# KBUILD_QUIET and KBUILD_VERBOSE to be configurable.
990#
991ifdef KBUILD_QUIET
992 # No output
993 QUIET := @
994 QUIET2:= @
995 MSG_L1 =
996 MSG_L2 =
997else
998 ifndef KBUILD_VERBOSE
999 # Default output level.
1000 QUIET := @
1001 QUIET2 := @
1002 MSG_L1 ?= @$(ECHO) "kBuild: $1"
1003 MSG_L2 =
1004 else ifeq ($(KBUILD_VERBOSE),1)
1005 # A bit more output
1006 QUIET := @
1007 QUIET2 := @
1008 MSG_L1 ?= @$(ECHO) "kBuild: $1 $2"
1009 MSG_L2 =
1010 else ifeq ($(KBUILD_VERBOSE),2)
1011 # Lot more output
1012 QUIET :=
1013 QUIET2 := @
1014 MSG_L1 ?= @$(ECHO) "kBuild: $1 $2"
1015 MSG_L2 ?= @$(ECHO) "kBuild: $1"
1016 else
1017 # maximal output.
1018 QUIET :=
1019 QUIET2 :=
1020 MSG_L1 ?= @$(ECHO) "kBuild: $1 $2"
1021 MSG_L2 ?= @$(ECHO) "kBuild: $1"
1022 endif
1023endif
1024
1025
1026ifdef KBUILD_PROFILE_SELF
1027 _KBUILD_TS_HEADER_END := $(nanots )
1028 $(info prof: $(int-sub $(_KBUILD_TS_HEADER_END), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_HEADER_END), $(_KBUILD_TS_PREV)) - end of header.kmk)
1029 _KBUILD_TS_PREV := $(_KBUILD_TS_HEADER_END)
1030endif
1031
1032# end-of-file-content
1033__header_kmk__ := 1
1034endif # __header_kmk__
1035
Note: See TracBrowser for help on using the repository browser.