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