ohair@494: # kevinw@2223: # Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. ohair@494: # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ohair@494: # ohair@494: # This code is free software; you can redistribute it and/or modify it ohair@494: # under the terms of the GNU General Public License version 2 only, as ohair@494: # published by the Free Software Foundation. Oracle designates this ohair@494: # particular file as subject to the "Classpath" exception as provided ohair@494: # by Oracle in the LICENSE file that accompanied this code. ohair@494: # ohair@494: # This code is distributed in the hope that it will be useful, but WITHOUT ohair@494: # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ohair@494: # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ohair@494: # version 2 for more details (a copy is included in the LICENSE file that ohair@494: # accompanied this code). ohair@494: # ohair@494: # You should have received a copy of the GNU General Public License version ohair@494: # 2 along with this work; if not, write to the Free Software Foundation, ohair@494: # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ohair@494: # ohair@494: # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohair@494: # or visit www.oracle.com if you need additional information or have any ohair@494: # questions. ohair@494: # ohair@494: kevinw@2223: ################################################################################ kevinw@2228: # The order of these defines the priority by which we try to find them. kevinw@2228: VALID_VS_VERSIONS="2010 2012 2013 2015 2017" kevinw@2223: kevinw@2223: VS_DESCRIPTION_2010="Microsoft Visual Studio 2010" kevinw@2223: VS_VERSION_INTERNAL_2010=100 kevinw@2223: VS_MSVCR_2010=msvcr100.dll kevinw@2223: # We don't use msvcp on Visual Studio 2010 kevinw@2223: #VS_MSVCP_2010=msvcp100.dll kevinw@2223: VS_ENVVAR_2010="VS100COMNTOOLS" kevinw@2223: VS_VS_INSTALLDIR_2010="Microsoft Visual Studio 10.0" kevinw@2223: VS_SDK_INSTALLDIR_2010="Microsoft SDKs/Windows/v7.1" kevinw@2223: VS_VS_PLATFORM_NAME_2010="v100" kevinw@2223: VS_SDK_PLATFORM_NAME_2010="Windows7.1SDK" kevinw@2223: kevinw@2223: VS_DESCRIPTION_2012="Microsoft Visual Studio 2012" kevinw@2223: VS_VERSION_INTERNAL_2012=110 kevinw@2223: VS_MSVCR_2012=msvcr110.dll kevinw@2223: VS_MSVCP_2012=msvcp110.dll kevinw@2223: VS_ENVVAR_2012="VS110COMNTOOLS" kevinw@2223: VS_VS_INSTALLDIR_2012="Microsoft Visual Studio 11.0" kevinw@2223: VS_SDK_INSTALLDIR_2012= kevinw@2223: VS_VS_PLATFORM_NAME_2012="v110" kevinw@2223: VS_SDK_PLATFORM_NAME_2012= kevinw@2223: kevinw@2223: VS_DESCRIPTION_2013="Microsoft Visual Studio 2013" kevinw@2223: VS_VERSION_INTERNAL_2013=120 kevinw@2223: VS_MSVCR_2013=msvcr120.dll kevinw@2223: VS_MSVCP_2013=msvcp120.dll kevinw@2223: VS_ENVVAR_2013="VS120COMNTOOLS" kevinw@2223: VS_VS_INSTALLDIR_2013="Microsoft Visual Studio 12.0" kevinw@2223: VS_SDK_INSTALLDIR_2013= kevinw@2223: VS_VS_PLATFORM_NAME_2013="v120" kevinw@2223: VS_SDK_PLATFORM_NAME_2013= kevinw@2223: kevinw@2228: VS_DESCRIPTION_2015="Microsoft Visual Studio 2015 - CURRENTLY NOT WORKING" kevinw@2228: VS_VERSION_INTERNAL_2015=140 kevinw@2228: VS_MSVCR_2015=vcruntime140.dll kevinw@2228: VS_MSVCP_2015=msvcp140.dll kevinw@2228: VS_ENVVAR_2015="VS140COMNTOOLS" kevinw@2228: VS_VS_INSTALLDIR_2015="Microsoft Visual Studio 14.0" kevinw@2228: VS_SDK_INSTALLDIR_2015= kevinw@2228: VS_VS_PLATFORM_NAME_2015="v140" kevinw@2228: VS_SDK_PLATFORM_NAME_2015= kevinw@2228: # The vcvars of 2015 breaks if 2017 is also installed. Work around this by kevinw@2228: # explicitly specifying Windows Kit 8.1 to be used. kevinw@2228: VS_ENV_ARGS_2015="8.1" kevinw@2228: kevinw@2228: VS_DESCRIPTION_2017="Microsoft Visual Studio 2017 - CURRENTLY NOT WORKING" kevinw@2228: VS_VERSION_INTERNAL_2017=141 kevinw@2228: VS_MSVCR_2017=vcruntime140.dll kevinw@2228: VS_MSVCP_2017=msvcp140.dll kevinw@2228: VS_ENVVAR_2017="VS150COMNTOOLS" kevinw@2333: VS_USE_UCRT_2017="true" kevinw@2228: VS_VS_INSTALLDIR_2017="Microsoft Visual Studio/2017" kevinw@2228: VS_EDITIONS_2017="Community Professional Enterprise" kevinw@2228: VS_SDK_INSTALLDIR_2017= kevinw@2228: VS_VS_PLATFORM_NAME_2017="v141" kevinw@2228: VS_SDK_PLATFORM_NAME_2017= kevinw@2228: kevinw@2223: ################################################################################ kevinw@2223: ohair@494: AC_DEFUN([TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT], ohair@494: [ ohair@494: if test "x$VS_ENV_CMD" = x; then kevinw@2223: VS_VERSION="$1" kevinw@2223: VS_BASE="$2" kevinw@2223: METHOD="$3" kevinw@2223: kevinw@2228: BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(VS_BASE) kevinw@2228: # In VS 2017, the default installation is in a subdir named after the edition. kevinw@2228: # Find the first one present and use that. kevinw@2228: if test "x$VS_EDITIONS" != x; then kevinw@2228: for edition in $VS_EDITIONS; do kevinw@2228: if test -d "$VS_BASE/$edition"; then kevinw@2228: VS_BASE="$VS_BASE/$edition" kevinw@2228: break kevinw@2228: fi kevinw@2228: done kevinw@2223: fi kevinw@2223: kevinw@2223: if test -d "$VS_BASE"; then kevinw@2228: AC_MSG_NOTICE([Found Visual Studio installation at $VS_BASE using $METHOD]) kevinw@2228: if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then kevinw@2228: VCVARSFILES="vc/bin/vcvars32.bat vc/auxiliary/build/vcvars32.bat" kevinw@2228: else kevinw@2228: VCVARSFILES="vc/bin/amd64/vcvars64.bat vc/bin/x86_amd64/vcvarsx86_amd64.bat \ kevinw@2228: vc/auxiliary/build/vcvarsx86_amd64.bat vc/auxiliary/build/vcvars64.bat" kevinw@2228: fi kevinw@2228: kevinw@2228: for VCVARSFILE in $VCVARSFILES; do kevinw@2228: if test -f "$VS_BASE/$VCVARSFILE"; then kevinw@2228: VS_ENV_CMD="$VS_BASE/$VCVARSFILE" kevinw@2228: break kevinw@2228: fi kevinw@2228: done kevinw@2228: kevinw@2228: if test "x$VS_ENV_CMD" = x; then kevinw@2228: AC_MSG_NOTICE([Warning: None of $VCVARSFILES were found, Visual Studio installation not recognized. Ignoring]) kevinw@2228: else kevinw@2228: # PLATFORM_TOOLSET is used during the compilation of the freetype sources kevinw@2228: # (see 'LIB_BUILD_FREETYPE' in libraries.m4) and must be one of 'v100', kevinw@2228: # 'v110' or 'v120' for VS 2010, 2012 or VS2013 kevinw@2223: eval PLATFORM_TOOLSET="\${VS_VS_PLATFORM_NAME_${VS_VERSION}}" kevinw@2228: ohair@494: fi ohair@494: fi ohair@494: fi ohair@494: ]) ohair@494: kevinw@2223: ################################################################################ kevinw@2223: ohair@494: AC_DEFUN([TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT], ohair@494: [ ohair@494: if test "x$VS_ENV_CMD" = x; then kevinw@2223: VS_VERSION="$1" kevinw@2223: WIN_SDK_BASE="$2" kevinw@2223: METHOD="$3" ohair@494: BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(WIN_SDK_BASE) ohair@494: if test -d "$WIN_SDK_BASE"; then erikj@525: # There have been cases of partial or broken SDK installations. A missing erikj@525: # lib dir is not going to work. kevinw@2223: if test ! -d "$WIN_SDK_BASE/lib"; then erikj@525: AC_MSG_NOTICE([Found Windows SDK installation at $WIN_SDK_BASE using $METHOD]) erikj@525: AC_MSG_NOTICE([Warning: Installation is broken, lib dir is missing. Ignoring]) kevinw@2223: elif test -f "$WIN_SDK_BASE/Bin/SetEnv.Cmd"; then ohair@494: AC_MSG_NOTICE([Found Windows SDK installation at $WIN_SDK_BASE using $METHOD]) kevinw@2223: VS_ENV_CMD="$WIN_SDK_BASE/Bin/SetEnv.Cmd" ohair@494: if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then ohair@494: VS_ENV_ARGS="/x86" ohair@494: else ohair@494: VS_ENV_ARGS="/x64" ohair@494: fi kevinw@2220: # PLATFORM_TOOLSET is used during the compilation of the freetype sources (see kevinw@2220: # 'LIB_BUILD_FREETYPE' in libraries.m4) and must be 'Windows7.1SDK' for Windows7.1SDK kevinw@2220: # TODO: improve detection for other versions of SDK kevinw@2223: eval PLATFORM_TOOLSET="\${VS_SDK_PLATFORM_NAME_${VS_VERSION}}" ohair@494: else ohair@494: AC_MSG_NOTICE([Found Windows SDK installation at $WIN_SDK_BASE using $METHOD]) ohair@494: AC_MSG_NOTICE([Warning: Installation is broken, SetEnv.Cmd is missing. Ignoring]) ohair@494: fi ohair@494: fi ohair@494: fi ohair@494: ]) ohair@494: kevinw@2223: ################################################################################ kevinw@2223: # Finds the bat or cmd file in Visual Studio or the SDK that sets up a proper kevinw@2223: # build environment and assigns it to VS_ENV_CMD ohair@494: AC_DEFUN([TOOLCHAIN_FIND_VISUAL_STUDIO_BAT_FILE], ohair@494: [ kevinw@2223: VS_VERSION="$1" kevinw@2223: eval VS_COMNTOOLS_VAR="\${VS_ENVVAR_${VS_VERSION}}" kevinw@2223: eval VS_COMNTOOLS="\$${VS_COMNTOOLS_VAR}" kevinw@2223: eval VS_INSTALL_DIR="\${VS_VS_INSTALLDIR_${VS_VERSION}}" kevinw@2228: eval VS_EDITIONS="\${VS_EDITIONS_${VS_VERSION}}" kevinw@2223: eval SDK_INSTALL_DIR="\${VS_SDK_INSTALLDIR_${VS_VERSION}}" kevinw@2228: eval VS_ENV_ARGS="\${VS_ENV_ARGS_${VS_VERSION}}" kevinw@2223: kevinw@2223: # When using --with-tools-dir, assume it points to the correct and default kevinw@2223: # version of Visual Studio or that --with-toolchain-version was also set. kevinw@2223: if test "x$with_tools_dir" != x; then kevinw@2223: TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}], kevinw@2223: [$with_tools_dir/../..], [--with-tools-dir]) kevinw@2223: TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}], kevinw@2223: [$with_tools_dir/../../..], [--with-tools-dir]) kevinw@2223: if test "x$VS_ENV_CMD" = x; then kevinw@2223: # Having specified an argument which is incorrect will produce an instant failure; kevinw@2223: # we should not go on looking kevinw@2223: AC_MSG_NOTICE([The path given by --with-tools-dir does not contain a valid]) kevinw@2223: AC_MSG_NOTICE([Visual Studio installation. Please point to the VC/bin or VC/bin/amd64]) kevinw@2223: AC_MSG_NOTICE([directory within the Visual Studio installation]) kevinw@2223: AC_MSG_ERROR([Cannot locate a valid Visual Studio installation]) kevinw@2223: fi ihse@839: fi ohair@494: ohair@494: VS_ENV_CMD="" kevinw@2223: kevinw@2223: if test "x$VS_COMNTOOLS" != x; then kevinw@2223: TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}], kevinw@2223: [$VS_COMNTOOLS/../..], [$VS_COMNTOOLS_VAR variable]) kevinw@2223: fi kevinw@2223: if test "x$PROGRAMFILES" != x; then kevinw@2223: TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}], kevinw@2223: [$PROGRAMFILES/$VS_INSTALL_DIR], [well-known name]) kevinw@2223: fi kevinw@2223: # Work around the insanely named ProgramFiles(x86) env variable kevinw@2223: PROGRAMFILES_X86="`env | $SED -n 's/^ProgramFiles(x86)=//p'`" kevinw@2223: if test "x$PROGRAMFILES_X86" != x; then kevinw@2223: TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}], kevinw@2223: [$PROGRAMFILES_X86/$VS_INSTALL_DIR], [well-known name]) kevinw@2223: fi kevinw@2223: TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}], kevinw@2223: [C:/Program Files/$VS_INSTALL_DIR], [well-known name]) kevinw@2223: TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}], kevinw@2223: [C:/Program Files (x86)/$VS_INSTALL_DIR], [well-known name]) kevinw@2223: kevinw@2223: if test "x$SDK_INSTALL_DIR" != x; then kevinw@2223: if test "x$ProgramW6432" != x; then kevinw@2223: TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([${VS_VERSION}], kevinw@2223: [$ProgramW6432/$SDK_INSTALL_DIR], [well-known name]) kevinw@2223: fi kevinw@2223: if test "x$PROGRAMW6432" != x; then kevinw@2223: TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([${VS_VERSION}], kevinw@2223: [$PROGRAMW6432/$SDK_INSTALL_DIR], [well-known name]) kevinw@2223: fi kevinw@2223: if test "x$PROGRAMFILES" != x; then kevinw@2223: TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([${VS_VERSION}], kevinw@2223: [$PROGRAMFILES/$SDK_INSTALL_DIR], [well-known name]) kevinw@2223: fi kevinw@2223: TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([${VS_VERSION}], kevinw@2223: [C:/Program Files/$SDK_INSTALL_DIR], [well-known name]) kevinw@2223: TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([${VS_VERSION}], kevinw@2223: [C:/Program Files (x86)/$SDK_INSTALL_DIR], [well-known name]) kevinw@2223: fi kevinw@2223: ]) kevinw@2223: kevinw@2223: ################################################################################ kevinw@2223: kevinw@2223: AC_DEFUN([TOOLCHAIN_FIND_VISUAL_STUDIO], kevinw@2223: [ kevinw@2223: AC_ARG_WITH(toolchain-version, [AS_HELP_STRING([--with-toolchain-version], kevinw@2223: [the version of the toolchain to look for, use '--help' to show possible values @<:@platform dependent@:>@])]) kevinw@2223: kevinw@2223: if test "x$with_toolchain_version" = xlist; then kevinw@2223: # List all toolchains kevinw@2223: AC_MSG_NOTICE([The following toolchain versions are valid on this platform:]) kevinw@2223: for version in $VALID_VS_VERSIONS; do kevinw@2223: eval VS_DESCRIPTION=\${VS_DESCRIPTION_$version} kevinw@2223: $PRINTF " %-10s %s\n" $version "$VS_DESCRIPTION" kevinw@2223: done kevinw@2223: kevinw@2223: exit 0 kevinw@2224: elif test "x$DEVKIT_VS_VERSION" != x; then kevinw@2224: VS_VERSION=$DEVKIT_VS_VERSION kevinw@2224: TOOLCHAIN_VERSION=$VS_VERSION kevinw@2228: # If the devkit has a name, use that as description kevinw@2228: VS_DESCRIPTION="$DEVKIT_NAME" kevinw@2228: if test "x$VS_DESCRIPTION" = x; then kevinw@2228: eval VS_DESCRIPTION="\${VS_DESCRIPTION_${VS_VERSION}}" kevinw@2228: fi kevinw@2224: eval VS_VERSION_INTERNAL="\${VS_VERSION_INTERNAL_${VS_VERSION}}" kevinw@2224: eval MSVCR_NAME="\${VS_MSVCR_${VS_VERSION}}" kevinw@2224: eval MSVCP_NAME="\${VS_MSVCP_${VS_VERSION}}" kevinw@2333: eval USE_UCRT="\${VS_USE_UCRT_${VS_VERSION}}" kevinw@2224: eval PLATFORM_TOOLSET="\${VS_VS_PLATFORM_NAME_${VS_VERSION}}" kevinw@2224: VS_PATH="$TOOLCHAIN_PATH:$PATH" kevinw@2224: kevinw@2224: # Convert DEVKIT_VS_INCLUDE into windows style VS_INCLUDE so that it kevinw@2224: # can still be exported as INCLUDE for compiler invocations without kevinw@2224: # SYSROOT_CFLAGS kevinw@2224: OLDIFS="$IFS" kevinw@2224: IFS=";" kevinw@2224: for i in $DEVKIT_VS_INCLUDE; do kevinw@2224: ipath=$i kevinw@2224: BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH([ipath]) kevinw@2224: VS_INCLUDE="$VS_INCLUDE;$ipath" kevinw@2224: done kevinw@2224: # Convert DEVKIT_VS_LIB into VS_LIB so that it can still be exported kevinw@2224: # as LIB for compiler invocations without SYSROOT_LDFLAGS kevinw@2224: for i in $DEVKIT_VS_LIB; do kevinw@2224: libpath=$i kevinw@2224: BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH([libpath]) kevinw@2224: VS_LIB="$VS_LIB;$libpath" kevinw@2224: done kevinw@2224: IFS="$OLDIFS" kevinw@2224: kevinw@2224: AC_MSG_NOTICE([Found devkit $VS_DESCRIPTION]) kevinw@2224: kevinw@2223: elif test "x$with_toolchain_version" != x; then kevinw@2223: # User override; check that it is valid kevinw@2223: if test "x${VALID_VS_VERSIONS/$with_toolchain_version/}" = "x${VALID_VS_VERSIONS}"; then kevinw@2223: AC_MSG_NOTICE([Visual Studio version $with_toolchain_version is not valid.]) kevinw@2223: AC_MSG_NOTICE([Valid Visual Studio versions: $VALID_VS_VERSIONS.]) kevinw@2223: AC_MSG_ERROR([Cannot continue.]) kevinw@2223: fi kevinw@2223: VS_VERSIONS_PROBE_LIST="$with_toolchain_version" kevinw@2223: else kevinw@2223: # No flag given, use default kevinw@2223: VS_VERSIONS_PROBE_LIST="$VALID_VS_VERSIONS" ohair@494: fi ohair@494: kevinw@2223: for VS_VERSION in $VS_VERSIONS_PROBE_LIST; do kevinw@2223: TOOLCHAIN_FIND_VISUAL_STUDIO_BAT_FILE([$VS_VERSION]) kevinw@2223: if test "x$VS_ENV_CMD" != x; then kevinw@2223: TOOLCHAIN_VERSION=$VS_VERSION kevinw@2223: eval VS_DESCRIPTION="\${VS_DESCRIPTION_${VS_VERSION}}" kevinw@2223: eval VS_VERSION_INTERNAL="\${VS_VERSION_INTERNAL_${VS_VERSION}}" kevinw@2223: eval MSVCR_NAME="\${VS_MSVCR_${VS_VERSION}}" kevinw@2223: eval MSVCP_NAME="\${VS_MSVCP_${VS_VERSION}}" kevinw@2333: eval USE_UCRT="\${VS_USE_UCRT_${VS_VERSION}}" kevinw@2223: # The rest of the variables are already evaled while probing kevinw@2223: AC_MSG_NOTICE([Found $VS_DESCRIPTION]) kevinw@2223: break kevinw@2223: fi kevinw@2223: done kevinw@2228: kevinw@2228: TOOLCHAIN_DESCRIPTION="$VS_DESCRIPTION" kevinw@2228: if test "$TOOLCHAIN_VERSION" -gt 2013; then kevinw@2228: UNSUPPORTED_TOOLCHAIN_VERSION=yes kevinw@2228: fi ohair@494: ]) ohair@494: kevinw@2223: ################################################################################ ohair@494: # Check if the VS env variables were setup prior to running configure. ohair@494: # If not, then find vcvarsall.bat and run it automatically, and integrate ohair@494: # the set env variables into the spec file. ohair@494: AC_DEFUN([TOOLCHAIN_SETUP_VISUAL_STUDIO_ENV], ohair@494: [ ihse@839: # Store path to cygwin link.exe to help excluding it when searching for ohair@494: # VS linker. This must be done before changing the PATH when looking for VS. ohair@494: AC_PATH_PROG(CYGWIN_LINK, link) ohair@494: if test "x$CYGWIN_LINK" != x; then ohair@494: AC_MSG_CHECKING([if the first found link.exe is actually the Cygwin link tool]) ohair@494: "$CYGWIN_LINK" --version > /dev/null ohair@494: if test $? -eq 0 ; then ohair@494: AC_MSG_RESULT([yes]) ohair@494: else ohair@494: AC_MSG_RESULT([no]) ohair@494: # This might be the VS linker. Don't exclude it later on. ohair@494: CYGWIN_LINK="" ohair@494: fi ohair@494: fi ohair@494: ohair@494: # First-hand choice is to locate and run the vsvars bat file. kevinw@2223: TOOLCHAIN_FIND_VISUAL_STUDIO kevinw@2223: kevinw@2224: # If we have a devkit, skip all of the below. kevinw@2224: if test "x$DEVKIT_VS_VERSION" = x; then kevinw@2224: if test "x$VS_ENV_CMD" != x; then kevinw@2224: # We have found a Visual Studio environment on disk, let's extract variables from the vsvars bat file. kevinw@2224: BASIC_FIXUP_EXECUTABLE(VS_ENV_CMD) ohair@494: kevinw@2224: # Lets extract the variables that are set by vcvarsall.bat/vsvars32.bat/vsvars64.bat kevinw@2224: AC_MSG_NOTICE([Trying to extract Visual Studio environment variables]) ohair@494: kevinw@2224: # We need to create a couple of temporary files. kevinw@2224: VS_ENV_TMP_DIR="$OUTPUT_ROOT/vs-env" kevinw@2224: $MKDIR -p $VS_ENV_TMP_DIR ohair@494: kevinw@2224: # Cannot use the VS10 setup script directly (since it only updates the DOS subshell environment). kevinw@2224: # Instead create a shell script which will set the relevant variables when run. kevinw@2224: WINPATH_VS_ENV_CMD="$VS_ENV_CMD" kevinw@2224: BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH([WINPATH_VS_ENV_CMD]) kevinw@2224: WINPATH_BASH="$BASH" kevinw@2224: BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH([WINPATH_BASH]) ohair@494: kevinw@2224: # Generate a DOS batch file which runs $VS_ENV_CMD, and then creates a shell kevinw@2224: # script (executable by bash) that will setup the important variables. kevinw@2224: EXTRACT_VC_ENV_BAT_FILE="$VS_ENV_TMP_DIR/extract-vs-env.bat" kevinw@2224: $ECHO "@echo off" > $EXTRACT_VC_ENV_BAT_FILE kevinw@2224: # This will end up something like: kevinw@2224: # call C:/progra~2/micros~2.0/vc/bin/amd64/vcvars64.bat kevinw@2224: $ECHO "call $WINPATH_VS_ENV_CMD $VS_ENV_ARGS" >> $EXTRACT_VC_ENV_BAT_FILE kevinw@2228: # In some cases, the VS_ENV_CMD will change directory, change back so kevinw@2228: # the set-vs-env.sh ends up in the right place. kevinw@2228: $ECHO 'cd %~dp0' >> $EXTRACT_VC_ENV_BAT_FILE kevinw@2224: # These will end up something like: kevinw@2224: # C:/CygWin/bin/bash -c 'echo VS_PATH=\"$PATH\" > localdevenv.sh kevinw@2224: # The trailing space for everyone except PATH is no typo, but is needed due kevinw@2224: # to trailing \ in the Windows paths. These will be stripped later. kevinw@2224: $ECHO "$WINPATH_BASH -c 'echo VS_PATH="'\"$PATH\" > set-vs-env.sh' \ kevinw@2224: >> $EXTRACT_VC_ENV_BAT_FILE kevinw@2224: $ECHO "$WINPATH_BASH -c 'echo VS_INCLUDE="'\"$INCLUDE \" >> set-vs-env.sh' \ kevinw@2224: >> $EXTRACT_VC_ENV_BAT_FILE kevinw@2224: $ECHO "$WINPATH_BASH -c 'echo VS_LIB="'\"$LIB \" >> set-vs-env.sh' \ kevinw@2224: >> $EXTRACT_VC_ENV_BAT_FILE kevinw@2224: $ECHO "$WINPATH_BASH -c 'echo VCINSTALLDIR="'\"$VCINSTALLDIR \" >> set-vs-env.sh' \ kevinw@2224: >> $EXTRACT_VC_ENV_BAT_FILE kevinw@2224: $ECHO "$WINPATH_BASH -c 'echo WindowsSdkDir="'\"$WindowsSdkDir \" >> set-vs-env.sh' \ kevinw@2224: >> $EXTRACT_VC_ENV_BAT_FILE kevinw@2224: $ECHO "$WINPATH_BASH -c 'echo WINDOWSSDKDIR="'\"$WINDOWSSDKDIR \" >> set-vs-env.sh' \ kevinw@2224: >> $EXTRACT_VC_ENV_BAT_FILE ohair@494: kevinw@2224: # Now execute the newly created bat file. kevinw@2224: # The | cat is to stop SetEnv.Cmd to mess with system colors on msys. kevinw@2224: # Change directory so we don't need to mess with Windows paths in redirects. kevinw@2224: cd $VS_ENV_TMP_DIR kevinw@2224: cmd /c extract-vs-env.bat | $CAT kevinw@2224: cd $CURDIR ohair@494: kevinw@2224: if test ! -s $VS_ENV_TMP_DIR/set-vs-env.sh; then kevinw@2224: AC_MSG_NOTICE([Could not succesfully extract the envionment variables needed for the VS setup.]) kevinw@2224: AC_MSG_NOTICE([Try setting --with-tools-dir to the VC/bin directory within the VS installation]) kevinw@2224: AC_MSG_NOTICE([or run "bash.exe -l" from a VS command prompt and then run configure from there.]) kevinw@2224: AC_MSG_ERROR([Cannot continue]) kevinw@2224: fi kevinw@2224: kevinw@2224: # Now set all paths and other env variables. This will allow the rest of kevinw@2224: # the configure script to find and run the compiler in the proper way. kevinw@2224: AC_MSG_NOTICE([Setting extracted environment variables]) kevinw@2224: . $VS_ENV_TMP_DIR/set-vs-env.sh kevinw@2224: # Now we have VS_PATH, VS_INCLUDE, VS_LIB. For further checking, we kevinw@2224: # also define VCINSTALLDIR, WindowsSdkDir and WINDOWSSDKDIR. kevinw@2224: else kevinw@2224: # We did not find a vsvars bat file, let's hope we are run from a VS command prompt. kevinw@2224: AC_MSG_NOTICE([Cannot locate a valid Visual Studio installation, checking current environment]) ohair@494: fi ohair@494: fi ohair@494: kevinw@2208: # At this point, we should have correct variables in the environment, or we can't continue. ohair@494: AC_MSG_CHECKING([for Visual Studio variables]) ihse@839: kevinw@2224: if test "x$VCINSTALLDIR" != x || test "x$WindowsSDKDir" != x \ kevinw@2224: || test "x$WINDOWSSDKDIR" != x || test "x$DEVKIT_NAME" != x; then kevinw@2208: if test "x$VS_INCLUDE" = x || test "x$VS_LIB" = x; then ohair@494: AC_MSG_RESULT([present but broken]) ohair@494: AC_MSG_ERROR([Your VC command prompt seems broken, INCLUDE and/or LIB is missing.]) ohair@494: else ohair@494: AC_MSG_RESULT([ok]) kevinw@2208: # Remove any trailing "\" and " " from the variables. kevinw@2208: VS_INCLUDE=`$ECHO "$VS_INCLUDE" | $SED 's/\\\\* *$//'` kevinw@2208: VS_LIB=`$ECHO "$VS_LIB" | $SED 's/\\\\* *$//'` kevinw@2208: VCINSTALLDIR=`$ECHO "$VCINSTALLDIR" | $SED 's/\\\\* *$//'` kevinw@2333: WindowsSdkDir=`$ECHO "$WindowsSdkDir" | $SED 's/\\\\* *$//'` kevinw@2208: WINDOWSSDKDIR=`$ECHO "$WINDOWSSDKDIR" | $SED 's/\\\\* *$//'` kevinw@2333: if test -z "$WINDOWSSDKDIR"; then kevinw@2333: WINDOWSSDKDIR="$WindowsSdkDir" kevinw@2333: fi kevinw@2209: # Remove any paths containing # (typically F#) as that messes up make. This kevinw@2209: # is needed if visual studio was installed with F# support. kevinw@2209: VS_PATH=`$ECHO "$VS_PATH" | $SED 's/[[^:#]]*#[^:]*://g'` kevinw@2208: kevinw@2208: AC_SUBST(VS_PATH) ohair@494: AC_SUBST(VS_INCLUDE) ohair@494: AC_SUBST(VS_LIB) ohair@494: fi ohair@494: else ohair@494: AC_MSG_RESULT([not found]) ohair@494: ohair@494: if test "x$VS_ENV_CMD" = x; then ohair@494: AC_MSG_NOTICE([Cannot locate a valid Visual Studio or Windows SDK installation on disk,]) ohair@494: AC_MSG_NOTICE([nor is this script run from a Visual Studio command prompt.]) ohair@494: else ohair@494: AC_MSG_NOTICE([Running the extraction script failed.]) ohair@494: fi ohair@494: AC_MSG_NOTICE([Try setting --with-tools-dir to the VC/bin directory within the VS installation]) ohair@494: AC_MSG_NOTICE([or run "bash.exe -l" from a VS command prompt and then run configure from there.]) ohair@494: AC_MSG_ERROR([Cannot continue]) ohair@494: fi ihse@857: ]) ihse@839: kevinw@2223: AC_DEFUN([TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL], ihse@857: [ kevinw@2223: DLL_NAME="$1" kevinw@2223: POSSIBLE_MSVC_DLL="$2" kevinw@2223: METHOD="$3" kevinw@2223: if test -n "$POSSIBLE_MSVC_DLL" -a -e "$POSSIBLE_MSVC_DLL"; then kevinw@2224: AC_MSG_NOTICE([Found $DLL_NAME at $POSSIBLE_MSVC_DLL using $METHOD]) kevinw@2223: ihse@857: # Need to check if the found msvcr is correct architecture kevinw@2224: AC_MSG_CHECKING([found $DLL_NAME architecture]) kevinw@2223: MSVC_DLL_FILETYPE=`$FILE -b "$POSSIBLE_MSVC_DLL"` kevinw@2219: if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then kevinw@2219: # The MSYS 'file' command returns "PE32 executable for MS Windows (DLL) (GUI) Intel 80386 32-bit" kevinw@2219: # on x32 and "PE32+ executable for MS Windows (DLL) (GUI) Mono/.Net assembly" on x64 systems. kevinw@2219: if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then kevinw@2219: CORRECT_MSVCR_ARCH="PE32 executable" kevinw@2219: else kevinw@2219: CORRECT_MSVCR_ARCH="PE32+ executable" kevinw@2219: fi ihse@857: else kevinw@2219: if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then kevinw@2219: CORRECT_MSVCR_ARCH=386 kevinw@2219: else kevinw@2219: CORRECT_MSVCR_ARCH=x86-64 kevinw@2219: fi ihse@857: fi kevinw@2223: if $ECHO "$MSVC_DLL_FILETYPE" | $GREP "$CORRECT_MSVCR_ARCH" 2>&1 > /dev/null; then ihse@857: AC_MSG_RESULT([ok]) kevinw@2223: MSVC_DLL="$POSSIBLE_MSVC_DLL" kevinw@2224: BASIC_FIXUP_PATH(MSVC_DLL) kevinw@2224: AC_MSG_CHECKING([for $DLL_NAME]) kevinw@2223: AC_MSG_RESULT([$MSVC_DLL]) ihse@857: else ihse@857: AC_MSG_RESULT([incorrect, ignoring]) kevinw@2224: AC_MSG_NOTICE([The file type of the located $DLL_NAME is $MSVC_DLL_FILETYPE]) ihse@857: fi ihse@857: fi ihse@857: ]) ihse@857: kevinw@2223: AC_DEFUN([TOOLCHAIN_SETUP_MSVC_DLL], ihse@857: [ kevinw@2224: DLL_NAME="$1" kevinw@2223: MSVC_DLL= ihse@857: kevinw@2223: if test "x$MSVC_DLL" = x; then ohair@494: if test "x$VCINSTALLDIR" != x; then ihse@857: CYGWIN_VC_INSTALL_DIR="$VCINSTALLDIR" kevinw@2333: BASIC_FIXUP_PATH(CYGWIN_VC_INSTALL_DIR) kevinw@2228: if test "$VS_VERSION" -lt 2017; then kevinw@2228: # Probe: Using well-known location from Visual Studio 12.0 and older kevinw@2228: if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then kevinw@2228: POSSIBLE_MSVC_DLL="$CYGWIN_VC_INSTALL_DIR/redist/x64/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME" kevinw@2228: else kevinw@2228: POSSIBLE_MSVC_DLL="$CYGWIN_VC_INSTALL_DIR/redist/x86/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME" kevinw@2228: fi ohair@494: else kevinw@2228: # Probe: Using well-known location from VS 2017 kevinw@2228: if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then kevinw@2228: POSSIBLE_MSVC_DLL="`ls $CYGWIN_VC_INSTALL_DIR/Redist/MSVC/*/x64/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME`" kevinw@2228: else kevinw@2228: POSSIBLE_MSVC_DLL="`ls $CYGWIN_VC_INSTALL_DIR/Redist/MSVC/*/x86/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME`" kevinw@2228: fi ihse@857: fi kevinw@2228: # In case any of the above finds more than one file, loop over them. kevinw@2228: for possible_msvc_dll in $POSSIBLE_MSVC_DLL; do kevinw@2228: $ECHO "POSSIBLE_MSVC_DLL $possible_msvc_dll" kevinw@2228: TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$possible_msvc_dll], kevinw@2223: [well-known location in VCINSTALLDIR]) kevinw@2228: done ihse@857: fi ihse@857: fi ihse@857: kevinw@2223: if test "x$MSVC_DLL" = x; then ihse@857: # Probe: Check in the Boot JDK directory. kevinw@2223: POSSIBLE_MSVC_DLL="$BOOT_JDK/bin/$DLL_NAME" kevinw@2223: TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL($[DLL_NAME], [$POSSIBLE_MSVC_DLL], kevinw@2223: [well-known location in Boot JDK]) ihse@857: fi ihse@857: kevinw@2223: if test "x$MSVC_DLL" = x; then ihse@857: # Probe: Look in the Windows system32 directory ihse@857: CYGWIN_SYSTEMROOT="$SYSTEMROOT" ihse@857: BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(CYGWIN_SYSTEMROOT) kevinw@2223: POSSIBLE_MSVC_DLL="$CYGWIN_SYSTEMROOT/system32/$DLL_NAME" kevinw@2223: TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$POSSIBLE_MSVC_DLL], kevinw@2223: [well-known location in SYSTEMROOT]) ihse@857: fi ihse@857: kevinw@2223: if test "x$MSVC_DLL" = x; then ihse@857: # Probe: If Visual Studio Express is installed, there is usually one with the debugger ihse@857: if test "x$VS100COMNTOOLS" != x; then ihse@857: CYGWIN_VS_TOOLS_DIR="$VS100COMNTOOLS/.." ihse@857: BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(CYGWIN_VS_TOOLS_DIR) ihse@857: if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then kevinw@2223: POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VS_TOOLS_DIR" -name $DLL_NAME \ kevinw@2223: | $GREP -i /x64/ | $HEAD --lines 1` ihse@857: else kevinw@2223: POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VS_TOOLS_DIR" -name $DLL_NAME \ kevinw@2223: | $GREP -i /x86/ | $HEAD --lines 1` ihse@857: fi kevinw@2223: TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$POSSIBLE_MSVC_DLL], kevinw@2223: [search of VS100COMNTOOLS]) ihse@857: fi ihse@857: fi ihse@857: kevinw@2223: if test "x$MSVC_DLL" = x; then ihse@857: # Probe: Search wildly in the VCINSTALLDIR. We've probably lost by now. kevinw@2223: # (This was the original behaviour; kept since it might turn something up) ihse@857: if test "x$CYGWIN_VC_INSTALL_DIR" != x; then ihse@857: if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then kevinw@2223: POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VC_INSTALL_DIR" -name $DLL_NAME \ kevinw@2223: | $GREP x64 | $HEAD --lines 1` ihse@857: else kevinw@2223: POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VC_INSTALL_DIR" -name $DLL_NAME \ kevinw@2223: | $GREP x86 | $GREP -v ia64 | $GREP -v x64 | $HEAD --lines 1` kevinw@2223: if test "x$POSSIBLE_MSVC_DLL" = x; then ihse@857: # We're grasping at straws now... kevinw@2223: POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VC_INSTALL_DIR" -name $DLL_NAME \ kevinw@2223: | $HEAD --lines 1` ohair@494: fi ohair@494: fi ihse@857: kevinw@2223: TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$POSSIBLE_MSVC_DLL], kevinw@2223: [search of VCINSTALLDIR]) ohair@494: fi ohair@494: fi ihse@857: kevinw@2223: if test "x$MSVC_DLL" = x; then kevinw@2223: AC_MSG_CHECKING([for $DLL_NAME]) ohair@494: AC_MSG_RESULT([no]) kevinw@2223: AC_MSG_ERROR([Could not find $DLL_NAME. Please specify using --with-msvcr-dll.]) ohair@494: fi ohair@494: ]) kevinw@2223: kevinw@2223: AC_DEFUN([TOOLCHAIN_SETUP_VS_RUNTIME_DLLS], kevinw@2223: [ kevinw@2223: AC_ARG_WITH(msvcr-dll, [AS_HELP_STRING([--with-msvcr-dll], kevinw@2223: [path to microsoft C runtime dll (msvcr*.dll) (Windows only) @<:@probed@:>@])]) kevinw@2223: kevinw@2223: if test "x$with_msvcr_dll" != x; then kevinw@2223: # If given explicitely by user, do not probe. If not present, fail directly. kevinw@2224: TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL($MSVCR_NAME, [$with_msvcr_dll], [--with-msvcr-dll]) kevinw@2223: if test "x$MSVC_DLL" = x; then kevinw@2223: AC_MSG_ERROR([Could not find a proper $MSVCR_NAME as specified by --with-msvcr-dll]) kevinw@2223: fi kevinw@2224: MSVCR_DLL="$MSVC_DLL" kevinw@2224: elif test "x$DEVKIT_MSVCR_DLL" != x; then kevinw@2224: TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL($MSVCR_NAME, [$DEVKIT_MSVCR_DLL], [devkit]) kevinw@2224: if test "x$MSVC_DLL" = x; then kevinw@2224: AC_MSG_ERROR([Could not find a proper $MSVCR_NAME as specified by devkit]) kevinw@2224: fi kevinw@2224: MSVCR_DLL="$MSVC_DLL" kevinw@2223: else kevinw@2224: TOOLCHAIN_SETUP_MSVC_DLL([${MSVCR_NAME}]) kevinw@2224: MSVCR_DLL="$MSVC_DLL" kevinw@2223: fi kevinw@2224: AC_SUBST(MSVCR_DLL) kevinw@2223: kevinw@2223: AC_ARG_WITH(msvcp-dll, [AS_HELP_STRING([--with-msvcp-dll], kevinw@2223: [path to microsoft C++ runtime dll (msvcp*.dll) (Windows only) @<:@probed@:>@])]) kevinw@2223: kevinw@2223: if test "x$MSVCP_NAME" != "x"; then kevinw@2223: if test "x$with_msvcp_dll" != x; then kevinw@2223: # If given explicitely by user, do not probe. If not present, fail directly. kevinw@2224: TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL($MSVCP_NAME, [$with_msvcp_dll], [--with-msvcp-dll]) kevinw@2223: if test "x$MSVC_DLL" = x; then kevinw@2223: AC_MSG_ERROR([Could not find a proper $MSVCP_NAME as specified by --with-msvcp-dll]) kevinw@2223: fi kevinw@2224: MSVCP_DLL="$MSVC_DLL" kevinw@2224: elif test "x$DEVKIT_MSVCP_DLL" != x; then kevinw@2224: TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL($MSVCP_NAME, [$DEVKIT_MSVCP_DLL], [devkit]) kevinw@2224: if test "x$MSVC_DLL" = x; then kevinw@2224: AC_MSG_ERROR([Could not find a proper $MSVCP_NAME as specified by devkit]) kevinw@2224: fi kevinw@2224: MSVCP_DLL="$MSVC_DLL" kevinw@2223: else kevinw@2224: TOOLCHAIN_SETUP_MSVC_DLL([${MSVCP_NAME}]) kevinw@2224: MSVCP_DLL="$MSVC_DLL" kevinw@2223: fi kevinw@2224: AC_SUBST(MSVCP_DLL) kevinw@2223: fi kevinw@2333: kevinw@2333: AC_ARG_WITH(ucrt-dll-dir, [AS_HELP_STRING([--with-ucrt-dll-dir], kevinw@2333: [path to Microsoft Windows Kit UCRT DLL dir (Windows only) @<:@probed@:>@])]) kevinw@2333: kevinw@2333: if test "x$USE_UCRT" = "xtrue"; then kevinw@2333: AC_MSG_CHECKING([for UCRT DLL dir]) kevinw@2333: if test "x$with_ucrt_dll_dir" != x; then stooke@2480: if test -z "$(ls -d "$with_ucrt_dll_dir/"*.dll 2> /dev/null)"; then kevinw@2333: AC_MSG_RESULT([no]) kevinw@2333: AC_MSG_ERROR([Could not find any dlls in $with_ucrt_dll_dir]) kevinw@2333: else kevinw@2333: AC_MSG_RESULT([$with_ucrt_dll_dir]) kevinw@2333: UCRT_DLL_DIR="$with_ucrt_dll_dir" kevinw@2333: BASIC_FIXUP_PATH([UCRT_DLL_DIR]) kevinw@2333: fi kevinw@2333: elif test "x$DEVKIT_UCRT_DLL_DIR" != "x"; then kevinw@2333: UCRT_DLL_DIR="$DEVKIT_UCRT_DLL_DIR" kevinw@2333: AC_MSG_RESULT($UCRT_DLL_DIR) kevinw@2333: else kevinw@2333: CYGWIN_WINDOWSSDKDIR="${WINDOWSSDKDIR}" kevinw@2333: BASIC_FIXUP_PATH([CYGWIN_WINDOWSSDKDIR]) kevinw@2333: dll_subdir=$OPENJDK_TARGET_CPU kevinw@2333: if test "x$dll_subdir" = "xx86_64"; then kevinw@2333: dll_subdir="x64" kevinw@2333: fi kevinw@2333: UCRT_DLL_DIR="$CYGWIN_WINDOWSSDKDIR/Redist/ucrt/DLLs/$dll_subdir" kevinw@2333: if test -z "$(ls -d "$UCRT_DLL_DIR/"*.dll 2> /dev/null)"; then kevinw@2333: AC_MSG_RESULT([no]) kevinw@2333: AC_MSG_ERROR([Could not find any dlls in $UCRT_DLL_DIR]) kevinw@2333: else kevinw@2333: AC_MSG_RESULT($UCRT_DLL_DIR) kevinw@2333: fi kevinw@2333: fi kevinw@2333: else kevinw@2333: UCRT_DLL_DIR= kevinw@2333: fi kevinw@2333: AC_SUBST(UCRT_DLL_DIR) kevinw@2223: ]) kevinw@2223: