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