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