aoqi@0: # aoqi@0: # Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. aoqi@0: # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: # aoqi@0: # This code is free software; you can redistribute it and/or modify it aoqi@0: # under the terms of the GNU General Public License version 2 only, as aoqi@0: # published by the Free Software Foundation. Oracle designates this aoqi@0: # particular file as subject to the "Classpath" exception as provided aoqi@0: # by Oracle in the LICENSE file that accompanied this code. aoqi@0: # aoqi@0: # This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: # version 2 for more details (a copy is included in the LICENSE file that aoqi@0: # accompanied this code). aoqi@0: # aoqi@0: # You should have received a copy of the GNU General Public License version aoqi@0: # 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: # aoqi@0: # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: # or visit www.oracle.com if you need additional information or have any aoqi@0: # questions. aoqi@0: # aoqi@0: aoqi@0: AC_DEFUN([TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT], aoqi@0: [ aoqi@0: if test "x$VS_ENV_CMD" = x; then aoqi@0: VS100BASE="$1" aoqi@0: METHOD="$2" aoqi@0: BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(VS100BASE) aoqi@0: if test -d "$VS100BASE"; then aoqi@0: if test -f "$VS100BASE/$VCVARSFILE"; then aoqi@0: AC_MSG_NOTICE([Found Visual Studio installation at $VS100BASE using $METHOD]) aoqi@0: VS_ENV_CMD="$VS100BASE/$VCVARSFILE" aoqi@0: else aoqi@0: AC_MSG_NOTICE([Found Visual Studio installation at $VS100BASE using $METHOD]) aoqi@0: AC_MSG_NOTICE([Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring]) aoqi@0: fi aoqi@0: fi aoqi@0: fi aoqi@0: ]) aoqi@0: aoqi@0: AC_DEFUN([TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT], aoqi@0: [ aoqi@0: if test "x$VS_ENV_CMD" = x; then aoqi@0: WIN_SDK_BASE="$1" aoqi@0: METHOD="$2" aoqi@0: BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(WIN_SDK_BASE) aoqi@0: if test -d "$WIN_SDK_BASE"; then aoqi@0: # There have been cases of partial or broken SDK installations. A missing aoqi@0: # lib dir is not going to work. aoqi@0: if test ! -d "$WIN_SDK_BASE/../lib"; then aoqi@0: AC_MSG_NOTICE([Found Windows SDK installation at $WIN_SDK_BASE using $METHOD]) aoqi@0: AC_MSG_NOTICE([Warning: Installation is broken, lib dir is missing. Ignoring]) aoqi@0: elif test -f "$WIN_SDK_BASE/SetEnv.Cmd"; then aoqi@0: AC_MSG_NOTICE([Found Windows SDK installation at $WIN_SDK_BASE using $METHOD]) aoqi@0: VS_ENV_CMD="$WIN_SDK_BASE/SetEnv.Cmd" aoqi@0: if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then aoqi@0: VS_ENV_ARGS="/x86" aoqi@0: else aoqi@0: VS_ENV_ARGS="/x64" aoqi@0: fi aoqi@0: else aoqi@0: AC_MSG_NOTICE([Found Windows SDK installation at $WIN_SDK_BASE using $METHOD]) aoqi@0: AC_MSG_NOTICE([Warning: Installation is broken, SetEnv.Cmd is missing. Ignoring]) aoqi@0: fi aoqi@0: fi aoqi@0: fi aoqi@0: ]) aoqi@0: aoqi@0: AC_DEFUN([TOOLCHAIN_FIND_VISUAL_STUDIO_BAT_FILE], aoqi@0: [ aoqi@0: if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then aoqi@0: VCVARSFILE="vc/bin/vcvars32.bat" aoqi@0: else aoqi@0: VCVARSFILE="vc/bin/amd64/vcvars64.bat" aoqi@0: fi aoqi@0: aoqi@0: VS_ENV_CMD="" aoqi@0: VS_ENV_ARGS="" aoqi@0: if test "x$with_toolsdir" != x; then aoqi@0: TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([$with_toolsdir/../..], [--with-tools-dir]) aoqi@0: fi aoqi@0: aoqi@0: if test "x$with_toolsdir" != x && test "x$VS_ENV_CMD" = x; then aoqi@0: # Having specified an argument which is incorrect will produce an instant failure; aoqi@0: # we should not go on looking aoqi@0: AC_MSG_NOTICE([The path given by --with-tools-dir does not contain a valid Visual Studio installation]) aoqi@0: AC_MSG_NOTICE([Please point to the VC/bin directory within the Visual Studio installation]) aoqi@0: AC_MSG_ERROR([Cannot locate a valid Visual Studio installation]) aoqi@0: fi aoqi@0: aoqi@0: if test "x$VS100COMNTOOLS" != x; then aoqi@0: TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([$VS100COMNTOOLS/../..], [VS100COMNTOOLS variable]) aoqi@0: fi aoqi@0: if test "x$PROGRAMFILES" != x; then aoqi@0: TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([$PROGRAMFILES/Microsoft Visual Studio 10.0], [well-known name]) aoqi@0: fi aoqi@0: TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([C:/Program Files/Microsoft Visual Studio 10.0], [well-known name]) aoqi@0: TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([C:/Program Files (x86)/Microsoft Visual Studio 10.0], [well-known name]) aoqi@0: aoqi@0: if test "x$ProgramW6432" != x; then aoqi@0: TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([$ProgramW6432/Microsoft SDKs/Windows/v7.1/Bin], [well-known name]) aoqi@0: fi aoqi@0: if test "x$PROGRAMW6432" != x; then aoqi@0: TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([$PROGRAMW6432/Microsoft SDKs/Windows/v7.1/Bin], [well-known name]) aoqi@0: fi aoqi@0: if test "x$PROGRAMFILES" != x; then aoqi@0: TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([$PROGRAMFILES/Microsoft SDKs/Windows/v7.1/Bin], [well-known name]) aoqi@0: fi aoqi@0: TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([C:/Program Files/Microsoft SDKs/Windows/v7.1/Bin], [well-known name]) aoqi@0: TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([C:/Program Files (x86)/Microsoft SDKs/Windows/v7.1/Bin], [well-known name]) aoqi@0: ]) aoqi@0: aoqi@0: # Check if the VS env variables were setup prior to running configure. aoqi@0: # If not, then find vcvarsall.bat and run it automatically, and integrate aoqi@0: # the set env variables into the spec file. aoqi@0: AC_DEFUN([TOOLCHAIN_SETUP_VISUAL_STUDIO_ENV], aoqi@0: [ aoqi@0: # Store path to cygwin link.exe to help excluding it when searching for aoqi@0: # VS linker. This must be done before changing the PATH when looking for VS. aoqi@0: AC_PATH_PROG(CYGWIN_LINK, link) aoqi@0: if test "x$CYGWIN_LINK" != x; then aoqi@0: AC_MSG_CHECKING([if the first found link.exe is actually the Cygwin link tool]) aoqi@0: "$CYGWIN_LINK" --version > /dev/null aoqi@0: if test $? -eq 0 ; then aoqi@0: AC_MSG_RESULT([yes]) aoqi@0: else aoqi@0: AC_MSG_RESULT([no]) aoqi@0: # This might be the VS linker. Don't exclude it later on. aoqi@0: CYGWIN_LINK="" aoqi@0: fi aoqi@0: fi aoqi@0: aoqi@0: # First-hand choice is to locate and run the vsvars bat file. aoqi@0: TOOLCHAIN_FIND_VISUAL_STUDIO_BAT_FILE aoqi@0: if test "x$VS_ENV_CMD" != x; then aoqi@0: # We have found a Visual Studio environment on disk, let's extract variables from the vsvars bat file. aoqi@0: BASIC_FIXUP_EXECUTABLE(VS_ENV_CMD) aoqi@0: aoqi@0: # Lets extract the variables that are set by vcvarsall.bat/vsvars32.bat/vsvars64.bat aoqi@0: AC_MSG_NOTICE([Trying to extract Visual Studio environment variables]) aoqi@0: cd $OUTPUT_ROOT aoqi@0: # FIXME: The code betweeen ---- was inlined from a separate script and is not properly adapted aoqi@0: # to autoconf standards. aoqi@0: aoqi@0: #---- aoqi@0: aoqi@0: # Cannot use the VS10 setup script directly (since it only updates the DOS subshell environment) aoqi@0: # but calculate the difference in Cygwin environment before/after running it and then aoqi@0: # apply the diff. aoqi@0: aoqi@0: if test "x$OPENJDK_BUILD_OS_ENV" = xwindows.cygwin; then aoqi@0: _vs10varsall=`cygpath -a -m -s "$VS_ENV_CMD"` aoqi@0: _dosvs10varsall=`cygpath -a -w -s $_vs10varsall` aoqi@0: _dosbash=`cygpath -a -w -s \`which bash\`.*` aoqi@0: else aoqi@0: _dosvs10varsall=`cmd //c echo $VS_ENV_CMD` aoqi@0: _dosbash=`cmd //c echo \`which bash\`` aoqi@0: fi aoqi@0: aoqi@0: # generate the set of exported vars before/after the vs10 setup aoqi@0: $ECHO "@echo off" > localdevenvtmp.bat aoqi@0: $ECHO "$_dosbash -c \"export -p\" > localdevenvtmp.export0" >> localdevenvtmp.bat aoqi@0: $ECHO "call $_dosvs10varsall $VS_ENV_ARGS" >> localdevenvtmp.bat aoqi@0: $ECHO "$_dosbash -c \"export -p\" > localdevenvtmp.export1" >> localdevenvtmp.bat aoqi@0: aoqi@0: # Now execute the newly created bat file. aoqi@0: # The | cat is to stop SetEnv.Cmd to mess with system colors on msys aoqi@0: cmd /c localdevenvtmp.bat | cat aoqi@0: aoqi@0: # apply the diff (less some non-vs10 vars named by "!") aoqi@0: $SORT localdevenvtmp.export0 | $GREP -v "!" > localdevenvtmp.export0.sort aoqi@0: $SORT localdevenvtmp.export1 | $GREP -v "!" > localdevenvtmp.export1.sort aoqi@0: $COMM -1 -3 localdevenvtmp.export0.sort localdevenvtmp.export1.sort > localdevenv.sh aoqi@0: aoqi@0: # cleanup aoqi@0: $RM localdevenvtmp* aoqi@0: #---- aoqi@0: cd $CURDIR aoqi@0: if test ! -s $OUTPUT_ROOT/localdevenv.sh; then aoqi@0: AC_MSG_RESULT([no]) aoqi@0: AC_MSG_NOTICE([Could not succesfully extract the envionment variables needed for the VS setup.]) aoqi@0: AC_MSG_NOTICE([Try setting --with-tools-dir to the VC/bin directory within the VS installation]) aoqi@0: AC_MSG_NOTICE([or run "bash.exe -l" from a VS command prompt and then run configure from there.]) aoqi@0: AC_MSG_ERROR([Cannot continue]) aoqi@0: fi aoqi@0: aoqi@0: # Now set all paths and other env variables. This will allow the rest of aoqi@0: # the configure script to find and run the compiler in the proper way. aoqi@0: AC_MSG_NOTICE([Setting extracted environment variables]) aoqi@0: . $OUTPUT_ROOT/localdevenv.sh aoqi@0: else aoqi@0: # We did not find a vsvars bat file, let's hope we are run from a VS command prompt. aoqi@0: AC_MSG_NOTICE([Cannot locate a valid Visual Studio installation, checking current environment]) aoqi@0: fi aoqi@0: aoqi@0: # At this point, we should have corrent variables in the environment, or we can't continue. aoqi@0: AC_MSG_CHECKING([for Visual Studio variables]) aoqi@0: aoqi@0: if test "x$VCINSTALLDIR" != x || test "x$WindowsSDKDir" != x || test "x$WINDOWSSDKDIR" != x; then aoqi@0: if test "x$INCLUDE" = x || test "x$LIB" = x; then aoqi@0: AC_MSG_RESULT([present but broken]) aoqi@0: AC_MSG_ERROR([Your VC command prompt seems broken, INCLUDE and/or LIB is missing.]) aoqi@0: else aoqi@0: AC_MSG_RESULT([ok]) aoqi@0: # Remove any trailing \ from INCLUDE and LIB to avoid trouble in spec.gmk. aoqi@0: VS_INCLUDE=`$ECHO "$INCLUDE" | $SED 's/\\\\$//'` aoqi@0: VS_LIB=`$ECHO "$LIB" | $SED 's/\\\\$//'` aoqi@0: # Remove any paths containing # (typically F#) as that messes up make aoqi@0: PATH=`$ECHO "$PATH" | $SED 's/[[^:#]]*#[^:]*://g'` aoqi@0: VS_PATH="$PATH" aoqi@0: AC_SUBST(VS_INCLUDE) aoqi@0: AC_SUBST(VS_LIB) aoqi@0: AC_SUBST(VS_PATH) aoqi@0: fi aoqi@0: else aoqi@0: AC_MSG_RESULT([not found]) aoqi@0: aoqi@0: if test "x$VS_ENV_CMD" = x; then aoqi@0: AC_MSG_NOTICE([Cannot locate a valid Visual Studio or Windows SDK installation on disk,]) aoqi@0: AC_MSG_NOTICE([nor is this script run from a Visual Studio command prompt.]) aoqi@0: else aoqi@0: AC_MSG_NOTICE([Running the extraction script failed.]) aoqi@0: fi aoqi@0: AC_MSG_NOTICE([Try setting --with-tools-dir to the VC/bin directory within the VS installation]) aoqi@0: AC_MSG_NOTICE([or run "bash.exe -l" from a VS command prompt and then run configure from there.]) aoqi@0: AC_MSG_ERROR([Cannot continue]) aoqi@0: fi aoqi@0: ]) aoqi@0: aoqi@0: AC_DEFUN([TOOLCHAIN_CHECK_POSSIBLE_MSVCR_DLL], aoqi@0: [ aoqi@0: POSSIBLE_MSVCR_DLL="$1" aoqi@0: METHOD="$2" aoqi@0: if test -e "$POSSIBLE_MSVCR_DLL"; then aoqi@0: AC_MSG_NOTICE([Found msvcr100.dll at $POSSIBLE_MSVCR_DLL using $METHOD]) aoqi@0: aoqi@0: # Need to check if the found msvcr is correct architecture aoqi@0: AC_MSG_CHECKING([found msvcr100.dll architecture]) aoqi@0: MSVCR_DLL_FILETYPE=`$FILE -b "$POSSIBLE_MSVCR_DLL"` aoqi@0: if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then aoqi@0: CORRECT_MSVCR_ARCH=386 aoqi@0: else aoqi@0: CORRECT_MSVCR_ARCH=x86-64 aoqi@0: fi aoqi@0: if $ECHO "$MSVCR_DLL_FILETYPE" | $GREP $CORRECT_MSVCR_ARCH 2>&1 > /dev/null; then aoqi@0: AC_MSG_RESULT([ok]) aoqi@0: MSVCR_DLL="$POSSIBLE_MSVCR_DLL" aoqi@0: AC_MSG_CHECKING([for msvcr100.dll]) aoqi@0: AC_MSG_RESULT([$MSVCR_DLL]) aoqi@0: else aoqi@0: AC_MSG_RESULT([incorrect, ignoring]) aoqi@0: AC_MSG_NOTICE([The file type of the located msvcr100.dll is $MSVCR_DLL_FILETYPE]) aoqi@0: fi aoqi@0: fi aoqi@0: ]) aoqi@0: aoqi@0: AC_DEFUN([TOOLCHAIN_SETUP_MSVCR_DLL], aoqi@0: [ aoqi@0: AC_ARG_WITH(msvcr-dll, [AS_HELP_STRING([--with-msvcr-dll], aoqi@0: [copy this msvcr100.dll into the built JDK (Windows only) @<:@probed@:>@])]) aoqi@0: aoqi@0: if test "x$with_msvcr_dll" != x; then aoqi@0: # If given explicitely by user, do not probe. If not present, fail directly. aoqi@0: TOOLCHAIN_CHECK_POSSIBLE_MSVCR_DLL([$with_msvcr_dll], [--with-msvcr-dll]) aoqi@0: if test "x$MSVCR_DLL" = x; then aoqi@0: AC_MSG_ERROR([Could not find a proper msvcr100.dll as specified by --with-msvcr-dll]) aoqi@0: fi aoqi@0: fi aoqi@0: aoqi@0: if test "x$MSVCR_DLL" = x; then aoqi@0: # Probe: Using well-known location from Visual Studio 10.0 aoqi@0: if test "x$VCINSTALLDIR" != x; then aoqi@0: CYGWIN_VC_INSTALL_DIR="$VCINSTALLDIR" aoqi@0: BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(CYGWIN_VC_INSTALL_DIR) aoqi@0: if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then aoqi@0: POSSIBLE_MSVCR_DLL="$CYGWIN_VC_INSTALL_DIR/redist/x64/Microsoft.VC100.CRT/msvcr100.dll" aoqi@0: else aoqi@0: POSSIBLE_MSVCR_DLL="$CYGWIN_VC_INSTALL_DIR/redist/x86/Microsoft.VC100.CRT/msvcr100.dll" aoqi@0: fi aoqi@0: TOOLCHAIN_CHECK_POSSIBLE_MSVCR_DLL([$POSSIBLE_MSVCR_DLL], [well-known location in VCINSTALLDIR]) aoqi@0: fi aoqi@0: fi aoqi@0: aoqi@0: if test "x$MSVCR_DLL" = x; then aoqi@0: # Probe: Check in the Boot JDK directory. aoqi@0: POSSIBLE_MSVCR_DLL="$BOOT_JDK/bin/msvcr100.dll" aoqi@0: TOOLCHAIN_CHECK_POSSIBLE_MSVCR_DLL([$POSSIBLE_MSVCR_DLL], [well-known location in Boot JDK]) aoqi@0: fi aoqi@0: aoqi@0: if test "x$MSVCR_DLL" = x; then aoqi@0: # Probe: Look in the Windows system32 directory aoqi@0: CYGWIN_SYSTEMROOT="$SYSTEMROOT" aoqi@0: BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(CYGWIN_SYSTEMROOT) aoqi@0: POSSIBLE_MSVCR_DLL="$CYGWIN_SYSTEMROOT/system32/msvcr100.dll" aoqi@0: TOOLCHAIN_CHECK_POSSIBLE_MSVCR_DLL([$POSSIBLE_MSVCR_DLL], [well-known location in SYSTEMROOT]) aoqi@0: fi aoqi@0: aoqi@0: if test "x$MSVCR_DLL" = x; then aoqi@0: # Probe: If Visual Studio Express is installed, there is usually one with the debugger aoqi@0: if test "x$VS100COMNTOOLS" != x; then aoqi@0: CYGWIN_VS_TOOLS_DIR="$VS100COMNTOOLS/.." aoqi@0: BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(CYGWIN_VS_TOOLS_DIR) aoqi@0: if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then aoqi@0: POSSIBLE_MSVCR_DLL=`$FIND "$CYGWIN_VS_TOOLS_DIR" -name msvcr100.dll | $GREP -i /x64/ | $HEAD --lines 1` aoqi@0: else aoqi@0: POSSIBLE_MSVCR_DLL=`$FIND "$CYGWIN_VS_TOOLS_DIR" -name msvcr100.dll | $GREP -i /x86/ | $HEAD --lines 1` aoqi@0: fi aoqi@0: TOOLCHAIN_CHECK_POSSIBLE_MSVCR_DLL([$POSSIBLE_MSVCR_DLL], [search of VS100COMNTOOLS]) aoqi@0: fi aoqi@0: fi aoqi@0: aoqi@0: if test "x$MSVCR_DLL" = x; then aoqi@0: # Probe: Search wildly in the VCINSTALLDIR. We've probably lost by now. aoqi@0: # (This was the original behaviour; kept since it might turn up something) aoqi@0: if test "x$CYGWIN_VC_INSTALL_DIR" != x; then aoqi@0: if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then aoqi@0: POSSIBLE_MSVCR_DLL=`$FIND "$CYGWIN_VC_INSTALL_DIR" -name msvcr100.dll | $GREP x64 | $HEAD --lines 1` aoqi@0: else aoqi@0: POSSIBLE_MSVCR_DLL=`$FIND "$CYGWIN_VC_INSTALL_DIR" -name msvcr100.dll | $GREP x86 | $GREP -v ia64 | $GREP -v x64 | $HEAD --lines 1` aoqi@0: if test "x$POSSIBLE_MSVCR_DLL" = x; then aoqi@0: # We're grasping at straws now... aoqi@0: POSSIBLE_MSVCR_DLL=`$FIND "$CYGWIN_VC_INSTALL_DIR" -name msvcr100.dll | $HEAD --lines 1` aoqi@0: fi aoqi@0: fi aoqi@0: aoqi@0: TOOLCHAIN_CHECK_POSSIBLE_MSVCR_DLL([$POSSIBLE_MSVCR_DLL], [search of VCINSTALLDIR]) aoqi@0: fi aoqi@0: fi aoqi@0: aoqi@0: if test "x$MSVCR_DLL" = x; then aoqi@0: AC_MSG_CHECKING([for msvcr100.dll]) aoqi@0: AC_MSG_RESULT([no]) aoqi@0: AC_MSG_ERROR([Could not find msvcr100.dll. Please specify using --with-msvcr-dll.]) aoqi@0: fi aoqi@0: aoqi@0: BASIC_FIXUP_PATH(MSVCR_DLL) aoqi@0: ])