common/autoconf/toolchain_windows.m4

Print this page




 124   if test "x$CYGWIN_LINK" != x; then
 125     AC_MSG_CHECKING([if the first found link.exe is actually the Cygwin link tool])
 126     "$CYGWIN_LINK" --version > /dev/null
 127     if test $? -eq 0 ; then
 128       AC_MSG_RESULT([yes])
 129     else
 130       AC_MSG_RESULT([no])
 131       # This might be the VS linker. Don't exclude it later on.
 132       CYGWIN_LINK=""
 133     fi
 134   fi
 135 
 136   # First-hand choice is to locate and run the vsvars bat file.
 137   TOOLCHAIN_FIND_VISUAL_STUDIO_BAT_FILE
 138   if test "x$VS_ENV_CMD" != x; then
 139     # We have found a Visual Studio environment on disk, let's extract variables from the vsvars bat file.
 140     BASIC_FIXUP_EXECUTABLE(VS_ENV_CMD)
 141 
 142     # Lets extract the variables that are set by vcvarsall.bat/vsvars32.bat/vsvars64.bat
 143     AC_MSG_NOTICE([Trying to extract Visual Studio environment variables])
 144     cd $OUTPUT_ROOT
 145     # FIXME: The code betweeen ---- was inlined from a separate script and is not properly adapted
 146     # to autoconf standards.
 147 
 148     #----
 149 
 150     # Cannot use the VS10 setup script directly (since it only updates the DOS subshell environment)
 151     # but calculate the difference in Cygwin environment before/after running it and then
 152     # apply the diff.
 153 
 154     if test "x$OPENJDK_BUILD_OS_ENV" = xwindows.cygwin; then
 155       _vs10varsall=`cygpath -a -m -s "$VS_ENV_CMD"`
 156       _dosvs10varsall=`cygpath -a -w -s $_vs10varsall`
 157       _dosbash=`cygpath -a -w -s \`which bash\`.*`
 158     else
 159       _dosvs10varsall=`cmd //c echo $VS_ENV_CMD`
 160       _dosbash=`cmd //c echo \`which bash\``
 161     fi
 162 
 163     # generate the set of exported vars before/after the vs10 setup
 164     $ECHO "@echo off"                                           >  localdevenvtmp.bat
 165     $ECHO "$_dosbash -c \"export -p\" > localdevenvtmp.export0" >> localdevenvtmp.bat
 166     $ECHO "call $_dosvs10varsall $VS_ENV_ARGS"                  >> localdevenvtmp.bat
 167     $ECHO "$_dosbash -c \"export -p\" > localdevenvtmp.export1" >> localdevenvtmp.bat























 168 
 169     # Now execute the newly created bat file.
 170     # The | cat is to stop SetEnv.Cmd to mess with system colors on msys
 171     cmd /c localdevenvtmp.bat | cat
 172 
 173     # apply the diff (less some non-vs10 vars named by "!")
 174     $SORT localdevenvtmp.export0 | $GREP -v "!" > localdevenvtmp.export0.sort
 175     $SORT localdevenvtmp.export1 | $GREP -v "!" > localdevenvtmp.export1.sort
 176     $COMM -1 -3 localdevenvtmp.export0.sort localdevenvtmp.export1.sort > localdevenv.sh
 177 
 178     # cleanup
 179     $RM localdevenvtmp*
 180     #----
 181     cd $CURDIR
 182     if test ! -s $OUTPUT_ROOT/localdevenv.sh; then
 183       AC_MSG_RESULT([no])



 184       AC_MSG_NOTICE([Could not succesfully extract the envionment variables needed for the VS setup.])
 185       AC_MSG_NOTICE([Try setting --with-tools-dir to the VC/bin directory within the VS installation])
 186       AC_MSG_NOTICE([or run "bash.exe -l" from a VS command prompt and then run configure from there.])
 187       AC_MSG_ERROR([Cannot continue])
 188     fi
 189 
 190     # Now set all paths and other env variables. This will allow the rest of
 191     # the configure script to find and run the compiler in the proper way.
 192     AC_MSG_NOTICE([Setting extracted environment variables])
 193     . $OUTPUT_ROOT/localdevenv.sh




 194   else
 195     # We did not find a vsvars bat file, let's hope we are run from a VS command prompt.
 196     AC_MSG_NOTICE([Cannot locate a valid Visual Studio installation, checking current environment])
 197   fi
 198 
 199   # At this point, we should have corrent variables in the environment, or we can't continue.
 200   AC_MSG_CHECKING([for Visual Studio variables])
 201 
 202   if test "x$VCINSTALLDIR" != x || test "x$WindowsSDKDir" != x || test "x$WINDOWSSDKDIR" != x; then
 203     if test "x$INCLUDE" = x || test "x$LIB" = x; then
 204       AC_MSG_RESULT([present but broken])
 205       AC_MSG_ERROR([Your VC command prompt seems broken, INCLUDE and/or LIB is missing.])
 206     else
 207       AC_MSG_RESULT([ok])
 208       # Remove any trailing \ from INCLUDE and LIB to avoid trouble in spec.gmk.
 209       VS_INCLUDE=`$ECHO "$INCLUDE" | $SED 's/\\\\$//'`
 210       VS_LIB=`$ECHO "$LIB" | $SED 's/\\\\$//'`
 211       # Remove any paths containing # (typically F#) as that messes up make
 212       PATH=`$ECHO "$PATH" | $SED 's/[[^:#]]*#[^:]*://g'`
 213       VS_PATH="$PATH"


 214       AC_SUBST(VS_INCLUDE)
 215       AC_SUBST(VS_LIB)
 216       AC_SUBST(VS_PATH)
 217     fi
 218   else
 219     AC_MSG_RESULT([not found])
 220 
 221     if test "x$VS_ENV_CMD" = x; then
 222       AC_MSG_NOTICE([Cannot locate a valid Visual Studio or Windows SDK installation on disk,])
 223       AC_MSG_NOTICE([nor is this script run from a Visual Studio command prompt.])
 224     else
 225       AC_MSG_NOTICE([Running the extraction script failed.])
 226     fi
 227     AC_MSG_NOTICE([Try setting --with-tools-dir to the VC/bin directory within the VS installation])
 228     AC_MSG_NOTICE([or run "bash.exe -l" from a VS command prompt and then run configure from there.])
 229     AC_MSG_ERROR([Cannot continue])
 230   fi
 231 ])
 232 
 233 AC_DEFUN([TOOLCHAIN_CHECK_POSSIBLE_MSVCR_DLL],
 234 [
 235   POSSIBLE_MSVCR_DLL="$1"
 236   METHOD="$2"




 124   if test "x$CYGWIN_LINK" != x; then
 125     AC_MSG_CHECKING([if the first found link.exe is actually the Cygwin link tool])
 126     "$CYGWIN_LINK" --version > /dev/null
 127     if test $? -eq 0 ; then
 128       AC_MSG_RESULT([yes])
 129     else
 130       AC_MSG_RESULT([no])
 131       # This might be the VS linker. Don't exclude it later on.
 132       CYGWIN_LINK=""
 133     fi
 134   fi
 135 
 136   # First-hand choice is to locate and run the vsvars bat file.
 137   TOOLCHAIN_FIND_VISUAL_STUDIO_BAT_FILE
 138   if test "x$VS_ENV_CMD" != x; then
 139     # We have found a Visual Studio environment on disk, let's extract variables from the vsvars bat file.
 140     BASIC_FIXUP_EXECUTABLE(VS_ENV_CMD)
 141 
 142     # Lets extract the variables that are set by vcvarsall.bat/vsvars32.bat/vsvars64.bat
 143     AC_MSG_NOTICE([Trying to extract Visual Studio environment variables])


















 144 
 145     # We need to create a couple of temporary files.
 146     VS_ENV_TMP_DIR="$OUTPUT_ROOT/tmp"
 147     $MKDIR -p $VS_ENV_TMP_DIR
 148 
 149     # Cannot use the VS10 setup script directly (since it only updates the DOS subshell environment).
 150     # Instead create a shell script which will set the relevant variables when run.
 151     WINPATH_VS_ENV_CMD="$VS_ENV_CMD"
 152     BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH([WINPATH_VS_ENV_CMD])
 153     WINPATH_BASH="$BASH"
 154     BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH([WINPATH_BASH])
 155 
 156     # Generate a DOS batch file which runs $VS_ENV_CMD, and then creates a shell
 157     # script (executable by bash) that will setup the important variables.
 158     EXTRACT_VC_ENV_BAT_FILE="$VS_ENV_TMP_DIR/extract_vs_env.bat"
 159     $ECHO "@echo off" >  $EXTRACT_VC_ENV_BAT_FILE
 160     # This will end up something like:
 161     # call C:/progra~2/micros~2.0/vc/bin/amd64/vcvars64.bat
 162     $ECHO "call $WINPATH_VS_ENV_CMD $VS_ENV_ARGS" >> $EXTRACT_VC_ENV_BAT_FILE
 163     # These will end up something like:
 164     # C:/CygWin/bin/bash -c 'echo VS_PATH=\"$PATH\" > localdevenv.sh
 165     # The trailing space for everyone except PATH is no typo, but is needed due
 166     # to trailing \ in the Windows paths. These will be stripped later.
 167     $ECHO "$WINPATH_BASH -c 'echo VS_PATH="'\"$PATH\" > set_vs_env.sh' >> $EXTRACT_VC_ENV_BAT_FILE
 168     $ECHO "$WINPATH_BASH -c 'echo VS_INCLUDE="'\"$INCLUDE \" >> set_vs_env.sh' >> $EXTRACT_VC_ENV_BAT_FILE
 169     $ECHO "$WINPATH_BASH -c 'echo VS_LIB="'\"$LIB \" >> set_vs_env.sh' >> $EXTRACT_VC_ENV_BAT_FILE
 170     $ECHO "$WINPATH_BASH -c 'echo VCINSTALLDIR="'\"$VCINSTALLDIR \" >> set_vs_env.sh' >> $EXTRACT_VC_ENV_BAT_FILE
 171     $ECHO "$WINPATH_BASH -c 'echo WindowsSdkDir="'\"$WindowsSdkDir \" >> set_vs_env.sh' >> $EXTRACT_VC_ENV_BAT_FILE
 172     $ECHO "$WINPATH_BASH -c 'echo WINDOWSSDKDIR="'\"$WINDOWSSDKDIR \" >> set_vs_env.sh' >> $EXTRACT_VC_ENV_BAT_FILE
 173 
 174     # Now execute the newly created bat file.
 175     # The | cat is to stop SetEnv.Cmd to mess with system colors on msys.
 176     # Change directory so we don't need to mess with Windows paths in redirects.
 177     cd $VS_ENV_TMP_DIR
 178     cmd /c extract_vs_env.bat | $CAT







 179     cd $CURDIR
 180 
 181     # Remove the generated batch file
 182     $RM $EXTRACT_VC_ENV_BAT_FILE
 183 
 184     if test ! -s $VS_ENV_TMP_DIR/set_vs_env.sh; then
 185       AC_MSG_NOTICE([Could not succesfully extract the envionment variables needed for the VS setup.])
 186       AC_MSG_NOTICE([Try setting --with-tools-dir to the VC/bin directory within the VS installation])
 187       AC_MSG_NOTICE([or run "bash.exe -l" from a VS command prompt and then run configure from there.])
 188       AC_MSG_ERROR([Cannot continue])
 189     fi
 190 
 191     # Now set all paths and other env variables. This will allow the rest of
 192     # the configure script to find and run the compiler in the proper way.
 193     AC_MSG_NOTICE([Setting extracted environment variables])
 194     . $VS_ENV_TMP_DIR/set_vs_env.sh
 195     # Now we have VS_PATH, VS_INCLUDE, VS_LIB. For further checking, we
 196     # also define VCINSTALLDIR, WindowsSdkDir and WINDOWSSDKDIR.
 197     # Remove the generated shell script
 198     $RM $VS_ENV_TMP_DIR/set_vs_env.sh
 199   else
 200     # We did not find a vsvars bat file, let's hope we are run from a VS command prompt.
 201     AC_MSG_NOTICE([Cannot locate a valid Visual Studio installation, checking current environment])
 202   fi
 203 
 204   # At this point, we should have corrent variables in the environment, or we can't continue.
 205   AC_MSG_CHECKING([for Visual Studio variables])
 206 
 207   if test "x$VCINSTALLDIR" != x || test "x$WindowsSDKDir" != x || test "x$WINDOWSSDKDIR" != x; then
 208     if test "x$VS_INCLUDE" = x || test "x$VS_LIB" = x; then
 209       AC_MSG_RESULT([present but broken])
 210       AC_MSG_ERROR([Your VC command prompt seems broken, INCLUDE and/or LIB is missing.])
 211     else
 212       AC_MSG_RESULT([ok])
 213       # Remove any trailing "\" and " " from the variables.
 214       VS_INCLUDE=`$ECHO "$VS_INCLUDE" | $SED 's/\\\\* *$//'`
 215       VS_LIB=`$ECHO "$VS_LIB" | $SED 's/\\\\* *$//'`
 216       VCINSTALLDIR=`$ECHO "$VCINSTALLDIR" | $SED 's/\\\\* *$//'`
 217       WindowsSDKDir=`$ECHO "$WindowsSDKDir" | $SED 's/\\\\* *$//'`
 218       WINDOWSSDKDIR=`$ECHO "$WINDOWSSDKDIR" | $SED 's/\\\\* *$//'`
 219 
 220       AC_SUBST(VS_PATH)
 221       AC_SUBST(VS_INCLUDE)
 222       AC_SUBST(VS_LIB)

 223     fi
 224   else
 225     AC_MSG_RESULT([not found])
 226 
 227     if test "x$VS_ENV_CMD" = x; then
 228       AC_MSG_NOTICE([Cannot locate a valid Visual Studio or Windows SDK installation on disk,])
 229       AC_MSG_NOTICE([nor is this script run from a Visual Studio command prompt.])
 230     else
 231       AC_MSG_NOTICE([Running the extraction script failed.])
 232     fi
 233     AC_MSG_NOTICE([Try setting --with-tools-dir to the VC/bin directory within the VS installation])
 234     AC_MSG_NOTICE([or run "bash.exe -l" from a VS command prompt and then run configure from there.])
 235     AC_MSG_ERROR([Cannot continue])
 236   fi
 237 ])
 238 
 239 AC_DEFUN([TOOLCHAIN_CHECK_POSSIBLE_MSVCR_DLL],
 240 [
 241   POSSIBLE_MSVCR_DLL="$1"
 242   METHOD="$2"