6360517: ALT_MSDEVTOOLS_PATH and rc.exe location, and rebase location

Reviewed-by: ksrini
diff --git a/jdk/make/Makefile b/jdk/make/Makefile
index 9ec6906..30790be 100644
--- a/jdk/make/Makefile
+++ b/jdk/make/Makefile
@@ -100,7 +100,6 @@
 DEVTOOLS_PATH.desc         = Directory containing zip and unzip
 CUPS_HEADERS_PATH.desc     = Include directory location for CUPS header files
 DXSDK_PATH.desc            = Root directory of DirectX SDK
-MSDEVTOOLS_PATH.desc       = Root directory of VC++ tools (e.g. rc.exe)
 MSVCRT_DLL_PATH.desc       = Directory containing mscvrt.dll
 
 # Make variables to print out (description and value)
@@ -135,12 +134,10 @@
 
 VARIABLE_PRINTVAL_LIST +=       \
     DXSDK_PATH                  \
-    MSDEVTOOLS_PATH             \
     MSVCRT_DLL_PATH
 
 VARIABLE_CHECKDIR_LIST +=       \
     DXSDK_PATH                  \
-    MSDEVTOOLS_PATH             \
     MSVCRT_DLL_PATH
 
 endif
diff --git a/jdk/make/common/shared/Compiler-gcc.gmk b/jdk/make/common/shared/Compiler-gcc.gmk
index b4a4f53..570ea1c 100644
--- a/jdk/make/common/shared/Compiler-gcc.gmk
+++ b/jdk/make/common/shared/Compiler-gcc.gmk
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -36,7 +36,7 @@
   CCC          = $(COMPILER_PATH)g++
   LIBEXE       = $(COMPILER_PATH)lib
   LINK         = $(COMPILER_PATH)link
-  RC           = $(MSDEVTOOLS_PATH)link
+  RC           = $(COMPILER_PATH)rc
   LINK32       = $(LINK)
   RSC          = $(RC)
   # unset any GNU Make settings of MFLAGS and MAKEFLAGS which may mess up nmake
diff --git a/jdk/make/common/shared/Compiler-msvc.gmk b/jdk/make/common/shared/Compiler-msvc.gmk
index 08ea9b3..49a0d5f 100644
--- a/jdk/make/common/shared/Compiler-msvc.gmk
+++ b/jdk/make/common/shared/Compiler-msvc.gmk
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -34,8 +34,6 @@
   CCC          = $(COMPILER_PATH)cl
   LIBEXE       = $(COMPILER_PATH)lib
   LINK         = $(COMPILER_PATH)link
-  RC           = $(MSDEVTOOLS_PATH)rc
-  RSC          = $(MSDEVTOOLS_PATH)rc
   LINK32       = $(LINK)
  
   # Fill in unknown values
@@ -47,7 +45,10 @@
 
   # Compiler version and type (Always get word after "Version")
   CC_VER  := $(shell $(CC) 2>&1 | $(HEAD) -n 1 | $(SED) 's/.*\(Version.*\)/\1/' | $(NAWK) '{print $$2}')
-  
+
+  # The MSDEVTOOLS_PATH is for older compilers, place for rc, mt, etc.
+  _OTHER_TOOLS_PATH = $(MSDEVTOOLS_PATH)
+
   # SDK-64 and MSVC6 put REBASE.EXE in a different places - go figure...
   ifeq ($(ARCH_DATA_MODEL), 32)
     LINK_VER := $(shell $(LINK) | $(HEAD) -n 1 | $(NAWK) '{print $$6}')
@@ -56,43 +57,26 @@
       # This should be: CC_VER=13.10.3077 LINK_VER=7.10.3077
       COMPILER_NAME=Visual Studio .NET 2003 Professional C++
       COMPILER_VERSION=VS2003
+      RC         = $(_OTHER_TOOLS_PATH)rc
       REBASE     = $(COMPILER_PATH)../../Common7/Tools/Bin/rebase
       MTL        = $(COMPILER_PATH)../../Common7/Tools/Bin/midl
-      ifndef COMPILER_PATH
-	COMPILER_PATH := $(error COMPILER_PATH cannot be empty here)
-      endif
     endif
     ifeq ($(CC_MAJORVER), 14)
       COMPILER_NAME=Visual Studio 8
       COMPILER_VERSION=VS2005
+      RC         = $(_OTHER_TOOLS_PATH)rc
       REBASE     = $(COMPILER_PATH)../../Common8/Tools/Bin/rebase
       MTL        = $(COMPILER_PATH)../../Common8/Tools/Bin/midl
-      MT         = $(MSDEVTOOLS_PATH)/mt
-      ifndef COMPILER_PATH
-	COMPILER_PATH := $(error COMPILER_PATH cannot be empty here)
-      endif
+      MT         = $(_OTHER_TOOLS_PATH)/mt
     endif
     ifeq ($(CC_MAJORVER), 15)
       COMPILER_NAME=Visual Studio 9
       COMPILER_VERSION=VS2008
+      RC         = $(_OTHER_TOOLS_PATH)rc
       #rebase and midl moved out of Visual Studio into the SDK:
-      REBASE     = $(MSDEVTOOLS_PATH)/rebase
-      MTL        = $(MSDEVTOOLS_PATH)/midl.exe
-      MT         = $(MSDEVTOOLS_PATH)mt
-      ifndef COMPILER_PATH
-	COMPILER_PATH := $(error COMPILER_PATH cannot be empty here)
-      endif
-    endif
-    ifeq ($(CC_MAJORVER), 16)
-      COMPILER_NAME=Visual Studio 10
-      COMPILER_VERSION=VS2010
-      #rebase and midl moved out of Visual Studio into the SDK:
-      REBASE     = $(MSDEVTOOLS_PATH)/rebase
-      MTL        = $(MSDEVTOOLS_PATH)/midl.exe
-      MT         = $(MSDEVTOOLS_PATH)mt
-      ifndef COMPILER_PATH
-	COMPILER_PATH := $(error COMPILER_PATH cannot be empty here)
-      endif
+      REBASE     = $(_OTHER_TOOLS_PATH)/rebase
+      MTL        = $(_OTHER_TOOLS_PATH)/midl.exe
+      MT         = $(_OTHER_TOOLS_PATH)mt
     endif
   else
     # else ARCH_DATA_MODEL is 64
@@ -105,13 +89,15 @@
         # This should be: CC_VER=13.00.9337.7 LINK_VER=7.00.9337.7
         COMPILER_NAME=Microsoft Platform SDK - November 2001 Edition
         COMPILER_VERSION=VS2003
+        RC = $(_OTHER_TOOLS_PATH)rc
       endif
     endif
     ifeq ($(CC_MAJORVER), 14)
       ifeq ($(ARCH), amd64)
         #rebase and midl moved out of Visual Studio into the SDK:
-        REBASE     = $(MSDEVTOOLS_PATH)/rebase
-        MTL        = $(MSDEVTOOLS_PATH)/midl.exe
+        RC         = $(_OTHER_TOOLS_PATH)/rc
+        REBASE     = $(_OTHER_TOOLS_PATH)/rebase
+        MTL        = $(_OTHER_TOOLS_PATH)/midl.exe
         ifeq ($(CC_MICROVER), 30701)
           # This should be: CC_VER=14.00.30701 LINK_VER=8.00.30701
 	  # WARNING: it says 14, but it is such an early build it doesn't
@@ -135,24 +121,42 @@
       MT = $(MSSDK61)/Bin/X64/mt.exe
       MTL = $(MSSDK61)/Bin/X64/midl.exe
     endif
-    ifeq ($(CC_MAJORVER), 16)
-      COMPILER_NAME=Microsoft Visual Studio 10 (16.00.30319.01)
-      COMPILER_VERSION=VS2010
-      RC = $(MSDEVTOOLS_PATH)/Bin/x64/rc.exe
-      RSC = $(MSDEVTOOLS_PATH)/Bin/x64/rc.exe
-      MT = $(MSDEVTOOLS_PATH)/Bin/x64/mt.exe
-      MTL = $(MSDEVTOOLS_PATH)/Bin/X64/midl.exe
+  endif
+  
+  # The VS2010 compiler is the same one used on both 32bit and 64bit
+  ifeq ($(CC_MAJORVER), 16)
+    COMPILER_NAME=Microsoft Visual Studio 10 (16.00.30319.01)
+    COMPILER_VERSION=VS2010
+    ifeq ($(WINDOWSSDKDIR),)
+      WINDOWSSDKDIR := $(error WINDOWSSDKDIR cannot be empty here)
     endif
-    # This will cause problems if ALT_COMPILER_PATH is defined to ""
-    # which is a directive to use the PATH.
-    ifndef COMPILER_PATH
-      COMPILER_PATH := $(error COMPILER_PATH cannot be empty here)
+    ifeq ($(ARCH_DATA_MODEL), 32)
+      _OTHER_TOOLS_BIN = $(WINDOWSSDKDIR)/Bin
+    else
+      ifeq ($(ARCH), ia64)
+        _OTHER_TOOLS_BIN = $(WINDOWSSDKDIR)/Bin/ia64
+      else
+        _OTHER_TOOLS_BIN = $(WINDOWSSDKDIR)/Bin/x64
+      endif
     endif
+    RC     = $(_OTHER_TOOLS_BIN)/rc.exe
+    REBASE = $(_OTHER_TOOLS_BIN)/rebase.exe
+    MT     = $(_OTHER_TOOLS_BIN)/mt.exe
+    MTL    = $(_OTHER_TOOLS_BIN)/midl.exe
+  endif
+  
+  # These variables can never be empty
+  ifndef COMPILER_PATH
+    COMPILER_PATH := $(error COMPILER_PATH cannot be empty here)
   endif
   ifndef COMPILER_VERSION
     COMPILER_VERSION := $(error COMPILER_VERSION cannot be empty here)
   endif
+  
   # Shared library generation flag
   SHARED_LIBRARY_FLAG = -LD
+  # RSC is always same as RC (Not sure who uses this RSC variable)
+  RSC = $(RC)
+
 endif
 
diff --git a/jdk/make/common/shared/Defs-solaris.gmk b/jdk/make/common/shared/Defs-solaris.gmk
index 8ba3f4e9..98b054e 100644
--- a/jdk/make/common/shared/Defs-solaris.gmk
+++ b/jdk/make/common/shared/Defs-solaris.gmk
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2005, 2007, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -91,7 +91,6 @@
 ifneq "$(origin ALT_COMPILER_PATH)" "undefined"
   COMPILER_PATH :=$(call PrefixPath,$(ALT_COMPILER_PATH))
 else
-  # Careful here, REQUIRED_COMPILER_VERSION may not be defined yet (see Defs-versions.gmk)
   # If the place where we keep a set of Sun Studio compilers doesn't exist,
   #  try and use /opt/SUNWspro, the default location for the SS compilers.
   #  (DirExists checks for this path twice, an automount double check)
diff --git a/jdk/make/common/shared/Defs-versions.gmk b/jdk/make/common/shared/Defs-versions.gmk
index 88e7ae5..72f3717 100644
--- a/jdk/make/common/shared/Defs-versions.gmk
+++ b/jdk/make/common/shared/Defs-versions.gmk
@@ -27,7 +27,22 @@
 # WARNING: This file is shared with other workspaces.
 #
 
-# This file needs these set: CC_VERSION, PLATFORM, ARCH_FAMILY, and ARCH_DATA_MODEL.
+# This file needs these set: PLATFORM, ARCH_FAMILY, and ARCH_DATA_MODEL.
+
+# Windows uses Microsoft compilers by default
+ifeq ($(PLATFORM), windows)
+  override CC_VERSION = msvc
+endif
+
+# Solaris uses Sun Studio compilers by default
+ifeq ($(PLATFORM), solaris)
+  override CC_VERSION = sun
+endif
+
+# Linux uses GNU compilers by default
+ifeq ($(PLATFORM), linux)
+  override CC_VERSION = gcc
+endif
 
 ##########################################################################
 #
diff --git a/jdk/make/common/shared/Defs-windows.gmk b/jdk/make/common/shared/Defs-windows.gmk
index ac9daf4..2c149e0 100644
--- a/jdk/make/common/shared/Defs-windows.gmk
+++ b/jdk/make/common/shared/Defs-windows.gmk
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -80,13 +80,20 @@
 #         their own variable assigned with :=, then use FullPath.
 #
 
-# Use FullPath to get C:/ style non-spaces path. Never ends with a /!
 ifdef USING_CYGWIN
+# All possible drive letters
+drives=a b c d e f g h i j k l m n o p q r s t v u w x y z
+# Convert /cygdrive/ paths to the mixed style without an exec of cygpath
+#   Must be a path with no spaces.
+define MixedPath
+$(patsubst /%,c:/cygwin/%,$(sort $(filter-out /cygdrive/%,$(foreach drive,$(drives),$(patsubst /cygdrive/$(drive)/%,$(drive):/%,$1)))))
+endef
+# Use FullPath to get C:/ style non-spaces path. Never ends with a /!
 # We assume cygpath is available in the search path
 #    NOTE: Use of 'pwd' with CYGWIN will not get you a mixed style path!
 CYGPATH_CMD=cygpath -a -s -m
 define FullPath
-$(shell $(CYGPATH_CMD) $1 2> $(DEV_NULL))
+$(if $(word 2,$1),$(shell $(CYGPATH_CMD) $1 2> $(DEV_NULL)),$(call MixedPath,$(realpath $(subst ",,$1))))
 endef
 define OptFullPath
 $(shell if [ "$1" != "" -a -d "$1" ]; then $(CYGPATH_CMD) "$1" 2> $(DEV_NULL); else echo "$1"; fi)
@@ -228,29 +235,125 @@
   _dx_sdk_dir :=$(call FullPath,$(xDXSDK_DIR))
 endif
 
-# Compilers, SDK, and Visual Studio (MSDEV) [32bit is different from 64bit]
-ifeq ($(ARCH_DATA_MODEL), 32)
-  # Try looking in MSVCDIR or MSVCDir area first 
-  # (set by vcvars32.bat for VC .NET, not defined in the VC 2008/2010)
-  ifdef MSVCDIR
-    xMSVCDIR  :="$(subst \,/,$(MSVCDIR))"
-    _msvc_dir :=$(call FullPath,$(xMSVCDIR))
+# Use of the Visual Studio compilers requires certain env variables be set:
+#   PATH should include the path to cl.exe
+#   INCLUDE should be defined
+#   LIB     should be defined
+#   LIBPATH should be defined
+#   VS100COMNTOOLS should be defined
+#   WINDOWSSDKDIR should be defined
+#     The 7.0a path is from VS2010 Pro, the 7.1 path is the standalone SDK.
+#     For 64bit either will work for us.
+#     If a developer chooses to install the standalone SDK in some other
+#     location, then they need to set WINDOWSSDKDIR.
+#
+# Compilers for 64bit may be from the free SDK, or Visual Studio Professional.
+#   The free Express compilers don't contain 64 bit compilers, which is why
+#   you instead need the SDK.
+#   Release enginering will use VS2010 Pro, so the frequency of testing of
+#     SDK based builds will depend entirely on individual usage.
+
+# We only need to do this once
+ifndef VS2010_EXISTS
+  # The 2 key paths we need are WINDOWSSDKDIR and VS100COMNTOOLS.
+  #   If not defined try to see if default location exists.
+  #   If defined make sure that the path has no spaces.
+  #   Finally, export path with no spaces so logic minimizes FullPath calls.
+  ifndef WINDOWSSDKDIR
+    # The 7.0a SDK is the second choice.
+    xWINDOWSSDKDIR :="$(_program_files32)/Microsoft SDKs/Windows/v7.0a/"
+    fWINDOWSSDKDIR :=$(call FullPath,$(xWINDOWSSDKDIR))
+    # The 7.1 SDK is the second choice.
+    ifeq ($(fWINDOWSSDKDIR),)
+      xWINDOWSSDKDIR :="$(_program_files32)/Microsoft SDKs/Windows/v7.1/"
+      fWINDOWSSDKDIR :=$(call FullPath,$(xWINDOWSSDKDIR))
+    endif
   else
-    ifdef MSVCDir
-      xMSVCDIR  :="$(subst \,/,$(MSVCDir))"
-      _msvc_dir :=$(call FullPath,$(xMSVCDIR))
+    ifneq ($(word 2,$(WINDOWSSDKDIR)),)
+      xWINDOWSSDKDIR :="$(subst \,/,$(WINDOWSSDKDIR))"
+      fWINDOWSSDKDIR :=$(call FullPath,$(xWINDOWSSDKDIR))
+    else
+      fWINDOWSSDKDIR :=$(WINDOWSSDKDIR)
     endif
   endif
-  # If we still don't have it, look for VSnnCOMNTOOLS (newest first),
-  # set by installer?
-  ifeq ($(_msvc_dir),)
-    ifdef VS100COMNTOOLS  # /Common/Tools directory, use ../../Vc
+  ifneq ($(fWINDOWSSDKDIR),)
+    WINDOWSSDKDIR  :=$(fWINDOWSSDKDIR)/
+  endif
+  ifndef VS100COMNTOOLS
+    xVS100COMNTOOLS :="$(_program_files32)/Microsoft Visual Studio 10.0/Common7/Tools/"
+    fVS100COMNTOOLS :=$(call FullPath,$(xVS100COMNTOOLS))
+  else
+    ifneq ($(word 2,$(VS100COMNTOOLS)),)
       xVS100COMNTOOLS :="$(subst \,/,$(VS100COMNTOOLS))"
-      _vs100tools     :=$(call FullPath,$(xVS100COMNTOOLS))
-    endif
-    ifneq ($(_vs100tools),)
-      _msvc_dir   :=$(_vs100tools)/../../Vc
+      fVS100COMNTOOLS :=$(call FullPath,$(xVS100COMNTOOLS))
     else
+      fVS100COMNTOOLS :=$(xVS100COMNTOOLS)
+    endif
+  endif
+  ifneq ($(fVS100COMNTOOLS),)
+    VS100COMNTOOLS :=$(fVS100COMNTOOLS)/
+  endif
+  # Check to see that both exist
+  ifeq ($(WINDOWSSDKDIR),)
+    _vs2010_message := No WINDOWSSDKDIR found on system. $(_vs2010_message)
+    VS2010_EXISTS   := false
+  endif
+  ifeq ($(VS100COMNTOOLS),)
+    _vs2010_message := No VS100COMNTOOLS found on system. $(_vs2010_message)
+    VS2010_EXISTS   := false
+  endif
+  ifeq ($(VS2010_EXISTS),false)
+    x:=$(warning WARNING: No VS2010 available. $(_vs2010_message))
+    VS100COMNTOOLS :=
+    WINDOWSSDKDIR  :=
+  else
+    VS2010_EXISTS := true
+    _msvc_dir     :=$(VS100COMNTOOLS)/../../Vc
+  endif
+  export VS2010_EXISTS
+  export VS100COMNTOOLS
+  export WINDOWSSDKDIR
+endif
+
+# Setup for VS2010 is simple, others logic is historic
+ifeq ($(VS2010_EXISTS),true)
+  
+  # VS2010 Compiler root directory
+  _msvc_dir :=$(VS100COMNTOOLS)/../../Vc
+  # SDK root directory
+  _ms_sdk   :=$(WINDOWSSDKDIR)
+  # Compiler bin directory and redist directory
+  ifeq ($(ARCH_DATA_MODEL), 32)
+    _compiler_bin :=$(_msvc_dir)/Bin
+    _redist_sdk   :=$(call FullPath,$(_msvc_dir)/redist/x86/Microsoft.VC100.CRT)
+  endif
+  ifeq ($(ARCH_DATA_MODEL), 64)
+    _compiler_bin :=$(_msvc_dir)/bin/amd64
+    _redist_sdk   :=$(call FullPath,$(_msvc_dir)/redist/x64/Microsoft.VC100.CRT)
+  endif
+  ifeq ($(_redist_sdk),)
+    _redist_sdk   :=$(_system_root)/system32
+  endif
+
+else # Not VS2010
+
+  # Compilers, SDK, and Visual Studio (MSDEV) [32bit is different from 64bit]
+  ifeq ($(ARCH_DATA_MODEL), 32)
+
+    # Try looking in MSVCDIR or MSVCDir area first 
+    # (set by vcvars32.bat for VC .NET, not defined in the VC 2008/2010)
+    ifdef MSVCDIR
+      xMSVCDIR  :="$(subst \,/,$(MSVCDIR))"
+      _msvc_dir :=$(call FullPath,$(xMSVCDIR))
+    else
+      ifdef MSVCDir
+        xMSVCDIR  :="$(subst \,/,$(MSVCDir))"
+        _msvc_dir :=$(call FullPath,$(xMSVCDIR))
+      endif
+    endif
+    # If we still don't have it, look for VSnnCOMNTOOLS (newest first),
+    # set by installer?
+    ifeq ($(_msvc_dir),)
       ifdef VS90COMNTOOLS  # /Common/Tools directory, use ../../Vc
         xVS90COMNTOOLS :="$(subst \,/,$(VS90COMNTOOLS))"
         _vs90tools     :=$(call FullPath,$(xVS90COMNTOOLS))
@@ -275,46 +378,38 @@
         endif
       endif
     endif
-  endif
-  ifneq ($(_msvc_dir),)
-    _compiler_bin :=$(_msvc_dir)/Bin
-    # Assume PlatformSDK is in VS71 (will be empty if VS90)
-    _ms_sdk       :=$(call FullPath,$(_msvc_dir)/PlatformSDK)
-    # Assume VS100, then VS90, then VS80, then VS71
-    _redist_sdk   :=$(call FullPath,$(_msvc_dir)/redist/x86/Microsoft.VC100.CRT)
-    ifeq ($(_redist_sdk),)
-      ifneq ($(VS100COMNTOOLS),)
-        _redist_sdk  :=c:/windows/system32
-      else
-        _redist_sdk   :=$(call FullPath,$(_msvc_dir)/redist/x86/Microsoft.VC90.CRT)
+  
+    ifneq ($(_msvc_dir),)
+      _compiler_bin :=$(_msvc_dir)/Bin
+      # Assume PlatformSDK is in VS71 (will be empty if VS90)
+      _ms_sdk       :=$(call FullPath,$(_msvc_dir)/PlatformSDK)
+      _redist_sdk   :=$(call FullPath,$(_msvc_dir)/redist/x86/Microsoft.VC90.CRT)
+      ifeq ($(_redist_sdk),)
+        _redist_sdk   :=$(call FullPath,$(_msvc_dir)/redist/x86/Microsoft.VC80.CRT)
         ifeq ($(_redist_sdk),)
-          _redist_sdk   :=$(call FullPath,$(_msvc_dir)/redist/x86/Microsoft.VC80.CRT)
-          ifeq ($(_redist_sdk),)
-            _redist_sdk   :=$(call FullPath,$(_msvc_dir)/../SDK/v1.1/Bin)
-          endif
+          _redist_sdk   :=$(call FullPath,$(_msvc_dir)/../SDK/v1.1/Bin)
         endif
       endif
     endif
   endif
-endif
 
-# The Microsoft Platform SDK installed by itself
-ifneq ($(_program_files),)
-  _PSDK :="$(_program_files)/Microsoft SDKs/Windows/v6.1/"
-  _psdk :=$(call FullPath,$(xMSSDK61))
-  ifeq ($(_psdk),)
-    xPSDK  :="$(_program_files)/Microsoft Platform SDK"
-    _psdk  :=$(call FullPath,$(xPSDK))
+  # The Microsoft Platform SDK installed by itself
+  ifneq ($(_program_files),)
+    _PSDK :="$(_program_files)/Microsoft SDKs/Windows/v6.1/"
+    _psdk :=$(call FullPath,$(xMSSDK61))
     ifeq ($(_psdk),)
-      xPSDK  :="$(_program_files)/Microsoft SDK"
-      _psdk :=$(call FullPath,$(xMSSDK))
+      xPSDK  :="$(_program_files)/Microsoft Platform SDK"
+      _psdk  :=$(call FullPath,$(xPSDK))
+      ifeq ($(_psdk),)
+        xPSDK  :="$(_program_files)/Microsoft SDK"
+        _psdk :=$(call FullPath,$(xMSSDK))
+      endif
     endif
   endif
-endif
 
-# If no SDK found yet, look in other places
-ifeq ($(_ms_sdk),)
-  ifdef MSSDK
+  # If no SDK found yet, look in other places
+  ifeq ($(_ms_sdk),)
+    ifdef MSSDK
     xMSSDK  :="$(subst \,/,$(MSSDK))"
     _ms_sdk :=$(call FullPath,$(xMSSDK))
   else
@@ -322,56 +417,13 @@
       xMSSDK  :="$(subst \,/,$(MSSdk))"
       _ms_sdk :=$(call FullPath,$(xMSSDK))
     else
-      _ms_sdk :=$(_psdk)
+        _ms_sdk :=$(_psdk)
+      endif
     endif
   endif
-endif
-
-# Compilers for 64bit may be from the free SDK, or Visual Studio Professional
-# The free Express compilers don't contain 64 bit compilers, which is why
-# you instead need the SDK.
-# So for VS2010 based builds, either VS2010 Pro with the 7.0a SDK, or
-# the Windows 7.1 standalone SDK with compilers may be used.
-# Release enginering will use VS2010 Pro, so the frequency of testing of
-# SDK based builds will depend entirely on individual usage.
-ifeq ($(ARCH_DATA_MODEL), 64)
-  ifdef VS100COMNTOOLS  # /Common7/Tools directory, use ../../Vc
-    # VS2010 default location is used when building 64 bit using the 7.1 SDK
-    # This is safe to hardwire as the SDK installer won't let you change it
-    # and the VS2010 variable is only used if the compilers are from the SDK
-    xVS2010 :="$(_program_files32)/Microsoft Visual Studio 10.0/"
-    VS2010 :=$(call FullPath,$(xVS2010))
-    xVS100COMNTOOLS :="$(subst \,/,$(VS100COMNTOOLS))"
-    _vs100tools     :=$(call FullPath,$(xVS100COMNTOOLS))
-  endif
-  ifneq ($(_vs100tools),)
-    _compiler_bin :=$(_vs100tools)/../../Vc/bin/amd64
-    x_redist_sdk   :=$(_vs100tools)/../../Vc/redist/x64/Microsoft.VC100.CRT
-    _redist_sdk    :=$(call FullPath,$(x_redist_sdk))
-    # The SDK doesn't have the redist directory, but the DLL is installed
-    # into the windows directory.
-    ifeq ($(_redist_sdk),)
-      _redist_sdk   :=c:/windows/system32
-    endif
-    # Not currently using MSSDK7n, but maybe we can make use of it for
-    # doing default location lookup to find some SDK tools that presently
-    # require the developer to explicitly set the path.
-    # The 7.0a path is from VS2010 Pro, the 7.1 path is the standalone SDK.
-    # Either will work for us.
-    # If a developer chooses to install the standalone SDK in some other
-    # location, then this will fail to find it, which won't matter so long as
-    # we aren't using this variable. If we do they'd still need to set the
-    # ALT_MSDEVTOOLS_PATH as now.
-    # %WindowsSdkDir% could be referenced instead but the SDK installer
-    # doesn't set it and in the case of the VS2010 compilers,
-    # you can't change this location in the installer anyway.
-    xMSSDK7n      :="$(_program_files32)/Microsoft SDKs/Windows/v7.0a/"
-    MSSDK7n       :=$(call FullPath,$(xMSSDK7n))
-    ifeq ($(MSSDK7n),)
-      xMSSDK7n      :="$(_program_files32)/Microsoft SDKs/Windows/v7.1/"
-      MSSDK7n       :=$(call FullPath,$(xMSSDK7n))
-    endif
-  else
+  
+  # Compilers for 64bit may be from the free SDK, or Visual Studio Professional.
+  ifeq ($(ARCH_DATA_MODEL), 64)
     xVS2008 :="$(_program_files32)/Microsoft Visual Studio 9.0/"
     VS2008 :=$(call FullPath,$(xVS2008))
     ifneq ($(VS2008),)
@@ -391,7 +443,8 @@
       endif
     endif
   endif
-endif
+
+endif # VS2010_EXISTS
 
 # Location on system where jdk installs might be
 ifneq ($(_program_files),)
@@ -509,7 +562,7 @@
 ifeq ($(ARCH_DATA_MODEL), 32)
   _NEEDS_MSVCRNN = true
 else
-  ifneq ($(VS2010),)
+  ifeq ($(VS2010_EXISTS),true)
     _NEEDS_MSVCRNN = true
   else 
     ifneq ($(VS2008),)
diff --git a/jdk/make/common/shared/Defs.gmk b/jdk/make/common/shared/Defs.gmk
index 43e27a5..aae5e6d 100644
--- a/jdk/make/common/shared/Defs.gmk
+++ b/jdk/make/common/shared/Defs.gmk
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -373,6 +373,9 @@
 # Get platform specific settings
 # NB: OUTPUTDIR must be defined. Otherwise hotspot import detection will not work correctly
 # On other hand this must be included early as it provides platform specific defines such as FullPath
+include $(JDK_MAKE_SHARED_DIR)/Defs-versions.gmk
+
+# Get platform specific settings (defines COMPILER_PATH)
 include $(JDK_MAKE_SHARED_DIR)/Defs-$(PLATFORM).gmk
 
 # Components
@@ -608,24 +611,9 @@
   COPYRIGHT_YEAR = $(shell $(DATE) '+%Y')
 endif
 
-# Windows uses Microsoft compilers by default
-ifeq ($(PLATFORM), windows)
-  override CC_VERSION = msvc
-endif
-
-# Solaris uses Sun Studio compilers by default
-ifeq ($(PLATFORM), solaris)
-  override CC_VERSION = sun
-endif
-
-# Linux uses GNU compilers by default
-ifeq ($(PLATFORM), linux)
-  override CC_VERSION = gcc
-endif
-
-# Get the REQUIRED versions (needs CC_VERSION set)
-include $(JDK_MAKE_SHARED_DIR)/Defs-versions.gmk
-
-# Get the compiler specific settings
+# Get the compiler specific settings (will run the compiler to find out)
+#   NOTE: COMPILER_PATH must be set by this time.
+#   Up until we include this file, we don't know what specific compiler
+#   version is actually being used (i.e. what is in PATH or COMPILER_PATH).
 include $(JDK_MAKE_SHARED_DIR)/Compiler-$(CC_VERSION).gmk
 
diff --git a/jdk/make/common/shared/Sanity-Settings.gmk b/jdk/make/common/shared/Sanity-Settings.gmk
index 75e0cc8..d18ccf7 100644
--- a/jdk/make/common/shared/Sanity-Settings.gmk
+++ b/jdk/make/common/shared/Sanity-Settings.gmk
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -100,7 +100,8 @@
   ifneq ($(MSVCRNN_DLL),)
     ALL_SETTINGS+=$(call addAltSetting,MSVCRNN_DLL_PATH)
   endif
-  ALL_SETTINGS+=$(call addAltSetting,MSDEVTOOLS_PATH)
+  ALL_SETTINGS+=$(call addRequiredSetting,INCLUDE)
+  ALL_SETTINGS+=$(call addRequiredSetting,LIB)
 endif
 ALL_SETTINGS+=$(call addOptionalSetting,COMPILER_NAME)
 ALL_SETTINGS+=$(call addOptionalSetting,COMPILER_VERSION)
@@ -223,6 +224,7 @@
   ALL_SETTINGS+=$(call addAltSetting,DXSDK_PATH)
   ALL_SETTINGS+=$(call addAltSetting,DXSDK_INCLUDE_PATH)
   ALL_SETTINGS+=$(call addAltSetting,DXSDK_LIB_PATH)
+  ALL_SETTINGS+=$(call addAltSetting,WINDOWSSDKDIR)
   ifndef OPENJDK
     ALL_SETTINGS+=$(call addAltSetting,DEPLOY_MSSDK)
     ALL_SETTINGS+=$(call addAltSetting,INSTALL_MSSDK)
diff --git a/jdk/make/common/shared/Sanity.gmk b/jdk/make/common/shared/Sanity.gmk
index 6b54515..b53f73b 100644
--- a/jdk/make/common/shared/Sanity.gmk
+++ b/jdk/make/common/shared/Sanity.gmk
@@ -1020,10 +1020,11 @@
 endif
 
 ######################################################
-# Check for existence of MSDEVTOOLS_PATH on windows
+# Check for existence of the extra tools on windows
 ######################################################
 sane-msdevtools_path:
 ifeq ($(PLATFORM), windows)
+  ifneq ($(COMPILER_VERSION), VS2010)
 	@if [ "$(MSDEVTOOLS_PATH)" != "" -a ! -r "$(MSDEVTOOLS_PATH)" ]; then \
 	  $(ECHO) "ERROR: You do not have a valid MSDEVTOOLS_PATH setting. \n" \
 	    "      Please check your access to \n" \
@@ -1031,6 +1032,7 @@
 	    "      and/or check your value of ALT_MSDEVTOOLS_PATH. \n" \
 	    "" >> $(ERROR_FILE) ; \
 	fi
+  endif
 endif
 
 ######################################################
@@ -1439,10 +1441,24 @@
 endif
 
 ######################################################
-# Check for existence of INSTALL_MSSDK on windows
+# Check for existence of the MSSDK on windows
 ######################################################
 sane-install-mssdk_path:
 ifeq ($(PLATFORM), windows)
+  ifeq ($(COMPILER_VERSION), VS2010)
+	@if [ -z "$(WINDOWSSDKDIR)" ]; then \
+	  $(ECHO) "WARNING: Your WINDOWSSDKDIR setting is empty.\n" \
+	    "        It is recommended to set ALT_WINDOWSSDKDIR.\n" \
+	    "" >> $(WARNING_FILE) ; \
+	fi
+	@if [ ! -r "$(WINDOWSSDKDIR)" ]; then \
+	  $(ECHO) "ERROR: You do not have a valid WINDOWSSDKDIR setting. \n" \
+	    "      Please check your access to \n" \
+	    "          $(WINDOWSSDKDIR) \n" \
+	    "      and/or check your value of ALT_WINDOWSSDKDIR. \n" \
+	    "" >> $(ERROR_FILE) ; \
+	fi
+  endif
 	@if [ -z "$(INSTALL_MSSDK)" ]; then \
 	  $(ECHO) "WARNING: Your INSTALL_MSSDK setting is empty.\n" \
 	    "        It is recommended to set ALT_INSTALL_MSSDK.\n" \
diff --git a/jdk/make/jdk_generic_profile.sh b/jdk/make/jdk_generic_profile.sh
index 4363a1b..151ecb6 100644
--- a/jdk/make/jdk_generic_profile.sh
+++ b/jdk/make/jdk_generic_profile.sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 #
-# Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -82,7 +82,6 @@
 #    ALT_CLOSED_JDK_IMPORT_PATH
 #    Windows Only:
 #      ALT_UNIXCOMMAND_PATH
-#      ALT_MSDEVTOOLS_PATH
 #      ALT_DXSDK_PATH
 #      ALT_MSVCRT_DLL_PATH
 #      ALT_MSVCR71_DLL_PATH
@@ -221,8 +220,6 @@
     # VisualStudio .NET 2003 VC++ 7.1 (VS71COMNTOOLS should be defined)
     vs_root=$(${cygpath} "${VS71COMNTOOLS}/../..")
     # Fill in PATH, LIB, and INCLUDE (unset all others to make sure)
-    msdev_root="${vs_root}/Common7/Tools"
-    msdevtools_path="${msdev_root}/bin"
     vc7_root="${vs_root}/Vc7"
     compiler_path="${vc7_root}/bin"
     platform_sdk="${vc7_root}/PlatformSDK"
@@ -260,12 +257,6 @@
     else
       compiler_path="${platform_sdk}/Bin/win64/x86/AMD64"
     fi
-    if [ "${ALT_MSDEVTOOLS_PATH}" != "" ] ; then
-      msdevtools_path=${ALT_MSDEVTOOLS_PATH}
-    else
-      msdevtools_path="${platform_sdk}/Bin/win64/x86/AMD64"
-    fi
-    msdevtools_path="${compiler_path}"
     # LIB and INCLUDE must use ; as a separator
     include4sdk="${platform_sdk}/Include"
     include4sdk="${include4sdk};${platform_sdk}/Include/crt/sys"