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