[69] | 1 | # $Id: header.kmk 660 2006-12-05 14:36:19Z 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
|
---|
[69] | 227 |
|
---|
[576] | 228 |
|
---|
[69] | 229 | #
|
---|
[72] | 230 | # Build platform setup.
|
---|
[69] | 231 | #
|
---|
| 232 | # OS/2
|
---|
[72] | 233 | ifeq ($(BUILD_PLATFORM),os2)
|
---|
[83] | 234 | EXEC_X86_WIN32 := innopec.exe
|
---|
[69] | 235 | HOSTSUFF_EXE := .exe
|
---|
| 236 | endif
|
---|
| 237 |
|
---|
| 238 | # Linux
|
---|
[72] | 239 | ifeq ($(BUILD_PLATFORM),linux)
|
---|
[135] | 240 | EXEC_X86_WIN32 := wine
|
---|
[69] | 241 | HOSTSUFF_EXE :=
|
---|
| 242 | endif
|
---|
[70] | 243 |
|
---|
[547] | 244 | # Win, Win32, Win64, NT.
|
---|
| 245 | ifeq ($(filter-out win32 win64 win nt,$(BUILD_PLATFORM)),)
|
---|
[69] | 246 | EXEC_X86_WIN32 :=
|
---|
| 247 | HOSTSUFF_EXE := .exe
|
---|
| 248 | endif
|
---|
| 249 |
|
---|
[299] | 250 | # FreeBSD
|
---|
| 251 | ifeq ($(BUILD_PLATFORM),freebsd)
|
---|
| 252 | EXEC_X86_WIN32 := wine
|
---|
| 253 | HOSTSUFF_EXE :=
|
---|
| 254 | endif
|
---|
[125] | 255 |
|
---|
[557] | 256 | # Darwin / Mac OS X
|
---|
| 257 | ifeq ($(BUILD_PLATFORM),darwin)
|
---|
| 258 | EXEC_X86_WIN32 := false
|
---|
| 259 | HOSTSUFF_EXE :=
|
---|
| 260 | endif
|
---|
| 261 |
|
---|
[578] | 262 | ifndef PATH_KBUILD_BIN
|
---|
| 263 | PATH_KBUILD_BIN := $(PATH_KBUILD)/bin/$(BUILD_PLATFORM_ARCH).$(BUILD_PLATFORM)
|
---|
| 264 | ifeq ($(wildcard $(PATH_KBUILD_BIN)/kmk_ash$(HOSTSUFF_EXE)),)
|
---|
| 265 | ifeq ($(BUILD_TARGET_ARCH),amd64)
|
---|
| 266 | PATH_KBUILD_BIN := $(PATH_KBUILD)/bin/x86.$(BUILD_PLATFORM)
|
---|
[478] | 267 | endif
|
---|
[578] | 268 | ifeq ($(wildcard $(PATH_KBUILD_BIN)/kmk_ash$(HOSTSUFF_EXE)),)
|
---|
[653] | 269 | ifeq ($(filter-out win64 win32 win nt ,$(BUILD_PLATFORM)),)
|
---|
| 270 | PATH_KBUILD_BIN := $(PATH_KBUILD)/bin/x86.win
|
---|
[578] | 271 | endif
|
---|
| 272 | endif
|
---|
| 273 | ifeq ($(wildcard $(PATH_KBUILD_BIN)/kmk_ash$(HOSTSUFF_EXE)),)
|
---|
| 274 | # give up
|
---|
| 275 | PATH_KBUILD_BIN := $(PATH_KBUILD)/bin/$(BUILD_PLATFORM_ARCH).$(BUILD_PLATFORM)
|
---|
| 276 | endif
|
---|
[478] | 277 | endif
|
---|
| 278 | endif
|
---|
[299] | 279 |
|
---|
[478] | 280 |
|
---|
[73] | 281 | #
|
---|
| 282 | # Build target setup.
|
---|
| 283 | #
|
---|
[480] | 284 | ifeq ($(filter-out win32 win64 win nt os2,$(BUILD_TARGET)),)
|
---|
[73] | 285 | SUFF_OBJ := .obj
|
---|
| 286 | SUFF_LIB := .lib
|
---|
| 287 | SUFF_DLL := .dll
|
---|
| 288 | SUFF_EXE := .exe
|
---|
[86] | 289 | SUFF_SYS := .sys
|
---|
[73] | 290 | SUFF_RES := .res
|
---|
| 291 | endif
|
---|
[480] | 292 | ifeq ($(BUILD_TARGET),l4)
|
---|
[73] | 293 | SUFF_OBJ := .o
|
---|
| 294 | SUFF_LIB := .a
|
---|
[480] | 295 | SUFF_DLL := .s.so
|
---|
[73] | 296 | SUFF_EXE :=
|
---|
[86] | 297 | SUFF_SYS := .a
|
---|
[73] | 298 | SUFF_RES :=
|
---|
| 299 | endif
|
---|
[557] | 300 | ifeq ($(BUILD_TARGET),darwin)
|
---|
| 301 | SUFF_OBJ := .o
|
---|
| 302 | SUFF_LIB := .a
|
---|
| 303 | SUFF_DLL := .dylib
|
---|
| 304 | SUFF_EXE :=
|
---|
| 305 | SUFF_SYS := .a
|
---|
| 306 | SUFF_RES :=
|
---|
| 307 | endif
|
---|
[480] | 308 | ifndef SUFF_OBJ
|
---|
[296] | 309 | SUFF_OBJ := .o
|
---|
| 310 | SUFF_LIB := .a
|
---|
[480] | 311 | SUFF_DLL := .so
|
---|
[296] | 312 | SUFF_EXE :=
|
---|
| 313 | SUFF_SYS := .a
|
---|
| 314 | SUFF_RES :=
|
---|
| 315 | endif
|
---|
[69] | 316 |
|
---|
| 317 | #
|
---|
| 318 | # Standard kBuild tools.
|
---|
| 319 | #
|
---|
[233] | 320 | ifeq ($(MAKE),kmk)
|
---|
[578] | 321 | MAKE := $(PATH_KBUILD_BIN)/kmk$(HOSTSUFF_EXE)
|
---|
[233] | 322 | endif
|
---|
| 323 |
|
---|
[578] | 324 | DEP_EXT := $(PATH_KBUILD_BIN)/kDep$(HOSTSUFF_EXE)
|
---|
[380] | 325 | ifeq ($(filter kDep,$(KMK_BUILTIN)),kDep)
|
---|
[397] | 326 | DEP := kmk_builtin_kDep
|
---|
[230] | 327 | else
|
---|
[380] | 328 | DEP := $(DEP_EXT)
|
---|
[230] | 329 | endif
|
---|
[69] | 330 |
|
---|
[578] | 331 | DEP_IDB_EXT := $(PATH_KBUILD_BIN)/kDepIDB$(HOSTSUFF_EXE)
|
---|
[397] | 332 | ifeq ($(filter kDepPre,$(KMK_BUILTIN)),kDepIDB)
|
---|
| 333 | DEP_IDB := $(if kmk_builtin_kDepIDB
|
---|
| 334 | else
|
---|
| 335 | DEP_IDB := $(DEP_IDB_EXT)
|
---|
| 336 | endif
|
---|
| 337 |
|
---|
[578] | 338 | DEP_PRE_EXT := $(PATH_KBUILD_BIN)/kDepPre$(HOSTSUFF_EXE)
|
---|
[380] | 339 | ifeq ($(filter kDepPre,$(KMK_BUILTIN)),kDepPre)
|
---|
| 340 | DEP_PRE := $(if kmk_builtin_kDepPre
|
---|
| 341 | else
|
---|
| 342 | DEP_PRE := $(DEP_PRE_EXT)
|
---|
| 343 | endif
|
---|
| 344 |
|
---|
[578] | 345 | APPEND_EXT := $(PATH_KBUILD_BIN)/kmk_append$(HOSTSUFF_EXE)
|
---|
[353] | 346 | ifeq ($(filter append,$(KMK_BUILTIN)),append)
|
---|
[380] | 347 | APPEND := kmk_builtin_append
|
---|
[353] | 348 | else
|
---|
[380] | 349 | APPEND := $(APPEND_EXT)
|
---|
[353] | 350 | endif
|
---|
[69] | 351 |
|
---|
[578] | 352 | CAT_EXT := $(PATH_KBUILD_BIN)/kmk_cat$(HOSTSUFF_EXE)
|
---|
[380] | 353 | ifeq ($(filter cat,$(KMK_BUILTIN)),cat)
|
---|
| 354 | CAT := kmk_builtin_cat
|
---|
| 355 | else
|
---|
| 356 | CAT := $(CAT_EXT)
|
---|
| 357 | endif
|
---|
[353] | 358 |
|
---|
[578] | 359 | CP_EXT := $(PATH_KBUILD_BIN)/kmk_cp$(HOSTSUFF_EXE)
|
---|
[380] | 360 | ifeq ($(filter cp,$(KMK_BUILTIN)),cp)
|
---|
| 361 | CP := kmk_builtin_cp
|
---|
| 362 | else
|
---|
| 363 | CP := $(CP_EXT)
|
---|
| 364 | endif
|
---|
| 365 |
|
---|
[578] | 366 | ECHO_EXT := $(PATH_KBUILD_BIN)/kmk_echo$(HOSTSUFF_EXE)
|
---|
[380] | 367 | ifeq ($(filter echo,$(KMK_BUILTIN)),echo)
|
---|
| 368 | ECHO := kmk_builtin_echo
|
---|
| 369 | else
|
---|
| 370 | ECHO := $(ECHO_EXT)
|
---|
| 371 | endif
|
---|
| 372 |
|
---|
[578] | 373 | INSTALL_EXT := $(PATH_KBUILD_BIN)/kmk_install$(HOSTSUFF_EXE)
|
---|
[380] | 374 | ifeq ($(filter install,$(KMK_BUILTIN)),install)
|
---|
| 375 | INSTALL := kmk_builtin_install
|
---|
| 376 | else
|
---|
| 377 | INSTALL := $(INSTALL_EXT)
|
---|
| 378 | endif
|
---|
| 379 |
|
---|
[578] | 380 | LN_EXT := $(PATH_KBUILD_BIN)/kmk_ln$(HOSTSUFF_EXE)
|
---|
[380] | 381 | ifeq ($(filter ln,$(KMK_BUILTIN)),ln)
|
---|
| 382 | LN := kmk_builtin_ln
|
---|
| 383 | else
|
---|
| 384 | LN := $(LN_EXT)
|
---|
| 385 | endif
|
---|
| 386 |
|
---|
[578] | 387 | MKDIR_EXT := $(PATH_KBUILD_BIN)/kmk_mkdir$(HOSTSUFF_EXE)
|
---|
[380] | 388 | ifeq ($(filter mkdir,$(KMK_BUILTIN)),mkdir)
|
---|
| 389 | MKDIR := kmk_builtin_mkdir
|
---|
| 390 | else
|
---|
| 391 | MKDIR := $(MKDIR_EXT)
|
---|
| 392 | endif
|
---|
| 393 |
|
---|
[578] | 394 | MV_EXT := $(PATH_KBUILD_BIN)/kmk_mv$(HOSTSUFF_EXE)
|
---|
[380] | 395 | ifeq ($(filter mv,$(KMK_BUILTIN)),mv)
|
---|
| 396 | MV := kmk_builtin_mv
|
---|
| 397 | else
|
---|
| 398 | MV := $(MV_EXT)
|
---|
| 399 | endif
|
---|
| 400 |
|
---|
[578] | 401 | RM_EXT := $(PATH_KBUILD_BIN)/kmk_rm$(HOSTSUFF_EXE)
|
---|
[380] | 402 | ifeq ($(filter rm,$(KMK_BUILTIN)),rm)
|
---|
| 403 | RM := kmk_builtin_rm
|
---|
| 404 | else
|
---|
| 405 | RM := $(RM_EXT)
|
---|
| 406 | endif
|
---|
| 407 |
|
---|
[601] | 408 | RMDIR_EXT := $(PATH_KBUILD_BIN)/kmk_rmdir$(HOSTSUFF_EXE)
|
---|
| 409 | ifeq ($(filter rmdir,$(KMK_BUILTIN)),rmdir)
|
---|
| 410 | RMDIR := kmk_builtin_rmdir
|
---|
| 411 | else
|
---|
| 412 | RMDIR := $(RMDIR_EXT)
|
---|
| 413 | endif
|
---|
| 414 |
|
---|
[578] | 415 | SED_EXT := $(PATH_KBUILD_BIN)/kmk_sed$(HOSTSUFF_EXE)
|
---|
[380] | 416 | ifeq ($(filter sed,$(KMK_BUILTIN)),sed)
|
---|
| 417 | SED := kmk_builtin_sed
|
---|
| 418 | else
|
---|
| 419 | SED := $(SED_EXT)
|
---|
| 420 | endif
|
---|
| 421 |
|
---|
| 422 | # Our default shell is the Almquist shell from *BSD.
|
---|
[578] | 423 | ASH := $(PATH_KBUILD_BIN)/kmk_ash$(HOSTSUFF_EXE)
|
---|
[380] | 424 | MAKESHELL := $(ASH)
|
---|
| 425 | SHELL := $(ASH)
|
---|
| 426 | export SHELL MAKESHELL
|
---|
| 427 |
|
---|
[414] | 428 | # Symlinking is problematic on some platforms...
|
---|
[380] | 429 | LN_SYMLINK := $(LN) -s
|
---|
| 430 |
|
---|
| 431 |
|
---|
| 432 |
|
---|
[69] | 433 | #
|
---|
[73] | 434 | # Message macros.
|
---|
[204] | 435 | #
|
---|
| 436 |
|
---|
[73] | 437 | ifndef BUILD_QUIET
|
---|
[75] | 438 | ifdef BUILD_DEBUG
|
---|
| 439 | BUILD_VERBOSE := 9
|
---|
| 440 | endif
|
---|
[230] | 441 | MSG_L1 = @$(ECHO) "kBuild: $1"
|
---|
[73] | 442 | ifdef BUILD_VERBOSE
|
---|
[230] | 443 | MSG_L2 = @$(ECHO) "kBuild: $1"
|
---|
[75] | 444 | QUIET :=
|
---|
[73] | 445 | else
|
---|
[75] | 446 | QUIET := @
|
---|
[73] | 447 | MSG_L2 =
|
---|
| 448 | endif
|
---|
| 449 | ifdef BUILD_DEBUG
|
---|
[230] | 450 | MSG_L3 = @$(ECHO) "kBuild: $1"
|
---|
[73] | 451 | else
|
---|
| 452 | MSG_L3 =
|
---|
| 453 | endif
|
---|
| 454 | else
|
---|
[75] | 455 | QUIET :=
|
---|
[73] | 456 | MSG_L1 =
|
---|
| 457 | MSG_L2 =
|
---|
| 458 | MSG_L3 =
|
---|
| 459 | endif
|
---|
| 460 |
|
---|
[130] | 461 | ## ABSPATH - make paths absolute.
|
---|
[129] | 462 | # This implementation is clumsy and doesn't resolve '..' and '.' components.
|
---|
[73] | 463 | #
|
---|
[129] | 464 | # @param $1 The paths to make absolute.
|
---|
[306] | 465 | ABSPATH = $(abspath $(1))
|
---|
[353] | 466 |
|
---|
[130] | 467 | ## DIRDEP - make create directory dependencies.
|
---|
| 468 | #
|
---|
| 469 | # @param $1 The paths to the directories which must be created.
|
---|
[353] | 470 | DIRDEP = $(foreach path,$(patsubst %/,%,$(1)),$(path)/)
|
---|
[129] | 471 |
|
---|
[204] | 472 |
|
---|
[129] | 473 | ## Cygwin kludge.
|
---|
| 474 | # This converts /cygdrive/x/% to x:%.
|
---|
| 475 | #
|
---|
| 476 | # @param $1 The paths to make native.
|
---|
| 477 | # @remark This macro is pretty much obsolete since we don't use cygwin base make.
|
---|
| 478 | ifneq ($(patsubst /cygdrive/%,%,$(CURDIR)),$(CURDIR))
|
---|
| 479 | CYGPATHMIXED = $(foreach path,$(1)\
|
---|
| 480 | ,$(if $(patsubst /cygdrive/%,,$(path)),$(path),$(patsubst $(strip $(firstword $(subst /, ,$(patsubst /cygdrive/%,%,$(path)))))/%,$(strip $(firstword $(subst /, ,$(patsubst /cygdrive/%,%,$(path))))):/%,$(patsubst /cygdrive/%,%,$(path)))))
|
---|
| 481 | else
|
---|
| 482 | CYGPATHMIXED = $(1)
|
---|
| 483 | endif
|
---|
| 484 |
|
---|
| 485 | #
|
---|
[353] | 486 | # Initialize some of the globals which the Config.kmk and
|
---|
| 487 | # others can add stuff to if they like for processing in the footer.
|
---|
| 488 | #
|
---|
| 489 |
|
---|
| 490 | ## ALL_TARGET
|
---|
| 491 | # This is the list of all targets.
|
---|
| 492 | ALL_TARGETS :=
|
---|
| 493 |
|
---|
| 494 | ## TEMPLATE_PATHS
|
---|
| 495 | # List a paths (separated by space) where templates can be found.
|
---|
| 496 | TEMPLATE_PATHS :=
|
---|
| 497 |
|
---|
| 498 | ## TOOL_PATHS
|
---|
| 499 | # List of paths (separated by space) where tools can be found.
|
---|
| 500 | TOOL_PATHS :=
|
---|
| 501 |
|
---|
| 502 | ## SDK_PATHS
|
---|
| 503 | # List of paths (separated by space) where SDKs can be found.
|
---|
| 504 | SDK_PATHS :=
|
---|
| 505 |
|
---|
| 506 | ## Proritized list of the default makefile when walking subdirectories.
|
---|
| 507 | # The user can overload this list.
|
---|
| 508 | DEFAULT_MAKEFILE := Makefile.kmk makefile.kmk Makefile makefile
|
---|
| 509 |
|
---|
[640] | 510 | ## PROPS_TOOLS
|
---|
| 511 | # This is a subset of the other PROPS
|
---|
[641] | 512 | PROPS_TOOLS := TOOL CTOOL CXXTOOL ASTOOL RCTOOL ARTOOL LDTOOL FETCHTOOL UNPACKTOOL PATCHTOOL
|
---|
[640] | 513 |
|
---|
[353] | 514 | ## PROPS_SINGLE
|
---|
| 515 | # The list of non-accumulative target properties.
|
---|
| 516 | # A Config.kmk file can add it's own properties to this list and kBuild
|
---|
| 517 | # will do the necessary inheritance from templates to targets.
|
---|
[641] | 518 | PROPS_SINGLE := $(PROPS_TOOLS) INST NOINST BLD_TYPE BLD_TRG BLD_TRG_ARCH BLD_TRG_CPU FETCHDIR \
|
---|
| 519 | OBJSUFF COBJSUFF CXXOBJSUFF ASOBJSUFF RCOBJSUFF SYSSUFF EXESUFF DLLSUFF LIBSUFF ARLIBSUFF
|
---|
[353] | 520 |
|
---|
| 521 | ## PROPS_DEFERRED
|
---|
| 522 | # This list of non-accumulative target properties which are functions,
|
---|
| 523 | # and thus should not be expanded until the very last moment.
|
---|
| 524 | PROPS_DEFERRED := INSTFUN INSTALLER
|
---|
| 525 |
|
---|
[660] | 526 | ## PROPS_ACCUMULATE_R
|
---|
| 527 | # The list of accumulative target properties where the right most value/flag
|
---|
| 528 | # is the 'most significant'.
|
---|
[353] | 529 | # A Config.kmk file can add it's own properties to this list and kBuild
|
---|
| 530 | # will do the necessary inheritance from templates to targets.
|
---|
[660] | 531 | PROPS_ACCUMULATE_R := \
|
---|
| 532 | DEFS DEPS \
|
---|
| 533 | CFLAGS CDEFS \
|
---|
| 534 | CXXFLAGS CXXDEFS \
|
---|
| 535 | ASFLAGS ASDEFS \
|
---|
| 536 | RCFLAGS RCDEFS \
|
---|
| 537 | LDFLAGS \
|
---|
[640] | 538 | FETCHFLAGS UNPACKFLAGS PATCHFLAGS
|
---|
[353] | 539 |
|
---|
[660] | 540 | ## PROPS_ACCUMULATE
|
---|
| 541 | # The list of accumulative target properties where the left most value/flag
|
---|
| 542 | # is the 'most significant'.
|
---|
| 543 | # A Config.kmk file can add it's own properties to this list and kBuild
|
---|
| 544 | # will do the necessary inheritance from templates to targets.
|
---|
| 545 | PROPS_ACCUMULATE_L := \
|
---|
| 546 | SDKS SOURCES \
|
---|
| 547 | INCS CINCS CXXINCX ASINCS RCINCS \
|
---|
| 548 | LIBS LIBPATH
|
---|
[353] | 549 |
|
---|
[660] | 550 |
|
---|
[353] | 551 | #
|
---|
| 552 | # Pass configuration.
|
---|
| 553 | #
|
---|
| 554 | # The PASS_<passname>_trgs variable is listing the targets.
|
---|
| 555 | # The PASS_<passname>_vars variable is listing the target variables.
|
---|
| 556 | # The PASS_<passname>_pass variable is the lowercased passname.
|
---|
| 557 | #
|
---|
| 558 |
|
---|
[640] | 559 | ## PASS: fetches
|
---|
| 560 | # This pass fetches and unpacks things needed to complete the build.
|
---|
| 561 | PASS_FETCHES := Fetches
|
---|
| 562 | PASS_FETCHES_trgs :=
|
---|
| 563 | PASS_FETCHES_vars := _FETCHES
|
---|
| 564 | PASS_FETCHES_pass := fetches
|
---|
| 565 |
|
---|
| 566 | ## PASS: patches
|
---|
| 567 | # This pass applies patches.
|
---|
| 568 | PASS_PATCHES := Patches
|
---|
| 569 | PASS_PATCHES_trgs :=
|
---|
| 570 | PASS_PATCHES_vars := _PATCHES
|
---|
| 571 | PASS_PATCHES_pass := patches
|
---|
| 572 |
|
---|
[353] | 573 | ## PASS: bldprogs
|
---|
| 574 | # This pass builds targets which are required for building the rest.
|
---|
| 575 | PASS_BLDPROGS := Build Programs
|
---|
| 576 | PASS_BLDPROGS_trgs :=
|
---|
| 577 | PASS_BLDPROGS_vars := _BLDPROGS
|
---|
| 578 | PASS_BLDPROGS_pass := bldprogs
|
---|
| 579 |
|
---|
| 580 | ## PASS: libraries
|
---|
| 581 | # This pass builds library targets.
|
---|
| 582 | PASS_LIBRARIES := Libraries
|
---|
| 583 | PASS_LIBRARIES_trgs :=
|
---|
| 584 | PASS_LIBRARIES_vars := _LIBS _IMPORT_LIBS _OTHER_LIBRARIES
|
---|
| 585 | PASS_LIBRARIES_pass := libraries
|
---|
| 586 |
|
---|
| 587 | ## PASS: binaries
|
---|
| 588 | # This pass builds dll targets.
|
---|
| 589 | PASS_DLLS := DLLs
|
---|
| 590 | PASS_DLLS_trgs :=
|
---|
| 591 | PASS_DLLS_vars := _DLLS _OTHER_DLLS
|
---|
| 592 | PASS_DLLS_pass := dlls
|
---|
| 593 |
|
---|
| 594 | ## PASS: binaries
|
---|
| 595 | # This pass builds binary targets, i.e. programs, system modules and stuff.
|
---|
| 596 | PASS_BINARIES := Programs
|
---|
| 597 | PASS_BINARIES_trgs :=
|
---|
| 598 | PASS_BINARIES_vars := _PROGRAMS _SYSMODS _OTHER_BINARIES
|
---|
| 599 | PASS_BINARIES_pass := binaries
|
---|
| 600 |
|
---|
| 601 | ## PASS: others
|
---|
| 602 | # This pass builds other targets.
|
---|
| 603 | PASS_OTHERS := Other Stuff
|
---|
| 604 | PASS_OTHERS_trgs :=
|
---|
| 605 | PASS_OTHERS_vars := _OTHERS
|
---|
| 606 | PASS_OTHERS_pass := others
|
---|
| 607 |
|
---|
| 608 | ## PASS: install
|
---|
| 609 | # This pass installs the built entities to a sandbox area.
|
---|
| 610 | PASS_INSTALLS := Install
|
---|
| 611 | PASS_INSTALLS_trgs :=
|
---|
[380] | 612 | PASS_INSTALLS_vars := _INSTALLS_DIRS _INSTALLS
|
---|
[353] | 613 | PASS_INSTALLS_pass := installs
|
---|
| 614 |
|
---|
| 615 | ## PASS: packing
|
---|
| 616 | # This pass processes custom packing rules.
|
---|
| 617 | PASS_PACKING := Packing
|
---|
[414] | 618 | PASS_PACKING_trgs :=
|
---|
[417] | 619 | PASS_PACKING_vars := _PACKING
|
---|
[353] | 620 | PASS_PACKING_pass := packing
|
---|
[414] | 621 | #alias
|
---|
| 622 | packing: pass_packing
|
---|
[353] | 623 |
|
---|
| 624 | ## PASS: clean
|
---|
| 625 | # This pass removes all generated files.
|
---|
| 626 | PASS_CLEAN := Clean
|
---|
| 627 | PASS_CLEAN_trgs := do-clean
|
---|
| 628 | PASS_CLEAN_vars :=
|
---|
| 629 | PASS_CLEAN_pass := clean
|
---|
| 630 | # alias
|
---|
| 631 | clean: pass_clean
|
---|
| 632 |
|
---|
| 633 | ## PASS: nothing
|
---|
| 634 | # This pass just walks the tree.
|
---|
| 635 | PASS_NOTHING := Nothing
|
---|
| 636 | PASS_NOTHING_trgs := do-nothing
|
---|
| 637 | PASS_NOTHING_vars :=
|
---|
| 638 | PASS_NOTHING_pass := nothing
|
---|
| 639 | # alias
|
---|
| 640 | nothing: pass_nothing
|
---|
| 641 |
|
---|
| 642 | ## DEFAULT_PASSES
|
---|
| 643 | # The default passes and their order.
|
---|
| 644 | DEFAULT_PASSES := BLDPROGS LIBRARIES DLLS BINARIES OTHERS INSTALLS
|
---|
| 645 |
|
---|
| 646 | ## PASSES
|
---|
| 647 | # The passes that should be defined. This must include
|
---|
| 648 | # all passes mentioned by DEFAULT_PASSES.
|
---|
[640] | 649 | PASSES := FETCHES PATCHES $(DEFAULT_PASSES) NOTHING CLEAN
|
---|
[353] | 650 |
|
---|
| 651 |
|
---|
| 652 | #
|
---|
[69] | 653 | # This is how we find the closest config.kmk.
|
---|
| 654 | # It's a little hacky but I think it works fine.
|
---|
[70] | 655 | #
|
---|
| 656 | _CFGDIR := .
|
---|
[78] | 657 | _CFGFILES := ./Config.kmk ./config.kmk
|
---|
[69] | 658 | define def_include_config
|
---|
[78] | 659 | $(eval _CFGDIR := $(_CFGDIR)/$(dir))
|
---|
| 660 | _CFGFILES += $(_CFGDIR)/Config.kmk $(_CFGDIR)/config.kmk
|
---|
[69] | 661 | endef
|
---|
| 662 | # walk down the _RELATIVE_ path specified by DEPTH.
|
---|
[78] | 663 | $(foreach dir,$(subst /, ,$(DEPTH)), $(eval $(def_include_config)) )
|
---|
[69] | 664 | # add the default config file.
|
---|
[78] | 665 | _CFGFILE := $(firstword $(wildcard $(_CFGFILES) $(FILE_KBUILD_CONFIG)))
|
---|
[69] | 666 | _CFGFILES :=
|
---|
| 667 | _CFGDIR :=
|
---|
[416] | 668 | ifeq ($(_CFGFILE),)
|
---|
| 669 | $(error kBuild: no Config.kmk file found! Check the DEPTH: DEPTH='$(DEPTH)' PATH_CURRENT='$(PATH_CURRENT)')
|
---|
| 670 | endif
|
---|
[69] | 671 |
|
---|
| 672 | # Include the config.kmk we found file (or the default one).
|
---|
| 673 | include $(_CFGFILE)
|
---|
| 674 |
|
---|
| 675 |
|
---|
| 676 | # end-of-file-content
|
---|
[72] | 677 | __header_kmk__ := 1
|
---|
[69] | 678 | endif # __header_kmk__
|
---|
[479] | 679 |
|
---|