toolchain_windows.m4 revision 1454:bc02cff96b92
138494Sobrien# 2174298Sobrien# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. 338494Sobrien# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 438494Sobrien# 538494Sobrien# This code is free software; you can redistribute it and/or modify it 638494Sobrien# under the terms of the GNU General Public License version 2 only, as 738494Sobrien# published by the Free Software Foundation. Oracle designates this 838494Sobrien# particular file as subject to the "Classpath" exception as provided 938494Sobrien# by Oracle in the LICENSE file that accompanied this code. 1038494Sobrien# 1138494Sobrien# This code is distributed in the hope that it will be useful, but WITHOUT 1238494Sobrien# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1338494Sobrien# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1438494Sobrien# version 2 for more details (a copy is included in the LICENSE file that 1538494Sobrien# accompanied this code). 1638494Sobrien# 1738494Sobrien# You should have received a copy of the GNU General Public License version 1838494Sobrien# 2 along with this work; if not, write to the Free Software Foundation, 1938494Sobrien# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2042633Sobrien# 2138494Sobrien# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2238494Sobrien# or visit www.oracle.com if you need additional information or have any 2338494Sobrien# questions. 2438494Sobrien# 2538494Sobrien 2638494Sobrien################################################################################ 2738494Sobrien# The order of these defines the priority by which we try to find them. 2838494SobrienVALID_VS_VERSIONS="2013 2012 2010" 2938494Sobrien 3038494SobrienVS_DESCRIPTION_2010="Microsoft Visual Studio 2010" 3138494SobrienVS_VERSION_INTERNAL_2010=100 3238494SobrienVS_MSVCR_2010=msvcr100.dll 3338494Sobrien# We don't use msvcp on Visual Studio 2010 3438494Sobrien#VS_MSVCP_2010=msvcp100.dll 3538494SobrienVS_ENVVAR_2010="VS100COMNTOOLS" 3638494SobrienVS_VS_INSTALLDIR_2010="Microsoft Visual Studio 10.0" 3738494SobrienVS_SDK_INSTALLDIR_2010="Microsoft SDKs/Windows/v7.1" 3838494SobrienVS_VS_PLATFORM_NAME_2010="v100" 3938494SobrienVS_SDK_PLATFORM_NAME_2010="Windows7.1SDK" 40131706Smbr 41174298SobrienVS_DESCRIPTION_2012="Microsoft Visual Studio 2012" 4238494SobrienVS_VERSION_INTERNAL_2012=110 4338494SobrienVS_MSVCR_2012=msvcr110.dll 4438494SobrienVS_MSVCP_2012=msvcp110.dll 45174298SobrienVS_ENVVAR_2012="VS110COMNTOOLS" 46174298SobrienVS_VS_INSTALLDIR_2012="Microsoft Visual Studio 11.0" 47174298SobrienVS_SDK_INSTALLDIR_2012= 4838494SobrienVS_VS_PLATFORM_NAME_2012="v110" 4938494SobrienVS_SDK_PLATFORM_NAME_2012= 5038494Sobrien 5138494SobrienVS_DESCRIPTION_2013="Microsoft Visual Studio 2013" 5238494SobrienVS_VERSION_INTERNAL_2013=120 5338494SobrienVS_MSVCR_2013=msvcr120.dll 5438494SobrienVS_MSVCP_2013=msvcp120.dll 5538494SobrienVS_ENVVAR_2013="VS120COMNTOOLS" 5638494SobrienVS_VS_INSTALLDIR_2013="Microsoft Visual Studio 12.0" 5738494SobrienVS_SDK_INSTALLDIR_2013= 5838494SobrienVS_VS_PLATFORM_NAME_2013="v120" 5938494SobrienVS_SDK_PLATFORM_NAME_2013= 60174298Sobrien 6138494Sobrien################################################################################ 62174298Sobrien 63174298SobrienAC_DEFUN([TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT], 6438494Sobrien[ 6538494Sobrien if test "x$VS_ENV_CMD" = x; then 6638494Sobrien VS_VERSION="$1" 6738494Sobrien VS_BASE="$2" 6838494Sobrien METHOD="$3" 6938494Sobrien 7042633Sobrien if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then 7138494Sobrien VCVARSFILE="vc/bin/vcvars32.bat" 7238494Sobrien else 7338494Sobrien VCVARSFILE="vc/bin/amd64/vcvars64.bat" 7438494Sobrien fi 7538494Sobrien 7638494Sobrien BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(VS_BASE) 7738494Sobrien if test -d "$VS_BASE"; then 78174298Sobrien if test -f "$VS_BASE/$VCVARSFILE"; then 79174298Sobrien AC_MSG_NOTICE([Found Visual Studio installation at $VS_BASE using $METHOD]) 80174298Sobrien VS_ENV_CMD="$VS_BASE/$VCVARSFILE" 81174298Sobrien # PLATFORM_TOOLSET is used during the compilation of the freetype sources (see 8238494Sobrien # 'LIB_BUILD_FREETYPE' in libraries.m4) and must be one of 'v100', 'v110' or 'v120' for VS 2010, 2012 or VS2013 8338494Sobrien eval PLATFORM_TOOLSET="\${VS_VS_PLATFORM_NAME_${VS_VERSION}}" 8438494Sobrien else 8538494Sobrien AC_MSG_NOTICE([Found Visual Studio installation at $VS_BASE using $METHOD]) 8638494Sobrien AC_MSG_NOTICE([Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring]) 8738494Sobrien fi 8838494Sobrien fi 8938494Sobrien fi 9038494Sobrien]) 9138494Sobrien 9238494Sobrien################################################################################ 9338494Sobrien 9438494SobrienAC_DEFUN([TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT], 9538494Sobrien[ 9638494Sobrien if test "x$VS_ENV_CMD" = x; then 9738494Sobrien VS_VERSION="$1" 9838494Sobrien WIN_SDK_BASE="$2" 9938494Sobrien METHOD="$3" 10038494Sobrien BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(WIN_SDK_BASE) 10138494Sobrien if test -d "$WIN_SDK_BASE"; then 10238494Sobrien # There have been cases of partial or broken SDK installations. A missing 10338494Sobrien # lib dir is not going to work. 10438494Sobrien if test ! -d "$WIN_SDK_BASE/lib"; then 10538494Sobrien AC_MSG_NOTICE([Found Windows SDK installation at $WIN_SDK_BASE using $METHOD]) 10638494Sobrien AC_MSG_NOTICE([Warning: Installation is broken, lib dir is missing. Ignoring]) 10738494Sobrien elif test -f "$WIN_SDK_BASE/Bin/SetEnv.Cmd"; then 10838494Sobrien AC_MSG_NOTICE([Found Windows SDK installation at $WIN_SDK_BASE using $METHOD]) 10938494Sobrien VS_ENV_CMD="$WIN_SDK_BASE/Bin/SetEnv.Cmd" 11038494Sobrien if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then 11138494Sobrien VS_ENV_ARGS="/x86" 11238494Sobrien else 11338494Sobrien VS_ENV_ARGS="/x64" 11438494Sobrien fi 11538494Sobrien # PLATFORM_TOOLSET is used during the compilation of the freetype sources (see 11638494Sobrien # 'LIB_BUILD_FREETYPE' in libraries.m4) and must be 'Windows7.1SDK' for Windows7.1SDK 11738494Sobrien # TODO: improve detection for other versions of SDK 11838494Sobrien eval PLATFORM_TOOLSET="\${VS_SDK_PLATFORM_NAME_${VS_VERSION}}" 11938494Sobrien else 12038494Sobrien AC_MSG_NOTICE([Found Windows SDK installation at $WIN_SDK_BASE using $METHOD]) 12138494Sobrien AC_MSG_NOTICE([Warning: Installation is broken, SetEnv.Cmd is missing. Ignoring]) 12238494Sobrien fi 12338494Sobrien fi 12438494Sobrien fi 12538494Sobrien]) 12638494Sobrien 12738494Sobrien################################################################################ 12838494Sobrien# Finds the bat or cmd file in Visual Studio or the SDK that sets up a proper 12938494Sobrien# build environment and assigns it to VS_ENV_CMD 13038494SobrienAC_DEFUN([TOOLCHAIN_FIND_VISUAL_STUDIO_BAT_FILE], 13138494Sobrien[ 13238494Sobrien VS_VERSION="$1" 13338494Sobrien eval VS_COMNTOOLS_VAR="\${VS_ENVVAR_${VS_VERSION}}" 13438494Sobrien eval VS_COMNTOOLS="\$${VS_COMNTOOLS_VAR}" 13538494Sobrien eval VS_INSTALL_DIR="\${VS_VS_INSTALLDIR_${VS_VERSION}}" 13638494Sobrien eval SDK_INSTALL_DIR="\${VS_SDK_INSTALLDIR_${VS_VERSION}}" 13738494Sobrien 13838494Sobrien # When using --with-tools-dir, assume it points to the correct and default 13938494Sobrien # version of Visual Studio or that --with-toolchain-version was also set. 14038494Sobrien if test "x$with_tools_dir" != x; then 14138494Sobrien TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}], 142174298Sobrien [$with_tools_dir/../..], [--with-tools-dir]) 143174298Sobrien TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}], 144174298Sobrien [$with_tools_dir/../../..], [--with-tools-dir]) 145174298Sobrien if test "x$VS_ENV_CMD" = x; then 146174298Sobrien # Having specified an argument which is incorrect will produce an instant failure; 147174298Sobrien # we should not go on looking 148174298Sobrien AC_MSG_NOTICE([The path given by --with-tools-dir does not contain a valid]) 149174298Sobrien AC_MSG_NOTICE([Visual Studio installation. Please point to the VC/bin or VC/bin/amd64]) 150174298Sobrien AC_MSG_NOTICE([directory within the Visual Studio installation]) 151174298Sobrien AC_MSG_ERROR([Cannot locate a valid Visual Studio installation]) 152174298Sobrien fi 153174298Sobrien fi 154174298Sobrien 155174298Sobrien VS_ENV_CMD="" 156174298Sobrien VS_ENV_ARGS="" 157174298Sobrien 158174298Sobrien if test "x$VS_COMNTOOLS" != x; then 159174298Sobrien TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}], 160174298Sobrien [$VS_COMNTOOLS/../..], [$VS_COMNTOOLS_VAR variable]) 161174298Sobrien fi 16238494Sobrien if test "x$PROGRAMFILES" != x; then 16338494Sobrien TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}], 16438494Sobrien [$PROGRAMFILES/$VS_INSTALL_DIR], [well-known name]) 16538494Sobrien fi 16638494Sobrien # Work around the insanely named ProgramFiles(x86) env variable 16738494Sobrien PROGRAMFILES_X86="`env | $SED -n 's/^ProgramFiles(x86)=//p'`" 16838494Sobrien if test "x$PROGRAMFILES_X86" != x; then 16938494Sobrien TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}], 17038494Sobrien [$PROGRAMFILES_X86/$VS_INSTALL_DIR], [well-known name]) 17138494Sobrien fi 17238494Sobrien TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}], 173174298Sobrien [C:/Program Files/$VS_INSTALL_DIR], [well-known name]) 17438494Sobrien TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}], 17538494Sobrien [C:/Program Files (x86)/$VS_INSTALL_DIR], [well-known name]) 17638494Sobrien 17738494Sobrien if test "x$SDK_INSTALL_DIR" != x; then 17838494Sobrien if test "x$ProgramW6432" != x; then 17938494Sobrien TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([${VS_VERSION}], 18038494Sobrien [$ProgramW6432/$SDK_INSTALL_DIR], [well-known name]) 18138494Sobrien fi 18238494Sobrien if test "x$PROGRAMW6432" != x; then 18338494Sobrien TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([${VS_VERSION}], 18438494Sobrien [$PROGRAMW6432/$SDK_INSTALL_DIR], [well-known name]) 18538494Sobrien fi 18638494Sobrien if test "x$PROGRAMFILES" != x; then 18738494Sobrien TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([${VS_VERSION}], 18838494Sobrien [$PROGRAMFILES/$SDK_INSTALL_DIR], [well-known name]) 18938494Sobrien fi 19038494Sobrien TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([${VS_VERSION}], 19138494Sobrien [C:/Program Files/$SDK_INSTALL_DIR], [well-known name]) 19242633Sobrien TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([${VS_VERSION}], 19338494Sobrien [C:/Program Files (x86)/$SDK_INSTALL_DIR], [well-known name]) 19438494Sobrien fi 19538494Sobrien]) 19638494Sobrien 19738494Sobrien################################################################################ 19838494Sobrien 19938494SobrienAC_DEFUN([TOOLCHAIN_FIND_VISUAL_STUDIO], 20038494Sobrien[ 20138494Sobrien AC_ARG_WITH(toolchain-version, [AS_HELP_STRING([--with-toolchain-version], 20238494Sobrien [the version of the toolchain to look for, use '--help' to show possible values @<:@platform dependent@:>@])]) 20338494Sobrien 20438494Sobrien if test "x$with_toolchain_version" = xlist; then 20542633Sobrien # List all toolchains 20682797Sobrien AC_MSG_NOTICE([The following toolchain versions are valid on this platform:]) 20738494Sobrien for version in $VALID_VS_VERSIONS; do 20838494Sobrien eval VS_DESCRIPTION=\${VS_DESCRIPTION_$version} 20938494Sobrien $PRINTF " %-10s %s\n" $version "$VS_DESCRIPTION" 21038494Sobrien done 21138494Sobrien 21238494Sobrien exit 0 21338494Sobrien elif test "x$DEVKIT_VS_VERSION" != x; then 21442633Sobrien VS_VERSION=$DEVKIT_VS_VERSION 21538494Sobrien TOOLCHAIN_VERSION=$VS_VERSION 21638494Sobrien eval VS_DESCRIPTION="\${VS_DESCRIPTION_${VS_VERSION}}" 21738494Sobrien eval VS_VERSION_INTERNAL="\${VS_VERSION_INTERNAL_${VS_VERSION}}" 21838494Sobrien eval MSVCR_NAME="\${VS_MSVCR_${VS_VERSION}}" 21938494Sobrien eval MSVCP_NAME="\${VS_MSVCP_${VS_VERSION}}" 22038494Sobrien eval PLATFORM_TOOLSET="\${VS_VS_PLATFORM_NAME_${VS_VERSION}}" 22138494Sobrien VS_PATH="$TOOLCHAIN_PATH:$PATH" 22238494Sobrien 22338494Sobrien # Convert DEVKIT_VS_INCLUDE into windows style VS_INCLUDE so that it 22438494Sobrien # can still be exported as INCLUDE for compiler invocations without 22538494Sobrien # SYSROOT_CFLAGS 22638494Sobrien OLDIFS="$IFS" 22738494Sobrien IFS=";" 22838494Sobrien for i in $DEVKIT_VS_INCLUDE; do 22938494Sobrien ipath=$i 23038494Sobrien BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH([ipath]) 23138494Sobrien VS_INCLUDE="$VS_INCLUDE;$ipath" 23238494Sobrien done 23338494Sobrien # Convert DEVKIT_VS_LIB into VS_LIB so that it can still be exported 23438494Sobrien # as LIB for compiler invocations without SYSROOT_LDFLAGS 23538494Sobrien for i in $DEVKIT_VS_LIB; do 23638494Sobrien libpath=$i 23738494Sobrien BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH([libpath]) 23838494Sobrien VS_LIB="$VS_LIB;$libpath" 23938494Sobrien done 24038494Sobrien IFS="$OLDIFS" 24138494Sobrien 24238494Sobrien AC_MSG_NOTICE([Found devkit $VS_DESCRIPTION]) 24338494Sobrien 24438494Sobrien elif test "x$with_toolchain_version" != x; then 24538494Sobrien # User override; check that it is valid 246174298Sobrien if test "x${VALID_VS_VERSIONS/$with_toolchain_version/}" = "x${VALID_VS_VERSIONS}"; then 24738494Sobrien AC_MSG_NOTICE([Visual Studio version $with_toolchain_version is not valid.]) 24838494Sobrien AC_MSG_NOTICE([Valid Visual Studio versions: $VALID_VS_VERSIONS.]) 24938494Sobrien AC_MSG_ERROR([Cannot continue.]) 25038494Sobrien fi 25138494Sobrien VS_VERSIONS_PROBE_LIST="$with_toolchain_version" 25238494Sobrien else 25338494Sobrien # No flag given, use default 25465308Sobrien VS_VERSIONS_PROBE_LIST="$VALID_VS_VERSIONS" 25538494Sobrien fi 256174298Sobrien 257174298Sobrien for VS_VERSION in $VS_VERSIONS_PROBE_LIST; do 258174298Sobrien TOOLCHAIN_FIND_VISUAL_STUDIO_BAT_FILE([$VS_VERSION]) 25938494Sobrien if test "x$VS_ENV_CMD" != x; then 26038494Sobrien TOOLCHAIN_VERSION=$VS_VERSION 26138494Sobrien eval VS_DESCRIPTION="\${VS_DESCRIPTION_${VS_VERSION}}" 262174298Sobrien eval VS_VERSION_INTERNAL="\${VS_VERSION_INTERNAL_${VS_VERSION}}" 263174298Sobrien eval MSVCR_NAME="\${VS_MSVCR_${VS_VERSION}}" 264174298Sobrien eval MSVCP_NAME="\${VS_MSVCP_${VS_VERSION}}" 26538494Sobrien # The rest of the variables are already evaled while probing 26638494Sobrien AC_MSG_NOTICE([Found $VS_DESCRIPTION]) 26738494Sobrien break 26838494Sobrien fi 26938494Sobrien done 27038494Sobrien]) 27138494Sobrien 27238494Sobrien################################################################################ 27338494Sobrien# Check if the VS env variables were setup prior to running configure. 27438494Sobrien# If not, then find vcvarsall.bat and run it automatically, and integrate 27538494Sobrien# the set env variables into the spec file. 27638494SobrienAC_DEFUN([TOOLCHAIN_SETUP_VISUAL_STUDIO_ENV], 27738494Sobrien[ 27838494Sobrien # Store path to cygwin link.exe to help excluding it when searching for 27938494Sobrien # VS linker. This must be done before changing the PATH when looking for VS. 28038494Sobrien AC_PATH_PROG(CYGWIN_LINK, link) 28138494Sobrien if test "x$CYGWIN_LINK" != x; then 28238494Sobrien AC_MSG_CHECKING([if the first found link.exe is actually the Cygwin link tool]) 28338494Sobrien "$CYGWIN_LINK" --version > /dev/null 28452897Sobrien if test $? -eq 0 ; then 28552897Sobrien AC_MSG_RESULT([yes]) 28652897Sobrien else 28752897Sobrien AC_MSG_RESULT([no]) 28852897Sobrien # This might be the VS linker. Don't exclude it later on. 28952897Sobrien CYGWIN_LINK="" 29038494Sobrien fi 29138494Sobrien fi 29238494Sobrien 29338494Sobrien # First-hand choice is to locate and run the vsvars bat file. 29438494Sobrien TOOLCHAIN_FIND_VISUAL_STUDIO 29538494Sobrien 296174298Sobrien # If we have a devkit, skip all of the below. 297174298Sobrien if test "x$DEVKIT_VS_VERSION" = x; then 298174298Sobrien if test "x$VS_ENV_CMD" != x; then 299174298Sobrien # We have found a Visual Studio environment on disk, let's extract variables from the vsvars bat file. 300174298Sobrien BASIC_FIXUP_EXECUTABLE(VS_ENV_CMD) 30138494Sobrien 30238494Sobrien # Lets extract the variables that are set by vcvarsall.bat/vsvars32.bat/vsvars64.bat 30338494Sobrien AC_MSG_NOTICE([Trying to extract Visual Studio environment variables]) 30438494Sobrien 30538494Sobrien # We need to create a couple of temporary files. 30638494Sobrien VS_ENV_TMP_DIR="$CONFIGURESUPPORT_OUTPUTDIR/vs-env" 30738494Sobrien $MKDIR -p $VS_ENV_TMP_DIR 308174298Sobrien 309174298Sobrien # Cannot use the VS10 setup script directly (since it only updates the DOS subshell environment). 310174298Sobrien # Instead create a shell script which will set the relevant variables when run. 31138494Sobrien WINPATH_VS_ENV_CMD="$VS_ENV_CMD" 312174298Sobrien BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH([WINPATH_VS_ENV_CMD]) 31338494Sobrien WINPATH_BASH="$BASH" 314174298Sobrien BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH([WINPATH_BASH]) 31538494Sobrien 31638494Sobrien # Generate a DOS batch file which runs $VS_ENV_CMD, and then creates a shell 31738494Sobrien # script (executable by bash) that will setup the important variables. 31838494Sobrien EXTRACT_VC_ENV_BAT_FILE="$VS_ENV_TMP_DIR/extract-vs-env.bat" 31938494Sobrien $ECHO "@echo off" > $EXTRACT_VC_ENV_BAT_FILE 32038494Sobrien # This will end up something like: 32138494Sobrien # call C:/progra~2/micros~2.0/vc/bin/amd64/vcvars64.bat 32238494Sobrien $ECHO "call $WINPATH_VS_ENV_CMD $VS_ENV_ARGS" >> $EXTRACT_VC_ENV_BAT_FILE 32338494Sobrien # These will end up something like: 32438494Sobrien # C:/CygWin/bin/bash -c 'echo VS_PATH=\"$PATH\" > localdevenv.sh 32538494Sobrien # The trailing space for everyone except PATH is no typo, but is needed due 32638494Sobrien # to trailing \ in the Windows paths. These will be stripped later. 32738494Sobrien $ECHO "$WINPATH_BASH -c 'echo VS_PATH="'\"$PATH\" > set-vs-env.sh' \ 32838494Sobrien >> $EXTRACT_VC_ENV_BAT_FILE 32938494Sobrien $ECHO "$WINPATH_BASH -c 'echo VS_INCLUDE="'\"$INCLUDE\;$include \" >> set-vs-env.sh' \ 33038494Sobrien >> $EXTRACT_VC_ENV_BAT_FILE 331174298Sobrien $ECHO "$WINPATH_BASH -c 'echo VS_LIB="'\"$LIB\;$lib \" >> set-vs-env.sh' \ 332174298Sobrien >> $EXTRACT_VC_ENV_BAT_FILE 333174298Sobrien $ECHO "$WINPATH_BASH -c 'echo VCINSTALLDIR="'\"$VCINSTALLDIR \" >> set-vs-env.sh' \ 33438494Sobrien >> $EXTRACT_VC_ENV_BAT_FILE 33538494Sobrien $ECHO "$WINPATH_BASH -c 'echo WindowsSdkDir="'\"$WindowsSdkDir \" >> set-vs-env.sh' \ 33638494Sobrien >> $EXTRACT_VC_ENV_BAT_FILE 33738494Sobrien $ECHO "$WINPATH_BASH -c 'echo WINDOWSSDKDIR="'\"$WINDOWSSDKDIR \" >> set-vs-env.sh' \ 33838494Sobrien >> $EXTRACT_VC_ENV_BAT_FILE 33938494Sobrien 34038494Sobrien # Now execute the newly created bat file. 34138494Sobrien # The | cat is to stop SetEnv.Cmd to mess with system colors on msys. 34238494Sobrien # Change directory so we don't need to mess with Windows paths in redirects. 343174298Sobrien cd $VS_ENV_TMP_DIR 344174298Sobrien cmd /c extract-vs-env.bat | $CAT 345174298Sobrien cd $CURDIR 346174298Sobrien 347174298Sobrien if test ! -s $VS_ENV_TMP_DIR/set-vs-env.sh; then 348174298Sobrien AC_MSG_NOTICE([Could not succesfully extract the envionment variables needed for the VS setup.]) 349174298Sobrien AC_MSG_NOTICE([Try setting --with-tools-dir to the VC/bin directory within the VS installation]) 350174298Sobrien AC_MSG_NOTICE([or run "bash.exe -l" from a VS command prompt and then run configure from there.]) 351174298Sobrien AC_MSG_ERROR([Cannot continue]) 352174298Sobrien fi 353174298Sobrien 354174298Sobrien # Now set all paths and other env variables. This will allow the rest of 355174298Sobrien # the configure script to find and run the compiler in the proper way. 356174298Sobrien AC_MSG_NOTICE([Setting extracted environment variables]) 357174298Sobrien . $VS_ENV_TMP_DIR/set-vs-env.sh 358174298Sobrien # Now we have VS_PATH, VS_INCLUDE, VS_LIB. For further checking, we 359174298Sobrien # also define VCINSTALLDIR, WindowsSdkDir and WINDOWSSDKDIR. 360174298Sobrien else 361174298Sobrien # We did not find a vsvars bat file, let's hope we are run from a VS command prompt. 362174298Sobrien AC_MSG_NOTICE([Cannot locate a valid Visual Studio installation, checking current environment]) 363174298Sobrien fi 364174298Sobrien fi 365174298Sobrien 366174298Sobrien # At this point, we should have correct variables in the environment, or we can't continue. 367174298Sobrien AC_MSG_CHECKING([for Visual Studio variables]) 368174298Sobrien 369174298Sobrien if test "x$VCINSTALLDIR" != x || test "x$WindowsSDKDir" != x \ 370174298Sobrien || test "x$WINDOWSSDKDIR" != x || test "x$DEVKIT_NAME" != x; then 371174298Sobrien if test "x$VS_INCLUDE" = x || test "x$VS_LIB" = x; then 372174298Sobrien AC_MSG_RESULT([present but broken]) 373174298Sobrien AC_MSG_ERROR([Your VC command prompt seems broken, INCLUDE and/or LIB is missing.]) 374174298Sobrien else 375174298Sobrien AC_MSG_RESULT([ok]) 376174298Sobrien # Remove any trailing "\" ";" and " " from the variables. 377174298Sobrien VS_INCLUDE=`$ECHO "$VS_INCLUDE" | $SED -e 's/\\\\*;* *$//'` 378174298Sobrien VS_LIB=`$ECHO "$VS_LIB" | $SED 's/\\\\*;* *$//'` 379174298Sobrien VCINSTALLDIR=`$ECHO "$VCINSTALLDIR" | $SED 's/\\\\* *$//'` 380174298Sobrien WindowsSDKDir=`$ECHO "$WindowsSDKDir" | $SED 's/\\\\* *$//'` 381174298Sobrien WINDOWSSDKDIR=`$ECHO "$WINDOWSSDKDIR" | $SED 's/\\\\* *$//'` 382174298Sobrien # Remove any paths containing # (typically F#) as that messes up make. This 383174298Sobrien # is needed if visual studio was installed with F# support. 384174298Sobrien VS_PATH=`$ECHO "$VS_PATH" | $SED 's/[[^:#]]*#[^:]*://g'` 385174298Sobrien 386174298Sobrien AC_SUBST(VS_PATH) 38738494Sobrien AC_SUBST(VS_INCLUDE) 38838494Sobrien AC_SUBST(VS_LIB) 38938494Sobrien 390174298Sobrien # Convert VS_INCLUDE into SYSROOT_CFLAGS 39138494Sobrien OLDIFS="$IFS" 39238494Sobrien IFS=";" 39342633Sobrien for i in $VS_INCLUDE; do 39442633Sobrien ipath=$i 39538494Sobrien # Only process non-empty elements 39638494Sobrien if test "x$ipath" != x; then 39738494Sobrien IFS="$OLDIFS" 39838494Sobrien # Check that directory exists before calling fixup_path 39938494Sobrien testpath=$ipath 40038494Sobrien BASIC_WINDOWS_REWRITE_AS_UNIX_PATH([testpath]) 40138494Sobrien if test -d "$testpath"; then 40238494Sobrien BASIC_FIXUP_PATH([ipath]) 40338494Sobrien SYSROOT_CFLAGS="$SYSROOT_CFLAGS -I$ipath" 40438494Sobrien fi 40538494Sobrien IFS=";" 40638494Sobrien fi 40738494Sobrien done 40838494Sobrien # Convert VS_LIB into SYSROOT_LDFLAGS 40938494Sobrien for i in $VS_LIB; do 41038494Sobrien libpath=$i 41138494Sobrien # Only process non-empty elements 41238494Sobrien if test "x$libpath" != x; then 41338494Sobrien IFS="$OLDIFS" 41438494Sobrien # Check that directory exists before calling fixup_path 41538494Sobrien testpath=$libpath 41638494Sobrien BASIC_WINDOWS_REWRITE_AS_UNIX_PATH([testpath]) 41738494Sobrien if test -d "$testpath"; then 41838494Sobrien BASIC_FIXUP_PATH([libpath]) 41942633Sobrien SYSROOT_LDFLAGS="$SYSROOT_LDFLAGS -libpath:$libpath" 42038494Sobrien fi 42138494Sobrien IFS=";" 42242633Sobrien fi 42338494Sobrien done 42438494Sobrien IFS="$OLDIFS" 42538494Sobrien fi 42642633Sobrien else 42738494Sobrien AC_MSG_RESULT([not found]) 42838494Sobrien 42938494Sobrien if test "x$VS_ENV_CMD" = x; then 43038494Sobrien AC_MSG_NOTICE([Cannot locate a valid Visual Studio or Windows SDK installation on disk,]) 43138494Sobrien AC_MSG_NOTICE([nor is this script run from a Visual Studio command prompt.]) 43238494Sobrien else 43338494Sobrien AC_MSG_NOTICE([Running the extraction script failed.]) 43438494Sobrien fi 43538500Sobrien AC_MSG_NOTICE([Try setting --with-tools-dir to the VC/bin directory within the VS installation]) 43638494Sobrien AC_MSG_NOTICE([or run "bash.exe -l" from a VS command prompt and then run configure from there.]) 43738494Sobrien AC_MSG_ERROR([Cannot continue]) 43838494Sobrien fi 43938494Sobrien]) 44038494Sobrien 44138494SobrienAC_DEFUN([TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL], 44238494Sobrien[ 44338494Sobrien DLL_NAME="$1" 44438494Sobrien POSSIBLE_MSVC_DLL="$2" 44538494Sobrien METHOD="$3" 44638494Sobrien if test -n "$POSSIBLE_MSVC_DLL" -a -e "$POSSIBLE_MSVC_DLL"; then 44738494Sobrien AC_MSG_NOTICE([Found $DLL_NAME at $POSSIBLE_MSVC_DLL using $METHOD]) 44838494Sobrien 44938494Sobrien # Need to check if the found msvcr is correct architecture 45038494Sobrien AC_MSG_CHECKING([found $DLL_NAME architecture]) 45142633Sobrien MSVC_DLL_FILETYPE=`$FILE -b "$POSSIBLE_MSVC_DLL"` 45238494Sobrien if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then 45338494Sobrien # The MSYS 'file' command returns "PE32 executable for MS Windows (DLL) (GUI) Intel 80386 32-bit" 45438494Sobrien # on x32 and "PE32+ executable for MS Windows (DLL) (GUI) Mono/.Net assembly" on x64 systems. 45538494Sobrien if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then 45638494Sobrien CORRECT_MSVCR_ARCH="PE32 executable" 45738494Sobrien else 45838494Sobrien CORRECT_MSVCR_ARCH="PE32+ executable" 45938494Sobrien fi 46038494Sobrien else 46138494Sobrien if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then 46238494Sobrien CORRECT_MSVCR_ARCH=386 463174298Sobrien else 46442633Sobrien CORRECT_MSVCR_ARCH=x86-64 46538494Sobrien fi 46638494Sobrien fi 467174298Sobrien if $ECHO "$MSVC_DLL_FILETYPE" | $GREP "$CORRECT_MSVCR_ARCH" 2>&1 > /dev/null; then 46838494Sobrien AC_MSG_RESULT([ok]) 469174298Sobrien MSVC_DLL="$POSSIBLE_MSVC_DLL" 470174298Sobrien BASIC_FIXUP_PATH(MSVC_DLL) 471174298Sobrien AC_MSG_CHECKING([for $DLL_NAME]) 472174298Sobrien AC_MSG_RESULT([$MSVC_DLL]) 473174298Sobrien else 474174298Sobrien AC_MSG_RESULT([incorrect, ignoring]) 47538494Sobrien AC_MSG_NOTICE([The file type of the located $DLL_NAME is $MSVC_DLL_FILETYPE]) 476174298Sobrien fi 477174298Sobrien fi 47838494Sobrien]) 479174298Sobrien 48038494SobrienAC_DEFUN([TOOLCHAIN_SETUP_MSVC_DLL], 481174298Sobrien[ 48238494Sobrien DLL_NAME="$1" 483174298Sobrien MSVC_DLL= 484174298Sobrien 48538494Sobrien if test "x$MSVC_DLL" = x; then 48638494Sobrien # Probe: Using well-known location from Visual Studio 10.0 487174298Sobrien if test "x$VCINSTALLDIR" != x; then 48838494Sobrien CYGWIN_VC_INSTALL_DIR="$VCINSTALLDIR" 48938494Sobrien BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(CYGWIN_VC_INSTALL_DIR) 49038494Sobrien if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then 49138494Sobrien POSSIBLE_MSVC_DLL="$CYGWIN_VC_INSTALL_DIR/redist/x64/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME" 49238494Sobrien else 49338494Sobrien POSSIBLE_MSVC_DLL="$CYGWIN_VC_INSTALL_DIR/redist/x86/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME" 49438494Sobrien fi 49538494Sobrien $ECHO "POSSIBLE_MSVC_DLL $POSSIBLEMSVC_DLL" 49638494Sobrien TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$POSSIBLE_MSVC_DLL], 49738494Sobrien [well-known location in VCINSTALLDIR]) 49838494Sobrien fi 49938494Sobrien fi 50038494Sobrien 50138494Sobrien if test "x$MSVC_DLL" = x; then 50238494Sobrien # Probe: Check in the Boot JDK directory. 50338494Sobrien POSSIBLE_MSVC_DLL="$BOOT_JDK/bin/$DLL_NAME" 50438494Sobrien TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$POSSIBLE_MSVC_DLL], 50538494Sobrien [well-known location in Boot JDK]) 50638494Sobrien fi 50738494Sobrien 508174298Sobrien if test "x$MSVC_DLL" = x; then 509174298Sobrien # Probe: Look in the Windows system32 directory 51038494Sobrien CYGWIN_SYSTEMROOT="$SYSTEMROOT" 51138494Sobrien BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(CYGWIN_SYSTEMROOT) 51282797Sobrien POSSIBLE_MSVC_DLL="$CYGWIN_SYSTEMROOT/system32/$DLL_NAME" 51338494Sobrien TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$POSSIBLE_MSVC_DLL], 51438494Sobrien [well-known location in SYSTEMROOT]) 515174298Sobrien fi 51638494Sobrien 51738494Sobrien if test "x$MSVC_DLL" = x; then 518174298Sobrien # Probe: If Visual Studio Express is installed, there is usually one with the debugger 519174298Sobrien if test "x$VS100COMNTOOLS" != x; then 520174298Sobrien CYGWIN_VS_TOOLS_DIR="$VS100COMNTOOLS/.." 52138494Sobrien BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(CYGWIN_VS_TOOLS_DIR) 522174298Sobrien if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then 52351300Sobrien POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VS_TOOLS_DIR" -name $DLL_NAME \ 52438494Sobrien | $GREP -i /x64/ | $HEAD --lines 1` 52538494Sobrien else 52638494Sobrien POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VS_TOOLS_DIR" -name $DLL_NAME \ 52738494Sobrien | $GREP -i /x86/ | $HEAD --lines 1` 52838494Sobrien fi 52938494Sobrien TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$POSSIBLE_MSVC_DLL], 53038494Sobrien [search of VS100COMNTOOLS]) 53138494Sobrien fi 53238494Sobrien fi 53351300Sobrien 53438494Sobrien if test "x$MSVC_DLL" = x; then 53538494Sobrien # Probe: Search wildly in the VCINSTALLDIR. We've probably lost by now. 53638494Sobrien # (This was the original behaviour; kept since it might turn something up) 53738494Sobrien if test "x$CYGWIN_VC_INSTALL_DIR" != x; then 53838494Sobrien if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then 53938494Sobrien POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VC_INSTALL_DIR" -name $DLL_NAME \ 54038494Sobrien | $GREP x64 | $HEAD --lines 1` 54138494Sobrien else 54238494Sobrien POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VC_INSTALL_DIR" -name $DLL_NAME \ 54338494Sobrien | $GREP x86 | $GREP -v ia64 | $GREP -v x64 | $HEAD --lines 1` 54438494Sobrien if test "x$POSSIBLE_MSVC_DLL" = x; then 54538494Sobrien # We're grasping at straws now... 54638494Sobrien POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VC_INSTALL_DIR" -name $DLL_NAME \ 54738494Sobrien | $HEAD --lines 1` 54838494Sobrien fi 549174298Sobrien fi 55038494Sobrien 55138494Sobrien TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$POSSIBLE_MSVC_DLL], 552174298Sobrien [search of VCINSTALLDIR]) 553174298Sobrien fi 554174298Sobrien fi 555174298Sobrien 556174298Sobrien if test "x$MSVC_DLL" = x; then 557174298Sobrien AC_MSG_CHECKING([for $DLL_NAME]) 55838494Sobrien AC_MSG_RESULT([no]) 559174298Sobrien AC_MSG_ERROR([Could not find $DLL_NAME. Please specify using --with-msvcr-dll.]) 56038494Sobrien fi 56138494Sobrien]) 56238494Sobrien 56338494SobrienAC_DEFUN([TOOLCHAIN_SETUP_VS_RUNTIME_DLLS], 56438494Sobrien[ 56538494Sobrien AC_ARG_WITH(msvcr-dll, [AS_HELP_STRING([--with-msvcr-dll], 56642633Sobrien [path to microsoft C runtime dll (msvcr*.dll) (Windows only) @<:@probed@:>@])]) 567174298Sobrien 568174298Sobrien if test "x$with_msvcr_dll" != x; then 569174298Sobrien # If given explicitely by user, do not probe. If not present, fail directly. 570174298Sobrien TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL($MSVCR_NAME, [$with_msvcr_dll], [--with-msvcr-dll]) 571174298Sobrien if test "x$MSVC_DLL" = x; then 572174298Sobrien AC_MSG_ERROR([Could not find a proper $MSVCR_NAME as specified by --with-msvcr-dll]) 573174298Sobrien fi 574174298Sobrien MSVCR_DLL="$MSVC_DLL" 575174298Sobrien elif test "x$DEVKIT_MSVCR_DLL" != x; then 576174298Sobrien TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL($MSVCR_NAME, [$DEVKIT_MSVCR_DLL], [devkit]) 57738494Sobrien if test "x$MSVC_DLL" = x; then 57838494Sobrien AC_MSG_ERROR([Could not find a proper $MSVCR_NAME as specified by devkit]) 57938494Sobrien fi 58038494Sobrien MSVCR_DLL="$MSVC_DLL" 58138494Sobrien else 582 TOOLCHAIN_SETUP_MSVC_DLL([${MSVCR_NAME}]) 583 MSVCR_DLL="$MSVC_DLL" 584 fi 585 AC_SUBST(MSVCR_DLL) 586 587 AC_ARG_WITH(msvcp-dll, [AS_HELP_STRING([--with-msvcp-dll], 588 [path to microsoft C++ runtime dll (msvcp*.dll) (Windows only) @<:@probed@:>@])]) 589 590 if test "x$MSVCP_NAME" != "x"; then 591 if test "x$with_msvcp_dll" != x; then 592 # If given explicitely by user, do not probe. If not present, fail directly. 593 TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL($MSVCP_NAME, [$with_msvcp_dll], [--with-msvcp-dll]) 594 if test "x$MSVC_DLL" = x; then 595 AC_MSG_ERROR([Could not find a proper $MSVCP_NAME as specified by --with-msvcp-dll]) 596 fi 597 MSVCP_DLL="$MSVC_DLL" 598 elif test "x$DEVKIT_MSVCP_DLL" != x; then 599 TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL($MSVCP_NAME, [$DEVKIT_MSVCP_DLL], [devkit]) 600 if test "x$MSVC_DLL" = x; then 601 AC_MSG_ERROR([Could not find a proper $MSVCP_NAME as specified by devkit]) 602 fi 603 MSVCP_DLL="$MSVC_DLL" 604 else 605 TOOLCHAIN_SETUP_MSVC_DLL([${MSVCP_NAME}]) 606 MSVCP_DLL="$MSVC_DLL" 607 fi 608 AC_SUBST(MSVCP_DLL) 609 fi 610]) 611