source: trunk/kBuild/header.kmk@ 2954

Last change on this file since 2954 was 2912, checked in by bird, 9 years ago

rewrote kmk_redirect to skip the separate process. Added chache invalidation after directory deletion for addressing kmk rebuild and fetching.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 50.0 KB
Line 
1# $Id: header.kmk 2912 2016-09-14 13:36:15Z bird $
2## @file
3# kBuild - File included at top of a makefile.
4#
5
6#
7# Copyright (c) 2004-2015 knut st. osmundsen <bird-kBuild-spam-xiv@anduin.net>
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# As a special exception you are granted permission to include this file, via
27# the kmk include directive, as you wish without this in itself causing the
28# resulting makefile, program or whatever to be covered by the GPL license.
29# This exception does not however invalidate any other reasons why the makefile,
30# program, whatever should not be covered the GPL.
31#
32#
33
34ifndef __header_kmk__
35# start-of-file-content
36ifdef KBUILD_PROFILE_SELF
37 _KBUILD_TS_HEADER_START := $(nanots ) # just a dummy warm up query
38 $(info prof: since start - since previous -- event description)
39 ifeq ($(KBUILD_PROFILE_SELF),2)
40 $(info stat: $(make-stats ))
41 endif
42 _KBUILD_TS_HEADER_START := $(nanots )
43 _KBUILD_TS_PREV := $(_KBUILD_TS_HEADER_START)
44
45 _KBUILD_FMT_ELAPSED_EX = $(int-div $(int-add $(int-sub $1, $2),500000),1000000)ms
46 _KBUILD_FMT_ELAPSED = $(call _KBUILD_FMT_ELAPSED_EX,$(_KBUILD_TS_NOW),$1)
47
48define def_profile_self
49 _KBUILD_TS_NOW := $(nanots )
50 $(info prof: $(call _KBUILD_FMT_ELAPSED,$(_KBUILD_TS_HEADER_START)) - $(call _KBUILD_FMT_ELAPSED, $(_KBUILD_TS_PREV)) -- $(strip $1))
51 ifeq ($(KBUILD_PROFILE_SELF),2)
52 $(info stat: $(make-stats ))
53 endif
54 _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
55endef
56
57endif
58
59
60#
61# Check make version before we do anything else.
62#
63ifndef KMK_VERSION
64 $(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)
65endif
66ifneq ($(KBUILD_VERSION_MAJOR).$(KBUILD_VERSION_MINOR),0.1)
67 ifneq ($(KBUILD_VERSION_MAJOR),0)
68 $(warning kBuild: kmk major version mismatch! Expected '0' but found '$(KBUILD_VERSION_MAJOR)'!)
69 else
70 $(warning kBuild: kmk minor version mismatch! Expected '1' but found '$(KBUILD_VERSION_MINOR)'!)
71 endif
72else
73 if $(KBUILD_VERSION_PATCH) < 999
74 $(error kBuild: kmk version mismatch! Expected 0.1.999 or later. Actual version is $(KBUILD_VERSION).)
75 endif
76endif
77
78#
79# The revision in which this file was last modified.
80# This can be useful when using development versions of kBuild.
81#
82KMK_REVISION := $(patsubst %:,, $Rev: 2912 $ )
83
84
85#
86# Define the default goal.
87#
88.PHONY: all all_recursive
89all: all_recursive
90
91#
92# The phony FORCE target.
93#
94.PHONY: FORCE
95FORCE:
96
97
98#
99# Enable delete on error and second expansion of prerequisites and targets.
100#
101.DELETE_ON_ERROR:
102
103.SECONDEXPANSION:
104
105.SECONDTARGETEXPANSION:
106
107
108#
109# General purpose macros.
110#
111
112##
113# Newline character(s).
114define NL
115
116
117endef
118
119##
120# Tab character.
121TAB := $(subst ., ,.)
122
123##
124# Newline + tab characters (for generating commands).
125NLTAB = $(NL)$(TAB)
126
127##
128# Space character.
129SP := $(subst ., ,.)
130
131##
132# Hash character.
133define HASH
134#
135endef
136
137##
138# Colon character.
139COLON := :
140
141##
142# Semicolon character.
143SEMICOLON := ;
144
145##
146# Comma character.
147COMMA := ,
148
149##
150# Dot character.
151DOT := .
152
153##
154# Dollar character.
155DOLLAR := $$
156
157##
158# Equal character.
159EQUAL := =
160
161##
162# Percent character.
163PERCENT := %
164
165##
166# Single quote character.
167SQUOTE := '
168
169##
170# Double quote character.
171DQUOTE := "
172
173
174#
175# The list of standard build types in kBuild.
176#
177# This list can be extended in Config.kmk and it's possible to extend
178# (inherit) another build type.
179#
180KBUILD_BLD_TYPES := release profile debug
181
182
183#
184# The OSes, Architectures and CPUs that kBuild recognizes.
185#
186# When kBuild is ported to a new OS or architecture a unique keyword needs
187# to be assigned to it and added here. This strictness is required because
188# this keyword namespace is shared between OSes, architectures, cpus and
189# build types. (PORTME)
190#
191KBUILD_OSES := darwin dos dragonfly freebsd haiku l4 linux netbsd nt openbsd os2 solaris win os-agnostic
192KBUILD_ARCHES := x86 amd64 sparc32 sparc64 s390 s390x ppc32 ppc64 mips32 mips64 ia64 hppa32 hppa64 arm alpha noarch
193KBUILD_ARCHES_64 := amd64 sparc64 s390x ppc64 mips64 ia64 hppa64 alpha
194KBUILD_ARCHES_32 := x86 sparc32 s390 ppc32 mips32 hppa32 arm
195
196
197#
198# Set default build type.
199#
200ifndef KBUILD_TYPE
201 ifdef BUILD_TYPE
202 KBUILD_TYPE := $(BUILD_TYPE)
203 endif
204else ifdef BUILD_TYPE
205 ifneq ($(KBUILD_TYPE),$(BUILD_TYPE))
206 ifeq ($(origin KBUILD_TYPE):$(origin BUILD_TYPE),environment:command line)
207 KBUILD_TYPE := $(BUILD_TYPE)
208 else ifneq ($(origin KBUILD_TYPE):$(origin BUILD_TYPE),command line:environment)
209 $(error kBuild: KBUILD_TYPE and BUILD_TYPE disagree.)
210 endif
211 endif
212endif
213override BUILD_TYPE = $(KBUILD_TYPE)
214
215ifndef KBUILD_TYPE
216 KBUILD_TYPE := release
217else
218 if1of ($(KBUILD_TYPE), $(KBUILD_OSES) $(KBUILD_ARCHES))
219 $(error kBuild: The KBUILD_TYPE value '$(KBUILD_TYPE)' is an OS or architecture!)
220 endif
221 ifneq (.$(words $(KBUILD_TYPE)).$(KBUILD_TYPE).,.1.$(strip $(KBUILD_TYPE)).)
222 $(error kBuild: The KBUILD_TYPE value '$(KBUILD_TYPE)' contains spaces/tabs!)
223 endif
224endif
225
226
227#
228# Host platform legacy
229# kmk deals with this, so this is only temporary until I've rebuilt everything.
230#
231ifndef KBUILD_HOST
232 KBUILD_HOST := $(BUILD_PLATFORM)
233endif
234ifndef KBUILD_HOST_ARCH
235 KBUILD_HOST_ARCH := $(BUILD_PLATFORM_ARCH)
236endif
237ifndef KBUILD_HOST_CPU
238 KBUILD_HOST_CPU := $(BUILD_PLATFORM_CPU)
239endif
240
241
242#
243# Assert valid build platform variables.
244#
245# All these are set by kmk so they shouldn't be any trouble
246# unless the user starts messing about with environment variables.
247#
248ifneq (.$(words $(KBUILD_HOST)).$(KBUILD_HOST).,.1.$(strip $(KBUILD_HOST)).)
249 $(error kBuild: The KBUILD_HOST value '$(KBUILD_HOST)' contains spaces/tabs!)
250endif
251ifneq ($(words $(filter $(KBUILD_HOST),$(KBUILD_OSES))),1)
252 $(error kBuild: KBUILD_HOST value '$(KBUILD_HOST)' is not recognized (valid: $(KBUILD_OSES)))
253endif
254
255ifneq (.$(words $(KBUILD_HOST_ARCH)).$(KBUILD_HOST_ARCH).,.1.$(strip $(KBUILD_HOST_ARCH)).)
256 $(error kBuild: The KBUILD_HOST_ARCH value '$(KBUILD_HOST_ARCH)' contains spaces/tabs!)
257endif
258ifneq ($(words $(filter $(KBUILD_HOST_ARCH),$(KBUILD_ARCHES))),1)
259 $(error kBuild: KBUILD_HOST_ARCH value '$(KBUILD_HOST_ARCH)' is not recognized (valid: $(KBUILD_ARCHES)))
260endif
261
262ifeq ($(strip $(KBUILD_HOST_CPU)),)
263 KBUILD_HOST_CPU := blend
264else
265 ifneq (.$(words $(KBUILD_HOST_CPU)).$(KBUILD_HOST_CPU).,.1.$(strip $(KBUILD_HOST_CPU)).)
266 $(error kBuild: The KBUILD_HOST_CPU value '$(KBUILD_HOST_CPU)' contains spaces/tabs!)
267 endif
268 if1of ($(KBUILD_HOST_CPU), $(KBUILD_OSES) $(KBUILD_ARCHES))
269 $(error kBuild: The KBUILD_HOST_CPU value '$(KBUILD_HOST_CPU)' was found in the OS or architecture keywords!)
270 endif
271 ifeq ($(KBUILD_HOST_CPU),$(KBUILD_TYPE))
272 $(error kBuild: The KBUILD_HOST_CPU value '$(KBUILD_HOST_CPU)' is the same as the KBUILD_TYPE!)
273 endif
274endif
275
276
277#
278# Deal with target platform legacy.
279#
280ifndef KBUILD_TARGET
281 ifdef BUILD_TARGET
282 KBUILD_TARGET := $(BUILD_TARGET)
283 endif
284else ifdef BUILD_TARGET
285 ifneq ($(KBUILD_TARGET),$(BUILD_TARGET))
286 ifeq ($(origin KBUILD_TARGET):$(origin BUILD_TARGET),environment:command line)
287 KBUILD_TARGET := $(BUILD_TARGET)
288 else ifneq ($(origin KBUILD_TARGET):$(origin BUILD_TARGET),command line:environment)
289 $(error kBuild: KBUILD_TARGET and BUILD_TARGET disagree)
290 endif
291 endif
292endif
293override BUILD_TARGET = $(KBUILD_TARGET)
294
295ifndef KBUILD_TARGET_ARCH
296 ifdef BUILD_TARGET_ARCH
297 KBUILD_TARGET_ARCH := $(BUILD_TARGET_ARCH)
298 endif
299else ifdef BUILD_TARGET_ARCH
300 ifneq ($(KBUILD_TARGET_ARCH),$(BUILD_TARGET_ARCH))
301 ifeq ($(origin KBUILD_TARGET_ARCH):$(origin BUILD_TARGET_ARCH),environment:command line)
302 KBUILD_TARGET_ARCH := $(BUILD_TARGET_ARCH)
303 else ifneq ($(origin KBUILD_TARGET_ARCH):$(origin BUILD_TARGET_ARCH),command line:environment)
304 $(error kBuild: KBUILD_TARGET_ARCH and BUILD_TARGET_ARCH disagree)
305 endif
306 endif
307endif
308override BUILD_TARGET_ARCH = $(KBUILD_TARGET_ARCH)
309
310ifndef KBUILD_TARGET_CPU
311 ifdef BUILD_TARGET_CPU
312 KBUILD_TARGET_CPU := $(BUILD_TARGET_CPU)
313 endif
314else ifdef BUILD_TARGET_CPU
315 ifneq ($(KBUILD_TARGET_CPU),$(BUILD_TARGET_CPU))
316 ifeq ($(origin KBUILD_TARGET_CPU):$(origin BUILD_TARGET_CPU),environment:command line)
317 KBUILD_TARGET_CPU := $(BUILD_TARGET_CPU)
318 else ifneq ($(origin KBUILD_TARGET_CPU):$(origin BUILD_TARGET_CPU),command line:environment)
319 $(error kBuild: KBUILD_TARGET_CPU and BUILD_TARGET_CPU disagree)
320 endif
321 endif
322endif
323override BUILD_TARGET_CPU = $(KBUILD_TARGET_CPU)
324
325
326#
327# Assert or set default target platform.
328# When not defined use the corresponding KBUILD_HOST value.
329#
330ifndef KBUILD_TARGET
331 KBUILD_TARGET := $(KBUILD_HOST)
332else
333 ifneq (.$(words $(KBUILD_TARGET)).$(KBUILD_TARGET).,.1.$(strip $(KBUILD_TARGET)).)
334 $(error kBuild: The KBUILD_TARGET value '$(KBUILD_TARGET)' contains spaces/tabs!)
335 endif
336 ifneq ($(words $(filter $(KBUILD_TARGET),$(KBUILD_OSES))),1)
337 $(error kBuild: KBUILD_TARGET value '$(KBUILD_TARGET)' is not recognized (valid: $(KBUILD_OSES)))
338 endif
339endif
340
341ifndef KBUILD_TARGET_ARCH
342 KBUILD_TARGET_ARCH := $(KBUILD_HOST_ARCH)
343else
344 ifneq (.$(words $(KBUILD_TARGET_ARCH)).$(KBUILD_TARGET_ARCH).,.1.$(strip $(KBUILD_TARGET_ARCH)).)
345 $(error kBuild: The KBUILD_TARGET_ARCH value '$(KBUILD_TARGET_ARCH)' contains spaces/tabs!)
346 endif
347 ifneq ($(words $(filter $(KBUILD_TARGET_ARCH),$(KBUILD_ARCHES))),1)
348 $(error kBuild: KBUILD_TARGET_ARCH value '$(KBUILD_TARGET_ARCH)' is not recognized (valid: $(KBUILD_ARCHES)))
349 endif
350endif
351
352ifndef KBUILD_TARGET_CPU
353 KBUILD_TARGET_CPU := $(KBUILD_HOST_CPU)
354else ifeq ($(strip $(KBUILD_TARGET_CPU)),)
355 ifeq ($(KBUILD_TARGET_ARCH),$(KBUILD_HOST_ARCH))
356 KBUILD_TARGET_CPU := $(KBUILD_HOST_CPU)
357 else
358 KBUILD_TARGET_CPU := blend
359 endif
360else
361 ifneq (.$(words $(KBUILD_TARGET_CPU)).$(KBUILD_TARGET_CPU).,.1.$(strip $(KBUILD_TARGET_CPU)).)
362 $(error kBuild: The KBUILD_TARGET_CPU value '$(KBUILD_TARGET_CPU)' contains spaces/tabs!)
363 endif
364 if1of ($(KBUILD_TARGET_CPU), $(KBUILD_OSES) $(KBUILD_ARCHES))
365 $(error kBuild: The KBUILD_TARGET_CPU value was found in the OS or architecture keywords!)
366 endif
367 ifeq ($(KBUILD_TARGET_CPU),$(KBUILD_TYPE))
368 $(error kBuild: The KBUILD_TARGET_CPU value '$(KBUILD_TARGET_CPU)' is the same as the KBUILD_TYPE!)
369 endif
370endif
371
372
373#
374# Paths and stuff.
375#
376
377# Adjust DEPTH first.
378DEPTH := $(strip $(DEPTH))
379ifeq ($(DEPTH),)
380 DEPTH := .
381endif
382
383## PATH_CURRENT is the current directory (getcwd).
384PATH_CURRENT := $(abspath $(CURDIR))
385## PATH_SUB_CURRENT points to current directory of the current makefile.
386# Meaning that it will change value as we enter and exit sub-makefiles.
387PATH_SUB_CURRENT := $(PATH_CURRENT)
388## PATH_ROOT points to the project root directory.
389PATH_ROOT := $(abspath $(PATH_CURRENT)/$(DEPTH))
390## PATH_SUB_ROOT points to the directory of the top-level makefile.
391ifneq ($(strip $(SUB_DEPTH)),)
392 SUB_DEPTH := $(strip $(SUB_DEPTH))
393 PATH_SUB_ROOT := $(abspath $(PATH_CURRENT)/$(SUB_DEPTH))
394else
395 PATH_SUB_ROOT := $(PATH_CURRENT)
396endif
397
398## CURSUBDIR is PATH_SUB_ROOT described relative to PATH_ROOT.
399# This variable is used to determin where the object files and other output goes.
400ifneq ($(PATH_ROOT),$(PATH_SUB_ROOT))
401 CURSUBDIR := $(patsubst $(PATH_ROOT)/%,%,$(PATH_SUB_ROOT))
402else
403 CURSUBDIR := .
404endif
405
406# Install directory layout. Relative to PATH_INS.
407KBUILD_INST_PATHS := BIN DLL SYS LIB DOC DEBUG SBIN LIBEXEC SHARE
408INST_BIN = bin/
409if1of ($(KBUILD_TARGET), win)
410INST_DLL = bin/
411else
412INST_DLL = lib/
413endif
414if1of ($(KBUILD_TARGET), os2 win)
415INST_SYS = drivers/
416else
417INST_SYS = kernel/
418endif
419INST_LIB = lib/
420INST_DOC = share/doc/
421INST_DEBUG = debug/
422INST_SBIN = sbin/
423INST_LIBEXEC = libexec/
424INST_SHARE = share/
425
426# Staging directory layout. Relative to PATH_STAGE.
427STAGE_BIN = $(INST_BIN)
428STAGE_DLL = $(INST_DLL)
429STAGE_SYS = $(INST_SYS)
430STAGE_LIB = $(INST_LIB)
431STAGE_DOC = $(INST_DOC)
432STAGE_DEBUG = $(INST_DEBUG)
433STAGE_SBIN = $(INST_SBIN)
434STAGE_LIBEXEC = $(INST_LIBEXEC)
435STAGE_SHARE = $(INST_SHARE)
436
437# Install and staging directory paths.
438$(foreach path, $(KBUILD_INST_PATHS), \
439 $(eval PATH_STAGE_$(path) = $$(patsubst %/,%,$$(PATH_STAGE)/$$(STAGE_$(path)))) \
440 $(eval PATH_INST_$(path) = $$(patsubst %/,%,$$(PATH_INS)/$$(INST_$(path)))) \
441)
442
443# Output directories.
444ifndef PATH_OUT_BASE
445 PATH_OUT_BASE := $(PATH_ROOT)/out
446endif
447ifndef PATH_OUT
448 ifdef BUILD_TARGET_SUB # (BUILD_TARGET_SUB is not currently recognized by kBuild in any other places - obsolete)
449 PATH_OUT = $(PATH_OUT_BASE)/$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH).$(BUILD_TARGET_SUB)/$(KBUILD_TYPE)
450 else
451 PATH_OUT = $(PATH_OUT_BASE)/$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)/$(KBUILD_TYPE)
452 endif
453endif # !define PATH_OUT
454PATH_OBJCACHE = $(PATH_OUT_BASE)/kObjCache
455PATH_OBJ = $(PATH_OUT)/obj
456PATH_TARGET = $(PATH_OBJ)/$(CURSUBDIR)
457PATH_STAGE = $(PATH_OUT)/stage
458ifndef PATH_INS
459 ifdef DESTROOT
460PATH_INS = $(DESTROOT)
461 else
462PATH_INS = $(PATH_OUT)/dist
463 endif
464endif
465
466# Tripwire obsolete PATH defines.
467PATH_BIN = $(error kBuild: PATH_BIN is obsoleted in kBuild 0.1.2. Use PATH_STAGE_BIN or PATH_INST_BIN instead)
468PATH_DLL = $(error kBuild: PATH_LIB is obsoleted in kBuild 0.1.2. Use PATH_STAGE_DLL or PATH_INST_DLL instead)
469PATH_LIB = $(error kBuild: PATH_LIB is obsoleted in kBuild 0.1.2. Use PATH_STAGE_LIB or PATH_INST_LIB instead)
470PATH_SYS = $(error kBuild: PATH_SYS is obsoleted in kBuild 0.1.2. Use PATH_STAGE_SYS or PATH_INST_SYS instead)
471PATH_DOC = $(error kBuild: PATH_DOC is obsoleted in kBuild 0.1.2. Use PATH_STAGE_DOC or PATH_INST_DOC instead)
472
473# Development tool tree.
474ifndef KBUILD_DEVTOOLS
475 ifeq ($(PATH_DEVTOOLS),)
476 KBUILD_DEVTOOLS = $(PATH_ROOT)/tools
477 else
478 KBUILD_DEVTOOLS := $(PATH_DEVTOOLS)
479 endif
480endif
481KBUILD_DEVTOOLS_TRG ?= $(KBUILD_DEVTOOLS)/$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)
482KBUILD_DEVTOOLS_HST ?= $(KBUILD_DEVTOOLS)/$(KBUILD_HOST).$(KBUILD_HOST_ARCH)
483
484if1of ($(KBUILD_TARGET_ARCH), amd64 hppa64 mips64 ppc64 s390x sparc64)
485 ifeq ($(KBUILD_TARGET_ARCH),amd64)
486 KBUILD_DEVTOOLS_TRG_ALT ?= $(KBUILD_DEVTOOLS)/$(KBUILD_TARGET).x86
487 else ifeq ($(KBUILD_TARGET_ARCH),hppa64)
488 KBUILD_DEVTOOLS_TRG_ALT ?= $(KBUILD_DEVTOOLS)/$(KBUILD_TARGET).hppa32
489 else ifeq ($(KBUILD_TARGET_ARCH),mips64)
490 KBUILD_DEVTOOLS_TRG_ALT ?= $(KBUILD_DEVTOOLS)/$(KBUILD_TARGET).mips32
491 else ifeq ($(KBUILD_TARGET_ARCH),ppc64)
492 KBUILD_DEVTOOLS_TRG_ALT ?= $(KBUILD_DEVTOOLS)/$(KBUILD_TARGET).ppc32
493 else ifeq ($(KBUILD_TARGET_ARCH),s390x)
494 KBUILD_DEVTOOLS_TRG_ALT ?= $(KBUILD_DEVTOOLS)/$(KBUILD_TARGET).s390
495 else ifeq ($(KBUILD_TARGET_ARCH),sparc64)
496 KBUILD_DEVTOOLS_TRG_ALT ?= $(KBUILD_DEVTOOLS)/$(KBUILD_TARGET).sparc32
497 endif
498endif
499
500if1of ($(KBUILD_HOST_ARCH), amd64 hppa64 mips64 ppc64 s390x sparc64)
501 ifeq ($(KBUILD_HOST_ARCH),amd64)
502 KBUILD_DEVTOOLS_HST_ALT ?= $(KBUILD_DEVTOOLS)/$(KBUILD_HOST).x86
503 else ifeq ($(KBUILD_HOST_ARCH),hppa64)
504 KBUILD_DEVTOOLS_HST_ALT ?= $(KBUILD_DEVTOOLS)/$(KBUILD_HOST).hppa32
505 else ifeq ($(KBUILD_HOST_ARCH),mips64)
506 KBUILD_DEVTOOLS_HST_ALT ?= $(KBUILD_DEVTOOLS)/$(KBUILD_HOST).mips32
507 else ifeq ($(KBUILD_HOST_ARCH),ppc64)
508 KBUILD_DEVTOOLS_HST_ALT ?= $(KBUILD_DEVTOOLS)/$(KBUILD_HOST).ppc32
509 else ifeq ($(KBUILD_HOST_ARCH),s390x)
510 KBUILD_DEVTOOLS_HST_ALT ?= $(KBUILD_DEVTOOLS)/$(KBUILD_HOST).s390
511 else ifeq ($(KBUILD_HOST_ARCH),sparc64)
512 KBUILD_DEVTOOLS_HST_ALT ?= $(KBUILD_DEVTOOLS)/$(KBUILD_HOST).sparc32
513 endif
514endif
515
516# Deprecated legacy names.
517PATH_DEVTOOLS ?= $(KBUILD_DEVTOOLS)
518PATH_DEVTOOLS_TRG ?= $(KBUILD_DEVTOOLS_TRG)
519PATH_DEVTOOLS_BLD ?= $(KBUILD_DEVTOOLS_TRG)
520PATH_DEVTOOLS_TRG_ALT ?= $(KBUILD_DEVTOOLS_TRG_ALT)
521PATH_DEVTOOLS_HST ?= $(KBUILD_DEVTOOLS_HST)
522PATH_DEVTOOLS_HST_ALT ?= $(KBUILD_DEVTOOLS_HST_ALT)
523
524# KBUILD_PATH / PATH_KBUILD is determined by kmk.
525ifndef KBUILD_PATH
526 KBUILD_PATH := $(PATH_KBUILD)
527endif
528ifeq ($(strip $(KBUILD_PATH)),)
529 $(error kBuild: KBUILD_PATH is missing or empty! kmk is supposed to set it.)
530endif
531# KBUILD_BIN_PATH / PATH_KBUILD_BIN is determined by kmk.
532ifndef KBUILD_BIN_PATH
533 KBUILD_BIN_PATH := $(PATH_KBUILD_BIN)
534endif
535ifeq ($(strip $(KBUILD_BIN_PATH)),)
536 $(error kBuild: KBUILD_BIN_PATH is missing or empty! kmk is supposed to set it.)
537endif
538
539# kBuild files which might be of interest.
540FILE_KBUILD_HEADER := $(KBUILD_PATH)/header.kmk
541#FILE_KBUILD_CONFIG := $(KBUILD_PATH)/config.kmk
542FILE_KBUILD_FOOTER := $(KBUILD_PATH)/footer.kmk
543FILE_KBUILD_SUB_HEADER := $(KBUILD_PATH)/subheader.kmk
544FILE_KBUILD_SUB_FOOTER := $(KBUILD_PATH)/subfooter.kmk
545
546## MAKEFILE is the name of the main makefile.
547MAKEFILE := $(firstword $(MAKEFILE_LIST))
548## MAKEFILE_CURRENT is the name of the current makefile.
549# This is updated everything a sub-makefile is included.
550MAKEFILE_CURRENT := $(MAKEFILE)
551
552
553## @todo this should be done via SUFF_XYZ.target/host...
554
555#
556# Build platform setup.
557# (PORTME)
558#
559if1of ($(KBUILD_HOST), win nt)
560# Win, Win32, Win64, NT.
561EXEC_X86_WIN32 :=
562HOSTSUFF_EXE := .exe
563
564# OS/2.
565else ifeq ($(KBUILD_HOST),os2)
566EXEC_X86_WIN32 := innopec.exe
567HOSTSUFF_EXE := .exe
568
569else if1of ($(KBUILD_HOST), freebsd dragonfly linux openbsd netbsd)
570# Unix (like) systems with wine.
571EXEC_X86_WIN32 := wine
572HOSTSUFF_EXE :=
573
574else
575# Unix (like) systems without wine.
576EXEC_X86_WIN32 := false
577HOSTSUFF_EXE :=
578endif
579
580
581#
582# Build target setup.
583# (PORTME)
584#
585SUFF_DEP := .dep
586SUFF_BIN :=
587if1of ($(KBUILD_TARGET), win nt os2)
588SUFF_OBJ := .obj
589SUFF_LIB := .lib
590SUFF_DLL := .dll
591SUFF_EXE := .exe
592SUFF_SYS := .sys
593SUFF_RES := .res
594else ifeq ($(KBUILD_TARGET),l4)
595SUFF_OBJ := .o
596SUFF_LIB := .a
597SUFF_DLL := .s.so
598SUFF_EXE :=
599SUFF_SYS := .a
600SUFF_RES :=
601else ifeq ($(KBUILD_TARGET),darwin)
602SUFF_OBJ := .o
603SUFF_LIB := .a
604SUFF_DLL := .dylib
605SUFF_EXE :=
606SUFF_SYS :=
607SUFF_RES :=
608else
609SUFF_OBJ := .o
610SUFF_LIB := .a
611SUFF_DLL := .so
612SUFF_EXE :=
613 if1of ($(KBUILD_TARGET), dragonfly freebsd linux netbsd openbsd) ## @todo check netbsd and openbsd.
614SUFF_SYS := .ko
615 else
616SUFF_SYS :=
617 endif
618SUFF_RES :=
619endif
620
621#
622# Standard kBuild tools.
623#
624ifeq ($(KMK),kmk)
625KMK := $(KBUILD_BIN_PATH)/kmk$(HOSTSUFF_EXE)
626endif
627MAKE := $(KMK)
628
629GMAKE := $(KBUILD_BIN_PATH)/kmk_gmake$(HOSTSUFF_EXE)
630
631#DEP_EXT := $(KBUILD_BIN_PATH)/kDep$(HOSTSUFF_EXE)
632#DEP_INT := $(KBUILD_BIN_PATH)/kDep$(HOSTSUFF_EXE)
633#DEP := $(DEP_INT)
634
635DEP_IDB_EXT := $(KBUILD_BIN_PATH)/kDepIDB$(HOSTSUFF_EXE)
636DEP_IDB_INT := kmk_builtin_kDepIDB
637DEP_IDB := $(DEP_IDB_INT)
638
639DEP_OBJ_EXT := $(KBUILD_BIN_PATH)/kDepObj$(HOSTSUFF_EXE)
640DEP_OBJ_INT := kmk_builtin_kDepObj
641DEP_OBJ := $(DEP_OBJ_INT)
642
643DEP_PRE := $(KBUILD_BIN_PATH)/kDepPre$(HOSTSUFF_EXE)
644
645KOBJCACHE_EXT := $(KBUILD_BIN_PATH)/kObjCache$(HOSTSUFF_EXE)
646KOBJCACHE := $(KOBJCACHE_EXT)
647
648KLIBTWEAKER_EXT := $(KBUILD_BIN_PATH)/kLibTweaker$(HOSTSUFF_EXE)
649KLIBTWEAKER := $(KLIBTWEAKER_EXT)
650
651APPEND_EXT := $(KBUILD_BIN_PATH)/kmk_append$(HOSTSUFF_EXE)
652APPEND_INT := kmk_builtin_append
653APPEND := $(APPEND_INT)
654
655CAT_EXT := $(KBUILD_BIN_PATH)/kmk_cat$(HOSTSUFF_EXE)
656CAT_INT := kmk_builtin_cat
657CAT := $(CAT_INT)
658
659CHMOD_EXT := $(KBUILD_BIN_PATH)/kmk_chmod$(HOSTSUFF_EXE)
660CHMOD_INT := kmk_builtin_chmod
661CHMOD := $(CHMOD_INT)
662
663CMP_EXT := $(KBUILD_BIN_PATH)/kmk_cmp$(HOSTSUFF_EXE)
664CMP_INT := kmk_builtin_cmp
665CMP := $(CMP_INT)
666
667CP_EXT := $(KBUILD_BIN_PATH)/kmk_cp$(HOSTSUFF_EXE)
668CP_INT := kmk_builtin_cp
669CP := $(CP_INT)
670
671ECHO_EXT := $(KBUILD_BIN_PATH)/kmk_echo$(HOSTSUFF_EXE)
672ECHO_INT := kmk_builtin_echo
673ECHO := $(ECHO_INT)
674
675EXPR_EXT := $(KBUILD_BIN_PATH)/kmk_expr$(HOSTSUFF_EXE)
676EXPR_INT := kmk_builtin_expr
677EXPR := $(EXPR_INT)
678
679INSTALL_EXT := $(KBUILD_BIN_PATH)/kmk_install$(HOSTSUFF_EXE)
680INSTALL_INT := kmk_builtin_install
681INSTALL := $(INSTALL_INT)
682
683LN_EXT := $(KBUILD_BIN_PATH)/kmk_ln$(HOSTSUFF_EXE)
684LN_INT := kmk_builtin_ln
685LN := $(LN_INT)
686
687MD5SUM_EXT := $(KBUILD_BIN_PATH)/kmk_md5sum$(HOSTSUFF_EXE)
688MD5SUM_INT := kmk_builtin_md5sum
689MD5SUM := $(MD5SUM_INT)
690
691MKDIR_EXT := $(KBUILD_BIN_PATH)/kmk_mkdir$(HOSTSUFF_EXE)
692MKDIR_INT := kmk_builtin_mkdir
693MKDIR := $(MKDIR_INT)
694
695MV_EXT := $(KBUILD_BIN_PATH)/kmk_mv$(HOSTSUFF_EXE)
696MV_INT := kmk_builtin_mv
697MV := $(MV_INT)
698
699PRINTF_EXT := $(KBUILD_BIN_PATH)/kmk_printf$(HOSTSUFF_EXE)
700PRINTF_INT := kmk_builtin_printf
701PRINTF := $(PRINTF_INT)
702
703REDIRECT_EXT:= $(KBUILD_BIN_PATH)/kmk_redirect$(HOSTSUFF_EXE)
704if $(KBUILD_KMK_REVISION) > 2911
705REDIRECT_INT:= kmk_builtin_redirect
706else
707REDIRECT_INT:= $(REDIRECT_EXT)
708endif
709REDIRECT := $(REDIRECT_INT)
710
711RM_EXT := $(KBUILD_BIN_PATH)/kmk_rm$(HOSTSUFF_EXE)
712RM_INT := kmk_builtin_rm
713RM := $(RM_INT)
714
715RMDIR_EXT := $(KBUILD_BIN_PATH)/kmk_rmdir$(HOSTSUFF_EXE)
716RMDIR_INT := kmk_builtin_rmdir
717RMDIR := $(RMDIR_INT)
718
719SED_EXT := $(KBUILD_BIN_PATH)/kmk_sed$(HOSTSUFF_EXE)
720SED_INT := $(SED_EXT)
721SED := $(SED_EXT)
722
723SLEEP_INT := kmk_builtin_sleep
724SLEEP_EXT := $(KBUILD_BIN_PATH)/kmk_sleep$(HOSTSUFF_EXE)
725SLEEP := $(SLEEP_EXT)
726
727TEST_EXT := $(KBUILD_BIN_PATH)/kmk_test$(HOSTSUFF_EXE)
728TEST_INT := kmk_builtin_test
729TEST := $(TEST_INT)
730
731TIME_EXT := $(KBUILD_BIN_PATH)/kmk_time$(HOSTSUFF_EXE)
732TIME_INT := $(TIME_EXT)
733TIME := $(TIME_INT)
734
735# Our default shell is the Almquist shell from *BSD.
736ASH := $(KBUILD_BIN_PATH)/kmk_ash$(HOSTSUFF_EXE)
737MAKESHELL := $(ASH)
738SHELL := $(ASH)
739export SHELL MAKESHELL
740
741# Symlinking is problematic on some platforms...
742LN_SYMLINK := $(LN) -s
743
744# When copying to the staging area, use hard links to save time and space.
745ifndef KBUILD_NO_HARD_LINKING
746 INSTALL_STAGING := $(INSTALL) --hard-link-files-when-possible
747else
748 INSTALL_STAGING := $(INSTALL)
749endif
750
751
752#
753# Some Functions.
754# The lower cased ones are either fallbacks or candidates for functions.c.
755#
756
757## ABSPATH - make paths absolute.
758# This implementation is clumsy and doesn't resolve '..' and '.' components.
759#
760# @param $1 The paths to make absolute.
761# @obsolete Use the GNU make function $(abspath) directly now.
762ABSPATH = $(abspath $(1))$(warning ABSPATH is deprecated, use abspath directly!)
763
764## DIRDEP - make create directory dependencies.
765#
766# @param $1 The paths to the directories which must be created.
767DIRDEP = $(foreach path,$(patsubst %/,%,$(1)),$(path)/)
768
769## Cygwin kludge.
770# This converts /cygdrive/x/% to x:%.
771#
772# @param $1 The paths to make native.
773# @remark This macro is pretty much obsolete since we don't use cygwin base make.
774ifneq ($(patsubst /cygdrive/%,%,$(CURDIR)),$(CURDIR))
775 CYGPATHMIXED = $(foreach path,$(1)\
776 ,$(if $(patsubst /cygdrive/%,,$(path)),$(path),$(patsubst $(strip $(firstword $(subst /, ,$(patsubst /cygdrive/%,%,$(path)))))/%,$(strip $(firstword $(subst /, ,$(patsubst /cygdrive/%,%,$(path))))):/%,$(patsubst /cygdrive/%,%,$(path)))))
777else
778 CYGPATHMIXED = $(1)
779endif
780
781## Removes the drive letter from a path (if it has one)
782# @param $1 the path
783no-drive = $(word $(words $(subst :, ,$(1))),$(subst :, ,$(1)))
784
785## Removes the root slash from a path (if it has one)
786# @param $1 the path
787no-root-slash = $(patsubst /%,%,$(1))
788
789##
790# Similar to firstword, except it returns the value of first defined variable.
791# @param $1 list of variables to probe.
792define FIRST-DEFINED-VAR
793local .RETURN := $(strip $(firstdefined $1, value))
794endef
795
796## Figure out where to put object files.
797# @param $1 real target name.
798# @param $2 normalized main target
799TARGET_BASE = $(PATH_TARGET)/$(2)/$(call no-root-slash,$(call no-drive,$(1)))
800
801## Figure out where to put object files.
802# @param $1 normalized main target
803TARGET_PATH = $(PATH_TARGET)/$(1)
804
805##
806# Checks if the specified short option ($1) is found in the flags ($2),
807# assuming getopt style options.
808#
809# @returns $3 if present, $4 not.
810#
811# @param $1 The option (single char!).
812# @param $2 The option arguments.
813# @param $3 Eval and return if present.
814# @param $4 Eval and return if not present.
815#
816# @todo May confuse option values starting with '-' for options.
817# @remarks Invoke like this: $(evalcall KB_FN_OPT_TEST_SHORT,d,$(flags),present,not-present)
818#
819define KB_FN_OPT_TEST_SHORT
820local options := $(translate $(strip $(filter -%,$(filter-out --%,$2))),$(SP)-,)
821local .RETURN := $(if-expr $(pos $1,$(options)) != 0,$3,$4)
822endef
823
824##
825# Checks if the specified long option ($1) is found in the flags ($2),
826# assuming getopt style options.
827#
828# @returns $3 if present, $4 not.
829#
830# @param $1 The long option, dashes included. No % chars.
831# @param $2 The option arguments.
832# @param $3 Eval and return if present.
833# @param $4 Eval and return if not present.
834#
835# @todo May confuse option values starting with '--' for options.
836# @remarks Invoke like this: $(evalcall KBFN_OPT_TEST_SHORT,--defined,$(flags),present,not-present)
837#
838define KB_FN_OPT_TEST_LONG
839local options := $(filter-out =delete=%,$(subst :, =delete=,$(subst =, =delete=,$2)))
840local .RETURN := $(if-expr "$(filter $1,$(options))" != "",$3,$4)
841endef
842
843##
844# Checks if the specified short ($1) or long ($2) option is found in the flags ($2),
845# assuming getopt style options.
846#
847# @returns $4 if present, $5 not.
848#
849# @param $1 The short option (single char!).
850# @param $2 The long option, dashes included. No % chars.
851# @param $3 The option arguments.
852# @param $4 Eval and return if present.
853# @param $5 Eval and return if not present.
854#
855# @todo May confuse option values starting with '--' for options.
856# @remarks Invoke like this: $(evalcall KB_FN_OPT_TEST_SHORT_LONG,d,--defined,$(flags),present,not-present)
857#
858define KB_FN_OPT_TEST_SHORT_LONG
859local short_options := $(translate $(strip $(filter -%,$(filter-out --%,$3))),$(SP)-,)
860local long_options := $(filter-out =delete=%,$(subst :, =delete=,$(subst =, =delete=,$3)))
861local .RETURN := $(if-expr $(pos $1,$(short_options)) != 0 || "$(filter $2,$(long_options))" != "",$4,$5)
862endef
863
864##
865# Make an assignment to a deprecated variable.
866#
867# @param $1 The variable name.
868# @param $2 The value.
869# @param $3 The variable to use instead.
870#
871ifdef KBUILD_WITH_DEPREATED_AS_ERROR
872 KB_FN_ASSIGN_DEPRECATED = $(eval $(subst :,$$(COLON),$1) = $2$$(error $1 is deprecated, use $3 instead))
873else
874 KB_FN_ASSIGN_DEPRECATED = $(eval $(subst :,$$(COLON),$1) = $2$$(warning $1 is deprecated, use $3 instead))
875endif
876
877##
878# Show an assertion message.
879#
880# @param $1 The assertion name.
881# @param $2 The details.
882#
883define KB_FN_ASSERT_MSG
884$(info !! kBuild $1 Assertion Failed !!)
885ifdef target
886 $(info !! target: $(target))
887 local varloc := $(where $(target))
888 if "$(varloc)" == "undefined"
889 local varloc := $(where $(target)_TEMPLATE)
890 endif
891 if "$(varloc)" == "undefined"
892 local varloc := $(where $(target)_SOURCES)
893 endif
894 if "$(varloc)" == "undefined"
895 local varloc := $(where $(target)_EXTENDS)
896 endif
897 if "$(varloc)" == "undefined"
898 local varloc := $(where target)
899 endif
900 ifneq ($(varloc),)
901 $(info !! location: $(varloc))
902 else
903 $(info !! probable location: $($(target)_DEFPATH)/Makefile.kmk)
904 endif
905endif
906$(info !! $2)
907$(error fixme)
908endef
909
910##
911# Throw an error if the given path $1 isn't absolute and assertions are enabled.
912#
913# @param $1 The name of the path variable to check.
914#
915ifdef KBUILD_INTERNAL_STRICT
916 KB_FN_ASSERT_ABSPATH = $(if-expr "$(abspath $($(strip $1)))" != "$(strip $($(strip $1)))",\
917 $(evalcall KB_FN_ASSERT_MSG,abspath,$1 is:$(NLTAB)'$($(strip $1))'$(NLTAB)expected:$(NLTAB)'$(abspath $($(strip $1)))'))
918else
919 KB_FN_ASSERT_ABSPATH :=
920endif
921
922
923#
924# Initialize some of the globals which the Config.kmk and
925# others can add stuff to if they like for processing in the footer.
926#
927
928## KBUILD_TEMPLATE_PATHS
929# List a paths (separated by space) where templates can be found.
930KBUILD_TEMPLATE_PATHS :=
931
932## KBUILD_TOOL_PATHS
933# List of paths (separated by space) where tools can be found.
934KBUILD_TOOL_PATHS :=
935
936## KBUILD_SDK_PATHS
937# List of paths (separated by space) where SDKs can be found.
938KBUILD_SDK_PATHS :=
939
940## KBUILD_UNIT_PATHS
941# List of paths (separated by space) where units (USES) can be found.
942KBUILD_UNIT_PATHS :=
943
944## KBUILD_DEFAULT_PATHS
945# List of paths (separated by space) to search for stuff as a last resort.
946KBUILD_DEFAULT_PATHS :=
947
948## Proritized list of the default makefile when walking subdirectories.
949# The user can overload this list.
950DEFAULT_MAKEFILE := Makefile.kmk makefile.kmk Makefile makefile
951
952## KBUILD_SRC_HANDLERS
953# The list of source handlers, pair of extension and handler.
954# The user can overload this list to provide additional or custom
955# handlers. On a per-target/template see SRC_HANDLERS.
956KBUILD_SRC_HANDLERS := \
957 .c:def_src_handler_c \
958 .C:def_src_handler_c \
959.cxx:def_src_handler_cxx \
960.CXX:def_src_handler_cxx \
961.cpp:def_src_handler_cxx \
962.CPP:def_src_handler_cxx \
963 .cc:def_src_handler_cxx \
964 .CC:def_src_handler_cxx \
965 .m:def_src_handler_objc \
966 .M:def_src_handler_objcxx \
967 .mm:def_src_handler_objcxx \
968.asm:def_src_handler_asm \
969.ASM:def_src_handler_asm \
970 .s:def_src_handler_asm \
971 .S:def_src_handler_asm \
972 .rc:def_src_handler_rc \
973.obj:def_src_handler_obj \
974 .o:def_src_handler_obj \
975.res:def_src_handler_obj
976
977## PROPS_TOOLS
978# This is a subset of PROPS_SINGLE.
979PROPS_TOOLS := TOOL CTOOL CXXTOOL OBJCTOOL OBJCXXTOOL ASTOOL RCTOOL ARTOOL LDTOOL FETCHTOOL UNPACKTOOL PATCHTOOL
980
981## PROPS_SINGLE
982# The list of non-accumulative target properties.
983# A Config.kmk file can add it's own properties to this list and kBuild
984# will do the necessary inheritance for templates, sdks, tools and targets.
985PROPS_SINGLE := $(PROPS_TOOLS) TEMPLATE INSTTYPE INST STAGE NOINST BLD_TYPE BLD_TRG BLD_TRG_ARCH BLD_TRG_CPU FETCHDIR \
986 OBJSUFF COBJSUFF CXXOBJSUFF OBJCOBJSUFF OBJCXXOBJSUFF ASOBJSUFF RCOBJSUFF SYSSUFF BINSUFF EXESUFF DLLSUFF LIBSUFF ARLIBSUFF \
987 MODE UID GID LD_DEBUG DEBUG_INSTTYPE DEBUG_INST DEBUG_STAGE
988## PROPS_SINGLE_LNK
989# Subset of PROPS_SINGLE which applies to all linkable targets.
990PROPS_SINGLE_LNK := $(filter-out FETCHTOOL UNPACKTOOL PATCHTOOL FETCHDIR, $(PROPS_SINGLE))
991
992## PROPS_DEFERRED
993# This list of non-accumulative target properties which are or may be
994# functions, and thus should not be expanded until the very last moment.
995PROPS_DEFERRED := INSTFUN INSTALLER PRE_CMDS POST_CMDS PRE_INST_CMDS POST_INST_CMDS \
996 PRE_FILE_CMDS POST_FILE_CMDS PRE_SYMLINK_CMDS POST_SYMLINK_CMDS PRE_DIRECTORY_CMDS POST_DIRECTORY_CMDS \
997 NAME SONAME
998
999## PROPS_ACCUMULATE_R
1000# The list of accumulative target properties where the right most value/flag
1001# is the 'most significant'.
1002# A Config.kmk file can add it's own properties to this list and kBuild
1003# will do the necessary inheritance from templates to targets.
1004PROPS_ACCUMULATE_R := \
1005 DEPS LNK_DEPS ORDERDEPS LNK_ORDERDEPS DEFS \
1006 ARFLAGS \
1007 CFLAGS CDEFS \
1008 CXXFLAGS CXXDEFS \
1009 OBJCFLAGS OBJCDEFS \
1010 OBJCXXFLAGS OBJCXXDEFS \
1011 ASFLAGS ASDEFS \
1012 RCFLAGS RCDEFS \
1013 LDFLAGS \
1014 IDFLAGS IFFLAGS EXEC_IFFLAGS ISFLAGS \
1015 FETCHFLAGS UNPACKFLAGS PATCHFLAGS
1016## PROPS_ACCUMULATE_R_LNK
1017# Subset of PROPS_ACCUMULATE_R which applies to all linkable targets.
1018PROPS_ACCUMULATE_R_LNK := $(filter-out ARFLAGS LDFLAGS EXEC_IFFLAGS FETCHFLAGS UNPACKFLAGS PATCHFLAGS, $(PROPS_ACCUMULATE_R))
1019
1020## PROPS_ACCUMULATE
1021# The list of accumulative target properties where the left most value/flag
1022# is the 'most significant'.
1023# A Config.kmk file can add it's own properties to this list and kBuild
1024# will do the necessary inheritance from templates to targets.
1025PROPS_ACCUMULATE_L := \
1026 SDKS USES SOURCES EXEC_SOURCES SRC_HANDLERS INTERMEDIATES \
1027 INCS CINCS CXXINCS OBJCINCS OBJCXXINCS ASINCS RCINCS \
1028 LIBS LIBPATH \
1029 DIRS BLDDIRS CLEAN
1030## PROPS_ACCUMULATE_L_LNK
1031# Subset of PROPS_ACCUMULATE_L which applies to all linkable targets.
1032PROPS_ACCUMULATE_L_LNK := $(filter-out LIBS LIBPATH EXEC_SOURCES DIRS, $(PROPS_ACCUMULATE_L))
1033
1034## PROPS_ALL
1035# List of all the properties.
1036PROPS_ALL = $(PROPS_SINGLE) $(PROPS_DEFERRED) $(PROPS_ACCUMULATE_L) $(PROPS_ACCUMULATE_R)
1037
1038## @name Properties valid on programs (BLDPROGS and PROGRAMS)
1039## @{
1040PROPS_PROGRAMS_SINGLE := $(PROPS_SINGLE_LNK) LDTOOL EXESUFF
1041PROPS_PROGRAMS_DEFERRED := $(PROPS_DEFERRED)
1042PROPS_PROGRAMS_ACCUMULATE_R := $(PROPS_ACCUMULATE_R_LNK) LDFLAGS
1043PROPS_PROGRAMS_ACCUMULATE_L := $(PROPS_ACCUMULATE_L_LNK) LIBS LIBPATH
1044## @}
1045
1046## @name Properties valid on libraries (LIBRARIES and IMPORT_LIBS)
1047## @{
1048PROPS_LIBRARIES_SINGLE := $(PROPS_SINGLE_LNK) ARTOOL LIBSUFF ARLIBSUFF LIBSUFF
1049PROPS_LIBRARIES_DEFERRED := $(filter-out SONAME,$(PROPS_DEFERRED))
1050PROPS_LIBRARIES_ACCUMULATE_R := $(PROPS_ACCUMULATE_R_LNK) ARFLAGS
1051PROPS_LIBRARIES_ACCUMULATE_L := $(PROPS_ACCUMULATE_L_LNK)
1052## @}
1053
1054## @name Properties valid on dlls (DLLS)
1055## @{
1056PROPS_DLLS_SINGLE := $(PROPS_SINGLE_LNK) LDTOOL DLLSUFF LIBSUFF
1057PROPS_DLLS_DEFERRED := $(PROPS_DEFERRED)
1058PROPS_DLLS_ACCUMULATE_R := $(PROPS_ACCUMULATE_R_LNK) LDFLAGS
1059PROPS_DLLS_ACCUMULATE_L := $(PROPS_ACCUMULATE_L_LNK) LIBS LIBPATH
1060## @}
1061
1062## @name Properties valid on system modules (SYSMODS)
1063## @{
1064PROPS_SYSMODS_SINGLE := $(PROPS_SINGLE_LNK) LDTOOL SYSSUFF
1065PROPS_SYSMODS_DEFERRED := $(PROPS_DEFERRED)
1066PROPS_SYSMODS_ACCUMULATE_R := $(PROPS_ACCUMULATE_R_LNK) LDFLAGS
1067PROPS_SYSMODS_ACCUMULATE_L := $(PROPS_ACCUMULATE_L_LNK) LIBS LIBPATH
1068## @}
1069
1070## @name Properties valid on misc binaries (MISCBINS)
1071## @{
1072PROPS_MISCBINS_SINGLE := $(PROPS_SINGLE_LNK) LDTOOL BINSUFF
1073PROPS_MISCBINS_DEFERRED := $(PROPS_DEFERRED)
1074PROPS_MISCBINS_ACCUMULATE_R := $(PROPS_ACCUMULATE_R_LNK) LDFLAGS
1075PROPS_MISCBINS_ACCUMULATE_L := $(PROPS_ACCUMULATE_L_LNK) LIBS LIBPATH
1076## @}
1077
1078## @name Properties valid on installs (INSTALLS)
1079## @{
1080PROPS_INSTALLS_SINGLE := TOOL TEMPLATE INSTTYPE INST STAGE NOINST BLD_TYPE BLD_TRG BLD_TRG_ARCH BLD_TRG_CPU MODE UID GID
1081PROPS_INSTALLS_DEFERRED := INSTFUN INSTALLER PRE_FILE_CMDS POST_FILE_CMDS PRE_SYMLINK_CMDS POST_SYMLINK_CMDS \
1082 PRE_DIRECTORY_CMDS POST_DIRECTORY_CMDS
1083PROPS_INSTALLS_ACCUMULATE_R := DEPS ORDERDEPS GOALS INST_ONLY_GOALS STAGE_ONLY_GOALS IFFLAGS EXEC_IFFLAGS
1084PROPS_INSTALLS_ACCUMULATE_L := SOURCES EXEC_SOURCES DIRS CLEAN
1085## @}
1086
1087## @name Properties valid on fetches (FETCHES)
1088## @{
1089PROPS_FETCHES_SINGLE := TOOL TEMPLATE FETCHTOOL UNPACKTOOL PATCHTOOL INST FETCHDIR
1090PROPS_FETCHES_DEFERRED :=
1091PROPS_FETCHES_ACCUMULATE_R := FETCHFLAGS UNPACKFLAGS PATCHFLAGS
1092PROPS_FETCHES_ACCUMULATE_L := SOURCES CLEAN
1093## @}
1094
1095## KBUILD_COMPILE_CATEGTORIES
1096# Tools categories for compiling.
1097KBUILD_COMPILE_CATEGTORIES := AS C CXX OBJC OBJCXX RC
1098
1099## KBUILD_GENERIC_CATEGORIES
1100# Generic tool categories.
1101KBUILD_GENERIC_CATEGORIES := FETCH UNPACK PATCH $(addprefix LINK_,LIBRARY PROGRAM DLL SYSMOD MISCBIN)
1102
1103## PROPS_TOOLS_ONLY
1104# Properties found only on tools.
1105# This is expanded in a deferred manner, so it will pick up changes made to
1106# KBUILD_COMPILE_CATEGTORIES and KBUILD_GENERIC_CATEGORIES made by units.
1107PROPS_TOOLS_ONLY = \
1108 $(foreach cat, $(KBUILD_COMPILE_CATEGTORIES), \
1109 COMPILE_$(cat)_CMDS \
1110 COMPILE_$(cat)_OUTPUT \
1111 COMPILE_$(cat)_OUTPUT_MAYBE \
1112 COMPILE_$(cat)_DEPEND \
1113 COMPILE_$(cat)_DEPORD \
1114 COMPILE_$(cat)_USES_KOBJCACHE ) \
1115 $(foreach cat, $(KBUILD_GENERIC_CATEGORIES), \
1116 $(cat)_CMDS \
1117 $(cat)_OUTPUT \
1118 $(cat)_OUTPUT_MAYBE \
1119 $(cat)_DEPEND \
1120 $(cat)_DEPORD ))
1121
1122
1123#
1124# Here is a special 'hack' to prevent innocent environment variables being
1125# picked up and treated as properties. (The most annoying example of why
1126# this is necessary is the Visual C++ commandline with it's LIBPATH.)
1127#
1128# Define KBUILD_DONT_KILL_ENV_PROPS in the env. or on the commandline to
1129# disable this 'hack'.
1130#
1131ifndef KBUILD_DONT_KILL_ENV_PROPS
1132
1133define def_nuke_environment_prop
1134ifeq ($(origin $(prop)),environment)
1135$(prop) =
1136endif
1137endef
1138$(foreach prop, $(PROPS_ALL) \
1139 FETCHES PATCHES BLDPROGS LIBRARIES IMPORT_LIBS DLLS PROGRAMS SYSMODS MISCBINS INSTALLS OTHERS \
1140 SUBDIRS MAKEFILES BLDDIRS \
1141 ,$(eval $(value def_nuke_environment_prop)))
1142
1143endif # KBUILD_DONT_KILL_ENV_PROPS
1144
1145
1146#
1147# Pass configuration.
1148#
1149# The PASS_<passname>_trgs variable is listing the targets.
1150# The PASS_<passname>_vars variable is listing the target variables.
1151# The PASS_<passname>_pass variable is the lowercased passname.
1152#
1153
1154## PASS: fetches
1155# This pass fetches and unpacks things needed to complete the build.
1156PASS_FETCHES := Fetches
1157PASS_FETCHES_trgs :=
1158PASS_FETCHES_vars := _FETCHES
1159PASS_FETCHES_pass := fetches
1160
1161## PASS: patches
1162# This pass applies patches.
1163PASS_PATCHES := Patches
1164PASS_PATCHES_trgs :=
1165PASS_PATCHES_vars := _PATCHES
1166PASS_PATCHES_pass := patches
1167
1168## PASS: bldprogs
1169# This pass builds targets which are required for building the rest.
1170PASS_BLDPROGS := Build Programs
1171PASS_BLDPROGS_trgs :=
1172PASS_BLDPROGS_vars := _BLDPROGS
1173PASS_BLDPROGS_pass := bldprogs
1174
1175## PASS: libraries
1176# This pass builds library targets.
1177PASS_LIBRARIES := Libraries
1178PASS_LIBRARIES_trgs :=
1179PASS_LIBRARIES_vars := _LIBS _IMPORT_LIBS _OTHER_LIBRARIES
1180PASS_LIBRARIES_pass := libraries
1181
1182## PASS: binaries
1183# This pass builds dll targets.
1184PASS_DLLS := DLLs
1185PASS_DLLS_trgs :=
1186PASS_DLLS_vars := _DLLS _OTHER_DLLS
1187PASS_DLLS_pass := dlls
1188
1189## PASS: binaries
1190# This pass builds binary targets, i.e. programs, system modules and stuff.
1191PASS_BINARIES := Programs
1192PASS_BINARIES_trgs :=
1193PASS_BINARIES_vars := _PROGRAMS _SYSMODS _MISC_BINS _OTHER_BINARIES
1194PASS_BINARIES_pass := binaries
1195
1196## PASS: others
1197# This pass builds other targets.
1198PASS_OTHERS := Other Stuff
1199PASS_OTHERS_trgs :=
1200PASS_OTHERS_vars := _OTHERS
1201PASS_OTHERS_pass := others
1202
1203## PASS: staging
1204# This pass installs the built entities to a sandbox area.
1205## @todo split this up into build install (to sandbox) and real installation.
1206PASS_STAGING := Staging
1207PASS_STAGING_trgs :=
1208PASS_STAGING_vars := _STAGE_DIRS _INSTALLS _STAGE_FILES _DEBUG_STAGE_DIRS _DEBUG_STAGE_FILES
1209PASS_STAGING_pass := staging
1210
1211## PASS: install
1212# This pass installs the built entities to where they will be used (using
1213# DESTROOT or PATH_INS to indicate where this is).
1214PASS_INSTALLS := Install
1215PASS_INSTALLS_trgs :=
1216PASS_INSTALLS_vars := _INSTALLS_DIRS _INSTALLS_FILES _DEBUG_INSTALL_DIRS _DEBUG_INSTALL_FILES
1217PASS_INSTALLS_pass := installs
1218
1219## PASS: testing
1220# This pass processes custom rules for executing tests.
1221PASS_TESTING := Tests
1222PASS_TESTING_trgs :=
1223PASS_TESTING_vars := _TESTING
1224PASS_TESTING_pass := testing
1225
1226## PASS: packing
1227# This pass processes custom packing rules.
1228PASS_PACKING := Packing
1229PASS_PACKING_trgs :=
1230PASS_PACKING_vars := _PACKING
1231PASS_PACKING_pass := packing
1232
1233## PASS: clean
1234# This pass removes all generated files.
1235PASS_CLEAN := Clean
1236PASS_CLEAN_trgs := do-clean
1237PASS_CLEAN_vars :=
1238PASS_CLEAN_pass := clean
1239
1240## PASS: nothing
1241# This pass just walks the tree.
1242PASS_NOTHING := Nothing
1243PASS_NOTHING_trgs := do-nothing
1244PASS_NOTHING_vars :=
1245PASS_NOTHING_pass := nothing
1246
1247## DEFAULT_PASSES
1248# The default passes and their order.
1249DEFAULT_PASSES := BLDPROGS LIBRARIES DLLS BINARIES OTHERS STAGING
1250
1251## PASSES
1252# The passes that should be defined. This must include
1253# all passes mentioned by DEFAULT_PASSES.
1254PASSES := FETCHES PATCHES $(DEFAULT_PASSES) INSTALLS TESTING PACKING CLEAN NOTHING
1255
1256
1257#
1258# Check for --pretty-command-printing before including the Config.kmk
1259# so that anyone overriding the message macros can take the implied
1260# verbosity level change into account.
1261#
1262ifndef KBUILD_VERBOSE
1263 ifndef KBUILD_QUIET
1264 ifeq ($(KMK_OPTS_PRETTY_COMMAND_PRINTING),1)
1265 export KBUILD_VERBOSE := 2
1266 endif
1267 endif
1268endif
1269
1270
1271#
1272# Legacy variable translation.
1273# These will be eliminated when switching to the next version.
1274#
1275ifdef USE_KOBJCACHE
1276 ifndef KBUILD_USE_KOBJCACHE
1277 export KBUILD_USE_KOBJCACHE := $(USE_KOBJCACHE)
1278 endif
1279endif
1280
1281
1282#
1283# Library path searching hints (target OS + arch).
1284#
1285# KBUILD_LIB_SEARCH_SUBS - Subdirs typically containing the right libraries.
1286# KBUILD_LIB_SEARCH_ROOTS - Roots to search for library subdirs.
1287# KBUILD_LIB_SEARCH_PATHS - ROOTS + SUBS.
1288#
1289ifeq ($(KBUILD_TARGET),darwin)
1290 KBUILD_LIB_SEARCH_ROOTS := \
1291 /usr/ \
1292 /Developer/usr/
1293 KBUILD_LIB_SEARCH_SUBS := lib/
1294
1295else if1of ($(KBUILD_TARGET), freebsd netbsd openbsd dragonfly)
1296 KBUILD_LIB_SEARCH_ROOTS := \
1297 / \
1298 /usr/ \
1299 /usr/local/
1300 KBUILD_LIB_SEARCH_SUBS := lib/
1301
1302else ifeq ($(KBUILD_TARGET),linux)
1303 ifeq ($(realpath /bin),/usr/bin)
1304 KBUILD_LIB_SEARCH_ROOTS := \
1305 /usr/ \
1306 / \
1307 /usr/local/
1308 else
1309 KBUILD_LIB_SEARCH_ROOTS := \
1310 / \
1311 /usr/ \
1312 /usr/local/
1313 endif
1314 ifeq ($(KBUILD_TARGET_ARCH),amd64)
1315 KBUILD_LIB_SEARCH_SUBS := \
1316 lib/x86_64-linux-gnu/ \
1317 lib64/ \
1318 lib/
1319 else ifeq ($(KBUILD_TARGET_ARCH),x86)
1320 KBUILD_LIB_SEARCH_SUBS := \
1321 lib/i686-linux-gnu/ \
1322 lib/i386-linux-gnu/ \
1323 lib32/ \
1324 lib/
1325 else
1326 KBUILD_LIB_SEARCH_SUBS := lib/
1327 endif
1328
1329else ifeq ($(KBUILD_TARGET),solaris)
1330 KBUILD_LIB_SEARCH_ROOTS := \
1331 / \
1332 /usr/ \
1333 /usr/sfw/ \
1334 /usr/local/ \
1335 /sw/
1336 ifeq ($(KBUILD_TARGET_ARCH),amd64)
1337 KBUILD_LIB_SEARCH_SUBS := lib/amd64/ lib/
1338 else ifeq ($(KBUILD_TARGET_ARCH),sparc64)
1339 KBUILD_LIB_SEARCH_SUBS := lib/sparcv9/ lib/
1340 else
1341 KBUILD_LIB_SEARCH_SUBS := lib/
1342 endif
1343
1344else
1345 KBUILD_LIB_SEARCH_SUBS :=
1346 KBUILD_LIB_SEARCH_ROOTS :=
1347endif
1348KBUILD_LIB_SEARCH_PATHS := $(foreach root, $(KBUILD_LIB_SEARCH_ROOTS), $(addprefix $(root),$(KBUILD_LIB_SEARCH_SUBS)))
1349
1350
1351#
1352# This is how we find the closest config.kmk.
1353# It's a little hacky but I think it works fine.
1354#
1355_CFGDIR := .
1356_CFGFILES := ./Config.kmk ./config.kmk
1357define def_include_config
1358$(eval _CFGDIR := $(_CFGDIR)/$(dir))
1359_CFGFILES += $(_CFGDIR)/Config.kmk $(_CFGDIR)/config.kmk
1360endef
1361# walk down the _RELATIVE_ path specified by DEPTH.
1362$(foreach dir,$(subst /, ,$(DEPTH)), $(eval $(def_include_config)) )
1363# add the default config file.
1364_CFGFILE := $(firstword $(wildcard $(_CFGFILES) $(FILE_KBUILD_CONFIG)))
1365_CFGFILES :=
1366_CFGDIR :=
1367ifeq ($(_CFGFILE),)
1368$(error kBuild: no Config.kmk file found! Check the DEPTH: DEPTH='$(DEPTH)' PATH_CURRENT='$(PATH_CURRENT)')
1369endif
1370
1371# Include the config.kmk we found file (or the default one).
1372ifdef KBUILD_PROFILE_SELF
1373 $(evalcall def_profile_self, including $(_CFGFILE))
1374 include $(_CFGFILE)
1375 $(evalcall def_profile_self, included $(_CFGFILE))
1376else
1377 include $(_CFGFILE)
1378endif
1379
1380
1381
1382#
1383# Finalize a the central path variables now that we've included the Config.kmk file.
1384#
1385# This prevents some trouble when users override the defaults for these
1386# variables and uses relative paths or paths with incorrect case.
1387#
1388PATH_OUT_BASE := $(abspath $(PATH_OUT_BASE))
1389PATH_OUT := $(abspath $(PATH_OUT))
1390PATH_OBJ := $(abspath $(PATH_OBJ))
1391PATH_TARGET := $(abspath $(PATH_TARGET))
1392PATH_INS := $(abspath $(PATH_INS))
1393PATH_STAGE := $(abspath $(PATH_STAGE))
1394
1395# Finalize the install and staging directory layouts.
1396define def_kbuild_finalize_inst
1397local val := $(strip $($(y)_$(x)))
1398ifeq ($(val),)
1399 $(error kBuild: '$(y)_$(x)' is set to an empty value.)
1400endif
1401ifneq ($(words $(val)),1)
1402 $(error kBuild: The '$(y)_$(x)' value '$(val)' should not contain spaces.)
1403endif
1404ifneq ($(pos \,$(val)), 0)
1405 $(error kBuild: The '$(y)_$(x)' value '$(val)' contains DOS slashes: not allowed.)
1406endif
1407ifneq ($(pos $(COLON),$(val)), 0)
1408 $(error kBuild: The '$(y)_$(x)' value '$(val)' contains colon: not allowed.)
1409endif
1410ifneq ($(substr $(val),-1), /)
1411 $(error kBuild: The '$(y)_$(x)' value '$(val)' has no trailing slash.)
1412endif
1413if $(pos /../,$(val)) != 0 || "$(substr $(val), 3)" == "../"
1414 $(error kBuild: The '$(y)_$(x)' value '$(val)' contains dot-dot escape.)
1415endif
1416$($(y)_$(x) := $(val)
1417
1418local val := $(strip $(PATH_$(y)_$(x)))
1419ifeq ($(val),)
1420 $(error kBuild: 'PATH_$(y)_$(x)' is set to an empty value.)
1421endif
1422PATH_$(y)_$(x) := $(val)
1423endef
1424$(foreach y, INST STAGE, $(foreach x, $(KBUILD_INST_PATHS), $(evalcall def_kbuild_finalize_inst)))
1425
1426# No abspath for devtools since they might've been referenced already and we
1427# don't want conflicting variable expansions.
1428KBUILD_DEVTOOLS := $(KBUILD_DEVTOOLS)
1429KBUILD_DEVTOOLS_TRG := $(KBUILD_DEVTOOLS_TRG)
1430KBUILD_DEVTOOLS_TRG_ALT := $(KBUILD_DEVTOOLS_TRG_ALT)
1431KBUILD_DEVTOOLS_HST := $(KBUILD_DEVTOOLS_HST)
1432KBUILD_DEVTOOLS_HST_ALT := $(KBUILD_DEVTOOLS_HST_ALT)
1433
1434
1435#
1436# Setup the message style. The default one is inlined.
1437#
1438# See kBuild/msgstyles for more styles or use KBUILD_MSG_STYLE_PATHS
1439# to create your own message style.
1440#
1441KBUILD_MSG_STYLE ?= default
1442ifeq ($(KBUILD_MSG_STYLE),default)
1443 #
1444 # The 'default' style.
1445 #
1446
1447 ## Fetch starting.
1448 # @param 1 Target name.
1449 MSG_FETCH ?= $(call MSG_L1,Fetching $1...)
1450 ## Re-fetch starting.
1451 # @param 1 Target name.
1452 MSG_REFETCH ?= $(call MSG_L1,Re-fetching $1...)
1453 ## Downloading a fetch component.
1454 # @param 1 Target name.
1455 # @param 2 The source URL.
1456 # @param 3 The destination file name.
1457 MSG_FETCH_DL ?= $(call MSG_L1,Downloading $1 - $2,=> $3)
1458 ## Checking a fetch component.
1459 # @param 1 Target name.
1460 # @param 2 The source URL.
1461 # @param 3 The destination file name.
1462 MSG_FETCH_CHK?= $(call MSG_L1,Checking $1 - $3, ($2))
1463 ## Unpacking a fetch component.
1464 # @param 1 Target name.
1465 # @param 2 The archive file name.
1466 # @param 3 The target directory.
1467 MSG_FETCH_UP ?= $(call MSG_L1,Unpacking $1 - $2 => $3)
1468 ## Fetch completed.
1469 # @param 1 Target name.
1470 MSG_FETCH_OK ?= $(call MSG_L1,Successfully fetched $1)
1471 ## Unfetch a fetch target.
1472 # @param 1 Target name.
1473 MSG_UNFETCH ?= $(call MSG_L1,Unfetching $1...)
1474 ## Compiling a source file.
1475 # @param 1 Target name.
1476 # @param 2 The source filename.
1477 # @param 3 The primary link output file name.
1478 # @param 4 The source type (C,CXX,OBJC,AS,RC,++).
1479 MSG_COMPILE ?= $(call MSG_L1,Compiling $1 - $2,=> $3)
1480 ## Tool
1481 # @param 1 The tool name (bin2c,...)
1482 # @param 2 Target name.
1483 # @param 3 The source filename.
1484 # @param 4 The primary output file name.
1485 MSG_TOOL ?= $(call MSG_L1,$1 $2 - $3,=> $4)
1486 ## Generate a file, typically a source file.
1487 # @param 1 Target name if applicable.
1488 # @param 2 Output file name.
1489 # @param 3 What it's generated from
1490 MSG_GENERATE ?= $(call MSG_L1,Generating $(if $1,$1 - )$2,$(if $3,from $3))
1491 ## Linking a bldprog/dll/program/sysmod target.
1492 # @param 1 Target name.
1493 # @param 2 The primary link output file name.
1494 # @param 3 The link tool operation (LINK_LIBRARY,LINK_PROGRAM,LINK_DLL,LINK_SYSMOD,++).
1495 MSG_LINK ?= $(call MSG_L1,Linking $1,=> $2)
1496 ## Merging a library into the target (during library linking).
1497 # @param 1 Target name.
1498 # @param 2 The output library name.
1499 # @param 3 The input library name.
1500 MSG_AR_MERGE ?= $(call MSG_L1,Merging $3 into $1, ($2))
1501 ## Creating a directory (build).
1502 # @param 1 Directory name.
1503 MSG_MKDIR ?= $(call MSG_L2,Creating directory $1)
1504 ## Cleaning.
1505 MSG_CLEAN ?= $(call MSG_L1,Cleaning...)
1506 ## Nothing.
1507 MSG_NOTHING ?= $(call MSG_L1,Did nothing in $(CURDIR))
1508 ## Pass
1509 # @param 1 The pass name.
1510 MSG_PASS ?= $(call MSG_L1,Pass - $1)
1511 ## Installing a bldprog/lib/dll/program/sysmod target.
1512 # @param 1 Target name.
1513 # @param 2 The source filename.
1514 # @param 3 The destination file name.
1515 MSG_INST_TRG ?= $(call MSG_L1,Installing $1 => $3)
1516 ## Installing a file (install target).
1517 # @param 1 The source filename.
1518 # @param 2 The destination filename.
1519 MSG_INST_FILE?= $(call MSG_L1,Installing $2,(<= $1))
1520 ## Installing a symlink.
1521 # @param 1 Symlink
1522 # @param 2 Link target
1523 MSG_INST_SYM ?= $(call MSG_L1,Installing symlink $1,=> $2)
1524 ## Installing a directory.
1525 # @param 1 Directory name.
1526 MSG_INST_DIR ?= $(call MSG_L1,Installing directory $1)
1527
1528else
1529 _KBUILD_MSG_STYLE_FILE := $(firstword $(foreach path, $(KBUILD_MSG_STYLE_PATHS) $(KBUILD_PATH)/msgstyles, $(wildcard $(path)/$(KBUILD_MSG_STYLE).kmk)))
1530 ifneq ($(_KBUILD_MSG_STYLE_FILE),)
1531 include $(_KBUILD_MSG_STYLE_FILE)
1532 else
1533 $(error kBuild: Can't find the style setup file for KBUILD_MSG_STYLE '$(KBUILD_MSG_STYLE)')
1534 endif
1535endif
1536
1537
1538#
1539# Message macros.
1540#
1541# This is done after including Config.kmk as to allow for
1542# KBUILD_QUIET and KBUILD_VERBOSE to be configurable.
1543#
1544ifdef KBUILD_QUIET
1545 # No output
1546 QUIET := @
1547 QUIET2:= @
1548 MSG_L1 =
1549 MSG_L2 =
1550else
1551 ifndef KBUILD_VERBOSE
1552 # Default output level.
1553 QUIET := @
1554 QUIET2 := @
1555 MSG_L1 ?= %@$(ECHO) "kBuild: $1"
1556 MSG_L2 =
1557 else ifeq ($(KBUILD_VERBOSE),1)
1558 # A bit more output
1559 QUIET := @
1560 QUIET2 := @
1561 MSG_L1 ?= %@$(ECHO) "kBuild: $1 $2"
1562 MSG_L2 =
1563 else ifeq ($(KBUILD_VERBOSE),2)
1564 # Lot more output
1565 QUIET :=
1566 QUIET2 := @
1567 MSG_L1 ?= %@$(ECHO) "kBuild: $1 $2"
1568 MSG_L2 ?= %@$(ECHO) "kBuild: $1"
1569 else
1570 # maximal output.
1571 QUIET :=
1572 QUIET2 :=
1573 MSG_L1 ?= %@$(ECHO) "kBuild: $1 $2"
1574 MSG_L2 ?= %@$(ECHO) "kBuild: $1"
1575 endif
1576endif
1577
1578
1579#
1580# An internal define used by subheader.kmk and subfooter.kmk.
1581# We keep them here to avoid redefining them for each sub-makefile.
1582#
1583define def_subfooter_header_target_pass
1584 ifndef $(target)_PATH
1585 ifndef $(target)_DEFPATH
1586 $(target)_DEFPATH := $(PATH_SUB_CURRENT)
1587 endif
1588 $(call KB_FN_ASSIGN_DEPRECATED,$(target)_PATH,$($(target)_DEFPATH), $(target)_DEFPATH)
1589 else ifndef $(target)_DEFPATH
1590 $(target)_DEFPATH := $($(target)_PATH)
1591 endif
1592 ifndef $(target)_MAKEFILE
1593 $(target)_MAKEFILE := $(MAKEFILE_CURRENT)
1594 endif
1595 ifndef $(target)_0_OUTDIR
1596 $(target)_0_OUTDIR := $(call TARGET_PATH,$(target))
1597 $(call KB_FN_ASSIGN_DEPRECATED,PATH_$(target),$($(target)_0_OUTDIR), $(target)_0_OUTDIR)
1598 endif
1599endef
1600
1601
1602#
1603# Validate any KBUILD_BLD_TYPES additions and finally the KBUILD_TYPE.
1604#
1605if1of ($(KBUILD_BLD_TYPES), $(KBUILD_OSES))
1606 $(error kBuild: found KBUILD_BLD_TYPES in KBUILD_OSES!)
1607endif
1608if1of ($(KBUILD_BLD_TYPES), $(KBUILD_ARCHES))
1609 $(error kBuild: found KBUILD_BLD_TYPES in KBUILD_ARCHES!)
1610endif
1611if1of ($(KBUILD_OSES), $(KBUILD_ARCHES))
1612 $(error kBuild: found KBUILD_OSES in KBUILD_ARCHES!)
1613endif
1614ifn1of ($(KBUILD_TYPE), $(KBUILD_BLD_TYPES))
1615 $(error kBuild: KBUILD_TYPE(=$(KBUILD_TYPE)) is not found in KBUILD_BLD_TYPES(=$(KBUILD_BLD_TYPES))!)
1616endif
1617
1618
1619#
1620# Mark the output and temporary directories as volatile on windows.
1621#
1622# This automatically means the directories not listed here are considered
1623# static and won't be invalidated once we start running compile jobs.
1624#
1625ifeq ($(KBUILD_HOST),win)
1626 if $(KBUILD_KMK_REVISION) >= 2886
1627 $(dircache-ctl volatile, $(PATH_OUT_BASE), $(PATH_OUT), $(TEMP), $(TMP), $(TMPDIR), $(TMP))
1628 endif
1629endif
1630
1631
1632ifdef KBUILD_PROFILE_SELF
1633 $(evalcall def_profile_self, end of header.kmk)
1634 _KBUILD_TS_HEADER_END := $(_KBUILD_TS_PREV)
1635endif
1636
1637# end-of-file-content
1638__header_kmk__ := 1
1639endif # !__header_kmk__
1640
Note: See TracBrowser for help on using the repository browser.