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