Mon, 15 Oct 2018 15:33:48 +0100
Merge
1 #
2 # Copyright (c) 2011, 2018, 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 #
26 ################################################################################
27 # The order of these defines the priority by which we try to find them.
28 VALID_VS_VERSIONS="2010 2012 2013 2015 2017"
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"
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=
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=
61 VS_DESCRIPTION_2015="Microsoft Visual Studio 2015 - CURRENTLY NOT WORKING"
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 # The vcvars of 2015 breaks if 2017 is also installed. Work around this by
71 # explicitly specifying Windows Kit 8.1 to be used.
72 VS_ENV_ARGS_2015="8.1"
74 VS_DESCRIPTION_2017="Microsoft Visual Studio 2017 - CURRENTLY NOT WORKING"
75 VS_VERSION_INTERNAL_2017=141
76 VS_MSVCR_2017=vcruntime140.dll
77 VS_MSVCP_2017=msvcp140.dll
78 VS_ENVVAR_2017="VS150COMNTOOLS"
79 VS_VS_INSTALLDIR_2017="Microsoft Visual Studio/2017"
80 VS_EDITIONS_2017="Community Professional Enterprise"
81 VS_SDK_INSTALLDIR_2017=
82 VS_VS_PLATFORM_NAME_2017="v141"
83 VS_SDK_PLATFORM_NAME_2017=
85 ################################################################################
87 AC_DEFUN([TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT],
88 [
89 if test "x$VS_ENV_CMD" = x; then
90 VS_VERSION="$1"
91 VS_BASE="$2"
92 METHOD="$3"
94 BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(VS_BASE)
95 # In VS 2017, the default installation is in a subdir named after the edition.
96 # Find the first one present and use that.
97 if test "x$VS_EDITIONS" != x; then
98 for edition in $VS_EDITIONS; do
99 if test -d "$VS_BASE/$edition"; then
100 VS_BASE="$VS_BASE/$edition"
101 break
102 fi
103 done
104 fi
106 if test -d "$VS_BASE"; then
107 AC_MSG_NOTICE([Found Visual Studio installation at $VS_BASE using $METHOD])
108 if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
109 VCVARSFILES="vc/bin/vcvars32.bat vc/auxiliary/build/vcvars32.bat"
110 else
111 VCVARSFILES="vc/bin/amd64/vcvars64.bat vc/bin/x86_amd64/vcvarsx86_amd64.bat \
112 vc/auxiliary/build/vcvarsx86_amd64.bat vc/auxiliary/build/vcvars64.bat"
113 fi
115 for VCVARSFILE in $VCVARSFILES; do
116 if test -f "$VS_BASE/$VCVARSFILE"; then
117 VS_ENV_CMD="$VS_BASE/$VCVARSFILE"
118 break
119 fi
120 done
122 if test "x$VS_ENV_CMD" = x; then
123 AC_MSG_NOTICE([Warning: None of $VCVARSFILES were found, Visual Studio installation not recognized. Ignoring])
124 else
125 # PLATFORM_TOOLSET is used during the compilation of the freetype sources
126 # (see 'LIB_BUILD_FREETYPE' in libraries.m4) and must be one of 'v100',
127 # 'v110' or 'v120' for VS 2010, 2012 or VS2013
128 eval PLATFORM_TOOLSET="\${VS_VS_PLATFORM_NAME_${VS_VERSION}}"
130 fi
131 fi
132 fi
133 ])
135 ################################################################################
137 AC_DEFUN([TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT],
138 [
139 if test "x$VS_ENV_CMD" = x; then
140 VS_VERSION="$1"
141 WIN_SDK_BASE="$2"
142 METHOD="$3"
143 BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(WIN_SDK_BASE)
144 if test -d "$WIN_SDK_BASE"; then
145 # There have been cases of partial or broken SDK installations. A missing
146 # lib dir is not going to work.
147 if test ! -d "$WIN_SDK_BASE/lib"; then
148 AC_MSG_NOTICE([Found Windows SDK installation at $WIN_SDK_BASE using $METHOD])
149 AC_MSG_NOTICE([Warning: Installation is broken, lib dir is missing. Ignoring])
150 elif test -f "$WIN_SDK_BASE/Bin/SetEnv.Cmd"; then
151 AC_MSG_NOTICE([Found Windows SDK installation at $WIN_SDK_BASE using $METHOD])
152 VS_ENV_CMD="$WIN_SDK_BASE/Bin/SetEnv.Cmd"
153 if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
154 VS_ENV_ARGS="/x86"
155 else
156 VS_ENV_ARGS="/x64"
157 fi
158 # PLATFORM_TOOLSET is used during the compilation of the freetype sources (see
159 # 'LIB_BUILD_FREETYPE' in libraries.m4) and must be 'Windows7.1SDK' for Windows7.1SDK
160 # TODO: improve detection for other versions of SDK
161 eval PLATFORM_TOOLSET="\${VS_SDK_PLATFORM_NAME_${VS_VERSION}}"
162 else
163 AC_MSG_NOTICE([Found Windows SDK installation at $WIN_SDK_BASE using $METHOD])
164 AC_MSG_NOTICE([Warning: Installation is broken, SetEnv.Cmd is missing. Ignoring])
165 fi
166 fi
167 fi
168 ])
170 ################################################################################
171 # Finds the bat or cmd file in Visual Studio or the SDK that sets up a proper
172 # build environment and assigns it to VS_ENV_CMD
173 AC_DEFUN([TOOLCHAIN_FIND_VISUAL_STUDIO_BAT_FILE],
174 [
175 VS_VERSION="$1"
176 eval VS_COMNTOOLS_VAR="\${VS_ENVVAR_${VS_VERSION}}"
177 eval VS_COMNTOOLS="\$${VS_COMNTOOLS_VAR}"
178 eval VS_INSTALL_DIR="\${VS_VS_INSTALLDIR_${VS_VERSION}}"
179 eval VS_EDITIONS="\${VS_EDITIONS_${VS_VERSION}}"
180 eval SDK_INSTALL_DIR="\${VS_SDK_INSTALLDIR_${VS_VERSION}}"
181 eval VS_ENV_ARGS="\${VS_ENV_ARGS_${VS_VERSION}}"
183 # When using --with-tools-dir, assume it points to the correct and default
184 # version of Visual Studio or that --with-toolchain-version was also set.
185 if test "x$with_tools_dir" != x; then
186 TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}],
187 [$with_tools_dir/../..], [--with-tools-dir])
188 TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}],
189 [$with_tools_dir/../../..], [--with-tools-dir])
190 if test "x$VS_ENV_CMD" = x; then
191 # Having specified an argument which is incorrect will produce an instant failure;
192 # we should not go on looking
193 AC_MSG_NOTICE([The path given by --with-tools-dir does not contain a valid])
194 AC_MSG_NOTICE([Visual Studio installation. Please point to the VC/bin or VC/bin/amd64])
195 AC_MSG_NOTICE([directory within the Visual Studio installation])
196 AC_MSG_ERROR([Cannot locate a valid Visual Studio installation])
197 fi
198 fi
200 VS_ENV_CMD=""
202 if test "x$VS_COMNTOOLS" != x; then
203 TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}],
204 [$VS_COMNTOOLS/../..], [$VS_COMNTOOLS_VAR variable])
205 fi
206 if test "x$PROGRAMFILES" != x; then
207 TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}],
208 [$PROGRAMFILES/$VS_INSTALL_DIR], [well-known name])
209 fi
210 # Work around the insanely named ProgramFiles(x86) env variable
211 PROGRAMFILES_X86="`env | $SED -n 's/^ProgramFiles(x86)=//p'`"
212 if test "x$PROGRAMFILES_X86" != x; then
213 TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}],
214 [$PROGRAMFILES_X86/$VS_INSTALL_DIR], [well-known name])
215 fi
216 TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}],
217 [C:/Program Files/$VS_INSTALL_DIR], [well-known name])
218 TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}],
219 [C:/Program Files (x86)/$VS_INSTALL_DIR], [well-known name])
221 if test "x$SDK_INSTALL_DIR" != x; then
222 if test "x$ProgramW6432" != x; then
223 TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([${VS_VERSION}],
224 [$ProgramW6432/$SDK_INSTALL_DIR], [well-known name])
225 fi
226 if test "x$PROGRAMW6432" != x; then
227 TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([${VS_VERSION}],
228 [$PROGRAMW6432/$SDK_INSTALL_DIR], [well-known name])
229 fi
230 if test "x$PROGRAMFILES" != x; then
231 TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([${VS_VERSION}],
232 [$PROGRAMFILES/$SDK_INSTALL_DIR], [well-known name])
233 fi
234 TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([${VS_VERSION}],
235 [C:/Program Files/$SDK_INSTALL_DIR], [well-known name])
236 TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([${VS_VERSION}],
237 [C:/Program Files (x86)/$SDK_INSTALL_DIR], [well-known name])
238 fi
239 ])
241 ################################################################################
243 AC_DEFUN([TOOLCHAIN_FIND_VISUAL_STUDIO],
244 [
245 AC_ARG_WITH(toolchain-version, [AS_HELP_STRING([--with-toolchain-version],
246 [the version of the toolchain to look for, use '--help' to show possible values @<:@platform dependent@:>@])])
248 if test "x$with_toolchain_version" = xlist; then
249 # List all toolchains
250 AC_MSG_NOTICE([The following toolchain versions are valid on this platform:])
251 for version in $VALID_VS_VERSIONS; do
252 eval VS_DESCRIPTION=\${VS_DESCRIPTION_$version}
253 $PRINTF " %-10s %s\n" $version "$VS_DESCRIPTION"
254 done
256 exit 0
257 elif test "x$DEVKIT_VS_VERSION" != x; then
258 VS_VERSION=$DEVKIT_VS_VERSION
259 TOOLCHAIN_VERSION=$VS_VERSION
260 # If the devkit has a name, use that as description
261 VS_DESCRIPTION="$DEVKIT_NAME"
262 if test "x$VS_DESCRIPTION" = x; then
263 eval VS_DESCRIPTION="\${VS_DESCRIPTION_${VS_VERSION}}"
264 fi
265 eval VS_VERSION_INTERNAL="\${VS_VERSION_INTERNAL_${VS_VERSION}}"
266 eval MSVCR_NAME="\${VS_MSVCR_${VS_VERSION}}"
267 eval MSVCP_NAME="\${VS_MSVCP_${VS_VERSION}}"
268 eval PLATFORM_TOOLSET="\${VS_VS_PLATFORM_NAME_${VS_VERSION}}"
269 VS_PATH="$TOOLCHAIN_PATH:$PATH"
271 # Convert DEVKIT_VS_INCLUDE into windows style VS_INCLUDE so that it
272 # can still be exported as INCLUDE for compiler invocations without
273 # SYSROOT_CFLAGS
274 OLDIFS="$IFS"
275 IFS=";"
276 for i in $DEVKIT_VS_INCLUDE; do
277 ipath=$i
278 BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH([ipath])
279 VS_INCLUDE="$VS_INCLUDE;$ipath"
280 done
281 # Convert DEVKIT_VS_LIB into VS_LIB so that it can still be exported
282 # as LIB for compiler invocations without SYSROOT_LDFLAGS
283 for i in $DEVKIT_VS_LIB; do
284 libpath=$i
285 BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH([libpath])
286 VS_LIB="$VS_LIB;$libpath"
287 done
288 IFS="$OLDIFS"
290 AC_MSG_NOTICE([Found devkit $VS_DESCRIPTION])
292 elif test "x$with_toolchain_version" != x; then
293 # User override; check that it is valid
294 if test "x${VALID_VS_VERSIONS/$with_toolchain_version/}" = "x${VALID_VS_VERSIONS}"; then
295 AC_MSG_NOTICE([Visual Studio version $with_toolchain_version is not valid.])
296 AC_MSG_NOTICE([Valid Visual Studio versions: $VALID_VS_VERSIONS.])
297 AC_MSG_ERROR([Cannot continue.])
298 fi
299 VS_VERSIONS_PROBE_LIST="$with_toolchain_version"
300 else
301 # No flag given, use default
302 VS_VERSIONS_PROBE_LIST="$VALID_VS_VERSIONS"
303 fi
305 for VS_VERSION in $VS_VERSIONS_PROBE_LIST; do
306 TOOLCHAIN_FIND_VISUAL_STUDIO_BAT_FILE([$VS_VERSION])
307 if test "x$VS_ENV_CMD" != x; then
308 TOOLCHAIN_VERSION=$VS_VERSION
309 eval VS_DESCRIPTION="\${VS_DESCRIPTION_${VS_VERSION}}"
310 eval VS_VERSION_INTERNAL="\${VS_VERSION_INTERNAL_${VS_VERSION}}"
311 eval MSVCR_NAME="\${VS_MSVCR_${VS_VERSION}}"
312 eval MSVCP_NAME="\${VS_MSVCP_${VS_VERSION}}"
313 # The rest of the variables are already evaled while probing
314 AC_MSG_NOTICE([Found $VS_DESCRIPTION])
315 break
316 fi
317 done
319 TOOLCHAIN_DESCRIPTION="$VS_DESCRIPTION"
320 if test "$TOOLCHAIN_VERSION" -gt 2013; then
321 UNSUPPORTED_TOOLCHAIN_VERSION=yes
322 fi
323 ])
325 ################################################################################
326 # Check if the VS env variables were setup prior to running configure.
327 # If not, then find vcvarsall.bat and run it automatically, and integrate
328 # the set env variables into the spec file.
329 AC_DEFUN([TOOLCHAIN_SETUP_VISUAL_STUDIO_ENV],
330 [
331 # Store path to cygwin link.exe to help excluding it when searching for
332 # VS linker. This must be done before changing the PATH when looking for VS.
333 AC_PATH_PROG(CYGWIN_LINK, link)
334 if test "x$CYGWIN_LINK" != x; then
335 AC_MSG_CHECKING([if the first found link.exe is actually the Cygwin link tool])
336 "$CYGWIN_LINK" --version > /dev/null
337 if test $? -eq 0 ; then
338 AC_MSG_RESULT([yes])
339 else
340 AC_MSG_RESULT([no])
341 # This might be the VS linker. Don't exclude it later on.
342 CYGWIN_LINK=""
343 fi
344 fi
346 # First-hand choice is to locate and run the vsvars bat file.
347 TOOLCHAIN_FIND_VISUAL_STUDIO
349 # If we have a devkit, skip all of the below.
350 if test "x$DEVKIT_VS_VERSION" = x; then
351 if test "x$VS_ENV_CMD" != x; then
352 # We have found a Visual Studio environment on disk, let's extract variables from the vsvars bat file.
353 BASIC_FIXUP_EXECUTABLE(VS_ENV_CMD)
355 # Lets extract the variables that are set by vcvarsall.bat/vsvars32.bat/vsvars64.bat
356 AC_MSG_NOTICE([Trying to extract Visual Studio environment variables])
358 # We need to create a couple of temporary files.
359 VS_ENV_TMP_DIR="$OUTPUT_ROOT/vs-env"
360 $MKDIR -p $VS_ENV_TMP_DIR
362 # Cannot use the VS10 setup script directly (since it only updates the DOS subshell environment).
363 # Instead create a shell script which will set the relevant variables when run.
364 WINPATH_VS_ENV_CMD="$VS_ENV_CMD"
365 BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH([WINPATH_VS_ENV_CMD])
366 WINPATH_BASH="$BASH"
367 BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH([WINPATH_BASH])
369 # Generate a DOS batch file which runs $VS_ENV_CMD, and then creates a shell
370 # script (executable by bash) that will setup the important variables.
371 EXTRACT_VC_ENV_BAT_FILE="$VS_ENV_TMP_DIR/extract-vs-env.bat"
372 $ECHO "@echo off" > $EXTRACT_VC_ENV_BAT_FILE
373 # This will end up something like:
374 # call C:/progra~2/micros~2.0/vc/bin/amd64/vcvars64.bat
375 $ECHO "call $WINPATH_VS_ENV_CMD $VS_ENV_ARGS" >> $EXTRACT_VC_ENV_BAT_FILE
376 # In some cases, the VS_ENV_CMD will change directory, change back so
377 # the set-vs-env.sh ends up in the right place.
378 $ECHO 'cd %~dp0' >> $EXTRACT_VC_ENV_BAT_FILE
379 # These will end up something like:
380 # C:/CygWin/bin/bash -c 'echo VS_PATH=\"$PATH\" > localdevenv.sh
381 # The trailing space for everyone except PATH is no typo, but is needed due
382 # to trailing \ in the Windows paths. These will be stripped later.
383 $ECHO "$WINPATH_BASH -c 'echo VS_PATH="'\"$PATH\" > set-vs-env.sh' \
384 >> $EXTRACT_VC_ENV_BAT_FILE
385 $ECHO "$WINPATH_BASH -c 'echo VS_INCLUDE="'\"$INCLUDE \" >> set-vs-env.sh' \
386 >> $EXTRACT_VC_ENV_BAT_FILE
387 $ECHO "$WINPATH_BASH -c 'echo VS_LIB="'\"$LIB \" >> set-vs-env.sh' \
388 >> $EXTRACT_VC_ENV_BAT_FILE
389 $ECHO "$WINPATH_BASH -c 'echo VCINSTALLDIR="'\"$VCINSTALLDIR \" >> set-vs-env.sh' \
390 >> $EXTRACT_VC_ENV_BAT_FILE
391 $ECHO "$WINPATH_BASH -c 'echo WindowsSdkDir="'\"$WindowsSdkDir \" >> set-vs-env.sh' \
392 >> $EXTRACT_VC_ENV_BAT_FILE
393 $ECHO "$WINPATH_BASH -c 'echo WINDOWSSDKDIR="'\"$WINDOWSSDKDIR \" >> set-vs-env.sh' \
394 >> $EXTRACT_VC_ENV_BAT_FILE
396 # Now execute the newly created bat file.
397 # The | cat is to stop SetEnv.Cmd to mess with system colors on msys.
398 # Change directory so we don't need to mess with Windows paths in redirects.
399 cd $VS_ENV_TMP_DIR
400 cmd /c extract-vs-env.bat | $CAT
401 cd $CURDIR
403 if test ! -s $VS_ENV_TMP_DIR/set-vs-env.sh; then
404 AC_MSG_NOTICE([Could not succesfully extract the envionment variables needed for the VS setup.])
405 AC_MSG_NOTICE([Try setting --with-tools-dir to the VC/bin directory within the VS installation])
406 AC_MSG_NOTICE([or run "bash.exe -l" from a VS command prompt and then run configure from there.])
407 AC_MSG_ERROR([Cannot continue])
408 fi
410 # Now set all paths and other env variables. This will allow the rest of
411 # the configure script to find and run the compiler in the proper way.
412 AC_MSG_NOTICE([Setting extracted environment variables])
413 . $VS_ENV_TMP_DIR/set-vs-env.sh
414 # Now we have VS_PATH, VS_INCLUDE, VS_LIB. For further checking, we
415 # also define VCINSTALLDIR, WindowsSdkDir and WINDOWSSDKDIR.
416 else
417 # We did not find a vsvars bat file, let's hope we are run from a VS command prompt.
418 AC_MSG_NOTICE([Cannot locate a valid Visual Studio installation, checking current environment])
419 fi
420 fi
422 # At this point, we should have correct variables in the environment, or we can't continue.
423 AC_MSG_CHECKING([for Visual Studio variables])
425 if test "x$VCINSTALLDIR" != x || test "x$WindowsSDKDir" != x \
426 || test "x$WINDOWSSDKDIR" != x || test "x$DEVKIT_NAME" != x; then
427 if test "x$VS_INCLUDE" = x || test "x$VS_LIB" = x; then
428 AC_MSG_RESULT([present but broken])
429 AC_MSG_ERROR([Your VC command prompt seems broken, INCLUDE and/or LIB is missing.])
430 else
431 AC_MSG_RESULT([ok])
432 # Remove any trailing "\" and " " from the variables.
433 VS_INCLUDE=`$ECHO "$VS_INCLUDE" | $SED 's/\\\\* *$//'`
434 VS_LIB=`$ECHO "$VS_LIB" | $SED 's/\\\\* *$//'`
435 VCINSTALLDIR=`$ECHO "$VCINSTALLDIR" | $SED 's/\\\\* *$//'`
436 WindowsSDKDir=`$ECHO "$WindowsSDKDir" | $SED 's/\\\\* *$//'`
437 WINDOWSSDKDIR=`$ECHO "$WINDOWSSDKDIR" | $SED 's/\\\\* *$//'`
438 # Remove any paths containing # (typically F#) as that messes up make. This
439 # is needed if visual studio was installed with F# support.
440 VS_PATH=`$ECHO "$VS_PATH" | $SED 's/[[^:#]]*#[^:]*://g'`
442 AC_SUBST(VS_PATH)
443 AC_SUBST(VS_INCLUDE)
444 AC_SUBST(VS_LIB)
445 fi
446 else
447 AC_MSG_RESULT([not found])
449 if test "x$VS_ENV_CMD" = x; then
450 AC_MSG_NOTICE([Cannot locate a valid Visual Studio or Windows SDK installation on disk,])
451 AC_MSG_NOTICE([nor is this script run from a Visual Studio command prompt.])
452 else
453 AC_MSG_NOTICE([Running the extraction script failed.])
454 fi
455 AC_MSG_NOTICE([Try setting --with-tools-dir to the VC/bin directory within the VS installation])
456 AC_MSG_NOTICE([or run "bash.exe -l" from a VS command prompt and then run configure from there.])
457 AC_MSG_ERROR([Cannot continue])
458 fi
459 ])
461 AC_DEFUN([TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL],
462 [
463 DLL_NAME="$1"
464 POSSIBLE_MSVC_DLL="$2"
465 METHOD="$3"
466 if test -n "$POSSIBLE_MSVC_DLL" -a -e "$POSSIBLE_MSVC_DLL"; then
467 AC_MSG_NOTICE([Found $DLL_NAME at $POSSIBLE_MSVC_DLL using $METHOD])
469 # Need to check if the found msvcr is correct architecture
470 AC_MSG_CHECKING([found $DLL_NAME architecture])
471 MSVC_DLL_FILETYPE=`$FILE -b "$POSSIBLE_MSVC_DLL"`
472 if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
473 # The MSYS 'file' command returns "PE32 executable for MS Windows (DLL) (GUI) Intel 80386 32-bit"
474 # on x32 and "PE32+ executable for MS Windows (DLL) (GUI) Mono/.Net assembly" on x64 systems.
475 if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
476 CORRECT_MSVCR_ARCH="PE32 executable"
477 else
478 CORRECT_MSVCR_ARCH="PE32+ executable"
479 fi
480 else
481 if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
482 CORRECT_MSVCR_ARCH=386
483 else
484 CORRECT_MSVCR_ARCH=x86-64
485 fi
486 fi
487 if $ECHO "$MSVC_DLL_FILETYPE" | $GREP "$CORRECT_MSVCR_ARCH" 2>&1 > /dev/null; then
488 AC_MSG_RESULT([ok])
489 MSVC_DLL="$POSSIBLE_MSVC_DLL"
490 BASIC_FIXUP_PATH(MSVC_DLL)
491 AC_MSG_CHECKING([for $DLL_NAME])
492 AC_MSG_RESULT([$MSVC_DLL])
493 else
494 AC_MSG_RESULT([incorrect, ignoring])
495 AC_MSG_NOTICE([The file type of the located $DLL_NAME is $MSVC_DLL_FILETYPE])
496 fi
497 fi
498 ])
500 AC_DEFUN([TOOLCHAIN_SETUP_MSVC_DLL],
501 [
502 DLL_NAME="$1"
503 MSVC_DLL=
505 if test "x$MSVC_DLL" = x; then
506 if test "x$VCINSTALLDIR" != x; then
507 CYGWIN_VC_INSTALL_DIR="$VCINSTALLDIR"
508 BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(CYGWIN_VC_INSTALL_DIR)
509 if test "$VS_VERSION" -lt 2017; then
510 # Probe: Using well-known location from Visual Studio 12.0 and older
511 if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
512 POSSIBLE_MSVC_DLL="$CYGWIN_VC_INSTALL_DIR/redist/x64/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME"
513 else
514 POSSIBLE_MSVC_DLL="$CYGWIN_VC_INSTALL_DIR/redist/x86/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME"
515 fi
516 else
517 # Probe: Using well-known location from VS 2017
518 if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
519 POSSIBLE_MSVC_DLL="`ls $CYGWIN_VC_INSTALL_DIR/Redist/MSVC/*/x64/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME`"
520 else
521 POSSIBLE_MSVC_DLL="`ls $CYGWIN_VC_INSTALL_DIR/Redist/MSVC/*/x86/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME`"
522 fi
523 fi
524 # In case any of the above finds more than one file, loop over them.
525 for possible_msvc_dll in $POSSIBLE_MSVC_DLL; do
526 $ECHO "POSSIBLE_MSVC_DLL $possible_msvc_dll"
527 TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$possible_msvc_dll],
528 [well-known location in VCINSTALLDIR])
529 done
530 fi
531 fi
533 if test "x$MSVC_DLL" = x; then
534 # Probe: Check in the Boot JDK directory.
535 POSSIBLE_MSVC_DLL="$BOOT_JDK/bin/$DLL_NAME"
536 TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL($[DLL_NAME], [$POSSIBLE_MSVC_DLL],
537 [well-known location in Boot JDK])
538 fi
540 if test "x$MSVC_DLL" = x; then
541 # Probe: Look in the Windows system32 directory
542 CYGWIN_SYSTEMROOT="$SYSTEMROOT"
543 BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(CYGWIN_SYSTEMROOT)
544 POSSIBLE_MSVC_DLL="$CYGWIN_SYSTEMROOT/system32/$DLL_NAME"
545 TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$POSSIBLE_MSVC_DLL],
546 [well-known location in SYSTEMROOT])
547 fi
549 if test "x$MSVC_DLL" = x; then
550 # Probe: If Visual Studio Express is installed, there is usually one with the debugger
551 if test "x$VS100COMNTOOLS" != x; then
552 CYGWIN_VS_TOOLS_DIR="$VS100COMNTOOLS/.."
553 BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(CYGWIN_VS_TOOLS_DIR)
554 if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
555 POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VS_TOOLS_DIR" -name $DLL_NAME \
556 | $GREP -i /x64/ | $HEAD --lines 1`
557 else
558 POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VS_TOOLS_DIR" -name $DLL_NAME \
559 | $GREP -i /x86/ | $HEAD --lines 1`
560 fi
561 TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$POSSIBLE_MSVC_DLL],
562 [search of VS100COMNTOOLS])
563 fi
564 fi
566 if test "x$MSVC_DLL" = x; then
567 # Probe: Search wildly in the VCINSTALLDIR. We've probably lost by now.
568 # (This was the original behaviour; kept since it might turn something up)
569 if test "x$CYGWIN_VC_INSTALL_DIR" != x; then
570 if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
571 POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VC_INSTALL_DIR" -name $DLL_NAME \
572 | $GREP x64 | $HEAD --lines 1`
573 else
574 POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VC_INSTALL_DIR" -name $DLL_NAME \
575 | $GREP x86 | $GREP -v ia64 | $GREP -v x64 | $HEAD --lines 1`
576 if test "x$POSSIBLE_MSVC_DLL" = x; then
577 # We're grasping at straws now...
578 POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VC_INSTALL_DIR" -name $DLL_NAME \
579 | $HEAD --lines 1`
580 fi
581 fi
583 TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$POSSIBLE_MSVC_DLL],
584 [search of VCINSTALLDIR])
585 fi
586 fi
588 if test "x$MSVC_DLL" = x; then
589 AC_MSG_CHECKING([for $DLL_NAME])
590 AC_MSG_RESULT([no])
591 AC_MSG_ERROR([Could not find $DLL_NAME. Please specify using --with-msvcr-dll.])
592 fi
593 ])
595 AC_DEFUN([TOOLCHAIN_SETUP_VS_RUNTIME_DLLS],
596 [
597 AC_ARG_WITH(msvcr-dll, [AS_HELP_STRING([--with-msvcr-dll],
598 [path to microsoft C runtime dll (msvcr*.dll) (Windows only) @<:@probed@:>@])])
600 if test "x$with_msvcr_dll" != x; then
601 # If given explicitely by user, do not probe. If not present, fail directly.
602 TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL($MSVCR_NAME, [$with_msvcr_dll], [--with-msvcr-dll])
603 if test "x$MSVC_DLL" = x; then
604 AC_MSG_ERROR([Could not find a proper $MSVCR_NAME as specified by --with-msvcr-dll])
605 fi
606 MSVCR_DLL="$MSVC_DLL"
607 elif test "x$DEVKIT_MSVCR_DLL" != x; then
608 TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL($MSVCR_NAME, [$DEVKIT_MSVCR_DLL], [devkit])
609 if test "x$MSVC_DLL" = x; then
610 AC_MSG_ERROR([Could not find a proper $MSVCR_NAME as specified by devkit])
611 fi
612 MSVCR_DLL="$MSVC_DLL"
613 else
614 TOOLCHAIN_SETUP_MSVC_DLL([${MSVCR_NAME}])
615 MSVCR_DLL="$MSVC_DLL"
616 fi
617 AC_SUBST(MSVCR_DLL)
619 AC_ARG_WITH(msvcp-dll, [AS_HELP_STRING([--with-msvcp-dll],
620 [path to microsoft C++ runtime dll (msvcp*.dll) (Windows only) @<:@probed@:>@])])
622 if test "x$MSVCP_NAME" != "x"; then
623 if test "x$with_msvcp_dll" != x; then
624 # If given explicitely by user, do not probe. If not present, fail directly.
625 TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL($MSVCP_NAME, [$with_msvcp_dll], [--with-msvcp-dll])
626 if test "x$MSVC_DLL" = x; then
627 AC_MSG_ERROR([Could not find a proper $MSVCP_NAME as specified by --with-msvcp-dll])
628 fi
629 MSVCP_DLL="$MSVC_DLL"
630 elif test "x$DEVKIT_MSVCP_DLL" != x; then
631 TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL($MSVCP_NAME, [$DEVKIT_MSVCP_DLL], [devkit])
632 if test "x$MSVC_DLL" = x; then
633 AC_MSG_ERROR([Could not find a proper $MSVCP_NAME as specified by devkit])
634 fi
635 MSVCP_DLL="$MSVC_DLL"
636 else
637 TOOLCHAIN_SETUP_MSVC_DLL([${MSVCP_NAME}])
638 MSVCP_DLL="$MSVC_DLL"
639 fi
640 AC_SUBST(MSVCP_DLL)
641 fi
642 ])