| 1 | # $Id: header.kmk 397 2006-01-13 00:51:03Z bird $
|
|---|
| 2 | ## @file
|
|---|
| 3 | #
|
|---|
| 4 | # kBuild - File included at top of makefile.
|
|---|
| 5 | #
|
|---|
| 6 | # Copyright (c) 2004-2005 knut st. osmundsen <bird-srcspam@anduin.net>
|
|---|
| 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 | # The FORCE rule.
|
|---|
| 37 | #
|
|---|
| 38 | FORCE:
|
|---|
| 39 |
|
|---|
| 40 | #
|
|---|
| 41 | # Try avoid inference rules.
|
|---|
| 42 | #
|
|---|
| 43 | .SUFFIXES:
|
|---|
| 44 | SUFFIXES :=
|
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 | #
|
|---|
| 48 | # General purpose macros.
|
|---|
| 49 | #
|
|---|
| 50 |
|
|---|
| 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 |
|
|---|
| 56 | ##
|
|---|
| 57 | # Newline character(s).
|
|---|
| 58 | define NL
|
|---|
| 59 |
|
|---|
| 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 |
|
|---|
| 79 | #
|
|---|
| 80 | # Assert build type.
|
|---|
| 81 | #
|
|---|
| 82 | ifndef BUILD_TYPE
|
|---|
| 83 | ifndef BUILD_MODE
|
|---|
| 84 | $(error kBuild: You must define BUILD_TYPE!)
|
|---|
| 85 | endif
|
|---|
| 86 | BUILD_TYPE := $(BUILD_MODE)
|
|---|
| 87 | endif
|
|---|
| 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
|
|---|
| 97 |
|
|---|
| 98 |
|
|---|
| 99 | #
|
|---|
| 100 | # Assert build platform.
|
|---|
| 101 | #
|
|---|
| 102 | _BUILD_PLATFORM_OK := 0
|
|---|
| 103 | # OS/2 (have uppercase legacy)
|
|---|
| 104 | ifeq ($(BUILD_PLATFORM),OS2)
|
|---|
| 105 | override BUILD_PLATFORM := os2
|
|---|
| 106 | endif
|
|---|
| 107 | ifeq ($(BUILD_PLATFORM),os2)
|
|---|
| 108 | _BUILD_PLATFORM_OK := 1
|
|---|
| 109 | endif
|
|---|
| 110 |
|
|---|
| 111 | # Linux
|
|---|
| 112 | ifeq ($(BUILD_PLATFORM),LINUX)
|
|---|
| 113 | $(error kBuild: BUILD_PLATFORM must be all lowercase!)
|
|---|
| 114 | endif
|
|---|
| 115 | ifeq ($(BUILD_PLATFORM),linux)
|
|---|
| 116 | _BUILD_PLATFORM_OK := 1
|
|---|
| 117 | endif
|
|---|
| 118 |
|
|---|
| 119 | # Win32
|
|---|
| 120 | ifeq ($(BUILD_PLATFORM),WIN32)
|
|---|
| 121 | $(error kBuild: BUILD_PLATFORM must be all lowercase!)
|
|---|
| 122 | endif
|
|---|
| 123 | ifeq ($(BUILD_PLATFORM),win32)
|
|---|
| 124 | _BUILD_PLATFORM_OK := 1
|
|---|
| 125 | endif
|
|---|
| 126 |
|
|---|
| 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 |
|
|---|
| 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 |
|
|---|
| 143 | ifeq ($(_BUILD_PLATFORM_OK),0)
|
|---|
| 144 | $(error kBuild: BUILD_PLATFORM value '$(BUILD_PLATFORM)' was not recongized!)
|
|---|
| 145 | endif
|
|---|
| 146 |
|
|---|
| 147 | # Fill in defaults if needed.
|
|---|
| 148 | ifndef BUILD_PLATFORM_ARCH
|
|---|
| 149 | BUILD_PLATFORM_ARCH := x86
|
|---|
| 150 | endif
|
|---|
| 151 | ifndef BUILD_PLATFORM_CPU
|
|---|
| 152 | BUILD_PLATFORM_CPU := i586
|
|---|
| 153 | endif
|
|---|
| 154 |
|
|---|
| 155 |
|
|---|
| 156 | #
|
|---|
| 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)
|
|---|
| 166 | $(error kBuild: BUILD_TARGET must be all lowercase!)
|
|---|
| 167 | endif
|
|---|
| 168 | ifeq ($(BUILD_TARGET),os2)
|
|---|
| 169 | _BUILD_TARGET_OK := 1
|
|---|
| 170 | endif
|
|---|
| 171 |
|
|---|
| 172 | # Linux
|
|---|
| 173 | ifeq ($(BUILD_TARGET),LINUX)
|
|---|
| 174 | $(error kBuild: BUILD_TARGET must be all lowercase!)
|
|---|
| 175 | endif
|
|---|
| 176 | ifeq ($(BUILD_TARGET),linux)
|
|---|
| 177 | _BUILD_TARGET_OK := 1
|
|---|
| 178 | endif
|
|---|
| 179 |
|
|---|
| 180 | # Win32
|
|---|
| 181 | ifeq ($(BUILD_TARGET),WIN32)
|
|---|
| 182 | $(error kBuild: BUILD_TARGET must be all lowercase!)
|
|---|
| 183 | endif
|
|---|
| 184 | ifeq ($(BUILD_TARGET),win32)
|
|---|
| 185 | _BUILD_TARGET_OK := 1
|
|---|
| 186 | endif
|
|---|
| 187 |
|
|---|
| 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 |
|
|---|
| 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 |
|
|---|
| 204 | ifeq ($(_BUILD_TARGET_OK),0)
|
|---|
| 205 | $(error kBuild: BUILD_TARGET value '$(BUILD_TARGET)' was not recongized!)
|
|---|
| 206 | endif
|
|---|
| 207 | endif
|
|---|
| 208 |
|
|---|
| 209 | # Fill in defaults if needed.
|
|---|
| 210 | ifndef BUILD_TARGET_ARCH
|
|---|
| 211 | BUILD_TARGET_ARCH := x86
|
|---|
| 212 | endif
|
|---|
| 213 | ifndef BUILD_TARGET_CPU
|
|---|
| 214 | BUILD_TARGET_CPU := i586
|
|---|
| 215 | endif
|
|---|
| 216 |
|
|---|
| 217 | # Adjust the DEPTH definition first
|
|---|
| 218 | ifeq ($(strip $(DEPTH)),)
|
|---|
| 219 | DEPTH := .
|
|---|
| 220 | endif
|
|---|
| 221 |
|
|---|
| 222 | #
|
|---|
| 223 | # Common definitions.
|
|---|
| 224 | #
|
|---|
| 225 | ifeq ($(filter abspath,$(KMK_FEATURES)),abspath)
|
|---|
| 226 | PATH_CURRENT := $(abspath $(CURDIR))
|
|---|
| 227 | PATH_ROOT := $(abspath $(PATH_CURRENT)/$(DEPTH))
|
|---|
| 228 |
|
|---|
| 229 | else
|
|---|
| 230 |
|
|---|
| 231 | PATH_CURRENT := $(CURDIR)
|
|---|
| 232 | # Get the real root path.
|
|---|
| 233 | PATH_ROOT := $(PATH_CURRENT)
|
|---|
| 234 | ifneq ($(DEPTH),.)
|
|---|
| 235 | $(foreach d,$(subst /, ,$(DEPTH)), $(eval PATH_ROOT := $(patsubst %/,%,$(dir $(PATH_ROOT)))) )
|
|---|
| 236 | endif
|
|---|
| 237 |
|
|---|
| 238 | endif
|
|---|
| 239 | # Subdirectory relative to the root.
|
|---|
| 240 | ifneq ($(PATH_ROOT),$(PATH_CURRENT))
|
|---|
| 241 | CURSUBDIR := $(patsubst $(PATH_ROOT)/%,%,$(PATH_CURRENT))
|
|---|
| 242 | else
|
|---|
| 243 | CURSUBDIR := .
|
|---|
| 244 | endif
|
|---|
| 245 |
|
|---|
| 246 | # Output directories.
|
|---|
| 247 | ifndef PATH_OUT_BASE
|
|---|
| 248 | PATH_OUT_BASE := $(PATH_ROOT)/out
|
|---|
| 249 | endif
|
|---|
| 250 | ifndef PATH_OUT
|
|---|
| 251 | ifeq ($(BUILD_PLATFORM_ARCH),x86)
|
|---|
| 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
|
|---|
| 255 | PATH_OUT := $(PATH_OUT_BASE)/$(BUILD_TARGET)/$(BUILD_TYPE)
|
|---|
| 256 | endif
|
|---|
| 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)
|
|---|
| 262 | endif
|
|---|
| 263 | endif # !x86
|
|---|
| 264 | endif # !define PATH_OUT
|
|---|
| 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
|
|---|
| 273 |
|
|---|
| 274 | # Usually kBuild is external to the source tree.
|
|---|
| 275 | ifndef PATH_KBUILD
|
|---|
| 276 | PATH_KBUILD := $(PATH_ROOT)/kBuild
|
|---|
| 277 | endif
|
|---|
| 278 | ifeq ($(filter abspath,$(KMK_FEATURES)),abspath)
|
|---|
| 279 | PATH_KBUILD := $(abspath $(PATH_KBUILD))
|
|---|
| 280 | endif
|
|---|
| 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 |
|
|---|
| 286 | SUFF_DEP := .dep
|
|---|
| 287 | MAKEFILE := $(firstword $(MAKEFILE_LIST))
|
|---|
| 288 |
|
|---|
| 289 |
|
|---|
| 290 | #
|
|---|
| 291 | # Get rid of the GNU Make default stuff
|
|---|
| 292 | #
|
|---|
| 293 | ifndef KMK_VERSION
|
|---|
| 294 | include $(PATH_KBUILD)/StampOutPredefines.kmk
|
|---|
| 295 | endif
|
|---|
| 296 |
|
|---|
| 297 | #
|
|---|
| 298 | # Build platform setup.
|
|---|
| 299 | #
|
|---|
| 300 | PATH_TOOLS := $(PATH_KBUILD)/bin/$(BUILD_PLATFORM_ARCH).$(BUILD_PLATFORM)
|
|---|
| 301 |
|
|---|
| 302 | # OS/2
|
|---|
| 303 | ifeq ($(BUILD_PLATFORM),os2)
|
|---|
| 304 | EXEC_X86_WIN32 := innopec.exe
|
|---|
| 305 | HOSTSUFF_EXE := .exe
|
|---|
| 306 | endif
|
|---|
| 307 |
|
|---|
| 308 | # Linux
|
|---|
| 309 | ifeq ($(BUILD_PLATFORM),linux)
|
|---|
| 310 | EXEC_X86_WIN32 := wine
|
|---|
| 311 | HOSTSUFF_EXE :=
|
|---|
| 312 | endif
|
|---|
| 313 |
|
|---|
| 314 | # Win32
|
|---|
| 315 | ifeq ($(BUILD_PLATFORM),win32)
|
|---|
| 316 | EXEC_X86_WIN32 :=
|
|---|
| 317 | HOSTSUFF_EXE := .exe
|
|---|
| 318 | endif
|
|---|
| 319 |
|
|---|
| 320 | # FreeBSD
|
|---|
| 321 | ifeq ($(BUILD_PLATFORM),freebsd)
|
|---|
| 322 | EXEC_X86_WIN32 := wine
|
|---|
| 323 | HOSTSUFF_EXE :=
|
|---|
| 324 | endif
|
|---|
| 325 |
|
|---|
| 326 |
|
|---|
| 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
|
|---|
| 335 | SUFF_SYS := .sys
|
|---|
| 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
|
|---|
| 343 | SUFF_SYS := .sys
|
|---|
| 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 :=
|
|---|
| 351 | SUFF_SYS := .a
|
|---|
| 352 | SUFF_RES :=
|
|---|
| 353 | endif
|
|---|
| 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
|
|---|
| 362 |
|
|---|
| 363 | #
|
|---|
| 364 | # Standard kBuild tools.
|
|---|
| 365 | #
|
|---|
| 366 | ifeq ($(MAKE),kmk)
|
|---|
| 367 | MAKE := $(PATH_TOOLS)/kmk$(HOSTSUFF_EXE)
|
|---|
| 368 | endif
|
|---|
| 369 |
|
|---|
| 370 | DEP_EXT := $(PATH_TOOLS)/kDep$(HOSTSUFF_EXE)
|
|---|
| 371 | ifeq ($(filter kDep,$(KMK_BUILTIN)),kDep)
|
|---|
| 372 | DEP := kmk_builtin_kDep
|
|---|
| 373 | else
|
|---|
| 374 | DEP := $(DEP_EXT)
|
|---|
| 375 | endif
|
|---|
| 376 |
|
|---|
| 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 |
|
|---|
| 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)
|
|---|
| 392 | ifeq ($(filter append,$(KMK_BUILTIN)),append)
|
|---|
| 393 | APPEND := kmk_builtin_append
|
|---|
| 394 | else
|
|---|
| 395 | APPEND := $(APPEND_EXT)
|
|---|
| 396 | endif
|
|---|
| 397 |
|
|---|
| 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
|
|---|
| 404 |
|
|---|
| 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 |
|
|---|
| 467 | # Symlinking is problematic on some platforms...
|
|---|
| 468 | LN_SYMLINK := $(LN) -s
|
|---|
| 469 |
|
|---|
| 470 |
|
|---|
| 471 |
|
|---|
| 472 | #
|
|---|
| 473 | # Message macros.
|
|---|
| 474 | #
|
|---|
| 475 |
|
|---|
| 476 | ifndef BUILD_QUIET
|
|---|
| 477 | ifdef BUILD_DEBUG
|
|---|
| 478 | BUILD_VERBOSE := 9
|
|---|
| 479 | endif
|
|---|
| 480 | MSG_L1 = @$(ECHO) "kBuild: $1"
|
|---|
| 481 | ifdef BUILD_VERBOSE
|
|---|
| 482 | MSG_L2 = @$(ECHO) "kBuild: $1"
|
|---|
| 483 | QUIET :=
|
|---|
| 484 | else
|
|---|
| 485 | QUIET := @
|
|---|
| 486 | MSG_L2 =
|
|---|
| 487 | endif
|
|---|
| 488 | ifdef BUILD_DEBUG
|
|---|
| 489 | MSG_L3 = @$(ECHO) "kBuild: $1"
|
|---|
| 490 | else
|
|---|
| 491 | MSG_L3 =
|
|---|
| 492 | endif
|
|---|
| 493 | else
|
|---|
| 494 | QUIET :=
|
|---|
| 495 | MSG_L1 =
|
|---|
| 496 | MSG_L2 =
|
|---|
| 497 | MSG_L3 =
|
|---|
| 498 | endif
|
|---|
| 499 |
|
|---|
| 500 | ## ABSPATH - make paths absolute.
|
|---|
| 501 | # This implementation is clumsy and doesn't resolve '..' and '.' components.
|
|---|
| 502 | #
|
|---|
| 503 | # @param $1 The paths to make absolute.
|
|---|
| 504 | ifeq ($(filter abspath,$(KMK_FEATURES)),abspath)
|
|---|
| 505 | ABSPATH = $(abspath $(1))
|
|---|
| 506 | else
|
|---|
| 507 | ABSPATH = $(foreach path,$(1)\
|
|---|
| 508 | ,$(strip $(if $(subst <,,$(firstword $(subst /, ,<$(path)))),\
|
|---|
| 509 | $(if $(patsubst %:,,$(firstword $(subst :,: ,$(path)))),$(PATH_CURRENT)/$(path),$(path)),\
|
|---|
| 510 | $(path))))
|
|---|
| 511 | endif
|
|---|
| 512 |
|
|---|
| 513 | ## DIRDEP - make create directory dependencies.
|
|---|
| 514 | #
|
|---|
| 515 | # @param $1 The paths to the directories which must be created.
|
|---|
| 516 | ifeq ($(BUILD_PLATFORM),win32)
|
|---|
| 517 | DIRDEP = $(patsubst %/,%,$(1))
|
|---|
| 518 | else
|
|---|
| 519 | DIRDEP = $(foreach path,$(patsubst %/,%,$(1)),$(path)/)
|
|---|
| 520 | endif
|
|---|
| 521 |
|
|---|
| 522 |
|
|---|
| 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 | #
|
|---|
| 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 :=
|
|---|
| 636 | PASS_INSTALLS_vars := _INSTALLS_DIRS _INSTALLS
|
|---|
| 637 | PASS_INSTALLS_pass := installs
|
|---|
| 638 |
|
|---|
| 639 | ## PASS: packing
|
|---|
| 640 | # This pass processes custom packing rules.
|
|---|
| 641 | PASS_PACKING := Packing
|
|---|
| 642 | PASS_PACKING_trgs := packing
|
|---|
| 643 | PASS_PACKING_vars :=
|
|---|
| 644 | PASS_PACKING_pass := packing
|
|---|
| 645 |
|
|---|
| 646 | ## PASS: clean
|
|---|
| 647 | # This pass removes all generated files.
|
|---|
| 648 | PASS_CLEAN := Clean
|
|---|
| 649 | PASS_CLEAN_trgs := do-clean
|
|---|
| 650 | PASS_CLEAN_vars :=
|
|---|
| 651 | PASS_CLEAN_pass := clean
|
|---|
| 652 | # alias
|
|---|
| 653 | clean: pass_clean
|
|---|
| 654 |
|
|---|
| 655 | ## PASS: nothing
|
|---|
| 656 | # This pass just walks the tree.
|
|---|
| 657 | PASS_NOTHING := Nothing
|
|---|
| 658 | PASS_NOTHING_trgs := do-nothing
|
|---|
| 659 | PASS_NOTHING_vars :=
|
|---|
| 660 | PASS_NOTHING_pass := nothing
|
|---|
| 661 | # alias
|
|---|
| 662 | nothing: pass_nothing
|
|---|
| 663 |
|
|---|
| 664 | ## DEFAULT_PASSES
|
|---|
| 665 | # The default passes and their order.
|
|---|
| 666 | DEFAULT_PASSES := BLDPROGS LIBRARIES DLLS BINARIES OTHERS INSTALLS
|
|---|
| 667 |
|
|---|
| 668 | ## PASSES
|
|---|
| 669 | # The passes that should be defined. This must include
|
|---|
| 670 | # all passes mentioned by DEFAULT_PASSES.
|
|---|
| 671 | PASSES := $(DEFAULT_PASSES) NOTHING CLEAN
|
|---|
| 672 |
|
|---|
| 673 |
|
|---|
| 674 | #
|
|---|
| 675 | # This is how we find the closest config.kmk.
|
|---|
| 676 | # It's a little hacky but I think it works fine.
|
|---|
| 677 | #
|
|---|
| 678 | _CFGDIR := .
|
|---|
| 679 | _CFGFILES := ./Config.kmk ./config.kmk
|
|---|
| 680 | define def_include_config
|
|---|
| 681 | $(eval _CFGDIR := $(_CFGDIR)/$(dir))
|
|---|
| 682 | _CFGFILES += $(_CFGDIR)/Config.kmk $(_CFGDIR)/config.kmk
|
|---|
| 683 | endef
|
|---|
| 684 | # walk down the _RELATIVE_ path specified by DEPTH.
|
|---|
| 685 | $(foreach dir,$(subst /, ,$(DEPTH)), $(eval $(def_include_config)) )
|
|---|
| 686 | # add the default config file.
|
|---|
| 687 | _CFGFILE := $(firstword $(wildcard $(_CFGFILES) $(FILE_KBUILD_CONFIG)))
|
|---|
| 688 | _CFGFILES :=
|
|---|
| 689 | _CFGDIR :=
|
|---|
| 690 |
|
|---|
| 691 | # Include the config.kmk we found file (or the default one).
|
|---|
| 692 | include $(_CFGFILE)
|
|---|
| 693 |
|
|---|
| 694 |
|
|---|
| 695 | # end-of-file-content
|
|---|
| 696 | __header_kmk__ := 1
|
|---|
| 697 | endif # __header_kmk__
|
|---|