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