1 #
   2 # Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
   3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4 #
   5 # This code is free software; you can redistribute it and/or modify it
   6 # under the terms of the GNU General Public License version 2 only, as
   7 # published by the Free Software Foundation.  Oracle designates this
   8 # particular file as subject to the "Classpath" exception as provided
   9 # by Oracle in the LICENSE file that accompanied this code.
  10 #
  11 # This code is distributed in the hope that it will be useful, but WITHOUT
  12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14 # version 2 for more details (a copy is included in the LICENSE file that
  15 # accompanied this code).
  16 #
  17 # You should have received a copy of the GNU General Public License version
  18 # 2 along with this work; if not, write to the Free Software Foundation,
  19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20 #
  21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22 # or visit www.oracle.com if you need additional information or have any
  23 # questions.
  24 #
  25 
  26 ################################################################################
  27 # The order of these defines the priority by which we try to find them.
  28 VALID_VS_VERSIONS="2019 2017 2013 2015 2012 2010"
  29 
  30 VS_DESCRIPTION_2010="Microsoft Visual Studio 2010"
  31 VS_VERSION_INTERNAL_2010=100
  32 VS_MSVCR_2010=msvcr100.dll
  33 # We don't use msvcp on Visual Studio 2010
  34 #VS_MSVCP_2010=msvcp100.dll
  35 VS_ENVVAR_2010="VS100COMNTOOLS"
  36 VS_VS_INSTALLDIR_2010="Microsoft Visual Studio 10.0"
  37 VS_SDK_INSTALLDIR_2010="Microsoft SDKs/Windows/v7.1"
  38 VS_VS_PLATFORM_NAME_2010="v100"
  39 VS_SDK_PLATFORM_NAME_2010="Windows7.1SDK"
  40 VS_SUPPORTED_2010=false
  41 
  42 VS_DESCRIPTION_2012="Microsoft Visual Studio 2012"
  43 VS_VERSION_INTERNAL_2012=110
  44 VS_MSVCR_2012=msvcr110.dll
  45 VS_MSVCP_2012=msvcp110.dll
  46 VS_ENVVAR_2012="VS110COMNTOOLS"
  47 VS_VS_INSTALLDIR_2012="Microsoft Visual Studio 11.0"
  48 VS_SDK_INSTALLDIR_2012=
  49 VS_VS_PLATFORM_NAME_2012="v110"
  50 VS_SDK_PLATFORM_NAME_2012=
  51 VS_SUPPORTED_2012=false
  52 
  53 VS_DESCRIPTION_2013="Microsoft Visual Studio 2013"
  54 VS_VERSION_INTERNAL_2013=120
  55 VS_MSVCR_2013=msvcr120.dll
  56 VS_MSVCP_2013=msvcp120.dll
  57 VS_ENVVAR_2013="VS120COMNTOOLS"
  58 VS_VS_INSTALLDIR_2013="Microsoft Visual Studio 12.0"
  59 VS_SDK_INSTALLDIR_2013=
  60 VS_VS_PLATFORM_NAME_2013="v120"
  61 VS_SDK_PLATFORM_NAME_2013=
  62 VS_SUPPORTED_2013=false
  63 
  64 VS_DESCRIPTION_2015="Microsoft Visual Studio 2015"
  65 VS_VERSION_INTERNAL_2015=140
  66 VS_MSVCR_2015=vcruntime140.dll
  67 VS_MSVCP_2015=msvcp140.dll
  68 VS_ENVVAR_2015="VS140COMNTOOLS"
  69 VS_VS_INSTALLDIR_2015="Microsoft Visual Studio 14.0"
  70 VS_SDK_INSTALLDIR_2015=
  71 VS_VS_PLATFORM_NAME_2015="v140"
  72 VS_SDK_PLATFORM_NAME_2015=
  73 # The vcvars of 2015 breaks if 2017 is also installed. Work around this by
  74 # explicitly specifying Windows Kit 8.1 to be used.
  75 VS_ENV_ARGS_2015="8.1"
  76 VS_SUPPORTED_2015=false
  77 
  78 VS_DESCRIPTION_2017="Microsoft Visual Studio 2017"
  79 VS_VERSION_INTERNAL_2017=141
  80 VS_MSVCR_2017=vcruntime140.dll
  81 VS_MSVCP_2017=msvcp140.dll
  82 VS_ENVVAR_2017="VS150COMNTOOLS"
  83 VS_USE_UCRT_2017="true"
  84 VS_VS_INSTALLDIR_2017="Microsoft Visual Studio/2017"
  85 VS_EDITIONS_2017="BuildTools Community Professional Enterprise"
  86 VS_SDK_INSTALLDIR_2017=
  87 VS_VS_PLATFORM_NAME_2017="v141"
  88 VS_SDK_PLATFORM_NAME_2017=
  89 VS_SUPPORTED_2017=true
  90 VS_TOOLSET_SUPPORTED_2017=true
  91 
  92 VS_DESCRIPTION_2019="Microsoft Visual Studio 2019"
  93 VS_VERSION_INTERNAL_2019=142
  94 VS_MSVCR_2019=vcruntime140.dll
  95 VS_VCRUNTIME_1_2019=vcruntime140_1.dll
  96 VS_MSVCP_2019=msvcp140.dll
  97 VS_ENVVAR_2019="VS160COMNTOOLS"
  98 VS_USE_UCRT_2019="true"
  99 VS_VS_INSTALLDIR_2019="Microsoft Visual Studio/2019"
 100 VS_EDITIONS_2019="BuildTools Community Professional Enterprise"
 101 VS_SDK_INSTALLDIR_2019=
 102 VS_VS_PLATFORM_NAME_2019="v142"
 103 VS_SDK_PLATFORM_NAME_2019=
 104 VS_SUPPORTED_2019=true
 105 VS_TOOLSET_SUPPORTED_2019=true
 106 
 107 ################################################################################
 108 
 109 AC_DEFUN([TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT],
 110 [
 111   if test "x$VS_ENV_CMD" = x; then
 112     VS_VERSION="$1"
 113     VS_BASE="$2"
 114     METHOD="$3"
 115 
 116     UTIL_REWRITE_AS_UNIX_PATH(VS_BASE)
 117     # In VS 2017 and VS 2019, the default installation is in a subdir named after the edition.
 118     # Find the first one present and use that.
 119     if test "x$VS_EDITIONS" != x; then
 120       for edition in $VS_EDITIONS; do
 121         if test -d "$VS_BASE/$edition"; then
 122           VS_BASE="$VS_BASE/$edition"
 123           break
 124         fi
 125       done
 126     fi
 127 
 128     if test -d "$VS_BASE"; then
 129       AC_MSG_NOTICE([Found Visual Studio installation at $VS_BASE using $METHOD])
 130       if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
 131         VCVARSFILES="vc/bin/vcvars32.bat vc/auxiliary/build/vcvars32.bat"
 132       else
 133         VCVARSFILES="vc/bin/amd64/vcvars64.bat vc/bin/x86_amd64/vcvarsx86_amd64.bat \
 134             VC/Auxiliary/Build/vcvarsx86_amd64.bat VC/Auxiliary/Build/vcvars64.bat"
 135       fi
 136 
 137       for VCVARSFILE in $VCVARSFILES; do
 138         if test -f "$VS_BASE/$VCVARSFILE"; then
 139           VS_ENV_CMD="$VS_BASE/$VCVARSFILE"
 140           break
 141         fi
 142       done
 143 
 144       if test "x$VS_ENV_CMD" = x; then
 145         AC_MSG_NOTICE([Warning: None of $VCVARSFILES were found, Visual Studio installation not recognized. Ignoring])
 146       else
 147         # PLATFORM_TOOLSET is used during the compilation of the freetype sources
 148         # (see 'LIB_BUILD_FREETYPE' in libraries.m4) and must be one of 'v100',
 149         # 'v110' or 'v120' for VS 2010, 2012 or VS2013
 150         eval PLATFORM_TOOLSET="\${VS_VS_PLATFORM_NAME_${VS_VERSION}}"
 151       fi
 152     fi
 153   fi
 154 ])
 155 
 156 ################################################################################
 157 
 158 AC_DEFUN([TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT],
 159 [
 160   if test "x$VS_ENV_CMD" = x; then
 161     VS_VERSION="$1"
 162     WIN_SDK_BASE="$2"
 163     METHOD="$3"
 164     UTIL_REWRITE_AS_UNIX_PATH(WIN_SDK_BASE)
 165     if test -d "$WIN_SDK_BASE"; then
 166       # There have been cases of partial or broken SDK installations. A missing
 167       # lib dir is not going to work.
 168       if test ! -d "$WIN_SDK_BASE/lib"; then
 169         AC_MSG_NOTICE([Found Windows SDK installation at $WIN_SDK_BASE using $METHOD])
 170         AC_MSG_NOTICE([Warning: Installation is broken, lib dir is missing. Ignoring])
 171       elif test -f "$WIN_SDK_BASE/Bin/SetEnv.Cmd"; then
 172         AC_MSG_NOTICE([Found Windows SDK installation at $WIN_SDK_BASE using $METHOD])
 173         VS_ENV_CMD="$WIN_SDK_BASE/Bin/SetEnv.Cmd"
 174         if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
 175           VS_ENV_ARGS="/x86"
 176         else
 177           VS_ENV_ARGS="/x64"
 178         fi
 179         # PLATFORM_TOOLSET is used during the compilation of the freetype sources (see
 180         # 'LIB_BUILD_FREETYPE' in libraries.m4) and must be 'Windows7.1SDK' for Windows7.1SDK
 181         # TODO: improve detection for other versions of SDK
 182         eval PLATFORM_TOOLSET="\${VS_SDK_PLATFORM_NAME_${VS_VERSION}}"
 183       else
 184         AC_MSG_NOTICE([Found Windows SDK installation at $WIN_SDK_BASE using $METHOD])
 185         AC_MSG_NOTICE([Warning: Installation is broken, SetEnv.Cmd is missing. Ignoring])
 186       fi
 187     fi
 188   fi
 189 ])
 190 
 191 ################################################################################
 192 # Finds the bat or cmd file in Visual Studio or the SDK that sets up a proper
 193 # build environment and assigns it to VS_ENV_CMD
 194 AC_DEFUN([TOOLCHAIN_FIND_VISUAL_STUDIO_BAT_FILE],
 195 [
 196   # VS2017 provides the option to install previous minor versions of the MSVC
 197   # toolsets. It is not possible to directly download earlier minor versions of
 198   # VS2017 and in order to build with a previous minor compiler toolset version,
 199   # it is now possible to compile with earlier minor versions by passing
 200   # -vcvars_ver=<toolset_version> argument to vcvarsall.bat.
 201   AC_ARG_WITH(msvc-toolset-version, [AS_HELP_STRING([--with-msvc-toolset-version],
 202       [specific MSVC toolset version to use, passed as -vcvars_ver argument to
 203        pass to vcvarsall.bat (Windows only)])])
 204 
 205   VS_VERSION="$1"
 206   eval VS_COMNTOOLS_VAR="\${VS_ENVVAR_${VS_VERSION}}"
 207   eval VS_COMNTOOLS="\$${VS_COMNTOOLS_VAR}"
 208   eval VS_INSTALL_DIR="\${VS_VS_INSTALLDIR_${VS_VERSION}}"
 209   eval VS_EDITIONS="\${VS_EDITIONS_${VS_VERSION}}"
 210   eval SDK_INSTALL_DIR="\${VS_SDK_INSTALLDIR_${VS_VERSION}}"
 211   eval VS_ENV_ARGS="\${VS_ENV_ARGS_${VS_VERSION}}"
 212   eval VS_TOOLSET_SUPPORTED="\${VS_TOOLSET_SUPPORTED_${VS_VERSION}}"
 213 
 214   VS_ENV_CMD=""
 215 
 216   # When using --with-tools-dir, assume it points to the correct and default
 217   # version of Visual Studio or that --with-toolchain-version was also set.
 218   if test "x$with_tools_dir" != x; then
 219     TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}],
 220         [$with_tools_dir/../..], [--with-tools-dir])
 221     TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}],
 222         [$with_tools_dir/../../..], [--with-tools-dir])
 223     if test "x$VS_ENV_CMD" = x; then
 224       # Having specified an argument which is incorrect will produce an instant failure;
 225       # we should not go on looking
 226       AC_MSG_NOTICE([The path given by --with-tools-dir does not contain a valid])
 227       AC_MSG_NOTICE([Visual Studio installation. Please point to the VC/bin or VC/bin/amd64])
 228       AC_MSG_NOTICE([directory within the Visual Studio installation])
 229       AC_MSG_ERROR([Cannot locate a valid Visual Studio installation])
 230     fi
 231   fi
 232 
 233   if test "x$VS_COMNTOOLS" != x; then
 234     TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}],
 235         [$VS_COMNTOOLS/../..], [$VS_COMNTOOLS_VAR variable])
 236   fi
 237   if test "x$PROGRAMFILES" != x; then
 238     TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}],
 239         [$PROGRAMFILES/$VS_INSTALL_DIR], [well-known name])
 240   fi
 241   # Work around the insanely named ProgramFiles(x86) env variable
 242   PROGRAMFILES_X86="`env | $SED -n 's/^ProgramFiles(x86)=//p'`"
 243   if test "x$PROGRAMFILES_X86" != x; then
 244     TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}],
 245         [$PROGRAMFILES_X86/$VS_INSTALL_DIR], [well-known name])
 246   fi
 247   TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}],
 248       [C:/Program Files/$VS_INSTALL_DIR], [well-known name])
 249   TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}],
 250       [C:/Program Files (x86)/$VS_INSTALL_DIR], [well-known name])
 251   if test "x$SDK_INSTALL_DIR" != x; then
 252     if test "x$ProgramW6432" != x; then
 253       TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([${VS_VERSION}],
 254           [$ProgramW6432/$SDK_INSTALL_DIR], [well-known name])
 255     fi
 256     if test "x$PROGRAMW6432" != x; then
 257       TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([${VS_VERSION}],
 258           [$PROGRAMW6432/$SDK_INSTALL_DIR], [well-known name])
 259     fi
 260     if test "x$PROGRAMFILES" != x; then
 261       TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([${VS_VERSION}],
 262           [$PROGRAMFILES/$SDK_INSTALL_DIR], [well-known name])
 263     fi
 264     TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([${VS_VERSION}],
 265         [C:/Program Files/$SDK_INSTALL_DIR], [well-known name])
 266     TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([${VS_VERSION}],
 267         [C:/Program Files (x86)/$SDK_INSTALL_DIR], [well-known name])
 268   fi
 269 
 270   if test "x$VS_TOOLSET_SUPPORTED" != x; then
 271     if test "x$with_msvc_toolset_version" != x; then
 272       VS_ENV_ARGS="$VS_ENV_ARGS -vcvars_ver=$with_msvc_toolset_version"
 273     fi
 274   fi
 275 ])
 276 
 277 ################################################################################
 278 
 279 AC_DEFUN([TOOLCHAIN_FIND_VISUAL_STUDIO],
 280 [
 281   AC_ARG_WITH(toolchain-version, [AS_HELP_STRING([--with-toolchain-version],
 282       [the version of the toolchain to look for, use '--help' to show possible values @<:@platform dependent@:>@])])
 283 
 284   if test "x$with_toolchain_version" = xlist; then
 285     # List all toolchains
 286     AC_MSG_NOTICE([The following toolchain versions are valid on this platform:])
 287     for version in $VALID_VS_VERSIONS; do
 288       eval VS_DESCRIPTION=\${VS_DESCRIPTION_$version}
 289       $PRINTF "  %-10s  %s\n" $version "$VS_DESCRIPTION"
 290     done
 291 
 292     exit 0
 293   elif test "x$DEVKIT_VS_VERSION" != x; then
 294     VS_VERSION=$DEVKIT_VS_VERSION
 295     TOOLCHAIN_VERSION=$VS_VERSION
 296     # If the devkit has a name, use that as description
 297     VS_DESCRIPTION="$DEVKIT_NAME"
 298     if test "x$VS_DESCRIPTION" = x; then
 299       eval VS_DESCRIPTION="\${VS_DESCRIPTION_${VS_VERSION}}"
 300     fi
 301     eval VS_VERSION_INTERNAL="\${VS_VERSION_INTERNAL_${VS_VERSION}}"
 302     eval MSVCR_NAME="\${VS_MSVCR_${VS_VERSION}}"
 303     eval VCRUNTIME_1_NAME="\${VS_VCRUNTIME_1_${VS_VERSION}}"
 304     eval MSVCP_NAME="\${VS_MSVCP_${VS_VERSION}}"
 305     eval USE_UCRT="\${VS_USE_UCRT_${VS_VERSION}}"
 306     eval VS_SUPPORTED="\${VS_SUPPORTED_${VS_VERSION}}"
 307     eval PLATFORM_TOOLSET="\${VS_VS_PLATFORM_NAME_${VS_VERSION}}"
 308 
 309     # The TOOLCHAIN_PATH from a devkit is in Unix format. In WSL we need a
 310     # windows version of the complete VS_PATH as VS_PATH_WINDOWS
 311     if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.wsl"; then
 312       # Convert the toolchain path
 313       OLDIFS="$IFS"
 314       IFS=":"
 315       VS_PATH_WINDOWS=""
 316       for i in $TOOLCHAIN_PATH; do
 317         path=$i
 318         UTIL_REWRITE_AS_WINDOWS_MIXED_PATH([path])
 319         VS_PATH_WINDOWS="$VS_PATH_WINDOWS;$path"
 320       done
 321       IFS="$OLDIFS"
 322       # Append the current path from Windows env
 323       WINDOWS_PATH="`$CMD /c echo %PATH%`"
 324       VS_PATH_WINDOWS="$VS_PATH_WINDOWS;$WINDOWS_PATH"
 325     else
 326       VS_PATH="$TOOLCHAIN_PATH:$PATH"
 327     fi
 328 
 329     # Convert DEVKIT_VS_INCLUDE into windows style VS_INCLUDE so that it
 330     # can still be exported as INCLUDE for compiler invocations without
 331     # SYSROOT_CFLAGS
 332     OLDIFS="$IFS"
 333     IFS=";"
 334     for i in $DEVKIT_VS_INCLUDE; do
 335       ipath=$i
 336       UTIL_REWRITE_AS_WINDOWS_MIXED_PATH([ipath])
 337       VS_INCLUDE="$VS_INCLUDE;$ipath"
 338     done
 339     # Convert DEVKIT_VS_LIB into VS_LIB so that it can still be exported
 340     # as LIB for compiler invocations without SYSROOT_LDFLAGS
 341     for i in $DEVKIT_VS_LIB; do
 342       libpath=$i
 343       UTIL_REWRITE_AS_WINDOWS_MIXED_PATH([libpath])
 344       VS_LIB="$VS_LIB;$libpath"
 345     done
 346     IFS="$OLDIFS"
 347 
 348     AC_MSG_NOTICE([Found devkit $VS_DESCRIPTION])
 349 
 350   elif test "x$with_toolchain_version" != x; then
 351     # User override; check that it is valid
 352     if test "x${VALID_VS_VERSIONS/$with_toolchain_version/}" = "x${VALID_VS_VERSIONS}"; then
 353       AC_MSG_NOTICE([Visual Studio version $with_toolchain_version is not valid.])
 354       AC_MSG_NOTICE([Valid Visual Studio versions: $VALID_VS_VERSIONS.])
 355       AC_MSG_ERROR([Cannot continue.])
 356     fi
 357     VS_VERSIONS_PROBE_LIST="$with_toolchain_version"
 358   else
 359     # No flag given, use default
 360     VS_VERSIONS_PROBE_LIST="$VALID_VS_VERSIONS"
 361   fi
 362 
 363   for VS_VERSION in $VS_VERSIONS_PROBE_LIST; do
 364     TOOLCHAIN_FIND_VISUAL_STUDIO_BAT_FILE([$VS_VERSION])
 365     if test "x$VS_ENV_CMD" != x; then
 366       TOOLCHAIN_VERSION=$VS_VERSION
 367       eval VS_DESCRIPTION="\${VS_DESCRIPTION_${VS_VERSION}}"
 368       eval VS_VERSION_INTERNAL="\${VS_VERSION_INTERNAL_${VS_VERSION}}"
 369       eval MSVCR_NAME="\${VS_MSVCR_${VS_VERSION}}"
 370       eval VCRUNTIME_1_NAME="\${VS_VCRUNTIME_1_${VS_VERSION}}"
 371       eval MSVCP_NAME="\${VS_MSVCP_${VS_VERSION}}"
 372       eval USE_UCRT="\${VS_USE_UCRT_${VS_VERSION}}"
 373       eval VS_SUPPORTED="\${VS_SUPPORTED_${VS_VERSION}}"
 374       # The rest of the variables are already evaled while probing
 375       AC_MSG_NOTICE([Found $VS_DESCRIPTION])
 376       break
 377     fi
 378   done
 379 
 380   TOOLCHAIN_DESCRIPTION="$VS_DESCRIPTION"
 381   if test "x$VS_SUPPORTED" = "xfalse"; then
 382     UNSUPPORTED_TOOLCHAIN_VERSION=yes
 383   fi
 384 ])
 385 
 386 ################################################################################
 387 # Check if the VS env variables were setup prior to running configure.
 388 # If not, then find vcvarsall.bat and run it automatically, and integrate
 389 # the set env variables into the spec file.
 390 AC_DEFUN([TOOLCHAIN_SETUP_VISUAL_STUDIO_ENV],
 391 [
 392   # Store path to cygwin link.exe to help excluding it when searching for
 393   # VS linker. This must be done before changing the PATH when looking for VS.
 394   AC_PATH_PROG(CYGWIN_LINK, link.exe)
 395   if test "x$CYGWIN_LINK" != x; then
 396     AC_MSG_CHECKING([if the first found link.exe is actually the Cygwin link tool])
 397     "$CYGWIN_LINK" --version > /dev/null
 398     if test $? -eq 0 ; then
 399       AC_MSG_RESULT([yes])
 400     else
 401       AC_MSG_RESULT([no])
 402       # This might be the VS linker. Don't exclude it later on.
 403       CYGWIN_LINK=""
 404     fi
 405   fi
 406 
 407   # First-hand choice is to locate and run the vsvars bat file.
 408   TOOLCHAIN_FIND_VISUAL_STUDIO
 409 
 410   # If we have a devkit, skip all of the below.
 411   if test "x$DEVKIT_VS_VERSION" = x; then
 412     if test "x$VS_ENV_CMD" != x; then
 413       # We have found a Visual Studio environment on disk, let's extract variables from the vsvars bat file.
 414       UTIL_FIXUP_EXECUTABLE(VS_ENV_CMD)
 415 
 416       # Lets extract the variables that are set by vcvarsall.bat/vsvars32.bat/vsvars64.bat
 417       AC_MSG_NOTICE([Trying to extract Visual Studio environment variables])
 418 
 419       # We need to create a couple of temporary files.
 420       VS_ENV_TMP_DIR="$CONFIGURESUPPORT_OUTPUTDIR/vs-env"
 421       $MKDIR -p $VS_ENV_TMP_DIR
 422 
 423       # Cannot use the VS10 setup script directly (since it only updates the DOS subshell environment).
 424       # Instead create a shell script which will set the relevant variables when run.
 425       WINPATH_VS_ENV_CMD="$VS_ENV_CMD"
 426       UTIL_REWRITE_AS_WINDOWS_MIXED_PATH([WINPATH_VS_ENV_CMD])
 427 
 428       if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.wsl"; then
 429         WINPATH_BASH="bash"
 430       else
 431         WINPATH_BASH="$BASH"
 432         UTIL_REWRITE_AS_WINDOWS_MIXED_PATH([WINPATH_BASH])
 433       fi
 434 
 435       # Generate a DOS batch file which runs $VS_ENV_CMD, and then creates a shell
 436       # script (executable by bash) that will setup the important variables.
 437       EXTRACT_VC_ENV_BAT_FILE="$VS_ENV_TMP_DIR/extract-vs-env.bat"
 438       $ECHO "@echo off" >  $EXTRACT_VC_ENV_BAT_FILE
 439       # This will end up something like:
 440       # call C:/progra~2/micros~2.0/vc/bin/amd64/vcvars64.bat
 441       $ECHO "call \"$WINPATH_VS_ENV_CMD\" $VS_ENV_ARGS" >> $EXTRACT_VC_ENV_BAT_FILE
 442       # In some cases, the VS_ENV_CMD will change directory, change back so
 443       # the set-vs-env.sh ends up in the right place.
 444       $ECHO 'cd %~dp0' >> $EXTRACT_VC_ENV_BAT_FILE
 445       if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.wsl"; then
 446         # These will end up something like:
 447         # echo VS_PATH=\"$PATH\" > set-vs-env.sh
 448         # The trailing space for everyone except PATH is no typo, but is needed due
 449         # to trailing \ in the Windows paths. These will be stripped later.
 450         # Trying pure CMD extract. This results in windows paths that need to
 451         # be converted post extraction, but a simpler script.
 452         $ECHO 'echo VS_PATH="%PATH%" > set-vs-env.sh' \
 453             >> $EXTRACT_VC_ENV_BAT_FILE
 454         $ECHO 'echo VS_INCLUDE="%INCLUDE% " >> set-vs-env.sh' \
 455             >> $EXTRACT_VC_ENV_BAT_FILE
 456         $ECHO 'echo VS_LIB="%LIB% " >> set-vs-env.sh' \
 457             >> $EXTRACT_VC_ENV_BAT_FILE
 458         $ECHO 'echo VCINSTALLDIR="%VCINSTALLDIR% " >> set-vs-env.sh' \
 459             >> $EXTRACT_VC_ENV_BAT_FILE
 460         $ECHO 'echo VCToolsRedistDir="%VCToolsRedistDir% " >> set-vs-env.sh' \
 461             >> $EXTRACT_VC_ENV_BAT_FILE
 462         $ECHO 'echo WindowsSdkDir="%WindowsSdkDir% " >> set-vs-env.sh' \
 463             >> $EXTRACT_VC_ENV_BAT_FILE
 464         $ECHO 'echo WINDOWSSDKDIR="%WINDOWSSDKDIR% " >> set-vs-env.sh' \
 465             >> $EXTRACT_VC_ENV_BAT_FILE
 466       else
 467         # These will end up something like:
 468         # C:/CygWin/bin/bash -c 'echo VS_PATH=\"$PATH\" > localdevenv.sh
 469         # The trailing space for everyone except PATH is no typo, but is needed due
 470         # to trailing \ in the Windows paths. These will be stripped later.
 471         $ECHO "$WINPATH_BASH -c 'echo VS_PATH="'\"$PATH\" > set-vs-env.sh' \
 472             >> $EXTRACT_VC_ENV_BAT_FILE
 473         $ECHO "$WINPATH_BASH -c 'echo VS_INCLUDE="'\"$INCLUDE\;$include \" >> set-vs-env.sh' \
 474             >> $EXTRACT_VC_ENV_BAT_FILE
 475         $ECHO "$WINPATH_BASH -c 'echo VS_LIB="'\"$LIB\;$lib \" >> set-vs-env.sh' \
 476             >> $EXTRACT_VC_ENV_BAT_FILE
 477         $ECHO "$WINPATH_BASH -c 'echo VCINSTALLDIR="'\"$VCINSTALLDIR \" >> set-vs-env.sh' \
 478             >> $EXTRACT_VC_ENV_BAT_FILE
 479         $ECHO "$WINPATH_BASH -c 'echo VCToolsRedistDir="'\"$VCToolsRedistDir \" >> set-vs-env.sh' \
 480             >> $EXTRACT_VC_ENV_BAT_FILE
 481         $ECHO "$WINPATH_BASH -c 'echo WindowsSdkDir="'\"$WindowsSdkDir \" >> set-vs-env.sh' \
 482             >> $EXTRACT_VC_ENV_BAT_FILE
 483         $ECHO "$WINPATH_BASH -c 'echo WINDOWSSDKDIR="'\"$WINDOWSSDKDIR \" >> set-vs-env.sh' \
 484             >> $EXTRACT_VC_ENV_BAT_FILE
 485       fi
 486 
 487       # Now execute the newly created bat file.
 488       # Change directory so we don't need to mess with Windows paths in redirects.
 489       cd $VS_ENV_TMP_DIR
 490       $CMD /c extract-vs-env.bat > extract-vs-env.log 2>&1
 491       cd $CONFIGURE_START_DIR
 492 
 493       if test ! -s $VS_ENV_TMP_DIR/set-vs-env.sh; then
 494         AC_MSG_NOTICE([Could not succesfully extract the environment variables needed for the VS setup.])
 495         AC_MSG_NOTICE([Try setting --with-tools-dir to the VC/bin directory within the VS installation])
 496         AC_MSG_NOTICE([or run "bash.exe -l" from a VS command prompt and then run configure from there.])
 497         AC_MSG_ERROR([Cannot continue])
 498       fi
 499 
 500       # Remove windows line endings
 501       $SED -i -e 's|\r||g' $VS_ENV_TMP_DIR/set-vs-env.sh
 502 
 503       # Now set all paths and other env variables. This will allow the rest of
 504       # the configure script to find and run the compiler in the proper way.
 505       AC_MSG_NOTICE([Setting extracted environment variables])
 506       . $VS_ENV_TMP_DIR/set-vs-env.sh
 507       # Now we have VS_PATH, VS_INCLUDE, VS_LIB. For further checking, we
 508       # also define VCINSTALLDIR, WindowsSdkDir and WINDOWSSDKDIR.
 509 
 510       # In WSL, the extracted VS_PATH is Windows style. This needs to be
 511       # rewritten as Unix style and the Windows style version is saved
 512       # in VS_PATH_WINDOWS.
 513       if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.wsl"; then
 514         OLDIFS="$IFS"
 515         IFS=";"
 516         # Convert VS_PATH to unix style
 517         VS_PATH_WINDOWS="$VS_PATH"
 518         VS_PATH=""
 519         for i in $VS_PATH_WINDOWS; do
 520           path=$i
 521           # Only process non-empty elements
 522           if test "x$path" != x; then
 523             IFS="$OLDIFS"
 524             # Check that directory exists before calling fixup_path
 525             testpath=$path
 526             UTIL_REWRITE_AS_UNIX_PATH([testpath])
 527             if test -d "$testpath"; then
 528               UTIL_FIXUP_PATH([path])
 529               UTIL_APPEND_TO_PATH(VS_PATH, $path)
 530             fi
 531             IFS=";"
 532           fi
 533         done
 534         IFS="$OLDIFS"
 535       fi
 536 
 537     else
 538       # We did not find a vsvars bat file, let's hope we are run from a VS command prompt.
 539       AC_MSG_NOTICE([Cannot locate a valid Visual Studio installation, checking current environment])
 540     fi
 541   fi
 542 
 543   # At this point, we should have correct variables in the environment, or we can't continue.
 544   AC_MSG_CHECKING([for Visual Studio variables])
 545 
 546   if test "x$VCINSTALLDIR" != x || test "x$WindowsSDKDir" != x \
 547       || test "x$WINDOWSSDKDIR" != x || test "x$DEVKIT_NAME" != x; then
 548     if test "x$VS_INCLUDE" = x || test "x$VS_LIB" = x; then
 549       AC_MSG_RESULT([present but broken])
 550       AC_MSG_ERROR([Your VC command prompt seems broken, INCLUDE and/or LIB is missing.])
 551     else
 552       AC_MSG_RESULT([ok])
 553       # Remove any trailing "\" ";" and " " from the variables.
 554       VS_INCLUDE=`$ECHO "$VS_INCLUDE" | $SED -e 's/\\\\*;* *$//'`
 555       VS_LIB=`$ECHO "$VS_LIB" | $SED 's/\\\\*;* *$//'`
 556       VCINSTALLDIR=`$ECHO "$VCINSTALLDIR" | $SED 's/\\\\* *$//'`
 557       VCToolsRedistDir=`$ECHO "$VCToolsRedistDir" | $SED 's/\\\\* *$//'`
 558       WindowsSdkDir=`$ECHO "$WindowsSdkDir" | $SED 's/\\\\* *$//'`
 559       WINDOWSSDKDIR=`$ECHO "$WINDOWSSDKDIR" | $SED 's/\\\\* *$//'`
 560       if test -z "$WINDOWSSDKDIR"; then
 561         WINDOWSSDKDIR="$WindowsSdkDir"
 562       fi
 563       # Remove any paths containing # (typically F#) as that messes up make. This
 564       # is needed if visual studio was installed with F# support.
 565       VS_PATH=`$ECHO "$VS_PATH" | $SED 's/[[^:#]]*#[^:]*://g'`
 566 
 567       AC_SUBST(VS_PATH)
 568       AC_SUBST(VS_INCLUDE)
 569       AC_SUBST(VS_LIB)
 570 
 571       # Convert VS_INCLUDE into SYSROOT_CFLAGS
 572       OLDIFS="$IFS"
 573       IFS=";"
 574       for i in $VS_INCLUDE; do
 575         ipath=$i
 576         # Only process non-empty elements
 577         if test "x$ipath" != x; then
 578           IFS="$OLDIFS"
 579           # Check that directory exists before calling fixup_path
 580           testpath=$ipath
 581           UTIL_REWRITE_AS_UNIX_PATH([testpath])
 582           if test -d "$testpath"; then
 583             UTIL_FIXUP_PATH([ipath])
 584             SYSROOT_CFLAGS="$SYSROOT_CFLAGS -I$ipath"
 585           fi
 586           IFS=";"
 587         fi
 588       done
 589       # Convert VS_LIB into SYSROOT_LDFLAGS
 590       for i in $VS_LIB; do
 591         libpath=$i
 592         # Only process non-empty elements
 593         if test "x$libpath" != x; then
 594           IFS="$OLDIFS"
 595           # Check that directory exists before calling fixup_path
 596           testpath=$libpath
 597           UTIL_REWRITE_AS_UNIX_PATH([testpath])
 598           if test -d "$testpath"; then
 599             UTIL_FIXUP_PATH([libpath])
 600             SYSROOT_LDFLAGS="$SYSROOT_LDFLAGS -libpath:$libpath"
 601           fi
 602           IFS=";"
 603         fi
 604       done
 605       IFS="$OLDIFS"
 606 
 607       AC_SUBST(VS_PATH_WINDOWS)
 608     fi
 609   else
 610     AC_MSG_RESULT([not found])
 611 
 612     if test "x$VS_ENV_CMD" = x; then
 613       AC_MSG_NOTICE([Cannot locate a valid Visual Studio or Windows SDK installation on disk,])
 614       AC_MSG_NOTICE([nor is this script run from a Visual Studio command prompt.])
 615     else
 616       AC_MSG_NOTICE([Running the extraction script failed.])
 617     fi
 618     AC_MSG_NOTICE([Try setting --with-tools-dir to the VC/bin directory within the VS installation])
 619     AC_MSG_NOTICE([or run "bash.exe -l" from a VS command prompt and then run configure from there.])
 620     AC_MSG_ERROR([Cannot continue])
 621   fi
 622 ])
 623 
 624 AC_DEFUN([TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL],
 625 [
 626   DLL_NAME="$1"
 627   POSSIBLE_MSVC_DLL="$2"
 628   METHOD="$3"
 629   if test -n "$POSSIBLE_MSVC_DLL" -a -e "$POSSIBLE_MSVC_DLL"; then
 630     AC_MSG_NOTICE([Found $DLL_NAME at $POSSIBLE_MSVC_DLL using $METHOD])
 631 
 632     # Need to check if the found msvcr is correct architecture
 633     AC_MSG_CHECKING([found $DLL_NAME architecture])
 634     MSVC_DLL_FILETYPE=`$FILE -b "$POSSIBLE_MSVC_DLL"`
 635     if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
 636       # The MSYS 'file' command returns "PE32 executable for MS Windows (DLL) (GUI) Intel 80386 32-bit"
 637       # on x32 and "PE32+ executable for MS Windows (DLL) (GUI) Mono/.Net assembly" on x64 systems.
 638       if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
 639         CORRECT_MSVCR_ARCH="PE32 executable"
 640       else
 641         CORRECT_MSVCR_ARCH="PE32+ executable"
 642       fi
 643     else
 644       if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
 645         CORRECT_MSVCR_ARCH=386
 646       else
 647         CORRECT_MSVCR_ARCH=x86-64
 648       fi
 649     fi
 650     if $ECHO "$MSVC_DLL_FILETYPE" | $GREP "$CORRECT_MSVCR_ARCH" 2>&1 > /dev/null; then
 651       AC_MSG_RESULT([ok])
 652       MSVC_DLL="$POSSIBLE_MSVC_DLL"
 653       AC_MSG_CHECKING([for $DLL_NAME])
 654       AC_MSG_RESULT([$MSVC_DLL])
 655     else
 656       AC_MSG_RESULT([incorrect, ignoring])
 657       AC_MSG_NOTICE([The file type of the located $DLL_NAME is $MSVC_DLL_FILETYPE])
 658     fi
 659   fi
 660 ])
 661 
 662 AC_DEFUN([TOOLCHAIN_SETUP_MSVC_DLL],
 663 [
 664   DLL_NAME="$1"
 665   MSVC_DLL=
 666 
 667   if test "x$MSVC_DLL" = x; then
 668     if test "x$VCINSTALLDIR" != x; then
 669       CYGWIN_VC_INSTALL_DIR="$VCINSTALLDIR"
 670       UTIL_FIXUP_PATH(CYGWIN_VC_INSTALL_DIR)
 671       if test "$VS_VERSION" -lt 2017; then
 672         # Probe: Using well-known location from Visual Studio 12.0 and older
 673         if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
 674           POSSIBLE_MSVC_DLL="$CYGWIN_VC_INSTALL_DIR/redist/x64/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME"
 675         else
 676           POSSIBLE_MSVC_DLL="$CYGWIN_VC_INSTALL_DIR/redist/x86/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME"
 677         fi
 678       else
 679         CYGWIN_VC_TOOLS_REDIST_DIR="$VCToolsRedistDir"
 680         UTIL_FIXUP_PATH(CYGWIN_VC_TOOLS_REDIST_DIR)
 681         # Probe: Using well-known location from VS 2017 and VS 2019
 682         if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
 683           POSSIBLE_MSVC_DLL="`ls $CYGWIN_VC_TOOLS_REDIST_DIR/x64/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME`"
 684         else
 685           POSSIBLE_MSVC_DLL="`ls $CYGWIN_VC_TOOLS_REDIST_DIR/x86/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME`"
 686         fi
 687       fi
 688       # In case any of the above finds more than one file, loop over them.
 689       for possible_msvc_dll in $POSSIBLE_MSVC_DLL; do
 690         $ECHO "POSSIBLE_MSVC_DLL $possible_msvc_dll"
 691         TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$possible_msvc_dll],
 692             [well-known location in VCINSTALLDIR])
 693       done
 694     fi
 695   fi
 696 
 697   if test "x$MSVC_DLL" = x; then
 698     # Probe: Check in the Boot JDK directory.
 699     POSSIBLE_MSVC_DLL="$BOOT_JDK/bin/$DLL_NAME"
 700     TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$POSSIBLE_MSVC_DLL],
 701         [well-known location in Boot JDK])
 702   fi
 703 
 704   if test "x$MSVC_DLL" = x; then
 705     # Probe: Look in the Windows system32 directory
 706     CYGWIN_SYSTEMROOT="$SYSTEMROOT"
 707     UTIL_REWRITE_AS_UNIX_PATH(CYGWIN_SYSTEMROOT)
 708     POSSIBLE_MSVC_DLL="$CYGWIN_SYSTEMROOT/system32/$DLL_NAME"
 709     TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$POSSIBLE_MSVC_DLL],
 710         [well-known location in SYSTEMROOT])
 711   fi
 712 
 713   if test "x$MSVC_DLL" = x; then
 714     # Probe: If Visual Studio Express is installed, there is usually one with the debugger
 715     if test "x$VS100COMNTOOLS" != x; then
 716       CYGWIN_VS_TOOLS_DIR="$VS100COMNTOOLS/.."
 717       UTIL_REWRITE_AS_UNIX_PATH(CYGWIN_VS_TOOLS_DIR)
 718       if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
 719         POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VS_TOOLS_DIR" -name $DLL_NAME \
 720         | $GREP -i /x64/ | $HEAD --lines 1`
 721       else
 722         POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VS_TOOLS_DIR" -name $DLL_NAME \
 723         | $GREP -i /x86/ | $HEAD --lines 1`
 724       fi
 725       TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$POSSIBLE_MSVC_DLL],
 726           [search of VS100COMNTOOLS])
 727     fi
 728   fi
 729 
 730   if test "x$MSVC_DLL" = x; then
 731     # Probe: Search wildly in the VCINSTALLDIR. We've probably lost by now.
 732     # (This was the original behaviour; kept since it might turn something up)
 733     if test "x$CYGWIN_VC_INSTALL_DIR" != x; then
 734       if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
 735         POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VC_INSTALL_DIR" -name $DLL_NAME \
 736         | $GREP x64 | $HEAD --lines 1`
 737       else
 738         POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VC_INSTALL_DIR" -name $DLL_NAME \
 739         | $GREP x86 | $GREP -v ia64 | $GREP -v x64 | $HEAD --lines 1`
 740         if test "x$POSSIBLE_MSVC_DLL" = x; then
 741           # We're grasping at straws now...
 742           POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VC_INSTALL_DIR" -name $DLL_NAME \
 743           | $HEAD --lines 1`
 744         fi
 745       fi
 746 
 747       TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$POSSIBLE_MSVC_DLL],
 748           [search of VCINSTALLDIR])
 749     fi
 750   fi
 751 
 752   if test "x$MSVC_DLL" = x; then
 753     AC_MSG_CHECKING([for $DLL_NAME])
 754     AC_MSG_RESULT([no])
 755     AC_MSG_ERROR([Could not find $DLL_NAME. Please specify using --with-msvcr-dll.])
 756   fi
 757 ])
 758 
 759 AC_DEFUN([TOOLCHAIN_SETUP_VS_RUNTIME_DLLS],
 760 [
 761   AC_ARG_WITH(msvcr-dll, [AS_HELP_STRING([--with-msvcr-dll],
 762       [path to microsoft C runtime dll (msvcr*.dll) (Windows only) @<:@probed@:>@])])
 763 
 764   if test "x$with_msvcr_dll" != x; then
 765     # If given explicitly by user, do not probe. If not present, fail directly.
 766     TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL($MSVCR_NAME, [$with_msvcr_dll], [--with-msvcr-dll])
 767     if test "x$MSVC_DLL" = x; then
 768       AC_MSG_ERROR([Could not find a proper $MSVCR_NAME as specified by --with-msvcr-dll])
 769     fi
 770     MSVCR_DLL="$MSVC_DLL"
 771   elif test "x$DEVKIT_MSVCR_DLL" != x; then
 772     TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL($MSVCR_NAME, [$DEVKIT_MSVCR_DLL], [devkit])
 773     if test "x$MSVC_DLL" = x; then
 774       AC_MSG_ERROR([Could not find a proper $MSVCR_NAME as specified by devkit])
 775     fi
 776     MSVCR_DLL="$MSVC_DLL"
 777   else
 778     TOOLCHAIN_SETUP_MSVC_DLL([${MSVCR_NAME}])
 779     MSVCR_DLL="$MSVC_DLL"
 780   fi
 781   AC_SUBST(MSVCR_DLL)
 782 
 783   AC_ARG_WITH(msvcp-dll, [AS_HELP_STRING([--with-msvcp-dll],
 784       [path to microsoft C++ runtime dll (msvcp*.dll) (Windows only) @<:@probed@:>@])])
 785 
 786   if test "x$MSVCP_NAME" != "x"; then
 787     if test "x$with_msvcp_dll" != x; then
 788       # If given explicitly by user, do not probe. If not present, fail directly.
 789       TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL($MSVCP_NAME, [$with_msvcp_dll], [--with-msvcp-dll])
 790       if test "x$MSVC_DLL" = x; then
 791         AC_MSG_ERROR([Could not find a proper $MSVCP_NAME as specified by --with-msvcp-dll])
 792       fi
 793       MSVCP_DLL="$MSVC_DLL"
 794     elif test "x$DEVKIT_MSVCP_DLL" != x; then
 795       TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL($MSVCP_NAME, [$DEVKIT_MSVCP_DLL], [devkit])
 796       if test "x$MSVC_DLL" = x; then
 797         AC_MSG_ERROR([Could not find a proper $MSVCP_NAME as specified by devkit])
 798       fi
 799       MSVCP_DLL="$MSVC_DLL"
 800     else
 801       TOOLCHAIN_SETUP_MSVC_DLL([${MSVCP_NAME}])
 802       MSVCP_DLL="$MSVC_DLL"
 803     fi
 804     AC_SUBST(MSVCP_DLL)
 805   fi
 806 
 807   AC_ARG_WITH(vcruntime-1-dll, [AS_HELP_STRING([--with-vcruntime-1-dll],
 808       [path to microsoft C++ runtime dll (vcruntime*_1.dll) (Windows only) @<:@probed@:>@])])
 809 
 810   if test "x$VCRUNTIME_1_NAME" != "x"; then
 811     if test "x$with_vcruntime_1_dll" != x; then
 812       # If given explicitly by user, do not probe. If not present, fail directly.
 813       TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL($VCRUNTIME_1_NAME, [$with_vcruntime_1_dll],
 814           [--with-vcruntime-1-dll])
 815       if test "x$MSVC_DLL" = x; then
 816         AC_MSG_ERROR([Could not find a proper $VCRUNTIME_1_NAME as specified by --with-vcruntime-1-dll])
 817       fi
 818       VCRUNTIME_1_DLL="$MSVC_DLL"
 819     elif test "x$DEVKIT_VCRUNTIME_1_DLL" != x; then
 820       TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL($VCRUNTIME_1_NAME, [$DEVKIT_VCRUNTIME_1_DLL], [devkit])
 821       if test "x$MSVC_DLL" = x; then
 822         AC_MSG_ERROR([Could not find a proper $VCRUNTIME_1_NAME as specified by devkit])
 823       fi
 824       VCRUNTIME_1_DLL="$MSVC_DLL"
 825     else
 826       TOOLCHAIN_SETUP_MSVC_DLL([${VCRUNTIME_1_NAME}])
 827       VCRUNTIME_1_DLL="$MSVC_DLL"
 828     fi
 829     AC_SUBST(VCRUNTIME_1_DLL)
 830   fi
 831 
 832   AC_ARG_WITH(ucrt-dll-dir, [AS_HELP_STRING([--with-ucrt-dll-dir],
 833       [path to Microsoft Windows Kit UCRT DLL dir (Windows only) @<:@probed@:>@])])
 834 
 835   if test "x$USE_UCRT" = "xtrue"; then
 836     AC_MSG_CHECKING([for UCRT DLL dir])
 837     if test "x$with_ucrt_dll_dir" != x; then
 838       if test -z "$(ls -d "$with_ucrt_dll_dir/"*.dll 2> /dev/null)"; then
 839         AC_MSG_RESULT([no])
 840         AC_MSG_ERROR([Could not find any dlls in $with_ucrt_dll_dir])
 841       else
 842         AC_MSG_RESULT([$with_ucrt_dll_dir])
 843         UCRT_DLL_DIR="$with_ucrt_dll_dir"
 844         UTIL_FIXUP_PATH([UCRT_DLL_DIR])
 845       fi
 846     elif test "x$DEVKIT_UCRT_DLL_DIR" != "x"; then
 847       UCRT_DLL_DIR="$DEVKIT_UCRT_DLL_DIR"
 848       AC_MSG_RESULT($UCRT_DLL_DIR)
 849     else
 850       CYGWIN_WINDOWSSDKDIR="${WINDOWSSDKDIR}"
 851       UTIL_FIXUP_PATH([CYGWIN_WINDOWSSDKDIR])
 852       dll_subdir=$OPENJDK_TARGET_CPU
 853       if test "x$dll_subdir" = "xx86_64"; then
 854         dll_subdir="x64"
 855       fi
 856       UCRT_DLL_DIR="$CYGWIN_WINDOWSSDKDIR/Redist/ucrt/DLLs/$dll_subdir"
 857       if test -z "$(ls -d "$UCRT_DLL_DIR/"*.dll 2> /dev/null)"; then
 858         # Try with version subdir
 859         UCRT_DLL_DIR="`ls -d $CYGWIN_WINDOWSSDKDIR/Redist/*/ucrt/DLLs/$dll_subdir \
 860             2> /dev/null | $SORT -d | $HEAD -n1`"
 861         if test -z "$UCRT_DLL_DIR" \
 862             || test -z "$(ls -d "$UCRT_DLL_DIR/"*.dll 2> /dev/null)"; then
 863           AC_MSG_RESULT([no])
 864           AC_MSG_ERROR([Could not find any dlls in $UCRT_DLL_DIR])
 865         else
 866           AC_MSG_RESULT($UCRT_DLL_DIR)
 867         fi
 868       else
 869         AC_MSG_RESULT($UCRT_DLL_DIR)
 870       fi
 871     fi
 872   else
 873     UCRT_DLL_DIR=
 874   fi
 875   AC_SUBST(UCRT_DLL_DIR)
 876 ])