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