[69] | 1 | # $Id: header.kmk 78 2004-06-01 01:07:24Z 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)
|
---|
| 68 | BUILD_PLATFORM := os2
|
---|
| 69 | endif
|
---|
| 70 | ifeq ($(BUILD_PLATFORM),os2)
|
---|
| 71 | _BUILD_PLATFORM_OK := 1
|
---|
| 72 | endif
|
---|
[70] | 73 |
|
---|
[72] | 74 | # Linux
|
---|
| 75 | ifeq ($(BUILD_PLATFORM),LINUX)
|
---|
| 76 | BUILD_PLATFORM := linux
|
---|
| 77 | endif
|
---|
| 78 | ifeq ($(BUILD_PLATFORM),linux)
|
---|
| 79 | _BUILD_PLATFORM_OK := 1
|
---|
| 80 | endif
|
---|
| 81 |
|
---|
| 82 | # Win32
|
---|
| 83 | ifeq ($(BUILD_PLATFORM),WIN32)
|
---|
| 84 | BUILD_PLATFORM := win32
|
---|
| 85 | endif
|
---|
| 86 | ifeq ($(BUILD_PLATFORM),WIN32)
|
---|
| 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)
|
---|
| 105 | BUILD_TARGET := os2
|
---|
| 106 | endif
|
---|
| 107 | ifeq ($(BUILD_TARGET),os2)
|
---|
| 108 | _BUILD_TARGET_OK := 1
|
---|
| 109 | endif
|
---|
| 110 |
|
---|
| 111 | # Linux
|
---|
| 112 | ifeq ($(BUILD_TARGET),LINUX)
|
---|
| 113 | BUILD_TARGET := linux
|
---|
| 114 | endif
|
---|
| 115 | ifeq ($(BUILD_TARGET),linux)
|
---|
| 116 | _BUILD_TARGET_OK := 1
|
---|
| 117 | endif
|
---|
| 118 |
|
---|
| 119 | # Win32
|
---|
| 120 | ifeq ($(BUILD_TARGET),WIN32)
|
---|
| 121 | BUILD_TARGET := win32
|
---|
| 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 |
|
---|
| 134 |
|
---|
| 135 | #
|
---|
[69] | 136 | # Common definitions.
|
---|
| 137 | #
|
---|
| 138 | PATH_CURRENT := $(CURDIR)
|
---|
[70] | 139 | # Get the real root path.
|
---|
| 140 | PATH_ROOT := $(CURDIR)
|
---|
| 141 | ifneq ($(DEPTH),.)
|
---|
| 142 | $(foreach d,$(subst /, ,$(DEPTH)), $(eval PATH_ROOT := $(patsubst %/,%,$(dir $(PATH_ROOT)))) )
|
---|
[69] | 143 | endif
|
---|
[70] | 144 | # Subdirectory relative to the root.
|
---|
[72] | 145 | CURSUBDIR := $(patsubst $(PATH_ROOT)/%,%,$(CURDIR))
|
---|
[70] | 146 | # Output directories.
|
---|
[69] | 147 | PATH_OUT := $(PATH_ROOT)/out/$(BUILD_TARGET)/$(BUILD_TYPE)
|
---|
| 148 | PATH_OBJ := $(PATH_OUT)/obj
|
---|
| 149 | PATH_BIN := $(PATH_OUT)/bin
|
---|
| 150 | PATH_LIB := $(PATH_OUT)/lib
|
---|
| 151 | PATH_DOC := $(PATH_ROOT)/out/doc
|
---|
[72] | 152 | PATH_TARGET := $(PATH_OBJ)/$(CURSUBDIR)
|
---|
[70] | 153 |
|
---|
| 154 | # Usually kBuild is external to the source tree.
|
---|
| 155 | ifndef PATH_KBUILD
|
---|
| 156 | PATH_KBUILD := $(PATH_ROOT)/kBuild
|
---|
| 157 | endif
|
---|
| 158 | # kBuild tools
|
---|
[69] | 159 | PATH_TOOLS_W32 := $(PATH_KBUILD)/bin/x86.win32
|
---|
| 160 | PATH_TOOLS_LNX := $(PATH_KBUILD)/bin/x86.linux
|
---|
| 161 | PATH_TOOLS_OS2 := $(PATH_KBUILD)/bin/x86.os2
|
---|
| 162 | # kBuild files which might be of interest.
|
---|
| 163 | FILE_KBUILD_HEADER := $(PATH_KBUILD)/header.kmk
|
---|
| 164 | FILE_KBUILD_CONFIG := $(PATH_KBUILD)/config.kmk
|
---|
| 165 | FILE_KBUILD_FOOTER := $(PATH_KBUILD)/footer.kmk
|
---|
| 166 |
|
---|
[72] | 167 | SUFF_DEP := .dep
|
---|
[69] | 168 |
|
---|
[72] | 169 |
|
---|
[69] | 170 | #
|
---|
| 171 | # Get rid of the GNU Make default stuff
|
---|
| 172 | #
|
---|
| 173 | include $(PATH_KBUILD)/StampOutPredefines.kmk
|
---|
| 174 |
|
---|
| 175 |
|
---|
| 176 | #
|
---|
[72] | 177 | # Build platform setup.
|
---|
[69] | 178 | #
|
---|
| 179 | # OS/2
|
---|
[72] | 180 | ifeq ($(BUILD_PLATFORM),os2)
|
---|
[69] | 181 | PATH_TOOLS := $(PATH_TOOLS_OS2)
|
---|
| 182 | EXEC_X86_WIN32 := $(PATH_TOOLS)/bin/innopec.exe
|
---|
| 183 | HOSTSUFF_EXE := .exe
|
---|
| 184 | endif
|
---|
| 185 |
|
---|
| 186 | # Linux
|
---|
[72] | 187 | ifeq ($(BUILD_PLATFORM),linux)
|
---|
[69] | 188 | PATH_TOOLS := $(PATH_TOOLS_LNX)
|
---|
| 189 | EXEC_X86_WIN32 := wine
|
---|
| 190 | HOSTSUFF_EXE :=
|
---|
| 191 | endif
|
---|
[70] | 192 |
|
---|
[69] | 193 | # Win32
|
---|
[72] | 194 | ifeq ($(BUILD_PLATFORM),win32)
|
---|
[69] | 195 | PATH_TOOLS := $(PATH_TOOLS_W32)
|
---|
| 196 | EXEC_X86_WIN32 :=
|
---|
| 197 | HOSTSUFF_EXE := .exe
|
---|
| 198 | endif
|
---|
| 199 |
|
---|
[73] | 200 | #
|
---|
| 201 | # Build target setup.
|
---|
| 202 | #
|
---|
| 203 | ifeq ($(BUILD_TARGET),os2)
|
---|
| 204 | SUFF_OBJ := .obj
|
---|
| 205 | SUFF_LIB := .lib
|
---|
| 206 | SUFF_DLL := .dll
|
---|
| 207 | SUFF_EXE := .exe
|
---|
| 208 | SUFF_DRV := .sys
|
---|
| 209 | SUFF_RES := .res
|
---|
| 210 | endif
|
---|
| 211 | ifeq ($(BUILD_TARGET),win32)
|
---|
| 212 | SUFF_OBJ := .obj
|
---|
| 213 | SUFF_LIB := .lib
|
---|
| 214 | SUFF_DLL := .dll
|
---|
| 215 | SUFF_EXE := .exe
|
---|
| 216 | SUFF_DRV := .sys
|
---|
| 217 | SUFF_RES := .res
|
---|
| 218 | endif
|
---|
| 219 | ifeq ($(BUILD_TARGET),linux)
|
---|
| 220 | SUFF_OBJ := .o
|
---|
| 221 | SUFF_LIB := .a
|
---|
| 222 | SUFF_DLL := .so
|
---|
| 223 | SUFF_EXE :=
|
---|
| 224 | SUFF_DRV := .a
|
---|
| 225 | SUFF_RES :=
|
---|
| 226 | endif
|
---|
[69] | 227 |
|
---|
[73] | 228 |
|
---|
[69] | 229 | #
|
---|
| 230 | # Standard kBuild tools.
|
---|
| 231 | #
|
---|
| 232 | DEP := $(PATH_TOOLS)/kDep$(HOSTSUFF_EXE)
|
---|
| 233 | # Standard Unix shell utils.
|
---|
| 234 | MKDIR := $(PATH_TOOLS)/mkdir$(HOSTSUFF_EXE)
|
---|
| 235 | RM := $(PATH_TOOLS)/rm$(HOSTSUFF_EXE)
|
---|
| 236 | CP := $(PATH_TOOLS)/mv$(HOSTSUFF_EXE)
|
---|
| 237 | MV := $(PATH_TOOLS)/cp$(HOSTSUFF_EXE)
|
---|
| 238 | SED := $(PATH_TOOLS)/sed$(HOSTSUFF_EXE)
|
---|
| 239 | CAT := $(PATH_TOOLS)/cat$(HOSTSUFF_EXE)
|
---|
| 240 | # Bourn shell clone.
|
---|
| 241 | MAKESHELL := $(PATH_TOOLS)/ash$(HOSTSUFF_EXE)
|
---|
| 242 | SHELL := $(MAKESHELL)
|
---|
| 243 | export SHELL MAKESHELL
|
---|
| 244 |
|
---|
| 245 |
|
---|
| 246 | #
|
---|
[73] | 247 | # Message macros.
|
---|
[75] | 248 | #
|
---|
| 249 |
|
---|
[73] | 250 | ifndef BUILD_QUIET
|
---|
[75] | 251 | ifdef BUILD_DEBUG
|
---|
| 252 | BUILD_VERBOSE := 9
|
---|
| 253 | endif
|
---|
[73] | 254 | MSG_L1 = @echo "kBuild: $1"
|
---|
| 255 | ifdef BUILD_VERBOSE
|
---|
| 256 | MSG_L2 = @echo "kBuild: $1"
|
---|
[75] | 257 | QUIET :=
|
---|
[73] | 258 | else
|
---|
[75] | 259 | QUIET := @
|
---|
[73] | 260 | MSG_L2 =
|
---|
| 261 | endif
|
---|
| 262 | ifdef BUILD_DEBUG
|
---|
| 263 | MSG_L3 = @echo "kBuild: $1"
|
---|
| 264 | else
|
---|
| 265 | MSG_L3 =
|
---|
| 266 | endif
|
---|
| 267 | else
|
---|
[75] | 268 | QUIET :=
|
---|
[73] | 269 | MSG_L1 =
|
---|
| 270 | MSG_L2 =
|
---|
| 271 | MSG_L3 =
|
---|
| 272 | endif
|
---|
| 273 |
|
---|
| 274 | #
|
---|
[69] | 275 | # This is how we find the closest config.kmk.
|
---|
| 276 | # It's a little hacky but I think it works fine.
|
---|
[70] | 277 | #
|
---|
| 278 | _CFGDIR := .
|
---|
[78] | 279 | _CFGFILES := ./Config.kmk ./config.kmk
|
---|
[69] | 280 | define def_include_config
|
---|
[78] | 281 | $(eval _CFGDIR := $(_CFGDIR)/$(dir))
|
---|
| 282 | _CFGFILES += $(_CFGDIR)/Config.kmk $(_CFGDIR)/config.kmk
|
---|
[69] | 283 | endef
|
---|
| 284 | # walk down the _RELATIVE_ path specified by DEPTH.
|
---|
[78] | 285 | $(foreach dir,$(subst /, ,$(DEPTH)), $(eval $(def_include_config)) )
|
---|
[69] | 286 | # add the default config file.
|
---|
[78] | 287 | _CFGFILE := $(firstword $(wildcard $(_CFGFILES) $(FILE_KBUILD_CONFIG)))
|
---|
[69] | 288 | _CFGFILES :=
|
---|
| 289 | _CFGDIR :=
|
---|
| 290 |
|
---|
| 291 | # Include the config.kmk we found file (or the default one).
|
---|
| 292 | include $(_CFGFILE)
|
---|
| 293 |
|
---|
| 294 |
|
---|
| 295 | # end-of-file-content
|
---|
[72] | 296 | __header_kmk__ := 1
|
---|
[69] | 297 | endif # __header_kmk__
|
---|