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