common/autoconf/toolchain_windows.m4

Wed, 16 May 2018 15:52:51 -0700

author
kevinw
date
Wed, 16 May 2018 15:52:51 -0700
changeset 2223
01cc48ed67f3
parent 2220
47fda751abb6
child 2224
20daa32eec6f
permissions
-rw-r--r--

8042707: Source changes needed to build JDK 9 with Visual Studio 2013 (VS2013)
Reviewed-by: erikj, ihse, ddehaven, billyh

ohair@494 1 #
kevinw@2223 2 # Copyright (c) 2011, 2018, 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
kevinw@2223 26 ################################################################################
kevinw@2223 27
kevinw@2223 28 VALID_VS_VERSIONS="2010 2012 2013"
kevinw@2223 29
kevinw@2223 30 VS_DESCRIPTION_2010="Microsoft Visual Studio 2010"
kevinw@2223 31 VS_VERSION_INTERNAL_2010=100
kevinw@2223 32 VS_MSVCR_2010=msvcr100.dll
kevinw@2223 33 # We don't use msvcp on Visual Studio 2010
kevinw@2223 34 #VS_MSVCP_2010=msvcp100.dll
kevinw@2223 35 VS_ENVVAR_2010="VS100COMNTOOLS"
kevinw@2223 36 VS_VS_INSTALLDIR_2010="Microsoft Visual Studio 10.0"
kevinw@2223 37 VS_SDK_INSTALLDIR_2010="Microsoft SDKs/Windows/v7.1"
kevinw@2223 38 VS_VS_PLATFORM_NAME_2010="v100"
kevinw@2223 39 VS_SDK_PLATFORM_NAME_2010="Windows7.1SDK"
kevinw@2223 40
kevinw@2223 41 VS_DESCRIPTION_2012="Microsoft Visual Studio 2012"
kevinw@2223 42 VS_VERSION_INTERNAL_2012=110
kevinw@2223 43 VS_MSVCR_2012=msvcr110.dll
kevinw@2223 44 VS_MSVCP_2012=msvcp110.dll
kevinw@2223 45 VS_ENVVAR_2012="VS110COMNTOOLS"
kevinw@2223 46 VS_VS_INSTALLDIR_2012="Microsoft Visual Studio 11.0"
kevinw@2223 47 VS_SDK_INSTALLDIR_2012=
kevinw@2223 48 VS_VS_PLATFORM_NAME_2012="v110"
kevinw@2223 49 VS_SDK_PLATFORM_NAME_2012=
kevinw@2223 50
kevinw@2223 51 VS_DESCRIPTION_2013="Microsoft Visual Studio 2013"
kevinw@2223 52 VS_VERSION_INTERNAL_2013=120
kevinw@2223 53 VS_MSVCR_2013=msvcr120.dll
kevinw@2223 54 VS_MSVCP_2013=msvcp120.dll
kevinw@2223 55 VS_ENVVAR_2013="VS120COMNTOOLS"
kevinw@2223 56 VS_VS_INSTALLDIR_2013="Microsoft Visual Studio 12.0"
kevinw@2223 57 VS_SDK_INSTALLDIR_2013=
kevinw@2223 58 VS_VS_PLATFORM_NAME_2013="v120"
kevinw@2223 59 VS_SDK_PLATFORM_NAME_2013=
kevinw@2223 60
kevinw@2223 61 ################################################################################
kevinw@2223 62
ohair@494 63 AC_DEFUN([TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT],
ohair@494 64 [
ohair@494 65 if test "x$VS_ENV_CMD" = x; then
kevinw@2223 66 VS_VERSION="$1"
kevinw@2223 67 VS_BASE="$2"
kevinw@2223 68 METHOD="$3"
kevinw@2223 69
kevinw@2223 70 if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
kevinw@2223 71 VCVARSFILE="vc/bin/vcvars32.bat"
kevinw@2223 72 else
kevinw@2223 73 VCVARSFILE="vc/bin/amd64/vcvars64.bat"
kevinw@2223 74 fi
kevinw@2223 75
kevinw@2223 76 BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(VS_BASE)
kevinw@2223 77 if test -d "$VS_BASE"; then
kevinw@2223 78 if test -f "$VS_BASE/$VCVARSFILE"; then
kevinw@2223 79 AC_MSG_NOTICE([Found Visual Studio installation at $VS_BASE using $METHOD])
kevinw@2223 80 VS_ENV_CMD="$VS_BASE/$VCVARSFILE"
kevinw@2220 81 # PLATFORM_TOOLSET is used during the compilation of the freetype sources (see
kevinw@2220 82 # 'LIB_BUILD_FREETYPE' in libraries.m4) and must be one of 'v100', 'v110' or 'v120' for VS 2010, 2012 or VS2013
kevinw@2223 83 eval PLATFORM_TOOLSET="\${VS_VS_PLATFORM_NAME_${VS_VERSION}}"
ohair@494 84 else
kevinw@2223 85 AC_MSG_NOTICE([Found Visual Studio installation at $VS_BASE using $METHOD])
ohair@494 86 AC_MSG_NOTICE([Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring])
ohair@494 87 fi
ohair@494 88 fi
ohair@494 89 fi
ohair@494 90 ])
ohair@494 91
kevinw@2223 92 ################################################################################
kevinw@2223 93
ohair@494 94 AC_DEFUN([TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT],
ohair@494 95 [
ohair@494 96 if test "x$VS_ENV_CMD" = x; then
kevinw@2223 97 VS_VERSION="$1"
kevinw@2223 98 WIN_SDK_BASE="$2"
kevinw@2223 99 METHOD="$3"
ohair@494 100 BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(WIN_SDK_BASE)
ohair@494 101 if test -d "$WIN_SDK_BASE"; then
erikj@525 102 # There have been cases of partial or broken SDK installations. A missing
erikj@525 103 # lib dir is not going to work.
kevinw@2223 104 if test ! -d "$WIN_SDK_BASE/lib"; then
erikj@525 105 AC_MSG_NOTICE([Found Windows SDK installation at $WIN_SDK_BASE using $METHOD])
erikj@525 106 AC_MSG_NOTICE([Warning: Installation is broken, lib dir is missing. Ignoring])
kevinw@2223 107 elif test -f "$WIN_SDK_BASE/Bin/SetEnv.Cmd"; then
ohair@494 108 AC_MSG_NOTICE([Found Windows SDK installation at $WIN_SDK_BASE using $METHOD])
kevinw@2223 109 VS_ENV_CMD="$WIN_SDK_BASE/Bin/SetEnv.Cmd"
ohair@494 110 if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
ohair@494 111 VS_ENV_ARGS="/x86"
ohair@494 112 else
ohair@494 113 VS_ENV_ARGS="/x64"
ohair@494 114 fi
kevinw@2220 115 # PLATFORM_TOOLSET is used during the compilation of the freetype sources (see
kevinw@2220 116 # 'LIB_BUILD_FREETYPE' in libraries.m4) and must be 'Windows7.1SDK' for Windows7.1SDK
kevinw@2220 117 # TODO: improve detection for other versions of SDK
kevinw@2223 118 eval PLATFORM_TOOLSET="\${VS_SDK_PLATFORM_NAME_${VS_VERSION}}"
ohair@494 119 else
ohair@494 120 AC_MSG_NOTICE([Found Windows SDK installation at $WIN_SDK_BASE using $METHOD])
ohair@494 121 AC_MSG_NOTICE([Warning: Installation is broken, SetEnv.Cmd is missing. Ignoring])
ohair@494 122 fi
ohair@494 123 fi
ohair@494 124 fi
ohair@494 125 ])
ohair@494 126
kevinw@2223 127 ################################################################################
kevinw@2223 128 # Finds the bat or cmd file in Visual Studio or the SDK that sets up a proper
kevinw@2223 129 # build environment and assigns it to VS_ENV_CMD
ohair@494 130 AC_DEFUN([TOOLCHAIN_FIND_VISUAL_STUDIO_BAT_FILE],
ohair@494 131 [
kevinw@2223 132 VS_VERSION="$1"
kevinw@2223 133 eval VS_COMNTOOLS_VAR="\${VS_ENVVAR_${VS_VERSION}}"
kevinw@2223 134 eval VS_COMNTOOLS="\$${VS_COMNTOOLS_VAR}"
kevinw@2223 135 eval VS_INSTALL_DIR="\${VS_VS_INSTALLDIR_${VS_VERSION}}"
kevinw@2223 136 eval SDK_INSTALL_DIR="\${VS_SDK_INSTALLDIR_${VS_VERSION}}"
kevinw@2223 137
kevinw@2223 138 # When using --with-tools-dir, assume it points to the correct and default
kevinw@2223 139 # version of Visual Studio or that --with-toolchain-version was also set.
kevinw@2223 140 if test "x$with_tools_dir" != x; then
kevinw@2223 141 TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}],
kevinw@2223 142 [$with_tools_dir/../..], [--with-tools-dir])
kevinw@2223 143 TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}],
kevinw@2223 144 [$with_tools_dir/../../..], [--with-tools-dir])
kevinw@2223 145 if test "x$VS_ENV_CMD" = x; then
kevinw@2223 146 # Having specified an argument which is incorrect will produce an instant failure;
kevinw@2223 147 # we should not go on looking
kevinw@2223 148 AC_MSG_NOTICE([The path given by --with-tools-dir does not contain a valid])
kevinw@2223 149 AC_MSG_NOTICE([Visual Studio installation. Please point to the VC/bin or VC/bin/amd64])
kevinw@2223 150 AC_MSG_NOTICE([directory within the Visual Studio installation])
kevinw@2223 151 AC_MSG_ERROR([Cannot locate a valid Visual Studio installation])
kevinw@2223 152 fi
ihse@839 153 fi
ohair@494 154
ohair@494 155 VS_ENV_CMD=""
ohair@494 156 VS_ENV_ARGS=""
kevinw@2223 157
kevinw@2223 158 if test "x$VS_COMNTOOLS" != x; then
kevinw@2223 159 TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}],
kevinw@2223 160 [$VS_COMNTOOLS/../..], [$VS_COMNTOOLS_VAR variable])
kevinw@2223 161 fi
kevinw@2223 162 if test "x$PROGRAMFILES" != x; then
kevinw@2223 163 TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}],
kevinw@2223 164 [$PROGRAMFILES/$VS_INSTALL_DIR], [well-known name])
kevinw@2223 165 fi
kevinw@2223 166 # Work around the insanely named ProgramFiles(x86) env variable
kevinw@2223 167 PROGRAMFILES_X86="`env | $SED -n 's/^ProgramFiles(x86)=//p'`"
kevinw@2223 168 if test "x$PROGRAMFILES_X86" != x; then
kevinw@2223 169 TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}],
kevinw@2223 170 [$PROGRAMFILES_X86/$VS_INSTALL_DIR], [well-known name])
kevinw@2223 171 fi
kevinw@2223 172 TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}],
kevinw@2223 173 [C:/Program Files/$VS_INSTALL_DIR], [well-known name])
kevinw@2223 174 TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}],
kevinw@2223 175 [C:/Program Files (x86)/$VS_INSTALL_DIR], [well-known name])
kevinw@2223 176
kevinw@2223 177 if test "x$SDK_INSTALL_DIR" != x; then
kevinw@2223 178 if test "x$ProgramW6432" != x; then
kevinw@2223 179 TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([${VS_VERSION}],
kevinw@2223 180 [$ProgramW6432/$SDK_INSTALL_DIR], [well-known name])
kevinw@2223 181 fi
kevinw@2223 182 if test "x$PROGRAMW6432" != x; then
kevinw@2223 183 TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([${VS_VERSION}],
kevinw@2223 184 [$PROGRAMW6432/$SDK_INSTALL_DIR], [well-known name])
kevinw@2223 185 fi
kevinw@2223 186 if test "x$PROGRAMFILES" != x; then
kevinw@2223 187 TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([${VS_VERSION}],
kevinw@2223 188 [$PROGRAMFILES/$SDK_INSTALL_DIR], [well-known name])
kevinw@2223 189 fi
kevinw@2223 190 TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([${VS_VERSION}],
kevinw@2223 191 [C:/Program Files/$SDK_INSTALL_DIR], [well-known name])
kevinw@2223 192 TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([${VS_VERSION}],
kevinw@2223 193 [C:/Program Files (x86)/$SDK_INSTALL_DIR], [well-known name])
kevinw@2223 194 fi
kevinw@2223 195 ])
kevinw@2223 196
kevinw@2223 197 ################################################################################
kevinw@2223 198
kevinw@2223 199 AC_DEFUN([TOOLCHAIN_FIND_VISUAL_STUDIO],
kevinw@2223 200 [
kevinw@2223 201 AC_ARG_WITH(toolchain-version, [AS_HELP_STRING([--with-toolchain-version],
kevinw@2223 202 [the version of the toolchain to look for, use '--help' to show possible values @<:@platform dependent@:>@])])
kevinw@2223 203
kevinw@2223 204 if test "x$with_toolchain_version" = xlist; then
kevinw@2223 205 # List all toolchains
kevinw@2223 206 AC_MSG_NOTICE([The following toolchain versions are valid on this platform:])
kevinw@2223 207 for version in $VALID_VS_VERSIONS; do
kevinw@2223 208 eval VS_DESCRIPTION=\${VS_DESCRIPTION_$version}
kevinw@2223 209 $PRINTF " %-10s %s\n" $version "$VS_DESCRIPTION"
kevinw@2223 210 done
kevinw@2223 211
kevinw@2223 212 exit 0
kevinw@2223 213 elif test "x$with_toolchain_version" != x; then
kevinw@2223 214 # User override; check that it is valid
kevinw@2223 215 if test "x${VALID_VS_VERSIONS/$with_toolchain_version/}" = "x${VALID_VS_VERSIONS}"; then
kevinw@2223 216 AC_MSG_NOTICE([Visual Studio version $with_toolchain_version is not valid.])
kevinw@2223 217 AC_MSG_NOTICE([Valid Visual Studio versions: $VALID_VS_VERSIONS.])
kevinw@2223 218 AC_MSG_ERROR([Cannot continue.])
kevinw@2223 219 fi
kevinw@2223 220 VS_VERSIONS_PROBE_LIST="$with_toolchain_version"
kevinw@2223 221 else
kevinw@2223 222 # No flag given, use default
kevinw@2223 223 VS_VERSIONS_PROBE_LIST="$VALID_VS_VERSIONS"
ohair@494 224 fi
ohair@494 225
kevinw@2223 226 for VS_VERSION in $VS_VERSIONS_PROBE_LIST; do
kevinw@2223 227 TOOLCHAIN_FIND_VISUAL_STUDIO_BAT_FILE([$VS_VERSION])
kevinw@2223 228 if test "x$VS_ENV_CMD" != x; then
kevinw@2223 229 TOOLCHAIN_VERSION=$VS_VERSION
kevinw@2223 230 eval VS_DESCRIPTION="\${VS_DESCRIPTION_${VS_VERSION}}"
kevinw@2223 231 eval VS_VERSION_INTERNAL="\${VS_VERSION_INTERNAL_${VS_VERSION}}"
kevinw@2223 232 eval MSVCR_NAME="\${VS_MSVCR_${VS_VERSION}}"
kevinw@2223 233 eval MSVCP_NAME="\${VS_MSVCP_${VS_VERSION}}"
kevinw@2223 234 # The rest of the variables are already evaled while probing
kevinw@2223 235 AC_MSG_NOTICE([Found $VS_DESCRIPTION])
kevinw@2223 236 break
kevinw@2223 237 fi
kevinw@2223 238 done
ohair@494 239 ])
ohair@494 240
kevinw@2223 241 ################################################################################
ohair@494 242 # Check if the VS env variables were setup prior to running configure.
ohair@494 243 # If not, then find vcvarsall.bat and run it automatically, and integrate
ohair@494 244 # the set env variables into the spec file.
ohair@494 245 AC_DEFUN([TOOLCHAIN_SETUP_VISUAL_STUDIO_ENV],
ohair@494 246 [
ihse@839 247 # Store path to cygwin link.exe to help excluding it when searching for
ohair@494 248 # VS linker. This must be done before changing the PATH when looking for VS.
ohair@494 249 AC_PATH_PROG(CYGWIN_LINK, link)
ohair@494 250 if test "x$CYGWIN_LINK" != x; then
ohair@494 251 AC_MSG_CHECKING([if the first found link.exe is actually the Cygwin link tool])
ohair@494 252 "$CYGWIN_LINK" --version > /dev/null
ohair@494 253 if test $? -eq 0 ; then
ohair@494 254 AC_MSG_RESULT([yes])
ohair@494 255 else
ohair@494 256 AC_MSG_RESULT([no])
ohair@494 257 # This might be the VS linker. Don't exclude it later on.
ohair@494 258 CYGWIN_LINK=""
ohair@494 259 fi
ohair@494 260 fi
ohair@494 261
ohair@494 262 # First-hand choice is to locate and run the vsvars bat file.
kevinw@2223 263 TOOLCHAIN_FIND_VISUAL_STUDIO
kevinw@2223 264
ohair@494 265 if test "x$VS_ENV_CMD" != x; then
ohair@494 266 # We have found a Visual Studio environment on disk, let's extract variables from the vsvars bat file.
ohair@494 267 BASIC_FIXUP_EXECUTABLE(VS_ENV_CMD)
ohair@494 268
ohair@494 269 # Lets extract the variables that are set by vcvarsall.bat/vsvars32.bat/vsvars64.bat
ohair@494 270 AC_MSG_NOTICE([Trying to extract Visual Studio environment variables])
ohair@494 271
kevinw@2208 272 # We need to create a couple of temporary files.
kevinw@2208 273 VS_ENV_TMP_DIR="$OUTPUT_ROOT/vs-env"
kevinw@2208 274 $MKDIR -p $VS_ENV_TMP_DIR
ohair@494 275
kevinw@2208 276 # Cannot use the VS10 setup script directly (since it only updates the DOS subshell environment).
kevinw@2208 277 # Instead create a shell script which will set the relevant variables when run.
kevinw@2208 278 WINPATH_VS_ENV_CMD="$VS_ENV_CMD"
kevinw@2208 279 BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH([WINPATH_VS_ENV_CMD])
kevinw@2208 280 WINPATH_BASH="$BASH"
kevinw@2208 281 BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH([WINPATH_BASH])
ohair@494 282
kevinw@2208 283 # Generate a DOS batch file which runs $VS_ENV_CMD, and then creates a shell
kevinw@2208 284 # script (executable by bash) that will setup the important variables.
kevinw@2208 285 EXTRACT_VC_ENV_BAT_FILE="$VS_ENV_TMP_DIR/extract-vs-env.bat"
kevinw@2208 286 $ECHO "@echo off" > $EXTRACT_VC_ENV_BAT_FILE
kevinw@2208 287 # This will end up something like:
kevinw@2208 288 # call C:/progra~2/micros~2.0/vc/bin/amd64/vcvars64.bat
kevinw@2208 289 $ECHO "call $WINPATH_VS_ENV_CMD $VS_ENV_ARGS" >> $EXTRACT_VC_ENV_BAT_FILE
kevinw@2208 290 # These will end up something like:
kevinw@2208 291 # C:/CygWin/bin/bash -c 'echo VS_PATH=\"$PATH\" > localdevenv.sh
kevinw@2208 292 # The trailing space for everyone except PATH is no typo, but is needed due
kevinw@2208 293 # to trailing \ in the Windows paths. These will be stripped later.
kevinw@2208 294 $ECHO "$WINPATH_BASH -c 'echo VS_PATH="'\"$PATH\" > set-vs-env.sh' >> $EXTRACT_VC_ENV_BAT_FILE
kevinw@2208 295 $ECHO "$WINPATH_BASH -c 'echo VS_INCLUDE="'\"$INCLUDE \" >> set-vs-env.sh' >> $EXTRACT_VC_ENV_BAT_FILE
kevinw@2208 296 $ECHO "$WINPATH_BASH -c 'echo VS_LIB="'\"$LIB \" >> set-vs-env.sh' >> $EXTRACT_VC_ENV_BAT_FILE
kevinw@2208 297 $ECHO "$WINPATH_BASH -c 'echo VCINSTALLDIR="'\"$VCINSTALLDIR \" >> set-vs-env.sh' >> $EXTRACT_VC_ENV_BAT_FILE
kevinw@2208 298 $ECHO "$WINPATH_BASH -c 'echo WindowsSdkDir="'\"$WindowsSdkDir \" >> set-vs-env.sh' >> $EXTRACT_VC_ENV_BAT_FILE
kevinw@2208 299 $ECHO "$WINPATH_BASH -c 'echo WINDOWSSDKDIR="'\"$WINDOWSSDKDIR \" >> set-vs-env.sh' >> $EXTRACT_VC_ENV_BAT_FILE
ohair@494 300
ohair@494 301 # Now execute the newly created bat file.
kevinw@2208 302 # The | cat is to stop SetEnv.Cmd to mess with system colors on msys.
kevinw@2208 303 # Change directory so we don't need to mess with Windows paths in redirects.
kevinw@2208 304 cd $VS_ENV_TMP_DIR
kevinw@2208 305 cmd /c extract-vs-env.bat | $CAT
kevinw@2208 306 cd $CURDIR
ohair@494 307
kevinw@2208 308 if test ! -s $VS_ENV_TMP_DIR/set-vs-env.sh; then
ohair@494 309 AC_MSG_NOTICE([Could not succesfully extract the envionment variables needed for the VS setup.])
ohair@494 310 AC_MSG_NOTICE([Try setting --with-tools-dir to the VC/bin directory within the VS installation])
ohair@494 311 AC_MSG_NOTICE([or run "bash.exe -l" from a VS command prompt and then run configure from there.])
ohair@494 312 AC_MSG_ERROR([Cannot continue])
ohair@494 313 fi
ohair@494 314
ihse@839 315 # Now set all paths and other env variables. This will allow the rest of
ohair@494 316 # the configure script to find and run the compiler in the proper way.
ohair@494 317 AC_MSG_NOTICE([Setting extracted environment variables])
kevinw@2208 318 . $VS_ENV_TMP_DIR/set-vs-env.sh
kevinw@2208 319 # Now we have VS_PATH, VS_INCLUDE, VS_LIB. For further checking, we
kevinw@2208 320 # also define VCINSTALLDIR, WindowsSdkDir and WINDOWSSDKDIR.
ohair@494 321 else
ohair@494 322 # We did not find a vsvars bat file, let's hope we are run from a VS command prompt.
ohair@494 323 AC_MSG_NOTICE([Cannot locate a valid Visual Studio installation, checking current environment])
ohair@494 324 fi
ohair@494 325
kevinw@2208 326 # At this point, we should have correct variables in the environment, or we can't continue.
ohair@494 327 AC_MSG_CHECKING([for Visual Studio variables])
ihse@839 328
ohair@494 329 if test "x$VCINSTALLDIR" != x || test "x$WindowsSDKDir" != x || test "x$WINDOWSSDKDIR" != x; then
kevinw@2208 330 if test "x$VS_INCLUDE" = x || test "x$VS_LIB" = x; then
ohair@494 331 AC_MSG_RESULT([present but broken])
ohair@494 332 AC_MSG_ERROR([Your VC command prompt seems broken, INCLUDE and/or LIB is missing.])
ohair@494 333 else
ohair@494 334 AC_MSG_RESULT([ok])
kevinw@2208 335 # Remove any trailing "\" and " " from the variables.
kevinw@2208 336 VS_INCLUDE=`$ECHO "$VS_INCLUDE" | $SED 's/\\\\* *$//'`
kevinw@2208 337 VS_LIB=`$ECHO "$VS_LIB" | $SED 's/\\\\* *$//'`
kevinw@2208 338 VCINSTALLDIR=`$ECHO "$VCINSTALLDIR" | $SED 's/\\\\* *$//'`
kevinw@2208 339 WindowsSDKDir=`$ECHO "$WindowsSDKDir" | $SED 's/\\\\* *$//'`
kevinw@2208 340 WINDOWSSDKDIR=`$ECHO "$WINDOWSSDKDIR" | $SED 's/\\\\* *$//'`
kevinw@2209 341 # Remove any paths containing # (typically F#) as that messes up make. This
kevinw@2209 342 # is needed if visual studio was installed with F# support.
kevinw@2209 343 VS_PATH=`$ECHO "$VS_PATH" | $SED 's/[[^:#]]*#[^:]*://g'`
kevinw@2208 344
kevinw@2208 345 AC_SUBST(VS_PATH)
ohair@494 346 AC_SUBST(VS_INCLUDE)
ohair@494 347 AC_SUBST(VS_LIB)
ohair@494 348 fi
ohair@494 349 else
ohair@494 350 AC_MSG_RESULT([not found])
ohair@494 351
ohair@494 352 if test "x$VS_ENV_CMD" = x; then
ohair@494 353 AC_MSG_NOTICE([Cannot locate a valid Visual Studio or Windows SDK installation on disk,])
ohair@494 354 AC_MSG_NOTICE([nor is this script run from a Visual Studio command prompt.])
ohair@494 355 else
ohair@494 356 AC_MSG_NOTICE([Running the extraction script failed.])
ohair@494 357 fi
ohair@494 358 AC_MSG_NOTICE([Try setting --with-tools-dir to the VC/bin directory within the VS installation])
ohair@494 359 AC_MSG_NOTICE([or run "bash.exe -l" from a VS command prompt and then run configure from there.])
ohair@494 360 AC_MSG_ERROR([Cannot continue])
ohair@494 361 fi
ihse@857 362 ])
ihse@839 363
kevinw@2223 364 AC_DEFUN([TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL],
ihse@857 365 [
kevinw@2223 366 DLL_NAME="$1"
kevinw@2223 367 POSSIBLE_MSVC_DLL="$2"
kevinw@2223 368 METHOD="$3"
kevinw@2223 369 if test -n "$POSSIBLE_MSVC_DLL" -a -e "$POSSIBLE_MSVC_DLL"; then
kevinw@2223 370 AC_MSG_NOTICE([Found $1 at $POSSIBLE_MSVC_DLL using $METHOD])
kevinw@2223 371
ihse@857 372 # Need to check if the found msvcr is correct architecture
kevinw@2223 373 AC_MSG_CHECKING([found $1 architecture])
kevinw@2223 374 MSVC_DLL_FILETYPE=`$FILE -b "$POSSIBLE_MSVC_DLL"`
kevinw@2219 375 if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
kevinw@2219 376 # The MSYS 'file' command returns "PE32 executable for MS Windows (DLL) (GUI) Intel 80386 32-bit"
kevinw@2219 377 # on x32 and "PE32+ executable for MS Windows (DLL) (GUI) Mono/.Net assembly" on x64 systems.
kevinw@2219 378 if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
kevinw@2219 379 CORRECT_MSVCR_ARCH="PE32 executable"
kevinw@2219 380 else
kevinw@2219 381 CORRECT_MSVCR_ARCH="PE32+ executable"
kevinw@2219 382 fi
ihse@857 383 else
kevinw@2219 384 if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
kevinw@2219 385 CORRECT_MSVCR_ARCH=386
kevinw@2219 386 else
kevinw@2219 387 CORRECT_MSVCR_ARCH=x86-64
kevinw@2219 388 fi
ihse@857 389 fi
kevinw@2223 390 if $ECHO "$MSVC_DLL_FILETYPE" | $GREP "$CORRECT_MSVCR_ARCH" 2>&1 > /dev/null; then
ihse@857 391 AC_MSG_RESULT([ok])
kevinw@2223 392 MSVC_DLL="$POSSIBLE_MSVC_DLL"
kevinw@2223 393 AC_MSG_CHECKING([for $1])
kevinw@2223 394 AC_MSG_RESULT([$MSVC_DLL])
ihse@857 395 else
ihse@857 396 AC_MSG_RESULT([incorrect, ignoring])
kevinw@2223 397 AC_MSG_NOTICE([The file type of the located $1 is $MSVC_DLL_FILETYPE])
ihse@857 398 fi
ihse@857 399 fi
ihse@857 400 ])
ihse@857 401
kevinw@2223 402 AC_DEFUN([TOOLCHAIN_SETUP_MSVC_DLL],
ihse@857 403 [
kevinw@2223 404 VAR_NAME="$1"
kevinw@2223 405 DLL_NAME="$2"
kevinw@2223 406 MSVC_DLL=
ihse@857 407
kevinw@2223 408 if test "x$MSVC_DLL" = x; then
ihse@857 409 # Probe: Using well-known location from Visual Studio 10.0
ohair@494 410 if test "x$VCINSTALLDIR" != x; then
ihse@857 411 CYGWIN_VC_INSTALL_DIR="$VCINSTALLDIR"
ihse@857 412 BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(CYGWIN_VC_INSTALL_DIR)
ohair@494 413 if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
kevinw@2223 414 POSSIBLE_MSVC_DLL="$CYGWIN_VC_INSTALL_DIR/redist/x64/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME"
ohair@494 415 else
kevinw@2223 416 POSSIBLE_MSVC_DLL="$CYGWIN_VC_INSTALL_DIR/redist/x86/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME"
ihse@857 417 fi
kevinw@2223 418 $ECHO "POSSIBLE_MSVC_DLL $POSSIBLEMSVC_DLL"
kevinw@2223 419 TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$POSSIBLE_MSVC_DLL],
kevinw@2223 420 [well-known location in VCINSTALLDIR])
ihse@857 421 fi
ihse@857 422 fi
ihse@857 423
kevinw@2223 424 if test "x$MSVC_DLL" = x; then
ihse@857 425 # Probe: Check in the Boot JDK directory.
kevinw@2223 426 POSSIBLE_MSVC_DLL="$BOOT_JDK/bin/$DLL_NAME"
kevinw@2223 427 TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL($[DLL_NAME], [$POSSIBLE_MSVC_DLL],
kevinw@2223 428 [well-known location in Boot JDK])
ihse@857 429 fi
ihse@857 430
kevinw@2223 431 if test "x$MSVC_DLL" = x; then
ihse@857 432 # Probe: Look in the Windows system32 directory
ihse@857 433 CYGWIN_SYSTEMROOT="$SYSTEMROOT"
ihse@857 434 BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(CYGWIN_SYSTEMROOT)
kevinw@2223 435 POSSIBLE_MSVC_DLL="$CYGWIN_SYSTEMROOT/system32/$DLL_NAME"
kevinw@2223 436 TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$POSSIBLE_MSVC_DLL],
kevinw@2223 437 [well-known location in SYSTEMROOT])
ihse@857 438 fi
ihse@857 439
kevinw@2223 440 if test "x$MSVC_DLL" = x; then
ihse@857 441 # Probe: If Visual Studio Express is installed, there is usually one with the debugger
ihse@857 442 if test "x$VS100COMNTOOLS" != x; then
ihse@857 443 CYGWIN_VS_TOOLS_DIR="$VS100COMNTOOLS/.."
ihse@857 444 BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(CYGWIN_VS_TOOLS_DIR)
ihse@857 445 if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
kevinw@2223 446 POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VS_TOOLS_DIR" -name $DLL_NAME \
kevinw@2223 447 | $GREP -i /x64/ | $HEAD --lines 1`
ihse@857 448 else
kevinw@2223 449 POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VS_TOOLS_DIR" -name $DLL_NAME \
kevinw@2223 450 | $GREP -i /x86/ | $HEAD --lines 1`
ihse@857 451 fi
kevinw@2223 452 TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$POSSIBLE_MSVC_DLL],
kevinw@2223 453 [search of VS100COMNTOOLS])
ihse@857 454 fi
ihse@857 455 fi
ihse@857 456
kevinw@2223 457 if test "x$MSVC_DLL" = x; then
ihse@857 458 # Probe: Search wildly in the VCINSTALLDIR. We've probably lost by now.
kevinw@2223 459 # (This was the original behaviour; kept since it might turn something up)
ihse@857 460 if test "x$CYGWIN_VC_INSTALL_DIR" != x; then
ihse@857 461 if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
kevinw@2223 462 POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VC_INSTALL_DIR" -name $DLL_NAME \
kevinw@2223 463 | $GREP x64 | $HEAD --lines 1`
ihse@857 464 else
kevinw@2223 465 POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VC_INSTALL_DIR" -name $DLL_NAME \
kevinw@2223 466 | $GREP x86 | $GREP -v ia64 | $GREP -v x64 | $HEAD --lines 1`
kevinw@2223 467 if test "x$POSSIBLE_MSVC_DLL" = x; then
ihse@857 468 # We're grasping at straws now...
kevinw@2223 469 POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VC_INSTALL_DIR" -name $DLL_NAME \
kevinw@2223 470 | $HEAD --lines 1`
ohair@494 471 fi
ohair@494 472 fi
ihse@857 473
kevinw@2223 474 TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$POSSIBLE_MSVC_DLL],
kevinw@2223 475 [search of VCINSTALLDIR])
ohair@494 476 fi
ohair@494 477 fi
ihse@857 478
kevinw@2223 479 if test "x$MSVC_DLL" = x; then
kevinw@2223 480 AC_MSG_CHECKING([for $DLL_NAME])
ohair@494 481 AC_MSG_RESULT([no])
kevinw@2223 482 AC_MSG_ERROR([Could not find $DLL_NAME. Please specify using --with-msvcr-dll.])
ohair@494 483 fi
ihse@857 484
kevinw@2223 485 $1=$MSVC_DLL
kevinw@2223 486 BASIC_FIXUP_PATH($1)
kevinw@2223 487 AC_SUBST($1, [$]$1)
ohair@494 488 ])
kevinw@2223 489
kevinw@2223 490 AC_DEFUN([TOOLCHAIN_SETUP_VS_RUNTIME_DLLS],
kevinw@2223 491 [
kevinw@2223 492 AC_ARG_WITH(msvcr-dll, [AS_HELP_STRING([--with-msvcr-dll],
kevinw@2223 493 [path to microsoft C runtime dll (msvcr*.dll) (Windows only) @<:@probed@:>@])])
kevinw@2223 494
kevinw@2223 495 if test "x$with_msvcr_dll" != x; then
kevinw@2223 496 # If given explicitely by user, do not probe. If not present, fail directly.
kevinw@2223 497 TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$with_msvcr_dll],
kevinw@2223 498 [--with-msvcr-dll])
kevinw@2223 499 if test "x$MSVC_DLL" = x; then
kevinw@2223 500 AC_MSG_ERROR([Could not find a proper $MSVCR_NAME as specified by --with-msvcr-dll])
kevinw@2223 501 fi
kevinw@2223 502 else
kevinw@2223 503 TOOLCHAIN_SETUP_MSVC_DLL([MSVCR_DLL], [${MSVCR_NAME}])
kevinw@2223 504 fi
kevinw@2223 505
kevinw@2223 506 AC_ARG_WITH(msvcp-dll, [AS_HELP_STRING([--with-msvcp-dll],
kevinw@2223 507 [path to microsoft C++ runtime dll (msvcp*.dll) (Windows only) @<:@probed@:>@])])
kevinw@2223 508
kevinw@2223 509 if test "x$MSVCP_NAME" != "x"; then
kevinw@2223 510 if test "x$with_msvcp_dll" != x; then
kevinw@2223 511 # If given explicitely by user, do not probe. If not present, fail directly.
kevinw@2223 512 TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$with_msvcp_dll],
kevinw@2223 513 [--with-msvcp-dll])
kevinw@2223 514 if test "x$MSVC_DLL" = x; then
kevinw@2223 515 AC_MSG_ERROR([Could not find a proper $MSVCP_NAME as specified by --with-msvcp-dll])
kevinw@2223 516 fi
kevinw@2223 517 else
kevinw@2223 518 TOOLCHAIN_SETUP_MSVC_DLL([MSVCP_DLL], [${MSVCP_NAME}])
kevinw@2223 519 fi
kevinw@2223 520 fi
kevinw@2223 521 ])
kevinw@2223 522

mercurial