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