annotate common/autoconf/toolchain_windows.m4 @ 890:13ddc5c3ebfc

Merge
author jlaskey
date Sat, 02 Mar 2013 10:28:16 -0400
parents 98a7af257bee
children 52741ab7c601
rev   line source
ohair@492 1 #
ohair@492 2 # Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
ohair@492 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ohair@492 4 #
ohair@492 5 # This code is free software; you can redistribute it and/or modify it
ohair@492 6 # under the terms of the GNU General Public License version 2 only, as
ohair@492 7 # published by the Free Software Foundation. Oracle designates this
ohair@492 8 # particular file as subject to the "Classpath" exception as provided
ohair@492 9 # by Oracle in the LICENSE file that accompanied this code.
ohair@492 10 #
ohair@492 11 # This code is distributed in the hope that it will be useful, but WITHOUT
ohair@492 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ohair@492 13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ohair@492 14 # version 2 for more details (a copy is included in the LICENSE file that
ohair@492 15 # accompanied this code).
ohair@492 16 #
ohair@492 17 # You should have received a copy of the GNU General Public License version
ohair@492 18 # 2 along with this work; if not, write to the Free Software Foundation,
ohair@492 19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ohair@492 20 #
ohair@492 21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@492 22 # or visit www.oracle.com if you need additional information or have any
ohair@492 23 # questions.
ohair@492 24 #
ohair@492 25
ohair@492 26 AC_DEFUN([TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT],
ohair@492 27 [
ohair@492 28 if test "x$VS_ENV_CMD" = x; then
ohair@492 29 VS100BASE="$1"
ohair@492 30 METHOD="$2"
ohair@492 31 BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(VS100BASE)
ohair@492 32 if test -d "$VS100BASE"; then
ohair@492 33 if test -f "$VS100BASE/$VCVARSFILE"; then
ohair@492 34 AC_MSG_NOTICE([Found Visual Studio installation at $VS100BASE using $METHOD])
ohair@492 35 VS_ENV_CMD="$VS100BASE/$VCVARSFILE"
ohair@492 36 else
ohair@492 37 AC_MSG_NOTICE([Found Visual Studio installation at $VS100BASE using $METHOD])
ohair@492 38 AC_MSG_NOTICE([Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring])
ohair@492 39 fi
ohair@492 40 fi
ohair@492 41 fi
ohair@492 42 ])
ohair@492 43
ohair@492 44 AC_DEFUN([TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT],
ohair@492 45 [
ohair@492 46 if test "x$VS_ENV_CMD" = x; then
ohair@492 47 WIN_SDK_BASE="$1"
ohair@492 48 METHOD="$2"
ohair@492 49 BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(WIN_SDK_BASE)
ohair@492 50 if test -d "$WIN_SDK_BASE"; then
erikj@523 51 # There have been cases of partial or broken SDK installations. A missing
erikj@523 52 # lib dir is not going to work.
erikj@523 53 if test ! -d "$WIN_SDK_BASE/../lib"; then
erikj@523 54 AC_MSG_NOTICE([Found Windows SDK installation at $WIN_SDK_BASE using $METHOD])
erikj@523 55 AC_MSG_NOTICE([Warning: Installation is broken, lib dir is missing. Ignoring])
erikj@523 56 elif test -f "$WIN_SDK_BASE/SetEnv.Cmd"; then
ohair@492 57 AC_MSG_NOTICE([Found Windows SDK installation at $WIN_SDK_BASE using $METHOD])
ohair@492 58 VS_ENV_CMD="$WIN_SDK_BASE/SetEnv.Cmd"
ohair@492 59 if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
ohair@492 60 VS_ENV_ARGS="/x86"
ohair@492 61 else
ohair@492 62 VS_ENV_ARGS="/x64"
ohair@492 63 fi
ohair@492 64 else
ohair@492 65 AC_MSG_NOTICE([Found Windows SDK installation at $WIN_SDK_BASE using $METHOD])
ohair@492 66 AC_MSG_NOTICE([Warning: Installation is broken, SetEnv.Cmd is missing. Ignoring])
ohair@492 67 fi
ohair@492 68 fi
ohair@492 69 fi
ohair@492 70 ])
ohair@492 71
ohair@492 72 AC_DEFUN([TOOLCHAIN_FIND_VISUAL_STUDIO_BAT_FILE],
ohair@492 73 [
ohair@492 74 if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
ohair@492 75 VCVARSFILE="vc/bin/vcvars32.bat"
ohair@492 76 else
ohair@492 77 VCVARSFILE="vc/bin/amd64/vcvars64.bat"
ohair@492 78 fi
ohair@492 79
ohair@492 80 VS_ENV_CMD=""
ohair@492 81 VS_ENV_ARGS=""
ohair@492 82 if test "x$with_toolsdir" != x; then
ohair@492 83 TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([$with_toolsdir/../..], [--with-tools-dir])
ohair@492 84 fi
ohair@492 85
ohair@492 86 if test "x$with_toolsdir" != x && test "x$VS_ENV_CMD" = x; then
ohair@492 87 # Having specified an argument which is incorrect will produce an instant failure;
ohair@492 88 # we should not go on looking
ohair@492 89 AC_MSG_NOTICE([The path given by --with-tools-dir does not contain a valid Visual Studio installation])
ohair@492 90 AC_MSG_NOTICE([Please point to the VC/bin directory within the Visual Studio installation])
ohair@492 91 AC_MSG_ERROR([Cannot locate a valid Visual Studio installation])
ohair@492 92 fi
ohair@492 93
ohair@492 94 if test "x$ProgramW6432" != x; then
ohair@492 95 TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([$ProgramW6432/Microsoft SDKs/Windows/v7.1/Bin], [well-known name])
ohair@492 96 fi
ohair@492 97 if test "x$PROGRAMW6432" != x; then
ohair@492 98 TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([$PROGRAMW6432/Microsoft SDKs/Windows/v7.1/Bin], [well-known name])
ohair@492 99 fi
ohair@492 100 if test "x$PROGRAMFILES" != x; then
ohair@492 101 TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([$PROGRAMFILES/Microsoft SDKs/Windows/v7.1/Bin], [well-known name])
ohair@492 102 fi
ohair@492 103 TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([C:/Program Files/Microsoft SDKs/Windows/v7.1/Bin], [well-known name])
ohair@492 104 TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([C:/Program Files (x86)/Microsoft SDKs/Windows/v7.1/Bin], [well-known name])
ohair@492 105
ohair@492 106 if test "x$VS100COMNTOOLS" != x; then
ohair@492 107 TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([$VS100COMNTOOLS/../..], [VS100COMNTOOLS variable])
ohair@492 108 fi
ohair@492 109 if test "x$PROGRAMFILES" != x; then
ohair@492 110 TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([$PROGRAMFILES/Microsoft Visual Studio 10.0], [well-known name])
ohair@492 111 fi
ohair@492 112 TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([C:/Program Files/Microsoft Visual Studio 10.0], [well-known name])
ohair@492 113 TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([C:/Program Files (x86)/Microsoft Visual Studio 10.0], [well-known name])
ohair@492 114 ])
ohair@492 115
ohair@492 116 # Check if the VS env variables were setup prior to running configure.
ohair@492 117 # If not, then find vcvarsall.bat and run it automatically, and integrate
ohair@492 118 # the set env variables into the spec file.
ohair@492 119 AC_DEFUN([TOOLCHAIN_SETUP_VISUAL_STUDIO_ENV],
ohair@492 120 [
ohair@492 121 # Store path to cygwin link.exe to help excluding it when searching for
ohair@492 122 # VS linker. This must be done before changing the PATH when looking for VS.
ohair@492 123 AC_PATH_PROG(CYGWIN_LINK, link)
ohair@492 124 if test "x$CYGWIN_LINK" != x; then
ohair@492 125 AC_MSG_CHECKING([if the first found link.exe is actually the Cygwin link tool])
ohair@492 126 "$CYGWIN_LINK" --version > /dev/null
ohair@492 127 if test $? -eq 0 ; then
ohair@492 128 AC_MSG_RESULT([yes])
ohair@492 129 else
ohair@492 130 AC_MSG_RESULT([no])
ohair@492 131 # This might be the VS linker. Don't exclude it later on.
ohair@492 132 CYGWIN_LINK=""
ohair@492 133 fi
ohair@492 134 fi
ohair@492 135
ohair@492 136 # First-hand choice is to locate and run the vsvars bat file.
ohair@492 137 TOOLCHAIN_FIND_VISUAL_STUDIO_BAT_FILE
ohair@492 138 if test "x$VS_ENV_CMD" != x; then
ohair@492 139 # We have found a Visual Studio environment on disk, let's extract variables from the vsvars bat file.
ohair@492 140 BASIC_FIXUP_EXECUTABLE(VS_ENV_CMD)
ohair@492 141
ohair@492 142 # Lets extract the variables that are set by vcvarsall.bat/vsvars32.bat/vsvars64.bat
ohair@492 143 AC_MSG_NOTICE([Trying to extract Visual Studio environment variables])
ohair@492 144 cd $OUTPUT_ROOT
ohair@492 145 # FIXME: The code betweeen ---- was inlined from a separate script and is not properly adapted
ohair@492 146 # to autoconf standards.
ohair@492 147
ohair@492 148 #----
ohair@492 149
ohair@492 150 # Cannot use the VS10 setup script directly (since it only updates the DOS subshell environment)
ohair@492 151 # but calculate the difference in Cygwin environment before/after running it and then
ohair@492 152 # apply the diff.
ohair@492 153
ohair@492 154 if test "x$OPENJDK_BUILD_OS_ENV" = xwindows.cygwin; then
ohair@492 155 _vs10varsall=`cygpath -a -m -s "$VS_ENV_CMD"`
ohair@492 156 _dosvs10varsall=`cygpath -a -w -s $_vs10varsall`
ohair@492 157 _dosbash=`cygpath -a -w -s \`which bash\`.*`
ohair@492 158 else
ohair@492 159 _dosvs10varsall=`cmd //c echo $VS_ENV_CMD`
ohair@492 160 _dosbash=`cmd //c echo \`which bash\``
ohair@492 161 fi
ohair@492 162
ohair@492 163 # generate the set of exported vars before/after the vs10 setup
ohair@492 164 $ECHO "@echo off" > localdevenvtmp.bat
ohair@492 165 $ECHO "$_dosbash -c \"export -p\" > localdevenvtmp.export0" >> localdevenvtmp.bat
ohair@492 166 $ECHO "call $_dosvs10varsall $VS_ENV_ARGS" >> localdevenvtmp.bat
ohair@492 167 $ECHO "$_dosbash -c \"export -p\" > localdevenvtmp.export1" >> localdevenvtmp.bat
ohair@492 168
ohair@492 169 # Now execute the newly created bat file.
ohair@492 170 # The | cat is to stop SetEnv.Cmd to mess with system colors on msys
ohair@492 171 cmd /c localdevenvtmp.bat | cat
ohair@492 172
ohair@492 173 # apply the diff (less some non-vs10 vars named by "!")
ohair@492 174 $SORT localdevenvtmp.export0 | $GREP -v "!" > localdevenvtmp.export0.sort
ohair@492 175 $SORT localdevenvtmp.export1 | $GREP -v "!" > localdevenvtmp.export1.sort
ohair@492 176 $COMM -1 -3 localdevenvtmp.export0.sort localdevenvtmp.export1.sort > localdevenv.sh
ohair@492 177
ohair@492 178 # cleanup
ohair@492 179 $RM localdevenvtmp*
ohair@492 180 #----
ohair@492 181 cd $CURDIR
ohair@492 182 if test ! -s $OUTPUT_ROOT/localdevenv.sh; then
ohair@492 183 AC_MSG_RESULT([no])
ohair@492 184 AC_MSG_NOTICE([Could not succesfully extract the envionment variables needed for the VS setup.])
ohair@492 185 AC_MSG_NOTICE([Try setting --with-tools-dir to the VC/bin directory within the VS installation])
ohair@492 186 AC_MSG_NOTICE([or run "bash.exe -l" from a VS command prompt and then run configure from there.])
ohair@492 187 AC_MSG_ERROR([Cannot continue])
ohair@492 188 fi
ohair@492 189
ohair@492 190 # Now set all paths and other env variables. This will allow the rest of
ohair@492 191 # the configure script to find and run the compiler in the proper way.
ohair@492 192 AC_MSG_NOTICE([Setting extracted environment variables])
ohair@492 193 . $OUTPUT_ROOT/localdevenv.sh
ohair@492 194 else
ohair@492 195 # We did not find a vsvars bat file, let's hope we are run from a VS command prompt.
ohair@492 196 AC_MSG_NOTICE([Cannot locate a valid Visual Studio installation, checking current environment])
ohair@492 197 fi
ohair@492 198
ohair@492 199 # At this point, we should have corrent variables in the environment, or we can't continue.
ohair@492 200 AC_MSG_CHECKING([for Visual Studio variables])
ohair@492 201
ohair@492 202 if test "x$VCINSTALLDIR" != x || test "x$WindowsSDKDir" != x || test "x$WINDOWSSDKDIR" != x; then
ohair@492 203 if test "x$INCLUDE" = x || test "x$LIB" = x; then
ohair@492 204 AC_MSG_RESULT([present but broken])
ohair@492 205 AC_MSG_ERROR([Your VC command prompt seems broken, INCLUDE and/or LIB is missing.])
ohair@492 206 else
ohair@492 207 AC_MSG_RESULT([ok])
erikj@520 208 # Remove any trailing \ from INCLUDE and LIB to avoid trouble in spec.gmk.
erikj@520 209 VS_INCLUDE=`$ECHO "$INCLUDE" | $SED 's/\\\\$//'`
erikj@520 210 VS_LIB=`$ECHO "$LIB" | $SED 's/\\\\$//'`
ohair@492 211 VS_PATH="$PATH"
ohair@492 212 AC_SUBST(VS_INCLUDE)
ohair@492 213 AC_SUBST(VS_LIB)
ohair@492 214 AC_SUBST(VS_PATH)
ohair@492 215 fi
ohair@492 216 else
ohair@492 217 AC_MSG_RESULT([not found])
ohair@492 218
ohair@492 219 if test "x$VS_ENV_CMD" = x; then
ohair@492 220 AC_MSG_NOTICE([Cannot locate a valid Visual Studio or Windows SDK installation on disk,])
ohair@492 221 AC_MSG_NOTICE([nor is this script run from a Visual Studio command prompt.])
ohair@492 222 else
ohair@492 223 AC_MSG_NOTICE([Running the extraction script failed.])
ohair@492 224 fi
ohair@492 225 AC_MSG_NOTICE([Try setting --with-tools-dir to the VC/bin directory within the VS installation])
ohair@492 226 AC_MSG_NOTICE([or run "bash.exe -l" from a VS command prompt and then run configure from there.])
ohair@492 227 AC_MSG_ERROR([Cannot continue])
ohair@492 228 fi
ohair@492 229
ohair@492 230 AC_MSG_CHECKING([for msvcr100.dll])
ohair@492 231 AC_ARG_WITH(msvcr-dll, [AS_HELP_STRING([--with-msvcr-dll],
ohair@492 232 [copy this msvcr100.dll into the built JDK (Windows only) @<:@probed@:>@])])
ohair@492 233 if test "x$with_msvcr_dll" != x; then
ohair@492 234 MSVCR_DLL="$with_msvcr_dll"
ohair@492 235 else
ohair@492 236 if test "x$VCINSTALLDIR" != x; then
ohair@492 237 if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
ohair@492 238 MSVCR_DLL=`find "$VCINSTALLDIR" -name msvcr100.dll | grep x64 | head --lines 1`
ohair@492 239 else
ohair@492 240 MSVCR_DLL=`find "$VCINSTALLDIR" -name msvcr100.dll | grep x86 | grep -v ia64 | grep -v x64 | head --lines 1`
ohair@492 241 if test "x$MSVCR_DLL" = x; then
ohair@492 242 MSVCR_DLL=`find "$VCINSTALLDIR" -name msvcr100.dll | head --lines 1`
ohair@492 243 fi
ohair@492 244 fi
ohair@492 245 if test "x$MSVCR_DLL" != x; then
ohair@492 246 AC_MSG_NOTICE([msvcr100.dll found in VCINSTALLDIR: $VCINSTALLDIR])
ohair@492 247 else
ohair@492 248 AC_MSG_NOTICE([Warning: msvcr100.dll not found in VCINSTALLDIR: $VCINSTALLDIR])
ohair@492 249 fi
ohair@492 250 fi
ohair@492 251 if test "x$MSVCR_DLL" = x; then
ohair@492 252 if test -f "$SYSTEMROOT/system32/msvcr100.dll"; then
ohair@492 253 AC_MSG_NOTICE([msvcr100.dll found in $SYSTEMROOT/system32])
ohair@492 254 MSVCR_DLL="$SYSTEMROOT/system32/msvcr100.dll"
ohair@492 255 fi
ohair@492 256 fi
ohair@492 257 fi
ohair@492 258 if test "x$MSVCR_DLL" = x; then
ohair@492 259 AC_MSG_RESULT([no])
ohair@492 260 AC_MSG_ERROR([Could not find msvcr100.dll !])
ohair@492 261 fi
ohair@492 262 AC_MSG_RESULT([$MSVCR_DLL])
ohair@492 263 BASIC_FIXUP_PATH(MSVCR_DLL)
ohair@492 264 ])