common/autoconf/toolchain_windows.m4

Mon, 21 May 2018 06:54:25 -0700

author
kevinw
date
Mon, 21 May 2018 06:54:25 -0700
changeset 2224
20daa32eec6f
parent 2223
01cc48ed67f3
child 2228
1a5c98aae346
permissions
-rw-r--r--

8078437: Enable use of devkits for Windows
Reviewed-by: erikj, ihse

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

mercurial