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