[69] | 1 | # $Id: header.kmk 88 2004-06-04 16:14:30Z bird $
|
---|
| 2 | ## @file
|
---|
| 3 | #
|
---|
| 4 | # kBuild - File included at top of makefile.
|
---|
| 5 | #
|
---|
| 6 | # Copyright (c) 2004 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 | # Try avoid inference rules.
|
---|
| 37 | #
|
---|
| 38 | .SUFFIXES:
|
---|
| 39 | SUFFIXES :=
|
---|
| 40 |
|
---|
[72] | 41 |
|
---|
[69] | 42 | #
|
---|
[72] | 43 | # Assert build type.
|
---|
[69] | 44 | #
|
---|
| 45 | ifndef BUILD_TYPE
|
---|
| 46 | ifndef BUILD_MODE
|
---|
[72] | 47 | $(error kBuild: You must define BUILD_TYPE!)
|
---|
[69] | 48 | endif
|
---|
| 49 | BUILD_TYPE := $(BUILD_MODE)
|
---|
| 50 | endif
|
---|
[72] | 51 | ifeq ($(BUILD_TYPE),DEBUG)
|
---|
| 52 | BUILD_TYPE := debug
|
---|
| 53 | endif
|
---|
| 54 | ifeq ($(BUILD_TYPE),RELEASE)
|
---|
| 55 | BUILD_TYPE := release
|
---|
| 56 | endif
|
---|
| 57 | ifeq ($(BUILD_TYPE),PROFILE)
|
---|
| 58 | BUILD_TYPE := profile
|
---|
| 59 | endif
|
---|
[69] | 60 |
|
---|
| 61 |
|
---|
| 62 | #
|
---|
[72] | 63 | # Assert build platform.
|
---|
[70] | 64 | #
|
---|
[72] | 65 | _BUILD_PLATFORM_OK := 0
|
---|
| 66 | # OS/2
|
---|
| 67 | ifeq ($(BUILD_PLATFORM),OS2)
|
---|
[88] | 68 | $(error kBuild: BUILD_PLATFORM must be all lowercase!)
|
---|
[72] | 69 | endif
|
---|
| 70 | ifeq ($(BUILD_PLATFORM),os2)
|
---|
| 71 | _BUILD_PLATFORM_OK := 1
|
---|
| 72 | endif
|
---|
[70] | 73 |
|
---|
[72] | 74 | # Linux
|
---|
| 75 | ifeq ($(BUILD_PLATFORM),LINUX)
|
---|
[88] | 76 | $(error kBuild: BUILD_PLATFORM must be all lowercase!)
|
---|
[72] | 77 | endif
|
---|
| 78 | ifeq ($(BUILD_PLATFORM),linux)
|
---|
| 79 | _BUILD_PLATFORM_OK := 1
|
---|
| 80 | endif
|
---|
| 81 |
|
---|
| 82 | # Win32
|
---|
| 83 | ifeq ($(BUILD_PLATFORM),WIN32)
|
---|
[88] | 84 | $(error kBuild: BUILD_PLATFORM must be all lowercase!)
|
---|
[72] | 85 | endif
|
---|
[83] | 86 | ifeq ($(BUILD_PLATFORM),win32)
|
---|
[72] | 87 | _BUILD_PLATFORM_OK := 1
|
---|
| 88 | endif
|
---|
| 89 |
|
---|
| 90 | ifeq ($(_BUILD_PLATFORM_OK),0)
|
---|
| 91 | $(error kBuild: BUILD_PLATFORM value '$(BUILD_PLATFORM)' was not recongized!)
|
---|
| 92 | endif
|
---|
| 93 |
|
---|
| 94 |
|
---|
[70] | 95 | #
|
---|
[72] | 96 | # Assert target platform.
|
---|
| 97 | #
|
---|
| 98 | ifndef BUILD_TARGET
|
---|
| 99 | # not defined, set to the same as build platform
|
---|
| 100 | BUILD_TARGET := $(BUILD_PLATFORM)
|
---|
| 101 | else
|
---|
| 102 | _BUILD_TARGET_OK := 0
|
---|
| 103 | # OS/2
|
---|
| 104 | ifeq ($(BUILD_TARGET),OS2)
|
---|
[88] | 105 | $(error kBuild: BUILD_TARGET must be all lowercase!)
|
---|
[72] | 106 | endif
|
---|
| 107 | ifeq ($(BUILD_TARGET),os2)
|
---|
| 108 | _BUILD_TARGET_OK := 1
|
---|
| 109 | endif
|
---|
| 110 |
|
---|
| 111 | # Linux
|
---|
| 112 | ifeq ($(BUILD_TARGET),LINUX)
|
---|
[88] | 113 | $(error kBuild: BUILD_TARGET must be all lowercase!)
|
---|
[72] | 114 | endif
|
---|
| 115 | ifeq ($(BUILD_TARGET),linux)
|
---|
| 116 | _BUILD_TARGET_OK := 1
|
---|
| 117 | endif
|
---|
| 118 |
|
---|
| 119 | # Win32
|
---|
| 120 | ifeq ($(BUILD_TARGET),WIN32)
|
---|
[88] | 121 | $(error kBuild: BUILD_TARGET must be all lowercase!)
|
---|
[72] | 122 | endif
|
---|
[77] | 123 | ifeq ($(BUILD_TARGET),win32)
|
---|
[72] | 124 | _BUILD_TARGET_OK := 1
|
---|
| 125 | endif
|
---|
| 126 |
|
---|
| 127 | ifeq ($(_BUILD_TARGET_OK),0)
|
---|
| 128 | $(error kBuild: BUILD_TARGET value '$(BUILD_TARGET)' was not recongized!)
|
---|
| 129 | endif
|
---|
| 130 | endif
|
---|
[78] | 131 | BUILD_TARGET_ARCH := x86
|
---|
| 132 | BUILD_TARGET_CPU := i586
|
---|
[72] | 133 |
|
---|
[85] | 134 | #
|
---|
| 135 | # Cygwin kludge.
|
---|
| 136 | #
|
---|
| 137 | ifneq ($(patsubst /cygdrive/%,%,$(CURDIR)),$(CURDIR))
|
---|
| 138 | CYGPATHMIXED = $(foreach path,$(1)\
|
---|
| 139 | ,$(if $(patsubst /cygdrive/%,,$(path)),$(path),$(patsubst $(strip $(firstword $(subst /, ,$(patsubst /cygdrive/%,%,$(path)))))/%,$(strip $(firstword $(subst /, ,$(patsubst /cygdrive/%,%,$(path))))):/%,$(patsubst /cygdrive/%,%,$(path)))))
|
---|
| 140 | else
|
---|
| 141 | CYGPATHMIXED = $(1)
|
---|
| 142 | endif
|
---|
[72] | 143 |
|
---|
| 144 | #
|
---|
[69] | 145 | # Common definitions.
|
---|
| 146 | #
|
---|
| 147 | PATH_CURRENT := $(CURDIR)
|
---|
[70] | 148 | # Get the real root path.
|
---|
[85] | 149 | PATH_ROOT := $(PATH_CURRENT)
|
---|
[70] | 150 | ifneq ($(DEPTH),.)
|
---|
| 151 | $(foreach d,$(subst /, ,$(DEPTH)), $(eval PATH_ROOT := $(patsubst %/,%,$(dir $(PATH_ROOT)))) )
|
---|
[69] | 152 | endif
|
---|
[70] | 153 | # Subdirectory relative to the root.
|
---|
[72] | 154 | CURSUBDIR := $(patsubst $(PATH_ROOT)/%,%,$(CURDIR))
|
---|
[70] | 155 | # Output directories.
|
---|
[69] | 156 | PATH_OUT := $(PATH_ROOT)/out/$(BUILD_TARGET)/$(BUILD_TYPE)
|
---|
| 157 | PATH_OBJ := $(PATH_OUT)/obj
|
---|
| 158 | PATH_BIN := $(PATH_OUT)/bin
|
---|
| 159 | PATH_LIB := $(PATH_OUT)/lib
|
---|
| 160 | PATH_DOC := $(PATH_ROOT)/out/doc
|
---|
[72] | 161 | PATH_TARGET := $(PATH_OBJ)/$(CURSUBDIR)
|
---|
[70] | 162 |
|
---|
| 163 | # Usually kBuild is external to the source tree.
|
---|
| 164 | ifndef PATH_KBUILD
|
---|
| 165 | PATH_KBUILD := $(PATH_ROOT)/kBuild
|
---|
| 166 | endif
|
---|
| 167 | # kBuild tools
|
---|
[69] | 168 | PATH_TOOLS_W32 := $(PATH_KBUILD)/bin/x86.win32
|
---|
| 169 | PATH_TOOLS_LNX := $(PATH_KBUILD)/bin/x86.linux
|
---|
| 170 | PATH_TOOLS_OS2 := $(PATH_KBUILD)/bin/x86.os2
|
---|
| 171 | # kBuild files which might be of interest.
|
---|
| 172 | FILE_KBUILD_HEADER := $(PATH_KBUILD)/header.kmk
|
---|
| 173 | FILE_KBUILD_CONFIG := $(PATH_KBUILD)/config.kmk
|
---|
| 174 | FILE_KBUILD_FOOTER := $(PATH_KBUILD)/footer.kmk
|
---|
| 175 |
|
---|
[72] | 176 | SUFF_DEP := .dep
|
---|
[69] | 177 |
|
---|
[72] | 178 |
|
---|
[69] | 179 | #
|
---|
| 180 | # Get rid of the GNU Make default stuff
|
---|
| 181 | #
|
---|
| 182 | include $(PATH_KBUILD)/StampOutPredefines.kmk
|
---|
| 183 |
|
---|
| 184 |
|
---|
| 185 | #
|
---|
[72] | 186 | # Build platform setup.
|
---|
[69] | 187 | #
|
---|
| 188 | # OS/2
|
---|
[72] | 189 | ifeq ($(BUILD_PLATFORM),os2)
|
---|
[69] | 190 | PATH_TOOLS := $(PATH_TOOLS_OS2)
|
---|
[83] | 191 | EXEC_X86_WIN32 := innopec.exe
|
---|
[69] | 192 | HOSTSUFF_EXE := .exe
|
---|
| 193 | endif
|
---|
| 194 |
|
---|
| 195 | # Linux
|
---|
[72] | 196 | ifeq ($(BUILD_PLATFORM),linux)
|
---|
[69] | 197 | PATH_TOOLS := $(PATH_TOOLS_LNX)
|
---|
| 198 | EXEC_X86_WIN32 := wine
|
---|
| 199 | HOSTSUFF_EXE :=
|
---|
| 200 | endif
|
---|
[70] | 201 |
|
---|
[69] | 202 | # Win32
|
---|
[72] | 203 | ifeq ($(BUILD_PLATFORM),win32)
|
---|
[69] | 204 | PATH_TOOLS := $(PATH_TOOLS_W32)
|
---|
| 205 | EXEC_X86_WIN32 :=
|
---|
| 206 | HOSTSUFF_EXE := .exe
|
---|
| 207 | endif
|
---|
| 208 |
|
---|
[73] | 209 | #
|
---|
| 210 | # Build target setup.
|
---|
| 211 | #
|
---|
| 212 | ifeq ($(BUILD_TARGET),os2)
|
---|
| 213 | SUFF_OBJ := .obj
|
---|
| 214 | SUFF_LIB := .lib
|
---|
| 215 | SUFF_DLL := .dll
|
---|
| 216 | SUFF_EXE := .exe
|
---|
[86] | 217 | SUFF_SYS := .sys
|
---|
[73] | 218 | SUFF_RES := .res
|
---|
| 219 | endif
|
---|
| 220 | ifeq ($(BUILD_TARGET),win32)
|
---|
| 221 | SUFF_OBJ := .obj
|
---|
| 222 | SUFF_LIB := .lib
|
---|
| 223 | SUFF_DLL := .dll
|
---|
| 224 | SUFF_EXE := .exe
|
---|
[86] | 225 | SUFF_SYS := .sys
|
---|
[73] | 226 | SUFF_RES := .res
|
---|
| 227 | endif
|
---|
| 228 | ifeq ($(BUILD_TARGET),linux)
|
---|
| 229 | SUFF_OBJ := .o
|
---|
| 230 | SUFF_LIB := .a
|
---|
| 231 | SUFF_DLL := .so
|
---|
| 232 | SUFF_EXE :=
|
---|
[86] | 233 | SUFF_SYS := .a
|
---|
[73] | 234 | SUFF_RES :=
|
---|
| 235 | endif
|
---|
[69] | 236 |
|
---|
[73] | 237 |
|
---|
[69] | 238 | #
|
---|
| 239 | # Standard kBuild tools.
|
---|
| 240 | #
|
---|
| 241 | DEP := $(PATH_TOOLS)/kDep$(HOSTSUFF_EXE)
|
---|
| 242 | # Standard Unix shell utils.
|
---|
| 243 | MKDIR := $(PATH_TOOLS)/mkdir$(HOSTSUFF_EXE)
|
---|
| 244 | RM := $(PATH_TOOLS)/rm$(HOSTSUFF_EXE)
|
---|
[87] | 245 | CP := $(PATH_TOOLS)/cp$(HOSTSUFF_EXE)
|
---|
| 246 | MV := $(PATH_TOOLS)/mv$(HOSTSUFF_EXE)
|
---|
[69] | 247 | SED := $(PATH_TOOLS)/sed$(HOSTSUFF_EXE)
|
---|
| 248 | CAT := $(PATH_TOOLS)/cat$(HOSTSUFF_EXE)
|
---|
| 249 | # Bourn shell clone.
|
---|
| 250 | MAKESHELL := $(PATH_TOOLS)/ash$(HOSTSUFF_EXE)
|
---|
| 251 | SHELL := $(MAKESHELL)
|
---|
| 252 | export SHELL MAKESHELL
|
---|
| 253 |
|
---|
| 254 |
|
---|
| 255 | #
|
---|
[73] | 256 | # Message macros.
|
---|
[75] | 257 | #
|
---|
| 258 |
|
---|
[73] | 259 | ifndef BUILD_QUIET
|
---|
[75] | 260 | ifdef BUILD_DEBUG
|
---|
| 261 | BUILD_VERBOSE := 9
|
---|
| 262 | endif
|
---|
[73] | 263 | MSG_L1 = @echo "kBuild: $1"
|
---|
| 264 | ifdef BUILD_VERBOSE
|
---|
| 265 | MSG_L2 = @echo "kBuild: $1"
|
---|
[75] | 266 | QUIET :=
|
---|
[73] | 267 | else
|
---|
[75] | 268 | QUIET := @
|
---|
[73] | 269 | MSG_L2 =
|
---|
| 270 | endif
|
---|
| 271 | ifdef BUILD_DEBUG
|
---|
| 272 | MSG_L3 = @echo "kBuild: $1"
|
---|
| 273 | else
|
---|
| 274 | MSG_L3 =
|
---|
| 275 | endif
|
---|
| 276 | else
|
---|
[75] | 277 | QUIET :=
|
---|
[73] | 278 | MSG_L1 =
|
---|
| 279 | MSG_L2 =
|
---|
| 280 | MSG_L3 =
|
---|
| 281 | endif
|
---|
| 282 |
|
---|
| 283 | #
|
---|
[69] | 284 | # This is how we find the closest config.kmk.
|
---|
| 285 | # It's a little hacky but I think it works fine.
|
---|
[70] | 286 | #
|
---|
| 287 | _CFGDIR := .
|
---|
[78] | 288 | _CFGFILES := ./Config.kmk ./config.kmk
|
---|
[69] | 289 | define def_include_config
|
---|
[78] | 290 | $(eval _CFGDIR := $(_CFGDIR)/$(dir))
|
---|
| 291 | _CFGFILES += $(_CFGDIR)/Config.kmk $(_CFGDIR)/config.kmk
|
---|
[69] | 292 | endef
|
---|
| 293 | # walk down the _RELATIVE_ path specified by DEPTH.
|
---|
[78] | 294 | $(foreach dir,$(subst /, ,$(DEPTH)), $(eval $(def_include_config)) )
|
---|
[69] | 295 | # add the default config file.
|
---|
[78] | 296 | _CFGFILE := $(firstword $(wildcard $(_CFGFILES) $(FILE_KBUILD_CONFIG)))
|
---|
[69] | 297 | _CFGFILES :=
|
---|
| 298 | _CFGDIR :=
|
---|
| 299 |
|
---|
| 300 | # Include the config.kmk we found file (or the default one).
|
---|
| 301 | include $(_CFGFILE)
|
---|
| 302 |
|
---|
| 303 |
|
---|
| 304 | # end-of-file-content
|
---|
[72] | 305 | __header_kmk__ := 1
|
---|
[69] | 306 | endif # __header_kmk__
|
---|