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