[69] | 1 | # $Id: header.kmk 353 2005-12-12 03:36:07Z bird $
|
---|
| 2 | ## @file
|
---|
| 3 | #
|
---|
| 4 | # kBuild - File included at top of makefile.
|
---|
| 5 | #
|
---|
[353] | 6 | # Copyright (c) 2004-2005 knut st. osmundsen <bird-srcspam@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
|
---|
| 29 |
|
---|
| 30 | #
|
---|
| 31 | # default rule
|
---|
| 32 | #
|
---|
| 33 | all: all_recursive
|
---|
| 34 |
|
---|
| 35 | #
|
---|
| 36 | # Try avoid inference rules.
|
---|
| 37 | #
|
---|
| 38 | .SUFFIXES:
|
---|
| 39 | SUFFIXES :=
|
---|
| 40 |
|
---|
[72] | 41 |
|
---|
[69] | 42 | #
|
---|
[95] | 43 | # General purpose macros.
|
---|
| 44 | #
|
---|
[204] | 45 |
|
---|
[95] | 46 | ## get last word in a list.
|
---|
| 47 | # @returns last word in $1.
|
---|
| 48 | # @param $1 Word list.
|
---|
| 49 | lastword = $(word $(words $(1)), $(1))
|
---|
| 50 |
|
---|
| 51 |
|
---|
| 52 | #
|
---|
[72] | 53 | # Assert build type.
|
---|
[69] | 54 | #
|
---|
| 55 | ifndef BUILD_TYPE
|
---|
| 56 | ifndef BUILD_MODE
|
---|
[72] | 57 | $(error kBuild: You must define BUILD_TYPE!)
|
---|
[69] | 58 | endif
|
---|
| 59 | BUILD_TYPE := $(BUILD_MODE)
|
---|
| 60 | endif
|
---|
[72] | 61 | ifeq ($(BUILD_TYPE),DEBUG)
|
---|
| 62 | BUILD_TYPE := debug
|
---|
| 63 | endif
|
---|
| 64 | ifeq ($(BUILD_TYPE),RELEASE)
|
---|
| 65 | BUILD_TYPE := release
|
---|
| 66 | endif
|
---|
| 67 | ifeq ($(BUILD_TYPE),PROFILE)
|
---|
| 68 | BUILD_TYPE := profile
|
---|
| 69 | endif
|
---|
[69] | 70 |
|
---|
| 71 |
|
---|
| 72 | #
|
---|
[72] | 73 | # Assert build platform.
|
---|
[70] | 74 | #
|
---|
[72] | 75 | _BUILD_PLATFORM_OK := 0
|
---|
[271] | 76 | # OS/2 (have uppercase legacy)
|
---|
[72] | 77 | ifeq ($(BUILD_PLATFORM),OS2)
|
---|
[271] | 78 | override BUILD_PLATFORM := os2
|
---|
[72] | 79 | endif
|
---|
| 80 | ifeq ($(BUILD_PLATFORM),os2)
|
---|
| 81 | _BUILD_PLATFORM_OK := 1
|
---|
| 82 | endif
|
---|
[70] | 83 |
|
---|
[72] | 84 | # Linux
|
---|
| 85 | ifeq ($(BUILD_PLATFORM),LINUX)
|
---|
[88] | 86 | $(error kBuild: BUILD_PLATFORM must be all lowercase!)
|
---|
[72] | 87 | endif
|
---|
| 88 | ifeq ($(BUILD_PLATFORM),linux)
|
---|
| 89 | _BUILD_PLATFORM_OK := 1
|
---|
| 90 | endif
|
---|
| 91 |
|
---|
| 92 | # Win32
|
---|
| 93 | ifeq ($(BUILD_PLATFORM),WIN32)
|
---|
[88] | 94 | $(error kBuild: BUILD_PLATFORM must be all lowercase!)
|
---|
[72] | 95 | endif
|
---|
[83] | 96 | ifeq ($(BUILD_PLATFORM),win32)
|
---|
[72] | 97 | _BUILD_PLATFORM_OK := 1
|
---|
| 98 | endif
|
---|
| 99 |
|
---|
[292] | 100 | # L4
|
---|
| 101 | ifeq ($(BUILD_PLATFORM),L4)
|
---|
| 102 | $(error kBuild: BUILD_PLATFORM must be all lowercase!)
|
---|
| 103 | endif
|
---|
| 104 | ifeq ($(BUILD_PLATFORM),l4)
|
---|
| 105 | _BUILD_PLATFORM_OK := 1
|
---|
| 106 | endif
|
---|
| 107 |
|
---|
[299] | 108 | # FreeBSD
|
---|
| 109 | ifeq ($(BUILD_PLATFORM),FreeBSD)
|
---|
| 110 | $(error kBuild: BUILD_PLATFORM must be all lowercase!)
|
---|
| 111 | endif
|
---|
| 112 | ifeq ($(BUILD_PLATFORM),freebsd)
|
---|
| 113 | _BUILD_PLATFORM_OK := 1
|
---|
| 114 | endif
|
---|
| 115 |
|
---|
[72] | 116 | ifeq ($(_BUILD_PLATFORM_OK),0)
|
---|
| 117 | $(error kBuild: BUILD_PLATFORM value '$(BUILD_PLATFORM)' was not recongized!)
|
---|
| 118 | endif
|
---|
[329] | 119 |
|
---|
| 120 | # Fill in defaults if needed.
|
---|
[353] | 121 | ifndef BUILD_PLATFORM_ARCH
|
---|
[95] | 122 | BUILD_PLATFORM_ARCH := x86
|
---|
[329] | 123 | endif
|
---|
| 124 | ifndef BUILD_PLATFORM_CPU
|
---|
[95] | 125 | BUILD_PLATFORM_CPU := i586
|
---|
[329] | 126 | endif
|
---|
[72] | 127 |
|
---|
| 128 |
|
---|
[70] | 129 | #
|
---|
[72] | 130 | # Assert target platform.
|
---|
| 131 | #
|
---|
| 132 | ifndef BUILD_TARGET
|
---|
| 133 | # not defined, set to the same as build platform
|
---|
| 134 | BUILD_TARGET := $(BUILD_PLATFORM)
|
---|
| 135 | else
|
---|
| 136 | _BUILD_TARGET_OK := 0
|
---|
| 137 | # OS/2
|
---|
| 138 | ifeq ($(BUILD_TARGET),OS2)
|
---|
[88] | 139 | $(error kBuild: BUILD_TARGET must be all lowercase!)
|
---|
[72] | 140 | endif
|
---|
| 141 | ifeq ($(BUILD_TARGET),os2)
|
---|
| 142 | _BUILD_TARGET_OK := 1
|
---|
| 143 | endif
|
---|
| 144 |
|
---|
| 145 | # Linux
|
---|
| 146 | ifeq ($(BUILD_TARGET),LINUX)
|
---|
[88] | 147 | $(error kBuild: BUILD_TARGET must be all lowercase!)
|
---|
[72] | 148 | endif
|
---|
| 149 | ifeq ($(BUILD_TARGET),linux)
|
---|
| 150 | _BUILD_TARGET_OK := 1
|
---|
| 151 | endif
|
---|
| 152 |
|
---|
| 153 | # Win32
|
---|
| 154 | ifeq ($(BUILD_TARGET),WIN32)
|
---|
[88] | 155 | $(error kBuild: BUILD_TARGET must be all lowercase!)
|
---|
[72] | 156 | endif
|
---|
[77] | 157 | ifeq ($(BUILD_TARGET),win32)
|
---|
[72] | 158 | _BUILD_TARGET_OK := 1
|
---|
| 159 | endif
|
---|
| 160 |
|
---|
[292] | 161 | # L4
|
---|
| 162 | ifeq ($(BUILD_TARGET),L4)
|
---|
| 163 | $(error kBuild: BUILD_TARGET must be all lowercase!)
|
---|
| 164 | endif
|
---|
| 165 | ifeq ($(BUILD_TARGET),l4)
|
---|
| 166 | _BUILD_TARGET_OK := 1
|
---|
| 167 | endif
|
---|
| 168 |
|
---|
[299] | 169 | # FreeBSD
|
---|
| 170 | ifeq ($(BUILD_TARGET),FreeBSD)
|
---|
| 171 | $(error kBuild: BUILD_TARGET must be all lowercase!)
|
---|
| 172 | endif
|
---|
| 173 | ifeq ($(BUILD_TARGET),freebsd)
|
---|
| 174 | _BUILD_TARGET_OK := 1
|
---|
| 175 | endif
|
---|
| 176 |
|
---|
[72] | 177 | ifeq ($(_BUILD_TARGET_OK),0)
|
---|
| 178 | $(error kBuild: BUILD_TARGET value '$(BUILD_TARGET)' was not recongized!)
|
---|
| 179 | endif
|
---|
| 180 | endif
|
---|
[329] | 181 |
|
---|
| 182 | # Fill in defaults if needed.
|
---|
| 183 | ifndef BUILD_TARGET_ARCH
|
---|
[78] | 184 | BUILD_TARGET_ARCH := x86
|
---|
[329] | 185 | endif
|
---|
| 186 | ifndef BUILD_TARGET_CPU
|
---|
[78] | 187 | BUILD_TARGET_CPU := i586
|
---|
[329] | 188 | endif
|
---|
[72] | 189 |
|
---|
[266] | 190 | # Adjust the DEPTH definition first
|
---|
| 191 | ifeq ($(strip $(DEPTH)),)
|
---|
| 192 | DEPTH := .
|
---|
| 193 | endif
|
---|
[72] | 194 |
|
---|
| 195 | #
|
---|
[69] | 196 | # Common definitions.
|
---|
| 197 | #
|
---|
[306] | 198 | ifeq ($(filter abspath,$(KMK_FEATURES)),abspath)
|
---|
| 199 | PATH_CURRENT := $(abspath $(CURDIR))
|
---|
| 200 | PATH_ROOT := $(abspath $(PATH_CURRENT)/$(DEPTH))
|
---|
| 201 |
|
---|
| 202 | else
|
---|
| 203 |
|
---|
[69] | 204 | PATH_CURRENT := $(CURDIR)
|
---|
[70] | 205 | # Get the real root path.
|
---|
[85] | 206 | PATH_ROOT := $(PATH_CURRENT)
|
---|
[70] | 207 | ifneq ($(DEPTH),.)
|
---|
| 208 | $(foreach d,$(subst /, ,$(DEPTH)), $(eval PATH_ROOT := $(patsubst %/,%,$(dir $(PATH_ROOT)))) )
|
---|
[69] | 209 | endif
|
---|
[306] | 210 |
|
---|
| 211 | endif
|
---|
[70] | 212 | # Subdirectory relative to the root.
|
---|
[306] | 213 | ifneq ($(PATH_ROOT),$(PATH_CURRENT))
|
---|
| 214 | CURSUBDIR := $(patsubst $(PATH_ROOT)/%,%,$(PATH_CURRENT))
|
---|
[266] | 215 | else
|
---|
| 216 | CURSUBDIR := .
|
---|
| 217 | endif
|
---|
[306] | 218 |
|
---|
[70] | 219 | # Output directories.
|
---|
[242] | 220 | ifndef PATH_OUT_BASE
|
---|
| 221 | PATH_OUT_BASE := $(PATH_ROOT)/out
|
---|
| 222 | endif
|
---|
[240] | 223 | ifndef PATH_OUT
|
---|
[329] | 224 | ifeq ($(BUILD_PLATFORM_ARCH),x86)
|
---|
[245] | 225 | ifdef BUILD_TARGET_SUB # (BUILD_TARGET_SUB is not currently recognized by kBuild in any other places.)
|
---|
| 226 | PATH_OUT := $(PATH_OUT_BASE)/$(BUILD_TARGET)/$(BUILD_TARGET_SUB)/$(BUILD_TYPE)
|
---|
| 227 | else
|
---|
[242] | 228 | PATH_OUT := $(PATH_OUT_BASE)/$(BUILD_TARGET)/$(BUILD_TYPE)
|
---|
[240] | 229 | endif
|
---|
[329] | 230 | else # !x86
|
---|
| 231 | ifdef BUILD_TARGET_SUB # (BUILD_TARGET_SUB is not currently recognized by kBuild in any other places.)
|
---|
| 232 | PATH_OUT := $(PATH_OUT_BASE)/$(BUILD_TARGET)/$(BUILD_TARGET_ARCH)/$(BUILD_TARGET_SUB)/$(BUILD_TYPE)
|
---|
| 233 | else
|
---|
| 234 | PATH_OUT := $(PATH_OUT_BASE)/$(BUILD_TARGET)/$(BUILD_TARGET_ARCH)/$(BUILD_TYPE)
|
---|
[245] | 235 | endif
|
---|
[353] | 236 | endif # !x86
|
---|
[329] | 237 | endif # !define PATH_OUT
|
---|
[353] | 238 | PATH_OBJ = $(PATH_OUT)/obj
|
---|
| 239 | PATH_TARGET = $(PATH_OBJ)/$(CURSUBDIR)
|
---|
| 240 | PATH_INS = $(PATH_OUT)
|
---|
| 241 | PATH_BIN = $(PATH_INS)/bin
|
---|
| 242 | PATH_DLL = $(PATH_INS)/bin
|
---|
| 243 | PATH_SYS = $(PATH_INS)/bin
|
---|
| 244 | PATH_LIB = $(PATH_INS)/lib
|
---|
| 245 | PATH_DOC = $(PATH_INS)/doc
|
---|
[70] | 246 |
|
---|
| 247 | # Usually kBuild is external to the source tree.
|
---|
| 248 | ifndef PATH_KBUILD
|
---|
| 249 | PATH_KBUILD := $(PATH_ROOT)/kBuild
|
---|
| 250 | endif
|
---|
[306] | 251 | ifeq ($(filter abspath,$(KMK_FEATURES)),abspath)
|
---|
| 252 | PATH_KBUILD := $(abspath $(PATH_KBUILD))
|
---|
| 253 | endif
|
---|
[69] | 254 | # kBuild files which might be of interest.
|
---|
| 255 | FILE_KBUILD_HEADER := $(PATH_KBUILD)/header.kmk
|
---|
| 256 | FILE_KBUILD_CONFIG := $(PATH_KBUILD)/config.kmk
|
---|
| 257 | FILE_KBUILD_FOOTER := $(PATH_KBUILD)/footer.kmk
|
---|
| 258 |
|
---|
[72] | 259 | SUFF_DEP := .dep
|
---|
[204] | 260 | MAKEFILE := $(firstword $(MAKEFILE_LIST))
|
---|
[69] | 261 |
|
---|
[72] | 262 |
|
---|
[69] | 263 | #
|
---|
| 264 | # Get rid of the GNU Make default stuff
|
---|
| 265 | #
|
---|
[230] | 266 | ifndef KMK_VERSION
|
---|
[69] | 267 | include $(PATH_KBUILD)/StampOutPredefines.kmk
|
---|
[216] | 268 | endif
|
---|
[69] | 269 |
|
---|
| 270 | #
|
---|
[72] | 271 | # Build platform setup.
|
---|
[69] | 272 | #
|
---|
[329] | 273 | PATH_TOOLS := $(PATH_KBUILD)/bin/$(BUILD_PLATFORM_ARCH).$(BUILD_PLATFORM)
|
---|
| 274 |
|
---|
[69] | 275 | # OS/2
|
---|
[72] | 276 | ifeq ($(BUILD_PLATFORM),os2)
|
---|
[83] | 277 | EXEC_X86_WIN32 := innopec.exe
|
---|
[69] | 278 | HOSTSUFF_EXE := .exe
|
---|
| 279 | endif
|
---|
| 280 |
|
---|
| 281 | # Linux
|
---|
[72] | 282 | ifeq ($(BUILD_PLATFORM),linux)
|
---|
[135] | 283 | EXEC_X86_WIN32 := wine
|
---|
[69] | 284 | HOSTSUFF_EXE :=
|
---|
| 285 | endif
|
---|
[70] | 286 |
|
---|
[69] | 287 | # Win32
|
---|
[72] | 288 | ifeq ($(BUILD_PLATFORM),win32)
|
---|
[69] | 289 | EXEC_X86_WIN32 :=
|
---|
| 290 | HOSTSUFF_EXE := .exe
|
---|
| 291 | endif
|
---|
| 292 |
|
---|
[299] | 293 | # FreeBSD
|
---|
| 294 | ifeq ($(BUILD_PLATFORM),freebsd)
|
---|
| 295 | EXEC_X86_WIN32 := wine
|
---|
| 296 | HOSTSUFF_EXE :=
|
---|
| 297 | endif
|
---|
[125] | 298 |
|
---|
[299] | 299 |
|
---|
[73] | 300 | #
|
---|
| 301 | # Build target setup.
|
---|
| 302 | #
|
---|
| 303 | ifeq ($(BUILD_TARGET),os2)
|
---|
| 304 | SUFF_OBJ := .obj
|
---|
| 305 | SUFF_LIB := .lib
|
---|
| 306 | SUFF_DLL := .dll
|
---|
| 307 | SUFF_EXE := .exe
|
---|
[86] | 308 | SUFF_SYS := .sys
|
---|
[73] | 309 | SUFF_RES := .res
|
---|
| 310 | endif
|
---|
| 311 | ifeq ($(BUILD_TARGET),win32)
|
---|
| 312 | SUFF_OBJ := .obj
|
---|
| 313 | SUFF_LIB := .lib
|
---|
| 314 | SUFF_DLL := .dll
|
---|
| 315 | SUFF_EXE := .exe
|
---|
[86] | 316 | SUFF_SYS := .sys
|
---|
[73] | 317 | SUFF_RES := .res
|
---|
| 318 | endif
|
---|
| 319 | ifeq ($(BUILD_TARGET),linux)
|
---|
| 320 | SUFF_OBJ := .o
|
---|
| 321 | SUFF_LIB := .a
|
---|
| 322 | SUFF_DLL := .so
|
---|
| 323 | SUFF_EXE :=
|
---|
[86] | 324 | SUFF_SYS := .a
|
---|
[73] | 325 | SUFF_RES :=
|
---|
| 326 | endif
|
---|
[296] | 327 | ifeq ($(BUILD_TARGET),l4)
|
---|
| 328 | SUFF_OBJ := .o
|
---|
| 329 | SUFF_LIB := .a
|
---|
| 330 | SUFF_DLL := .s.so
|
---|
| 331 | SUFF_EXE :=
|
---|
| 332 | SUFF_SYS := .a
|
---|
| 333 | SUFF_RES :=
|
---|
| 334 | endif
|
---|
[69] | 335 |
|
---|
| 336 | #
|
---|
| 337 | # Standard kBuild tools.
|
---|
| 338 | #
|
---|
| 339 | DEP := $(PATH_TOOLS)/kDep$(HOSTSUFF_EXE)
|
---|
[262] | 340 | DEP_PRE := $(PATH_TOOLS)/kDepPre$(HOSTSUFF_EXE)
|
---|
[233] | 341 | ifeq ($(MAKE),kmk)
|
---|
| 342 | MAKE := $(PATH_TOOLS)/kmk$(HOSTSUFF_EXE)
|
---|
| 343 | endif
|
---|
| 344 |
|
---|
[353] | 345 | # Standard Unix shell utils
|
---|
[230] | 346 | ifdef KMK_BUILTIN
|
---|
| 347 | ECHO := kmk_builtin_echo
|
---|
| 348 | MKDIR := kmk_builtin_mkdir
|
---|
| 349 | RM := kmk_builtin_rm
|
---|
| 350 | CP := kmk_builtin_cp
|
---|
| 351 | else
|
---|
| 352 | ECHO := echo
|
---|
[69] | 353 | MKDIR := $(PATH_TOOLS)/mkdir$(HOSTSUFF_EXE)
|
---|
| 354 | RM := $(PATH_TOOLS)/rm$(HOSTSUFF_EXE)
|
---|
[87] | 355 | CP := $(PATH_TOOLS)/cp$(HOSTSUFF_EXE)
|
---|
[353] | 356 | APPEND := $(PATH_TOOLS)/append$(HOSTSUFF_EXE)
|
---|
[230] | 357 | endif
|
---|
[237] | 358 | CP_EXT := $(PATH_TOOLS)/cp$(HOSTSUFF_EXE)
|
---|
[87] | 359 | MV := $(PATH_TOOLS)/mv$(HOSTSUFF_EXE)
|
---|
[69] | 360 | SED := $(PATH_TOOLS)/sed$(HOSTSUFF_EXE)
|
---|
| 361 | CAT := $(PATH_TOOLS)/cat$(HOSTSUFF_EXE)
|
---|
[353] | 362 | LN_SYMLINK := $(CP)
|
---|
| 363 | #LN_SYMLINK := ln -s
|
---|
[69] | 364 | # Bourn shell clone.
|
---|
| 365 | MAKESHELL := $(PATH_TOOLS)/ash$(HOSTSUFF_EXE)
|
---|
| 366 | SHELL := $(MAKESHELL)
|
---|
| 367 | export SHELL MAKESHELL
|
---|
| 368 |
|
---|
[353] | 369 | # kBuild utils.
|
---|
| 370 | ifeq ($(filter append,$(KMK_BUILTIN)),append)
|
---|
| 371 | APPEND := kmk_builtin_append
|
---|
| 372 | else
|
---|
| 373 | APPEND := $(PATH_TOOLS)/append$(HOSTSUFF_EXE)
|
---|
| 374 | endif
|
---|
[69] | 375 |
|
---|
[353] | 376 |
|
---|
[69] | 377 | #
|
---|
[73] | 378 | # Message macros.
|
---|
[204] | 379 | #
|
---|
| 380 |
|
---|
[73] | 381 | ifndef BUILD_QUIET
|
---|
[75] | 382 | ifdef BUILD_DEBUG
|
---|
| 383 | BUILD_VERBOSE := 9
|
---|
| 384 | endif
|
---|
[230] | 385 | MSG_L1 = @$(ECHO) "kBuild: $1"
|
---|
[73] | 386 | ifdef BUILD_VERBOSE
|
---|
[230] | 387 | MSG_L2 = @$(ECHO) "kBuild: $1"
|
---|
[75] | 388 | QUIET :=
|
---|
[73] | 389 | else
|
---|
[75] | 390 | QUIET := @
|
---|
[73] | 391 | MSG_L2 =
|
---|
| 392 | endif
|
---|
| 393 | ifdef BUILD_DEBUG
|
---|
[230] | 394 | MSG_L3 = @$(ECHO) "kBuild: $1"
|
---|
[73] | 395 | else
|
---|
| 396 | MSG_L3 =
|
---|
| 397 | endif
|
---|
| 398 | else
|
---|
[75] | 399 | QUIET :=
|
---|
[73] | 400 | MSG_L1 =
|
---|
| 401 | MSG_L2 =
|
---|
| 402 | MSG_L3 =
|
---|
| 403 | endif
|
---|
| 404 |
|
---|
[130] | 405 | ## ABSPATH - make paths absolute.
|
---|
[129] | 406 | # This implementation is clumsy and doesn't resolve '..' and '.' components.
|
---|
[73] | 407 | #
|
---|
[129] | 408 | # @param $1 The paths to make absolute.
|
---|
[306] | 409 | ifeq ($(filter abspath,$(KMK_FEATURES)),abspath)
|
---|
| 410 | ABSPATH = $(abspath $(1))
|
---|
| 411 | else
|
---|
[129] | 412 | ABSPATH = $(foreach path,$(1)\
|
---|
| 413 | ,$(strip $(if $(subst <,,$(firstword $(subst /, ,<$(path)))),\
|
---|
| 414 | $(if $(patsubst %:,,$(firstword $(subst :,: ,$(path)))),$(PATH_CURRENT)/$(path),$(path)),\
|
---|
| 415 | $(path))))
|
---|
[306] | 416 | endif
|
---|
[353] | 417 |
|
---|
[130] | 418 | ## DIRDEP - make create directory dependencies.
|
---|
| 419 | #
|
---|
| 420 | # @param $1 The paths to the directories which must be created.
|
---|
[353] | 421 | ifeq ($(BUILD_PLATFORM),win32)
|
---|
| 422 | DIRDEP = $(patsubst %/,%,$(1))
|
---|
| 423 | else
|
---|
| 424 | DIRDEP = $(foreach path,$(patsubst %/,%,$(1)),$(path)/)
|
---|
| 425 | endif
|
---|
[129] | 426 |
|
---|
[204] | 427 |
|
---|
[129] | 428 | ## Cygwin kludge.
|
---|
| 429 | # This converts /cygdrive/x/% to x:%.
|
---|
| 430 | #
|
---|
| 431 | # @param $1 The paths to make native.
|
---|
| 432 | # @remark This macro is pretty much obsolete since we don't use cygwin base make.
|
---|
| 433 | ifneq ($(patsubst /cygdrive/%,%,$(CURDIR)),$(CURDIR))
|
---|
| 434 | CYGPATHMIXED = $(foreach path,$(1)\
|
---|
| 435 | ,$(if $(patsubst /cygdrive/%,,$(path)),$(path),$(patsubst $(strip $(firstword $(subst /, ,$(patsubst /cygdrive/%,%,$(path)))))/%,$(strip $(firstword $(subst /, ,$(patsubst /cygdrive/%,%,$(path))))):/%,$(patsubst /cygdrive/%,%,$(path)))))
|
---|
| 436 | else
|
---|
| 437 | CYGPATHMIXED = $(1)
|
---|
| 438 | endif
|
---|
| 439 |
|
---|
| 440 | #
|
---|
[353] | 441 | # Initialize some of the globals which the Config.kmk and
|
---|
| 442 | # others can add stuff to if they like for processing in the footer.
|
---|
| 443 | #
|
---|
| 444 |
|
---|
| 445 | ## ALL_TARGET
|
---|
| 446 | # This is the list of all targets.
|
---|
| 447 | ALL_TARGETS :=
|
---|
| 448 |
|
---|
| 449 | ## TEMPLATE_PATHS
|
---|
| 450 | # List a paths (separated by space) where templates can be found.
|
---|
| 451 | TEMPLATE_PATHS :=
|
---|
| 452 |
|
---|
| 453 | ## TOOL_PATHS
|
---|
| 454 | # List of paths (separated by space) where tools can be found.
|
---|
| 455 | TOOL_PATHS :=
|
---|
| 456 |
|
---|
| 457 | ## SDK_PATHS
|
---|
| 458 | # List of paths (separated by space) where SDKs can be found.
|
---|
| 459 | SDK_PATHS :=
|
---|
| 460 |
|
---|
| 461 | ## Proritized list of the default makefile when walking subdirectories.
|
---|
| 462 | # The user can overload this list.
|
---|
| 463 | DEFAULT_MAKEFILE := Makefile.kmk makefile.kmk Makefile makefile
|
---|
| 464 |
|
---|
| 465 | ## PROPS_SINGLE
|
---|
| 466 | # The list of non-accumulative target properties.
|
---|
| 467 | # A Config.kmk file can add it's own properties to this list and kBuild
|
---|
| 468 | # will do the necessary inheritance from templates to targets.
|
---|
| 469 | PROPS_SINGLE := TOOL ARTOOL CTOOL CXXTOOL ASTOOL LDTOOL INST NOINST
|
---|
| 470 |
|
---|
| 471 | ## PROPS_DEFERRED
|
---|
| 472 | # This list of non-accumulative target properties which are functions,
|
---|
| 473 | # and thus should not be expanded until the very last moment.
|
---|
| 474 | PROPS_DEFERRED := INSTFUN INSTALLER
|
---|
| 475 |
|
---|
| 476 | ## PROPS_ACCUMULATE
|
---|
| 477 | # The list of accumulative target properties.
|
---|
| 478 | # A Config.kmk file can add it's own properties to this list and kBuild
|
---|
| 479 | # will do the necessary inheritance from templates to targets.
|
---|
| 480 | PROPS_ACCUMULATE := \
|
---|
| 481 | SDKS DEFS INCS SOURCES \
|
---|
| 482 | COPTS CFLAGS CDEFS CINCS CXXOPTS CXXFLAGS CXXDEFS CXXINCS \
|
---|
| 483 | ASOPTS ASFLAGS ASDEFS ASINCS \
|
---|
| 484 | LDFLAGS LIBS LIBPATH \
|
---|
| 485 | BLD_TYPE BLD_TRG BLD_TRG_ARCH BLD_TRG_CPU \
|
---|
| 486 | SYSSUFF EXESUFF DLLSUFF LIBSUFF ARLIBSUFF \
|
---|
| 487 |
|
---|
| 488 |
|
---|
| 489 | ## PROPS_TOOLS
|
---|
| 490 | # This is a subset of the other PROPS
|
---|
| 491 | PROPS_TOOLS := TOOL CTOOL CXXTOOL ASTOOL ARTOOL LDTOOL
|
---|
| 492 |
|
---|
| 493 |
|
---|
| 494 | #
|
---|
| 495 | # Pass configuration.
|
---|
| 496 | #
|
---|
| 497 | # The PASS_<passname>_trgs variable is listing the targets.
|
---|
| 498 | # The PASS_<passname>_vars variable is listing the target variables.
|
---|
| 499 | # The PASS_<passname>_pass variable is the lowercased passname.
|
---|
| 500 | #
|
---|
| 501 |
|
---|
| 502 | ## PASS: bldprogs
|
---|
| 503 | # This pass builds targets which are required for building the rest.
|
---|
| 504 | PASS_BLDPROGS := Build Programs
|
---|
| 505 | PASS_BLDPROGS_trgs :=
|
---|
| 506 | PASS_BLDPROGS_vars := _BLDPROGS
|
---|
| 507 | PASS_BLDPROGS_pass := bldprogs
|
---|
| 508 |
|
---|
| 509 | ## PASS: libraries
|
---|
| 510 | # This pass builds library targets.
|
---|
| 511 | PASS_LIBRARIES := Libraries
|
---|
| 512 | PASS_LIBRARIES_trgs :=
|
---|
| 513 | PASS_LIBRARIES_vars := _LIBS _IMPORT_LIBS _OTHER_LIBRARIES
|
---|
| 514 | PASS_LIBRARIES_pass := libraries
|
---|
| 515 |
|
---|
| 516 | ## PASS: binaries
|
---|
| 517 | # This pass builds dll targets.
|
---|
| 518 | PASS_DLLS := DLLs
|
---|
| 519 | PASS_DLLS_trgs :=
|
---|
| 520 | PASS_DLLS_vars := _DLLS _OTHER_DLLS
|
---|
| 521 | PASS_DLLS_pass := dlls
|
---|
| 522 |
|
---|
| 523 | ## PASS: binaries
|
---|
| 524 | # This pass builds binary targets, i.e. programs, system modules and stuff.
|
---|
| 525 | PASS_BINARIES := Programs
|
---|
| 526 | PASS_BINARIES_trgs :=
|
---|
| 527 | PASS_BINARIES_vars := _PROGRAMS _SYSMODS _OTHER_BINARIES
|
---|
| 528 | PASS_BINARIES_pass := binaries
|
---|
| 529 |
|
---|
| 530 | ## PASS: others
|
---|
| 531 | # This pass builds other targets.
|
---|
| 532 | PASS_OTHERS := Other Stuff
|
---|
| 533 | PASS_OTHERS_trgs :=
|
---|
| 534 | PASS_OTHERS_vars := _OTHERS
|
---|
| 535 | PASS_OTHERS_pass := others
|
---|
| 536 |
|
---|
| 537 | ## PASS: install
|
---|
| 538 | # This pass installs the built entities to a sandbox area.
|
---|
| 539 | PASS_INSTALLS := Install
|
---|
| 540 | PASS_INSTALLS_trgs :=
|
---|
| 541 | PASS_INSTALLS_vars := _INSTALLS
|
---|
| 542 | PASS_INSTALLS_pass := installs
|
---|
| 543 |
|
---|
| 544 | ## PASS: packing
|
---|
| 545 | # This pass processes custom packing rules.
|
---|
| 546 | PASS_PACKING := Packing
|
---|
| 547 | PASS_PACKING_trgs := packing
|
---|
| 548 | PASS_PACKING_vars :=
|
---|
| 549 | PASS_PACKING_pass := packing
|
---|
| 550 |
|
---|
| 551 | ## PASS: clean
|
---|
| 552 | # This pass removes all generated files.
|
---|
| 553 | PASS_CLEAN := Clean
|
---|
| 554 | PASS_CLEAN_trgs := do-clean
|
---|
| 555 | PASS_CLEAN_vars :=
|
---|
| 556 | PASS_CLEAN_pass := clean
|
---|
| 557 | # alias
|
---|
| 558 | clean: pass_clean
|
---|
| 559 |
|
---|
| 560 | ## PASS: nothing
|
---|
| 561 | # This pass just walks the tree.
|
---|
| 562 | PASS_NOTHING := Nothing
|
---|
| 563 | PASS_NOTHING_trgs := do-nothing
|
---|
| 564 | PASS_NOTHING_vars :=
|
---|
| 565 | PASS_NOTHING_pass := nothing
|
---|
| 566 | # alias
|
---|
| 567 | nothing: pass_nothing
|
---|
| 568 |
|
---|
| 569 | ## DEFAULT_PASSES
|
---|
| 570 | # The default passes and their order.
|
---|
| 571 | DEFAULT_PASSES := BLDPROGS LIBRARIES DLLS BINARIES OTHERS INSTALLS
|
---|
| 572 |
|
---|
| 573 | ## PASSES
|
---|
| 574 | # The passes that should be defined. This must include
|
---|
| 575 | # all passes mentioned by DEFAULT_PASSES.
|
---|
| 576 | PASSES := $(DEFAULT_PASSES) NOTHING CLEAN
|
---|
| 577 |
|
---|
| 578 |
|
---|
| 579 | #
|
---|
[69] | 580 | # This is how we find the closest config.kmk.
|
---|
| 581 | # It's a little hacky but I think it works fine.
|
---|
[70] | 582 | #
|
---|
| 583 | _CFGDIR := .
|
---|
[78] | 584 | _CFGFILES := ./Config.kmk ./config.kmk
|
---|
[69] | 585 | define def_include_config
|
---|
[78] | 586 | $(eval _CFGDIR := $(_CFGDIR)/$(dir))
|
---|
| 587 | _CFGFILES += $(_CFGDIR)/Config.kmk $(_CFGDIR)/config.kmk
|
---|
[69] | 588 | endef
|
---|
| 589 | # walk down the _RELATIVE_ path specified by DEPTH.
|
---|
[78] | 590 | $(foreach dir,$(subst /, ,$(DEPTH)), $(eval $(def_include_config)) )
|
---|
[69] | 591 | # add the default config file.
|
---|
[78] | 592 | _CFGFILE := $(firstword $(wildcard $(_CFGFILES) $(FILE_KBUILD_CONFIG)))
|
---|
[69] | 593 | _CFGFILES :=
|
---|
| 594 | _CFGDIR :=
|
---|
| 595 |
|
---|
| 596 | # Include the config.kmk we found file (or the default one).
|
---|
| 597 | include $(_CFGFILE)
|
---|
| 598 |
|
---|
| 599 |
|
---|
| 600 | # end-of-file-content
|
---|
[72] | 601 | __header_kmk__ := 1
|
---|
[69] | 602 | endif # __header_kmk__
|
---|