common/autoconf/toolchain_windows.m4

Thu, 12 Sep 2013 12:12:13 +0200

author
vadim
date
Thu, 12 Sep 2013 12:12:13 +0200
changeset 796
b1e9396fb8af
parent 759
0d0c983a817b
child 839
174a54ce39c4
permissions
-rw-r--r--

8008022: Upgrade Direct X SDK used to build JDK
Reviewed-by: erikj, prr, ihse

ohair@494 1 #
ohair@494 2 # Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
ohair@494 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ohair@494 4 #
ohair@494 5 # This code is free software; you can redistribute it and/or modify it
ohair@494 6 # under the terms of the GNU General Public License version 2 only, as
ohair@494 7 # published by the Free Software Foundation. Oracle designates this
ohair@494 8 # particular file as subject to the "Classpath" exception as provided
ohair@494 9 # by Oracle in the LICENSE file that accompanied this code.
ohair@494 10 #
ohair@494 11 # This code is distributed in the hope that it will be useful, but WITHOUT
ohair@494 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ohair@494 13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ohair@494 14 # version 2 for more details (a copy is included in the LICENSE file that
ohair@494 15 # accompanied this code).
ohair@494 16 #
ohair@494 17 # You should have received a copy of the GNU General Public License version
ohair@494 18 # 2 along with this work; if not, write to the Free Software Foundation,
ohair@494 19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ohair@494 20 #
ohair@494 21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@494 22 # or visit www.oracle.com if you need additional information or have any
ohair@494 23 # questions.
ohair@494 24 #
ohair@494 25
ohair@494 26 AC_DEFUN([TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT],
ohair@494 27 [
ohair@494 28 if test "x$VS_ENV_CMD" = x; then
ohair@494 29 VS100BASE="$1"
ohair@494 30 METHOD="$2"
ohair@494 31 BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(VS100BASE)
ohair@494 32 if test -d "$VS100BASE"; then
ohair@494 33 if test -f "$VS100BASE/$VCVARSFILE"; then
ohair@494 34 AC_MSG_NOTICE([Found Visual Studio installation at $VS100BASE using $METHOD])
ohair@494 35 VS_ENV_CMD="$VS100BASE/$VCVARSFILE"
ohair@494 36 else
ohair@494 37 AC_MSG_NOTICE([Found Visual Studio installation at $VS100BASE using $METHOD])
ohair@494 38 AC_MSG_NOTICE([Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring])
ohair@494 39 fi
ohair@494 40 fi
ohair@494 41 fi
ohair@494 42 ])
ohair@494 43
ohair@494 44 AC_DEFUN([TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT],
ohair@494 45 [
ohair@494 46 if test "x$VS_ENV_CMD" = x; then
ohair@494 47 WIN_SDK_BASE="$1"
ohair@494 48 METHOD="$2"
ohair@494 49 BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(WIN_SDK_BASE)
ohair@494 50 if test -d "$WIN_SDK_BASE"; then
erikj@525 51 # There have been cases of partial or broken SDK installations. A missing
erikj@525 52 # lib dir is not going to work.
erikj@525 53 if test ! -d "$WIN_SDK_BASE/../lib"; then
erikj@525 54 AC_MSG_NOTICE([Found Windows SDK installation at $WIN_SDK_BASE using $METHOD])
erikj@525 55 AC_MSG_NOTICE([Warning: Installation is broken, lib dir is missing. Ignoring])
erikj@525 56 elif test -f "$WIN_SDK_BASE/SetEnv.Cmd"; then
ohair@494 57 AC_MSG_NOTICE([Found Windows SDK installation at $WIN_SDK_BASE using $METHOD])
ohair@494 58 VS_ENV_CMD="$WIN_SDK_BASE/SetEnv.Cmd"
ohair@494 59 if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
ohair@494 60 VS_ENV_ARGS="/x86"
ohair@494 61 else
ohair@494 62 VS_ENV_ARGS="/x64"
ohair@494 63 fi
ohair@494 64 else
ohair@494 65 AC_MSG_NOTICE([Found Windows SDK installation at $WIN_SDK_BASE using $METHOD])
ohair@494 66 AC_MSG_NOTICE([Warning: Installation is broken, SetEnv.Cmd is missing. Ignoring])
ohair@494 67 fi
ohair@494 68 fi
ohair@494 69 fi
ohair@494 70 ])
ohair@494 71
ohair@494 72 AC_DEFUN([TOOLCHAIN_FIND_VISUAL_STUDIO_BAT_FILE],
ohair@494 73 [
ohair@494 74 if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
ohair@494 75 VCVARSFILE="vc/bin/vcvars32.bat"
ohair@494 76 else
ohair@494 77 VCVARSFILE="vc/bin/amd64/vcvars64.bat"
ohair@494 78 fi
ohair@494 79
ohair@494 80 VS_ENV_CMD=""
ohair@494 81 VS_ENV_ARGS=""
ohair@494 82 if test "x$with_toolsdir" != x; then
ohair@494 83 TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([$with_toolsdir/../..], [--with-tools-dir])
ohair@494 84 fi
ohair@494 85
ohair@494 86 if test "x$with_toolsdir" != x && test "x$VS_ENV_CMD" = x; then
ohair@494 87 # Having specified an argument which is incorrect will produce an instant failure;
ohair@494 88 # we should not go on looking
ohair@494 89 AC_MSG_NOTICE([The path given by --with-tools-dir does not contain a valid Visual Studio installation])
ohair@494 90 AC_MSG_NOTICE([Please point to the VC/bin directory within the Visual Studio installation])
ohair@494 91 AC_MSG_ERROR([Cannot locate a valid Visual Studio installation])
ohair@494 92 fi
ohair@494 93
erikj@733 94 if test "x$VS100COMNTOOLS" != x; then
erikj@733 95 TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([$VS100COMNTOOLS/../..], [VS100COMNTOOLS variable])
erikj@733 96 fi
erikj@733 97 if test "x$PROGRAMFILES" != x; then
erikj@733 98 TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([$PROGRAMFILES/Microsoft Visual Studio 10.0], [well-known name])
erikj@733 99 fi
erikj@733 100 TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([C:/Program Files/Microsoft Visual Studio 10.0], [well-known name])
erikj@733 101 TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([C:/Program Files (x86)/Microsoft Visual Studio 10.0], [well-known name])
erikj@733 102
ohair@494 103 if test "x$ProgramW6432" != x; then
ohair@494 104 TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([$ProgramW6432/Microsoft SDKs/Windows/v7.1/Bin], [well-known name])
ohair@494 105 fi
ohair@494 106 if test "x$PROGRAMW6432" != x; then
ohair@494 107 TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([$PROGRAMW6432/Microsoft SDKs/Windows/v7.1/Bin], [well-known name])
ohair@494 108 fi
ohair@494 109 if test "x$PROGRAMFILES" != x; then
ohair@494 110 TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([$PROGRAMFILES/Microsoft SDKs/Windows/v7.1/Bin], [well-known name])
ohair@494 111 fi
ohair@494 112 TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([C:/Program Files/Microsoft SDKs/Windows/v7.1/Bin], [well-known name])
ohair@494 113 TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([C:/Program Files (x86)/Microsoft SDKs/Windows/v7.1/Bin], [well-known name])
ohair@494 114 ])
ohair@494 115
ohair@494 116 # Check if the VS env variables were setup prior to running configure.
ohair@494 117 # If not, then find vcvarsall.bat and run it automatically, and integrate
ohair@494 118 # the set env variables into the spec file.
ohair@494 119 AC_DEFUN([TOOLCHAIN_SETUP_VISUAL_STUDIO_ENV],
ohair@494 120 [
ohair@494 121 # Store path to cygwin link.exe to help excluding it when searching for
ohair@494 122 # VS linker. This must be done before changing the PATH when looking for VS.
ohair@494 123 AC_PATH_PROG(CYGWIN_LINK, link)
ohair@494 124 if test "x$CYGWIN_LINK" != x; then
ohair@494 125 AC_MSG_CHECKING([if the first found link.exe is actually the Cygwin link tool])
ohair@494 126 "$CYGWIN_LINK" --version > /dev/null
ohair@494 127 if test $? -eq 0 ; then
ohair@494 128 AC_MSG_RESULT([yes])
ohair@494 129 else
ohair@494 130 AC_MSG_RESULT([no])
ohair@494 131 # This might be the VS linker. Don't exclude it later on.
ohair@494 132 CYGWIN_LINK=""
ohair@494 133 fi
ohair@494 134 fi
ohair@494 135
ohair@494 136 # First-hand choice is to locate and run the vsvars bat file.
ohair@494 137 TOOLCHAIN_FIND_VISUAL_STUDIO_BAT_FILE
ohair@494 138 if test "x$VS_ENV_CMD" != x; then
ohair@494 139 # We have found a Visual Studio environment on disk, let's extract variables from the vsvars bat file.
ohair@494 140 BASIC_FIXUP_EXECUTABLE(VS_ENV_CMD)
ohair@494 141
ohair@494 142 # Lets extract the variables that are set by vcvarsall.bat/vsvars32.bat/vsvars64.bat
ohair@494 143 AC_MSG_NOTICE([Trying to extract Visual Studio environment variables])
ohair@494 144 cd $OUTPUT_ROOT
ohair@494 145 # FIXME: The code betweeen ---- was inlined from a separate script and is not properly adapted
ohair@494 146 # to autoconf standards.
ohair@494 147
ohair@494 148 #----
ohair@494 149
ohair@494 150 # Cannot use the VS10 setup script directly (since it only updates the DOS subshell environment)
ohair@494 151 # but calculate the difference in Cygwin environment before/after running it and then
ohair@494 152 # apply the diff.
ohair@494 153
ohair@494 154 if test "x$OPENJDK_BUILD_OS_ENV" = xwindows.cygwin; then
ohair@494 155 _vs10varsall=`cygpath -a -m -s "$VS_ENV_CMD"`
ohair@494 156 _dosvs10varsall=`cygpath -a -w -s $_vs10varsall`
ohair@494 157 _dosbash=`cygpath -a -w -s \`which bash\`.*`
ohair@494 158 else
ohair@494 159 _dosvs10varsall=`cmd //c echo $VS_ENV_CMD`
ohair@494 160 _dosbash=`cmd //c echo \`which bash\``
ohair@494 161 fi
ohair@494 162
ohair@494 163 # generate the set of exported vars before/after the vs10 setup
ohair@494 164 $ECHO "@echo off" > localdevenvtmp.bat
ohair@494 165 $ECHO "$_dosbash -c \"export -p\" > localdevenvtmp.export0" >> localdevenvtmp.bat
ohair@494 166 $ECHO "call $_dosvs10varsall $VS_ENV_ARGS" >> localdevenvtmp.bat
ohair@494 167 $ECHO "$_dosbash -c \"export -p\" > localdevenvtmp.export1" >> localdevenvtmp.bat
ohair@494 168
ohair@494 169 # Now execute the newly created bat file.
ohair@494 170 # The | cat is to stop SetEnv.Cmd to mess with system colors on msys
ohair@494 171 cmd /c localdevenvtmp.bat | cat
ohair@494 172
ohair@494 173 # apply the diff (less some non-vs10 vars named by "!")
ohair@494 174 $SORT localdevenvtmp.export0 | $GREP -v "!" > localdevenvtmp.export0.sort
ohair@494 175 $SORT localdevenvtmp.export1 | $GREP -v "!" > localdevenvtmp.export1.sort
ohair@494 176 $COMM -1 -3 localdevenvtmp.export0.sort localdevenvtmp.export1.sort > localdevenv.sh
ohair@494 177
ohair@494 178 # cleanup
ohair@494 179 $RM localdevenvtmp*
ohair@494 180 #----
ohair@494 181 cd $CURDIR
ohair@494 182 if test ! -s $OUTPUT_ROOT/localdevenv.sh; then
ohair@494 183 AC_MSG_RESULT([no])
ohair@494 184 AC_MSG_NOTICE([Could not succesfully extract the envionment variables needed for the VS setup.])
ohair@494 185 AC_MSG_NOTICE([Try setting --with-tools-dir to the VC/bin directory within the VS installation])
ohair@494 186 AC_MSG_NOTICE([or run "bash.exe -l" from a VS command prompt and then run configure from there.])
ohair@494 187 AC_MSG_ERROR([Cannot continue])
ohair@494 188 fi
ohair@494 189
ohair@494 190 # Now set all paths and other env variables. This will allow the rest of
ohair@494 191 # the configure script to find and run the compiler in the proper way.
ohair@494 192 AC_MSG_NOTICE([Setting extracted environment variables])
ohair@494 193 . $OUTPUT_ROOT/localdevenv.sh
ohair@494 194 else
ohair@494 195 # We did not find a vsvars bat file, let's hope we are run from a VS command prompt.
ohair@494 196 AC_MSG_NOTICE([Cannot locate a valid Visual Studio installation, checking current environment])
ohair@494 197 fi
ohair@494 198
ohair@494 199 # At this point, we should have corrent variables in the environment, or we can't continue.
ohair@494 200 AC_MSG_CHECKING([for Visual Studio variables])
ohair@494 201
ohair@494 202 if test "x$VCINSTALLDIR" != x || test "x$WindowsSDKDir" != x || test "x$WINDOWSSDKDIR" != x; then
ohair@494 203 if test "x$INCLUDE" = x || test "x$LIB" = x; then
ohair@494 204 AC_MSG_RESULT([present but broken])
ohair@494 205 AC_MSG_ERROR([Your VC command prompt seems broken, INCLUDE and/or LIB is missing.])
ohair@494 206 else
ohair@494 207 AC_MSG_RESULT([ok])
erikj@522 208 # Remove any trailing \ from INCLUDE and LIB to avoid trouble in spec.gmk.
erikj@522 209 VS_INCLUDE=`$ECHO "$INCLUDE" | $SED 's/\\\\$//'`
erikj@522 210 VS_LIB=`$ECHO "$LIB" | $SED 's/\\\\$//'`
tbell@759 211 # Remove any paths containing # (typically F#) as that messes up make
tbell@759 212 PATH=`$ECHO "$PATH" | $SED 's/[[^:#]]*#[^:]*://g'`
ohair@494 213 VS_PATH="$PATH"
ohair@494 214 AC_SUBST(VS_INCLUDE)
ohair@494 215 AC_SUBST(VS_LIB)
ohair@494 216 AC_SUBST(VS_PATH)
ohair@494 217 fi
ohair@494 218 else
ohair@494 219 AC_MSG_RESULT([not found])
ohair@494 220
ohair@494 221 if test "x$VS_ENV_CMD" = x; then
ohair@494 222 AC_MSG_NOTICE([Cannot locate a valid Visual Studio or Windows SDK installation on disk,])
ohair@494 223 AC_MSG_NOTICE([nor is this script run from a Visual Studio command prompt.])
ohair@494 224 else
ohair@494 225 AC_MSG_NOTICE([Running the extraction script failed.])
ohair@494 226 fi
ohair@494 227 AC_MSG_NOTICE([Try setting --with-tools-dir to the VC/bin directory within the VS installation])
ohair@494 228 AC_MSG_NOTICE([or run "bash.exe -l" from a VS command prompt and then run configure from there.])
ohair@494 229 AC_MSG_ERROR([Cannot continue])
ohair@494 230 fi
ohair@494 231
ohair@494 232 AC_MSG_CHECKING([for msvcr100.dll])
ohair@494 233 AC_ARG_WITH(msvcr-dll, [AS_HELP_STRING([--with-msvcr-dll],
ohair@494 234 [copy this msvcr100.dll into the built JDK (Windows only) @<:@probed@:>@])])
ohair@494 235 if test "x$with_msvcr_dll" != x; then
ohair@494 236 MSVCR_DLL="$with_msvcr_dll"
ohair@494 237 else
ohair@494 238 if test "x$VCINSTALLDIR" != x; then
ohair@494 239 if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
ohair@494 240 MSVCR_DLL=`find "$VCINSTALLDIR" -name msvcr100.dll | grep x64 | head --lines 1`
ohair@494 241 else
ohair@494 242 MSVCR_DLL=`find "$VCINSTALLDIR" -name msvcr100.dll | grep x86 | grep -v ia64 | grep -v x64 | head --lines 1`
ohair@494 243 if test "x$MSVCR_DLL" = x; then
ohair@494 244 MSVCR_DLL=`find "$VCINSTALLDIR" -name msvcr100.dll | head --lines 1`
ohair@494 245 fi
ohair@494 246 fi
ohair@494 247 if test "x$MSVCR_DLL" != x; then
ohair@494 248 AC_MSG_NOTICE([msvcr100.dll found in VCINSTALLDIR: $VCINSTALLDIR])
ohair@494 249 else
ohair@494 250 AC_MSG_NOTICE([Warning: msvcr100.dll not found in VCINSTALLDIR: $VCINSTALLDIR])
ohair@494 251 fi
ohair@494 252 fi
erikj@733 253 # Try some fallback alternatives
ohair@494 254 if test "x$MSVCR_DLL" = x; then
erikj@733 255 # If visual studio express is installed, there is usually one with the debugger
erikj@733 256 if test "x$VS100COMNTOOLS" != x; then
erikj@733 257 if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
erikj@733 258 MSVCR_DLL=`find "$VS100COMNTOOLS/.." -name msvcr100.dll | grep -i x64 | head --lines 1`
erikj@733 259 AC_MSG_NOTICE([msvcr100.dll found in $VS100COMNTOOLS..: $VS100COMNTOOLS..])
erikj@733 260 fi
erikj@733 261 fi
erikj@733 262 fi
erikj@733 263 if test "x$MSVCR_DLL" = x; then
erikj@733 264 if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
erikj@733 265 # Fallback for 32bit builds, look in the windows directory.
erikj@733 266 if test -f "$SYSTEMROOT/system32/msvcr100.dll"; then
erikj@733 267 AC_MSG_NOTICE([msvcr100.dll found in $SYSTEMROOT/system32])
erikj@733 268 MSVCR_DLL="$SYSTEMROOT/system32/msvcr100.dll"
erikj@733 269 fi
ohair@494 270 fi
ohair@494 271 fi
ohair@494 272 fi
ohair@494 273 if test "x$MSVCR_DLL" = x; then
ohair@494 274 AC_MSG_RESULT([no])
ohair@494 275 AC_MSG_ERROR([Could not find msvcr100.dll !])
ohair@494 276 fi
ohair@494 277 AC_MSG_RESULT([$MSVCR_DLL])
ohair@494 278 BASIC_FIXUP_PATH(MSVCR_DLL)
ohair@494 279 ])

mercurial