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