#
#                             stb225 Project
#                   ---------------------------------
#
# Copyright (C) 2007 NXP B.V.,
# All Rights Reserved.
#
# Filename: setup_windows.sh
#
#
# Rev Date       Author      Comments
#-------------------------------------------------------------------------------
#   1 20070620   batelaan    Initial

# Windows-specific setup script sourced from $PRJROOT/setup.sh
# Used when the build host is running Windows.

# Under Windows we need to use GNU make, not cygwin make, since
# our PRJROOT and therefore all our paths use C:/... paths,
# because we are going to run native Windows tools (WinCE toolchain),
# which expect the C:/... paths.
_SetOverride MAKE $_TMROOT/sde/cygwin/gmake.exe

# TODO: not correct yet for building Linux using Cygwin, only for WInCE.
setup_windows() {
  local PC VISUALSTUDIOCOMMON VISUALSTUDIO WINCE VISUALCWINCE
  if [ "`uname`" = Linux ]; then
    # Attempt to run WinCE tools on Linux PC, using Wine for example!
    PC="$HOME/pc/c"
    VISUALSTUDIOCOMMON="$PC/Program\ Files/Microsoft\ Visual\ Studio\ 8/Common7/Tools"
    WINCE="$PC/WINCE600"
  else
    if [ -z "$VS80COMNTOOLS" ]; then
      echo >&2 "wince_setup.sh: variable VS80COMNTOOLS is undefined"
      echo >&2 ""
      return 1
    fi

    VISUALSTUDIOCOMMON="`cygpath \"${VS80COMNTOOLS}\"`"
    #VISUALSTUDIOCOMMON="${VS80COMNTOOLS/[cC]://cygdrive/c}"
    VISUALSTUDIOCOMMON="`echo \"$VISUALSTUDIOCOMMON\" | tr '\\' /`"
    VISUALSTUDIOCOMMON="${VISUALSTUDIOCOMMON%/}"
    WINCE=c:/WINCE600
  fi
  VISUALSTUDIO="${VISUALSTUDIOCOMMON%/*/*}"
  echo "VISUALSTUDIO = $VISUALSTUDIO"
  #ls $WINCE
  VISUALCWINCE="${VISUALSTUDIO}/VC/ce"
  echo "VISUALCWINCE = $VISUALCWINCE"
  PATH="$VISUALCWINCE/bin/x86_mips:$VISUALCWINCE/Dll/x86:${VISUALSTUDIOCOMMON%/*}/IDE:$PATH"
  echo "cl.exe is found in: `type -p cl.exe`"
#@set PATH=C:\Program Files\Microsoft Visual Studio 8\Common7\IDE;C:\Program Files\Microsoft Visual Studio 8\VC\BIN;C:\Program Files\Microsoft Visual Studio 8\Common7\Tools;C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\bin;C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\bin;C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\bin;C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727;C:\Program Files\Microsoft Visual Studio 8\VC\VCPackages;%PATH%
}

if ! type cl.exe &>/dev/null; then
  setup_windows
fi
unset -f setup_windows
