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