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