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