| 1 | #!/bin/sh
|
|---|
| 2 | # $Id: env.sh 1517 2008-04-09 22:25:57Z bird $
|
|---|
| 3 | ## @file
|
|---|
| 4 | # Environment setup script.
|
|---|
| 5 | #
|
|---|
| 6 |
|
|---|
| 7 | #
|
|---|
| 8 | # Copyright (c) 2005-2008 knut st. osmundsen <bird-kBuild-spam@anduin.net>
|
|---|
| 9 | #
|
|---|
| 10 | # This file is part of kBuild.
|
|---|
| 11 | #
|
|---|
| 12 | # kBuild is free software; you can redistribute it and/or modify
|
|---|
| 13 | # it under the terms of the GNU General Public License as published by
|
|---|
| 14 | # the Free Software Foundation; either version 2 of the License, or
|
|---|
| 15 | # (at your option) any later version.
|
|---|
| 16 | #
|
|---|
| 17 | # kBuild is distributed in the hope that it will be useful,
|
|---|
| 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 20 | # GNU General Public License for more details.
|
|---|
| 21 | #
|
|---|
| 22 | # You should have received a copy of the GNU General Public License
|
|---|
| 23 | # along with kBuild; if not, write to the Free Software
|
|---|
| 24 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|---|
| 25 | #
|
|---|
| 26 | #
|
|---|
| 27 | #set -x
|
|---|
| 28 |
|
|---|
| 29 | #
|
|---|
| 30 | # Check if we're in eval mode or not.
|
|---|
| 31 | #
|
|---|
| 32 | ERR_REDIR=1
|
|---|
| 33 | DBG_REDIR=1
|
|---|
| 34 | EVAL_OPT=
|
|---|
| 35 | DBG_OPT=
|
|---|
| 36 | QUIET_OPT=
|
|---|
| 37 | FULL_OPT=
|
|---|
| 38 | LEGACY_OPT="true"
|
|---|
| 39 | VAR_OPT=
|
|---|
| 40 | VALUE_ONLY_OPT=
|
|---|
| 41 | while test $# -gt 0;
|
|---|
| 42 | do
|
|---|
| 43 | case "$1" in
|
|---|
| 44 | "--debug")
|
|---|
| 45 | DBG_OPT="true"
|
|---|
| 46 | ;;
|
|---|
| 47 | "--no-debug")
|
|---|
| 48 | DBG_OPT=
|
|---|
| 49 | ;;
|
|---|
| 50 | "--quiet")
|
|---|
| 51 | QUIET_OPT="true"
|
|---|
| 52 | ;;
|
|---|
| 53 | "--verbose")
|
|---|
| 54 | QUIET_OPT=
|
|---|
| 55 | ;;
|
|---|
| 56 | "--full")
|
|---|
| 57 | FULL_OPT="true"
|
|---|
| 58 | ;;
|
|---|
| 59 | "--normal")
|
|---|
| 60 | FULL_OPT=
|
|---|
| 61 | ;;
|
|---|
| 62 | "--legacy")
|
|---|
| 63 | LEGACY_OPT="true"
|
|---|
| 64 | ;;
|
|---|
| 65 | "--no-legacy")
|
|---|
| 66 | LEGACY_OPT=
|
|---|
| 67 | ;;
|
|---|
| 68 | "--eval")
|
|---|
| 69 | EVAL_OPT="true"
|
|---|
| 70 | ERR_REDIR=2
|
|---|
| 71 | DBG_REDIR=2
|
|---|
| 72 | ;;
|
|---|
| 73 | "--var")
|
|---|
| 74 | shift
|
|---|
| 75 | VAR_OPT="${VAR_OPT} $1"
|
|---|
| 76 | ERR_REDIR=2
|
|---|
| 77 | DBG_REDIR=2
|
|---|
| 78 | ;;
|
|---|
| 79 | "--value-only")
|
|---|
| 80 | VALUE_ONLY_OPT="true"
|
|---|
| 81 | ;;
|
|---|
| 82 | "--name-and-value")
|
|---|
| 83 | VALUE_ONLY_OPT=
|
|---|
| 84 | ;;
|
|---|
| 85 | "--help")
|
|---|
| 86 | echo "kBuild Environment Setup Script, v0.1.3"
|
|---|
| 87 | echo ""
|
|---|
| 88 | echo "syntax: $0 [options] [command [args]]"
|
|---|
| 89 | echo " or: $0 [options] --var <varname>"
|
|---|
| 90 | echo " or: $0 [options] --eval"
|
|---|
| 91 | echo " or: $0 [options] --eval --var <varname>"
|
|---|
| 92 | echo ""
|
|---|
| 93 | echo "The first form will execute the command, or if no command is givne start"
|
|---|
| 94 | echo "an interactive shell."
|
|---|
| 95 | echo "The second form will print the specfified variable(s)."
|
|---|
| 96 | echo "The third form will print all exported variables suitable for bourne shell"
|
|---|
| 97 | echo "evalutation."
|
|---|
| 98 | echo "The forth form will only print the specified variable(s)."
|
|---|
| 99 | echo ""
|
|---|
| 100 | echo "Options:"
|
|---|
| 101 | echo " --debug, --no-debug"
|
|---|
| 102 | echo " Controls debug output. Default: --no-debug"
|
|---|
| 103 | echo " --quiet, --verbose"
|
|---|
| 104 | echo " Controls informational output. Default: --verbose"
|
|---|
| 105 | echo " --full, --normal"
|
|---|
| 106 | echo " Controls the variable set. Default: --normal"
|
|---|
| 107 | echo " --legacy, --no-legacy"
|
|---|
| 108 | echo " Include legacy variables in result. Default: --legacy"
|
|---|
| 109 | echo " --value-only, --name-and-value"
|
|---|
| 110 | echo " Controls what the result of a --var query. Default: --name-and-value"
|
|---|
| 111 | echo ""
|
|---|
| 112 | exit 1
|
|---|
| 113 | ;;
|
|---|
| 114 | *)
|
|---|
| 115 | break
|
|---|
| 116 | ;;
|
|---|
| 117 | esac
|
|---|
| 118 | shift
|
|---|
| 119 | done
|
|---|
| 120 |
|
|---|
| 121 |
|
|---|
| 122 | #
|
|---|
| 123 | # Deal with legacy environment variables.
|
|---|
| 124 | #
|
|---|
| 125 | if test -n "$PATH_KBUILD"; then
|
|---|
| 126 | if test -n "$KBUILD_PATH" -a "$KBUILD_PATH" != "$PATH_KBUILD"; then
|
|---|
| 127 | echo "$0: error: KBUILD_PATH ($KBUILD_PATH) and PATH_KBUILD ($PATH_KBUILD) disagree." 1>&${ERR_REDIR}
|
|---|
| 128 | sleep 1
|
|---|
| 129 | exit 1
|
|---|
| 130 | fi
|
|---|
| 131 | KBUILD_PATH=$PATH_KBUILD
|
|---|
| 132 | fi
|
|---|
| 133 | if test -n "$PATH_KBUILD_BIN"; then
|
|---|
| 134 | if test -n "$KBUILD_BIN_PATH" -a "$KBUILD_BIN_PATH" != "$PATH_KBUILD_BIN"; then
|
|---|
| 135 | echo "$0: error: KBUILD_BIN_PATH ($KBUILD_BIN_PATH) and PATH_KBUILD_BIN ($PATH_KBUILD_BIN) disagree." 1>&${ERR_REDIR}
|
|---|
| 136 | sleep 1
|
|---|
| 137 | exit 1
|
|---|
| 138 | fi
|
|---|
| 139 | KBUILD_BIN_PATH=$PATH_KBUILD_BIN
|
|---|
| 140 | fi
|
|---|
| 141 |
|
|---|
| 142 | if test -n "$BUILD_TYPE"; then
|
|---|
| 143 | if test -n "$KBUILD_TYPE" -a "$KBUILD_TYPE" != "$BUILD_TYPE"; then
|
|---|
| 144 | echo "$0: error: KBUILD_TYPE ($KBUILD_TYPE) and BUILD_TYPE ($BUILD_TYPE) disagree." 1>&${ERR_REDIR}
|
|---|
| 145 | sleep 1
|
|---|
| 146 | exit 1
|
|---|
| 147 | fi
|
|---|
| 148 | KBUILD_TYPE=$BUILD_TYPE
|
|---|
| 149 | fi
|
|---|
| 150 |
|
|---|
| 151 | if test -n "$BUILD_PLATFORM"; then
|
|---|
| 152 | if test -n "$KBUILD_HOST" -a "$KBUILD_HOST" != "$BUILD_PLATFORM"; then
|
|---|
| 153 | echo "$0: error: KBUILD_HOST ($KBUILD_HOST) and BUILD_PLATFORM ($BUILD_PLATFORM) disagree." 1>&${ERR_REDIR}
|
|---|
| 154 | sleep 1
|
|---|
| 155 | exit 1
|
|---|
| 156 | fi
|
|---|
| 157 | KBUILD_HOST=$BUILD_PLATFORM
|
|---|
| 158 | fi
|
|---|
| 159 | if test -n "$BUILD_PLATFORM_ARCH"; then
|
|---|
| 160 | if test -n "$KBUILD_HOST_ARCH" -a "$KBUILD_HOST_ARCH" != "$BUILD_PLATFORM_ARCH"; then
|
|---|
| 161 | echo "$0: error: KBUILD_HOST_ARCH ($KBUILD_HOST_ARCH) and BUILD_PLATFORM_ARCH ($BUILD_PLATFORM_ARCH) disagree." 1>&${ERR_REDIR}
|
|---|
| 162 | sleep 1
|
|---|
| 163 | exit 1
|
|---|
| 164 | fi
|
|---|
| 165 | KBUILD_HOST_ARCH=$BUILD_PLATFORM_ARCH
|
|---|
| 166 | fi
|
|---|
| 167 | if test -n "$BUILD_PLATFORM_CPU"; then
|
|---|
| 168 | if test -n "$KBUILD_HOST_CPU" -a "$KBUILD_HOST_CPU" != "$BUILD_PLATFORM_CPU"; then
|
|---|
| 169 | echo "$0: error: KBUILD_HOST_CPU ($KBUILD_HOST_CPU) and BUILD_PLATFORM_CPU ($BUILD_PLATFORM_CPU) disagree." 1>&${ERR_REDIR}
|
|---|
| 170 | sleep 1
|
|---|
| 171 | exit 1
|
|---|
| 172 | fi
|
|---|
| 173 | KBUILD_HOST_CPU=$BUILD_PLATFORM_CPU
|
|---|
| 174 | fi
|
|---|
| 175 |
|
|---|
| 176 | if test -n "$BUILD_TARGET"; then
|
|---|
| 177 | if test -n "$KBUILD_TARGET" -a "$KBUILD_TARGET" != "$BUILD_TARGET"; then
|
|---|
| 178 | echo "$0: error: KBUILD_TARGET ($KBUILD_TARGET) and BUILD_TARGET ($BUILD_TARGET) disagree." 1>&${ERR_REDIR}
|
|---|
| 179 | sleep 1
|
|---|
| 180 | exit 1
|
|---|
| 181 | fi
|
|---|
| 182 | KBUILD_TARGET=$BUILD_TARGET
|
|---|
| 183 | fi
|
|---|
| 184 | if test -n "$BUILD_TARGET_ARCH"; then
|
|---|
| 185 | if test -n "$KBUILD_TARGET_ARCH" -a "$KBUILD_TARGET_ARCH" != "$BUILD_TARGET_ARCH"; then
|
|---|
| 186 | echo "$0: error: KBUILD_TARGET_ARCH ($KBUILD_TARGET_ARCH) and BUILD_TARGET_ARCH ($BUILD_TARGET_ARCH) disagree." 1>&${ERR_REDIR}
|
|---|
| 187 | sleep 1
|
|---|
| 188 | exit 1
|
|---|
| 189 | fi
|
|---|
| 190 | KBUILD_TARGET_ARCH=$BUILD_TARGET_ARCH
|
|---|
| 191 | fi
|
|---|
| 192 | if test -n "$BUILD_TARGET_CPU"; then
|
|---|
| 193 | if test -n "$KBUILD_TARGET_CPU" -a "$KBUILD_TARGET_CPU" != "$BUILD_TARGET_CPU"; then
|
|---|
| 194 | echo "$0: error: KBUILD_TARGET_CPU ($KBUILD_TARGET_CPU) and BUILD_TARGET_CPU ($BUILD_TARGET_CPU) disagree." 1>&${ERR_REDIR}
|
|---|
| 195 | sleep 1
|
|---|
| 196 | exit 1
|
|---|
| 197 | fi
|
|---|
| 198 | KBUILD_TARGET_CPU=$BUILD_TARGET_CPU
|
|---|
| 199 | fi
|
|---|
| 200 |
|
|---|
| 201 |
|
|---|
| 202 | #
|
|---|
| 203 | # Set default build type.
|
|---|
| 204 | #
|
|---|
| 205 | if test -z "$KBUILD_TYPE"; then
|
|---|
| 206 | KBUILD_TYPE=release
|
|---|
| 207 | fi
|
|---|
| 208 | test -n "$DBG_OPT" && echo "dbg: KBUILD_TYPE=$KBUILD_TYPE" 1>&${DBG_REDIR}
|
|---|
| 209 |
|
|---|
| 210 | #
|
|---|
| 211 | # Determin the host platform.
|
|---|
| 212 | #
|
|---|
| 213 | # The CPU isn't important, only the other two are. But, since the cpu,
|
|---|
| 214 | # arch and platform (and build type) share a common key space, try make
|
|---|
| 215 | # sure any new additions are unique. (See header.kmk, KBUILD_OSES/ARCHES.)
|
|---|
| 216 | #
|
|---|
| 217 | if test -z "$KBUILD_HOST"; then
|
|---|
| 218 | KBUILD_HOST=`uname`
|
|---|
| 219 | case "$KBUILD_HOST" in
|
|---|
| 220 | linux|Linux|GNU/Linux|LINUX)
|
|---|
| 221 | KBUILD_HOST=linux
|
|---|
| 222 | ;;
|
|---|
| 223 |
|
|---|
| 224 | os2|OS/2|OS2)
|
|---|
| 225 | KBUILD_HOST=os2
|
|---|
| 226 | ;;
|
|---|
| 227 |
|
|---|
| 228 | freebsd|FreeBSD|FREEBSD)
|
|---|
| 229 | KBUILD_HOST=freebsd
|
|---|
| 230 | ;;
|
|---|
| 231 |
|
|---|
| 232 | openbsd|OpenBSD|OPENBSD)
|
|---|
| 233 | KBUILD_HOST=openbsd
|
|---|
| 234 | ;;
|
|---|
| 235 |
|
|---|
| 236 | netbsd|NetBSD|NETBSD)
|
|---|
| 237 | KBUILD_HOST=netbsd
|
|---|
| 238 | ;;
|
|---|
| 239 |
|
|---|
| 240 | Darwin|darwin)
|
|---|
| 241 | KBUILD_HOST=darwin
|
|---|
| 242 | ;;
|
|---|
| 243 |
|
|---|
| 244 | SunOS)
|
|---|
| 245 | KBUILD_HOST=solaris
|
|---|
| 246 | ;;
|
|---|
| 247 |
|
|---|
| 248 | WindowsNT|CYGWIN_NT-*)
|
|---|
| 249 | KBUILD_HOST=win
|
|---|
| 250 | ;;
|
|---|
| 251 |
|
|---|
| 252 | *)
|
|---|
| 253 | echo "$0: unknown os $KBUILD_HOST" 1>&${ERR_REDIR}
|
|---|
| 254 | sleep 1
|
|---|
| 255 | exit 1
|
|---|
| 256 | ;;
|
|---|
| 257 | esac
|
|---|
| 258 | fi
|
|---|
| 259 | test -n "$DBG_OPT" && echo "dbg: KBUILD_HOST=$KBUILD_HOST" 1>&${DBG_REDIR}
|
|---|
| 260 |
|
|---|
| 261 | if test -z "$KBUILD_HOST_ARCH"; then
|
|---|
| 262 | # Try deduce it from the cpu if given.
|
|---|
| 263 | if test -n "$KBUILD_HOST_CPU"; then
|
|---|
| 264 | case "$KBUILD_HOST_CPU" in
|
|---|
| 265 | i[3456789]86)
|
|---|
| 266 | KBUILD_HOST_ARCH='x86'
|
|---|
| 267 | ;;
|
|---|
| 268 | k8|k8l|k9|k10)
|
|---|
| 269 | KBUILD_HOST_ARCH='amd64'
|
|---|
| 270 | ;;
|
|---|
| 271 | esac
|
|---|
| 272 | fi
|
|---|
| 273 | fi
|
|---|
| 274 | if test -z "$KBUILD_HOST_ARCH"; then
|
|---|
| 275 | # Use uname -m or isainfo (lots of guesses here, please help clean this up...)
|
|---|
| 276 | if test "$KBUILD_HOST" = "solaris"; then
|
|---|
| 277 | KBUILD_HOST_ARCH=`isainfo | cut -f 1 -d ' '`
|
|---|
| 278 |
|
|---|
| 279 | else
|
|---|
| 280 | KBUILD_HOST_ARCH=`uname -m`
|
|---|
| 281 | fi
|
|---|
| 282 | case "$KBUILD_HOST_ARCH" in
|
|---|
| 283 | x86_64|AMD64|amd64|k8|k8l|k9|k10)
|
|---|
| 284 | KBUILD_HOST_ARCH='amd64'
|
|---|
| 285 | ;;
|
|---|
| 286 | x86|i86pc|ia32|i[3456789]86)
|
|---|
| 287 | KBUILD_HOST_ARCH='x86'
|
|---|
| 288 | ;;
|
|---|
| 289 | sparc32|sparc)
|
|---|
| 290 | KBUILD_HOST_ARCH='sparc32'
|
|---|
| 291 | ;;
|
|---|
| 292 | sparc64)
|
|---|
| 293 | KBUILD_HOST_ARCH='sparc64'
|
|---|
| 294 | ;;
|
|---|
| 295 | s390)
|
|---|
| 296 | KBUILD_HOST_ARCH='s390'
|
|---|
| 297 | ;;
|
|---|
| 298 | s390x)
|
|---|
| 299 | KBUILD_HOST_ARCH='s390x'
|
|---|
| 300 | ;;
|
|---|
| 301 | ppc32|ppc|powerpc)
|
|---|
| 302 | KBUILD_HOST_ARCH='ppc32'
|
|---|
| 303 | ;;
|
|---|
| 304 | ppc64|powerpc64)
|
|---|
| 305 | KBUILD_HOST_ARCH='ppc64'
|
|---|
| 306 | ;;
|
|---|
| 307 | mips32|mips)
|
|---|
| 308 | KBUILD_HOST_ARCH='mips32'
|
|---|
| 309 | ;;
|
|---|
| 310 | mips64)
|
|---|
| 311 | KBUILD_HOST_ARCH='mips64'
|
|---|
| 312 | ;;
|
|---|
| 313 | ia64)
|
|---|
| 314 | KBUILD_HOST_ARCH='ia64'
|
|---|
| 315 | ;;
|
|---|
| 316 | #hppa32|hppa|parisc32|parisc)?
|
|---|
| 317 | hppa32|parisc32)
|
|---|
| 318 | KBUILD_HOST_ARCH='hppa32'
|
|---|
| 319 | ;;
|
|---|
| 320 | hppa64|parisc64)
|
|---|
| 321 | KBUILD_HOST_ARCH='hppa64'
|
|---|
| 322 | ;;
|
|---|
| 323 | arm|armv4l|armv5tel)
|
|---|
| 324 | KBUILD_HOST_ARCH='arm'
|
|---|
| 325 | ;;
|
|---|
| 326 | alpha)
|
|---|
| 327 | KBUILD_HOST_ARCH='alpha'
|
|---|
| 328 | ;;
|
|---|
| 329 |
|
|---|
| 330 | *) echo "$0: unknown cpu/arch - $KBUILD_HOST_ARCH" 1>&${ERR_REDIR}
|
|---|
| 331 | sleep 1
|
|---|
| 332 | exit 1
|
|---|
| 333 | ;;
|
|---|
| 334 | esac
|
|---|
| 335 |
|
|---|
| 336 | fi
|
|---|
| 337 | test -n "$DBG_OPT" && echo "dbg: KBUILD_HOST_ARCH=$KBUILD_HOST_ARCH" 1>&${DBG_REDIR}
|
|---|
| 338 |
|
|---|
| 339 | if test -z "$KBUILD_HOST_CPU"; then
|
|---|
| 340 | KBUILD_HOST_CPU="blend"
|
|---|
| 341 | fi
|
|---|
| 342 | test -n "$DBG_OPT" && echo "dbg: KBUILD_HOST_CPU=$KBUILD_HOST_CPU" 1>&${DBG_REDIR}
|
|---|
| 343 |
|
|---|
| 344 | #
|
|---|
| 345 | # The target platform.
|
|---|
| 346 | # Defaults to the host when not specified.
|
|---|
| 347 | #
|
|---|
| 348 | if test -z "$KBUILD_TARGET"; then
|
|---|
| 349 | KBUILD_TARGET="$KBUILD_HOST"
|
|---|
| 350 | fi
|
|---|
| 351 | test -n "$DBG_OPT" && echo "dbg: KBUILD_TARGET=$KBUILD_TARGET" 1>&${DBG_REDIR}
|
|---|
| 352 |
|
|---|
| 353 | if test -z "$KBUILD_TARGET_ARCH"; then
|
|---|
| 354 | KBUILD_TARGET_ARCH="$KBUILD_HOST_ARCH"
|
|---|
| 355 | fi
|
|---|
| 356 | test -n "$DBG_OPT" && echo "dbg: KBUILD_TARGET_ARCH=$KBUILD_TARGET_ARCH" 1>&${DBG_REDIR}
|
|---|
| 357 |
|
|---|
| 358 | if test -z "$KBUILD_TARGET_CPU"; then
|
|---|
| 359 | if test "$KBUILD_TARGET_ARCH" = "$KBUILD_HOST_ARCH"; then
|
|---|
| 360 | KBUILD_TARGET_CPU="$KBUILD_HOST_CPU"
|
|---|
| 361 | else
|
|---|
| 362 | KBUILD_TARGET_CPU="blend"
|
|---|
| 363 | fi
|
|---|
| 364 | fi
|
|---|
| 365 | test -n "$DBG_OPT" && echo "dbg: KBUILD_TARGET_CPU=$KBUILD_TARGET_CPU" 1>&${DBG_REDIR}
|
|---|
| 366 |
|
|---|
| 367 | #
|
|---|
| 368 | # Determin executable extension and path separator.
|
|---|
| 369 | #
|
|---|
| 370 | _SUFF_EXE=
|
|---|
| 371 | _PATH_SEP=":"
|
|---|
| 372 | case "$KBUILD_HOST" in
|
|---|
| 373 | os2|win|nt)
|
|---|
| 374 | _SUFF_EXE=".exe"
|
|---|
| 375 | _PATH_SEP=";"
|
|---|
| 376 | ;;
|
|---|
| 377 | esac
|
|---|
| 378 |
|
|---|
| 379 | #
|
|---|
| 380 | # Determin KBUILD_PATH from the script location and calc KBUILD_BIN_PATH from there.
|
|---|
| 381 | #
|
|---|
| 382 | if test -z "$KBUILD_PATH"; then
|
|---|
| 383 | KBUILD_PATH=`dirname "$0"`
|
|---|
| 384 | KBUILD_PATH=`cd "$KBUILD_PATH" ; /bin/pwd`
|
|---|
| 385 | fi
|
|---|
| 386 | if test ! -f "$KBUILD_PATH/footer.kmk" -o ! -f "$KBUILD_PATH/header.kmk" -o ! -f "$KBUILD_PATH/rules.kmk"; then
|
|---|
| 387 | echo "$0: error: KBUILD_PATH ($KBUILD_PATH) is not pointing to a popluated kBuild directory." 1>&${ERR_REDIR}
|
|---|
| 388 | sleep 1
|
|---|
| 389 | exit 1
|
|---|
| 390 | fi
|
|---|
| 391 | test -n "$DBG_OPT" && echo "dbg: KBUILD_PATH=$KBUILD_PATH" 1>&${DBG_REDIR}
|
|---|
| 392 |
|
|---|
| 393 | if test -z "$KBUILD_BIN_PATH"; then
|
|---|
| 394 | KBUILD_BIN_PATH="${KBUILD_PATH}/bin/${KBUILD_HOST}.${KBUILD_HOST_ARCH}"
|
|---|
| 395 | fi
|
|---|
| 396 | test -n "$DBG_OPT" && echo "dbg: KBUILD_BIN_PATH=${KBUILD_BIN_PATH}" 1>&${DBG_REDIR}
|
|---|
| 397 |
|
|---|
| 398 | #
|
|---|
| 399 | # Make shell - OS/2 only.
|
|---|
| 400 | # Remove this!
|
|---|
| 401 | #
|
|---|
| 402 | if test "$KBUILD_HOST" = "os2"; then
|
|---|
| 403 | export MAKESHELL="${KBUILD_BIN_PATH}/kmk_ash${_SUFF_EXE}";
|
|---|
| 404 | fi
|
|---|
| 405 |
|
|---|
| 406 | #
|
|---|
| 407 | # Add the bin/x.y/ directory to the PATH.
|
|---|
| 408 | # NOTE! Once bootstrapped this is the only thing that is actually necessary.
|
|---|
| 409 | #
|
|---|
| 410 | PATH="${KBUILD_BIN_PATH}${_PATH_SEP}$PATH"
|
|---|
| 411 | test -n "$DBG_OPT" && echo "dbg: PATH=$PATH" 1>&${DBG_REDIR}
|
|---|
| 412 |
|
|---|
| 413 | #
|
|---|
| 414 | # Sanity and x bits.
|
|---|
| 415 | #
|
|---|
| 416 | if test ! -d "${KBUILD_BIN_PATH}/"; then
|
|---|
| 417 | echo "$0: warning: The bin directory for this platform doesn't exists. (${KBUILD_BIN_PATH}/)" 1>&${ERR_REDIR}
|
|---|
| 418 | else
|
|---|
| 419 | for prog in kmk kDepPre kDepIDB kmk_append kmk_ash kmk_cat kmk_cp kmk_echo kmk_install kmk_ln kmk_mkdir kmk_mv kmk_rm kmk_rmdir kmk_sed;
|
|---|
| 420 | do
|
|---|
| 421 | chmod a+x ${KBUILD_BIN_PATH}/${prog} > /dev/null 2>&1
|
|---|
| 422 | if test ! -f "${KBUILD_BIN_PATH}/${prog}${_SUFF_EXE}"; then
|
|---|
| 423 | echo "$0: warning: The ${prog} program doesn't exist for this platform. (${KBUILD_BIN_PATH}/${prog}${_SUFF_EXE})" 1>&${ERR_REDIR}
|
|---|
| 424 | fi
|
|---|
| 425 | done
|
|---|
| 426 | fi
|
|---|
| 427 |
|
|---|
| 428 | #
|
|---|
| 429 | # The environment is in place, now take the requested action.
|
|---|
| 430 | #
|
|---|
| 431 | if test -n "${VAR_OPT}"; then
|
|---|
| 432 | # Echo variable values or variable export statements.
|
|---|
| 433 | for var in ${VAR_OPT};
|
|---|
| 434 | do
|
|---|
| 435 | val=
|
|---|
| 436 | case "$var" in
|
|---|
| 437 | PATH)
|
|---|
| 438 | val=$PATH
|
|---|
| 439 | ;;
|
|---|
| 440 | KBUILD_PATH)
|
|---|
| 441 | val=$KBUILD_PATH
|
|---|
| 442 | ;;
|
|---|
| 443 | KBUILD_BIN_PATH)
|
|---|
| 444 | val=$KBUILD_BIN_PATH
|
|---|
| 445 | ;;
|
|---|
| 446 | KBUILD_HOST)
|
|---|
| 447 | val=$KBUILD_HOST
|
|---|
| 448 | ;;
|
|---|
| 449 | KBUILD_HOST_ARCH)
|
|---|
| 450 | val=$KBUILD_HOST_ARCH
|
|---|
| 451 | ;;
|
|---|
| 452 | KBUILD_HOST_CPU)
|
|---|
| 453 | val=$KBUILD_HOST_CPU
|
|---|
| 454 | ;;
|
|---|
| 455 | KBUILD_TARGET)
|
|---|
| 456 | val=$KBUILD_TARGET
|
|---|
| 457 | ;;
|
|---|
| 458 | KBUILD_TARGET_ARCH)
|
|---|
| 459 | val=$KBUILD_TARGET_ARCH
|
|---|
| 460 | ;;
|
|---|
| 461 | KBUILD_TARGET_CPU)
|
|---|
| 462 | val=$KBUILD_TARGET_CPU
|
|---|
| 463 | ;;
|
|---|
| 464 | KBUILD_TYPE)
|
|---|
| 465 | val=$KBUILD_TYPE
|
|---|
| 466 | ;;
|
|---|
| 467 | *)
|
|---|
| 468 | echo "$0: error: Unknown variable $var specified in --var request." 1>&${ERR_REDIR}
|
|---|
| 469 | sleep 1
|
|---|
| 470 | exit 1
|
|---|
| 471 | ;;
|
|---|
| 472 | esac
|
|---|
| 473 |
|
|---|
| 474 | if test -n "$EVAL_OPT"; then
|
|---|
| 475 | echo "export $var=$val"
|
|---|
| 476 | else
|
|---|
| 477 | if test -n "$VALUE_ONLY_OPT"; then
|
|---|
| 478 | echo "$val"
|
|---|
| 479 | else
|
|---|
| 480 | echo "$var=$val"
|
|---|
| 481 | fi
|
|---|
| 482 | fi
|
|---|
| 483 | done
|
|---|
| 484 | else
|
|---|
| 485 | if test -n "$EVAL_OPT"; then
|
|---|
| 486 | # Echo statements for the shell to evaluate.
|
|---|
| 487 | test -n "$DBG_OPT" && echo "dbg: echoing exported variables" 1>&${DBG_REDIR}
|
|---|
| 488 | echo "export PATH=${PATH}"
|
|---|
| 489 | if test -n "${FULL_OPT}"; then
|
|---|
| 490 | echo "export KBUILD_PATH=${KBUILD_PATH}"
|
|---|
| 491 | echo "export KBUILD_TYPE=${KBUILD_TYPE}"
|
|---|
| 492 | echo "export KBUILD_HOST=${KBUILD_HOST}"
|
|---|
| 493 | echo "export KBUILD_HOST_ARCH=${KBUILD_HOST_ARCH}"
|
|---|
| 494 | echo "export KBUILD_HOST_CPU=${KBUILD_HOST_CPU}"
|
|---|
| 495 | echo "export KBUILD_TARGET=${KBUILD_TARGET}"
|
|---|
| 496 | echo "export KBUILD_TARGET_ARCH=${KBUILD_TARGET_ARCH}"
|
|---|
| 497 | echo "export KBUILD_TARGET_CPU=${KBUILD_TARGET_CPU}"
|
|---|
| 498 |
|
|---|
| 499 | if test -n "${LEGACY_OPT}"; then
|
|---|
| 500 | echo "export PATH_KBUILD=${KBUILD_PATH}"
|
|---|
| 501 | echo "export BUILD_TYPE=${KBUILD_TYPE}"
|
|---|
| 502 | echo "export BUILD_PLATFORM=${KBUILD_HOST}"
|
|---|
| 503 | echo "export BUILD_PLATFORM_ARCH=${KBUILD_HOST_ARCH}"
|
|---|
| 504 | echo "export BUILD_PLATFORM_CPU=${KBUILD_HOST_CPU}"
|
|---|
| 505 | echo "export BUILD_TARGET=${KBUILD_TARGET}"
|
|---|
| 506 | echo "export BUILD_TARGET_ARCH=${KBUILD_TARGET_ARCH}"
|
|---|
| 507 | echo "export BUILD_TARGET_CPU=${KBUILD_TARGET_CPU}"
|
|---|
| 508 | fi
|
|---|
| 509 | fi
|
|---|
| 510 | else
|
|---|
| 511 | # Export variables.
|
|---|
| 512 | export PATH
|
|---|
| 513 | if test -n "${FULL_OPT}"; then
|
|---|
| 514 | export KBUILD_PATH
|
|---|
| 515 | export KBUILD_TYPE
|
|---|
| 516 | export KBUILD_HOST
|
|---|
| 517 | export KBUILD_HOST_ARCH
|
|---|
| 518 | export KBUILD_HOST_CPU
|
|---|
| 519 | export KBUILD_TARGET
|
|---|
| 520 | export KBUILD_TARGET_ARCH
|
|---|
| 521 | export KBUILD_TARGET_CPU
|
|---|
| 522 |
|
|---|
| 523 | if test -n "${LEGACY_OPT}"; then
|
|---|
| 524 | export PATH_KBUILD=$KBUILD_PATH
|
|---|
| 525 | export BUILD_TYPE=$KBUILD_TYPE
|
|---|
| 526 | export BUILD_PLATFORM=$KBUILD_HOST
|
|---|
| 527 | export BUILD_PLATFORM_ARCH=$KBUILD_HOST_ARCH
|
|---|
| 528 | export BUILD_PLATFORM_CPU=$KBUILD_HOST_CPU
|
|---|
| 529 | export BUILD_TARGET=$KBUILD_TARGET
|
|---|
| 530 | export BUILD_TARGET_ARCH=$KBUILD_TARGET_ARCH
|
|---|
| 531 | export BUILD_TARGET_CPU=$KBUILD_TARGET_CPU
|
|---|
| 532 | fi
|
|---|
| 533 | fi
|
|---|
| 534 |
|
|---|
| 535 | # Execute command or spawn shell.
|
|---|
| 536 | if test $# -eq 0; then
|
|---|
| 537 | test -z "${QUIET_OPT}" && echo "$0: info: Spawning work shell..." 1>&${ERR_REDIR}
|
|---|
| 538 | if test "$TERM" != 'dumb' -a -n "$BASH"; then
|
|---|
| 539 | export PS1='\[\033[01;32m\]\u@\h \[\033[01;34m\]\W \$ \[\033[00m\]'
|
|---|
| 540 | fi
|
|---|
| 541 | $SHELL -i
|
|---|
| 542 | else
|
|---|
| 543 | test -z "${QUIET_OPT}" && echo "$0: info: Executing command: $*" 1>&${ERR_REDIR}
|
|---|
| 544 | $*
|
|---|
| 545 | fi
|
|---|
| 546 | fi
|
|---|
| 547 | fi
|
|---|
| 548 | test -n "$DBG_OPT" && echo "dbg: finished" 1>&${DBG_REDIR}
|
|---|
| 549 |
|
|---|