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