< prev index next >

make/autoconf/basics_windows.m4

Print this page




  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 AC_DEFUN([BASIC_WINDOWS_REWRITE_AS_UNIX_PATH],
  27 [
  28   windows_path="[$]$1"
  29   if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
  30     unix_path=`$CYGPATH -u "$windows_path"`
  31     $1="$unix_path"
  32   elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
  33     unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'`
  34     $1="$unix_path"
  35   elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.wsl"; then
  36     # wslpath does not check the input, only call if an actual windows path was
  37     # given.
  38     if $ECHO "$windows_path" | $GREP -q ["^[a-zA-Z]:[\\\\/]"]; then
  39       unix_path=`$WSLPATH -u "$windows_path"`
  40       $1="$unix_path"
  41     fi
  42   fi
  43 ])
  44 
  45 AC_DEFUN([BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH],
  46 [
  47   unix_path="[$]$1"
  48   if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
  49     windows_path=`$CYGPATH -m "$unix_path"`
  50     $1="$windows_path"
  51   elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
  52     windows_path=`cmd //c echo $unix_path`
  53     $1="$windows_path"
  54   elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.wsl"; then
  55     windows_path=`$WSLPATH -m "$unix_path"`
  56     $1="$windows_path"
  57   fi
  58 ])
  59 
  60 # Helper function which possibly converts a path using DOS-style short mode.
  61 # If so, the updated path is stored in $new_path.
  62 # $1: The path to check
  63 AC_DEFUN([BASIC_MAKE_WINDOWS_SPACE_SAFE_CYGWIN],
  64 [
  65   input_path="$1"
  66   # Check if we need to convert this using DOS-style short mode. If the path
  67   # contains just simple characters, use it. Otherwise (spaces, weird characters),
  68   # take no chances and rewrite it.
  69   # Note: m4 eats our [], so we need to use @<:@ and @:>@ instead.
  70   has_forbidden_chars=`$ECHO "$input_path" | $GREP @<:@^-._/a-zA-Z0-9@:>@`
  71   if test "x$has_forbidden_chars" != x; then
  72     # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \)
  73     shortmode_path=`$CYGPATH -s -m -a "$input_path"`
  74     path_after_shortmode=`$CYGPATH -u "$shortmode_path"`
  75     if test "x$path_after_shortmode" != "x$input_to_shortpath"; then
  76       # Going to short mode and back again did indeed matter. Since short mode is


  93   fi
  94 ])
  95 
  96 # Helper function which possibly converts a path using DOS-style short mode.
  97 # If so, the updated path is stored in $new_path.
  98 # $1: The path to check
  99 AC_DEFUN([BASIC_MAKE_WINDOWS_SPACE_SAFE_MSYS],
 100 [
 101   input_path="$1"
 102   # Check if we need to convert this using DOS-style short mode. If the path
 103   # contains just simple characters, use it. Otherwise (spaces, weird characters),
 104   # take no chances and rewrite it.
 105   # Note: m4 eats our [], so we need to use @<:@ and @:>@ instead.
 106   has_forbidden_chars=`$ECHO "$input_path" | $GREP @<:@^-_/:a-zA-Z0-9@:>@`
 107   if test "x$has_forbidden_chars" != x; then
 108     # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \)
 109     new_path=`cmd /c "for %A in (\"$input_path\") do @echo %~sA"|$TR \\\\\\\\ / | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
 110   fi
 111 ])
 112 
 113 # Helper function which possibly converts a path using DOS-style short mode.
 114 # If so, the updated path is stored in $new_path.
 115 # $1: The path to check
 116 AC_DEFUN([BASIC_MAKE_WINDOWS_SPACE_SAFE_WSL],
 117 [
 118   input_path="$1"
 119   # Check if we need to convert this using DOS-style short mode. If the path
 120   # contains just simple characters, use it. Otherwise (spaces, weird characters),
 121   # take no chances and rewrite it.
 122   # Note: m4 eats our [], so we need to use @<:@ and @:>@ instead.
 123   has_forbidden_chars=`$ECHO "$input_path" | $GREP [[^-_/:a-zA-Z0-9\\.]]`
 124   if test "x$has_forbidden_chars" != x; then
 125     # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \)
 126     TOPDIR_windows="$TOPDIR"
 127     BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH([TOPDIR_windows])
 128     # First convert to Windows path to make input valid for cmd
 129     BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH([input_path])
 130     new_path=`$CMD /c $TOPDIR_windows/make/scripts/windowsShortName.bat "$input_path" \
 131         | $SED -e 's|\r||g' \
 132         | $TR \\\\\\\\ / | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
 133     # Rewrite back to unix style
 134     BASIC_WINDOWS_REWRITE_AS_UNIX_PATH([new_path])
 135   fi
 136 ])
 137 
 138 # FIXME: The BASIC_FIXUP_*_CYGWIN/MSYS is most likely too convoluted
 139 # and could probably be heavily simplified. However, all changes in this
 140 # area tend to need lot of testing in different scenarios, and in lack of
 141 # proper unit testing, cleaning this up has not been deemed worth the effort
 142 # at the moment.
 143 
 144 AC_DEFUN([BASIC_FIXUP_PATH_CYGWIN],
 145 [
 146   # Input might be given as Windows format, start by converting to
 147   # unix format.
 148   path="[$]$1"
 149   new_path=`$CYGPATH -u "$path"`
 150 
 151   # Cygwin tries to hide some aspects of the Windows file system, such that binaries are
 152   # named .exe but called without that suffix. Therefore, "foo" and "foo.exe" are considered
 153   # the same file, most of the time (as in "test -f"). But not when running cygpath -s, then
 154   # "foo.exe" is OK but "foo" is an error.
 155   #
 156   # This test is therefore slightly more accurate than "test -f" to check for file precense.
 157   # It is also a way to make sure we got the proper file name for the real test later on.


 175 [
 176   path="[$]$1"
 177   has_colon=`$ECHO $path | $GREP ^.:`
 178   new_path="$path"
 179   if test "x$has_colon" = x; then
 180     # Not in mixed or Windows style, start by that.
 181     new_path=`cmd //c echo $path`
 182   fi
 183 
 184   BASIC_MAKE_WINDOWS_SPACE_SAFE_MSYS([$new_path])
 185   BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(new_path)
 186   if test "x$path" != "x$new_path"; then
 187     $1="$new_path"
 188     AC_MSG_NOTICE([Rewriting $1 to "$new_path"])
 189   fi
 190 
 191   # Save the first 10 bytes of this path to the storage, so fixpath can work.
 192   all_fixpath_prefixes=("${all_fixpath_prefixes@<:@@@:>@}" "${new_path:0:10}")
 193 ])
 194 
 195 AC_DEFUN([BASIC_FIXUP_PATH_WSL],
 196 [
 197   # Input might be given as Windows format, start by converting to
 198   # unix format.
 199   new_path="[$]$1"
 200   BASIC_WINDOWS_REWRITE_AS_UNIX_PATH([new_path])
 201 
 202   # Call helper function which possibly converts this using DOS-style short mode.
 203   # If so, the updated path is stored in $new_path.
 204   BASIC_MAKE_WINDOWS_SPACE_SAFE_WSL([$new_path])
 205 
 206   if test "x$path" != "x$new_path"; then
 207     $1="$new_path"
 208     AC_MSG_NOTICE([Rewriting $1 to "$new_path"])
 209   fi
 210 ])
 211 
 212 AC_DEFUN([BASIC_FIXUP_EXECUTABLE_CYGWIN],
 213 [
 214   # First separate the path from the arguments. This will split at the first
 215   # space.
 216   complete="[$]$1"
 217   path="${complete%% *}"
 218   tmp="$complete EOL"
 219   arguments="${tmp#* }"
 220 
 221   # Input might be given as Windows format, start by converting to
 222   # unix format.
 223   new_path=`$CYGPATH -u "$path"`
 224 
 225   # Now try to locate executable using which
 226   new_path=`$WHICH "$new_path" 2> /dev/null`
 227   # bat and cmd files are not always considered executable in cygwin causing which
 228   # to not find them
 229   if test "x$new_path" = x \
 230       && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \
 231       && test "x`$LS \"$path\" 2>/dev/null`" != x; then


 340 
 341   # Now new_path has a complete unix path to the binary
 342   if test "x`$ECHO $new_path | $GREP ^/bin/`" != x; then
 343     # Keep paths in /bin as-is, but remove trailing .exe if any
 344     new_path="${new_path/%.exe/}"
 345     # Do not save /bin paths to all_fixpath_prefixes!
 346   else
 347     # Not in mixed or Windows style, start by that.
 348     new_path=`cmd //c echo $new_path`
 349     BASIC_MAKE_WINDOWS_SPACE_SAFE_MSYS([$new_path])
 350     # Output is in $new_path
 351     BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(new_path)
 352     # remove trailing .exe if any
 353     new_path="${new_path/%.exe/}"
 354 
 355     # Save the first 10 bytes of this path to the storage, so fixpath can work.
 356     all_fixpath_prefixes=("${all_fixpath_prefixes@<:@@@:>@}" "${new_path:0:10}")
 357   fi
 358 ])
 359 
 360 AC_DEFUN([BASIC_FIXUP_EXECUTABLE_WSL],
 361 [
 362   # First separate the path from the arguments. This will split at the first
 363   # space.
 364   complete="[$]$1"
 365   path="${complete%% *}"
 366   tmp="$complete EOL"
 367   arguments="${tmp#* }"
 368 
 369   # Input might be given as Windows format, start by converting to
 370   # unix format.
 371   new_path="$path"
 372   BASIC_WINDOWS_REWRITE_AS_UNIX_PATH([new_path])
 373 
 374   # Now try to locate executable using which
 375   new_path_bak="$new_path"
 376   new_path=`$WHICH "$new_path" 2> /dev/null`
 377   # bat and cmd files are not considered executable in WSL
 378   if test "x$new_path" = x \
 379       && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \
 380       && test "x`$LS \"$path\" 2>/dev/null`" != x; then
 381     new_path="$new_path_back"
 382   fi
 383   if test "x$new_path" = x; then
 384     # Oops. Which didn't find the executable.
 385     # The splitting of arguments from the executable at a space might have been incorrect,
 386     # since paths with space are more likely in Windows. Give it another try with the whole
 387     # argument.
 388     path="$complete"
 389     arguments="EOL"
 390     new_path="$path"
 391     BASIC_WINDOWS_REWRITE_AS_UNIX_PATH([new_path])
 392     new_path_bak="$new_path"
 393     new_path=`$WHICH "$new_path" 2> /dev/null`
 394     # bat and cmd files are not considered executable in WSL
 395     if test "x$new_path" = x \
 396         && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \
 397         && test "x`$LS \"$path\" 2>/dev/null`" != x; then
 398       new_path="$new_path_bak"
 399     fi
 400     if test "x$new_path" = x; then
 401       # It's still not found. Now this is an unrecoverable error.
 402       AC_MSG_NOTICE([The path of $1, which resolves as "$complete", is not found.])
 403       has_space=`$ECHO "$complete" | $GREP " "`
 404       if test "x$has_space" != x; then
 405         AC_MSG_NOTICE([You might be mixing spaces in the path and extra arguments, which is not allowed.])
 406       fi
 407       AC_MSG_ERROR([Cannot locate the the path of $1])
 408     fi
 409   fi
 410 
 411   # In WSL, suffixes must be present for Windows executables
 412   if test ! -f "$new_path"; then
 413     # Try adding .exe or .cmd
 414     if test -f "${new_path}.exe"; then
 415       input_to_shortpath="${new_path}.exe"
 416     elif test -f "${new_path}.cmd"; then
 417       input_to_shortpath="${new_path}.cmd"
 418     else
 419       AC_MSG_NOTICE([The path of $1, which resolves as "$new_path", is invalid.])
 420       AC_MSG_NOTICE([Neither "$new_path" nor "$new_path.exe/cmd" can be found])
 421       AC_MSG_ERROR([Cannot locate the the path of $1])
 422     fi
 423   else
 424     input_to_shortpath="$new_path"
 425   fi
 426 
 427   # Call helper function which possibly converts this using DOS-style short mode.
 428   # If so, the updated path is stored in $new_path.
 429   new_path="$input_to_shortpath"
 430   BASIC_MAKE_WINDOWS_SPACE_SAFE_WSL([$input_to_shortpath])
 431 ])
 432 
 433 # Setup basic configuration paths, and platform-specific stuff related to PATHs.
 434 AC_DEFUN([BASIC_CHECK_PATHS_WINDOWS],
 435 [
 436   SRC_ROOT_LENGTH=`$THEPWDCMD -L|$WC -m`
 437   if test $SRC_ROOT_LENGTH -gt 100; then
 438     AC_MSG_ERROR([Your base path is too long. It is $SRC_ROOT_LENGTH characters long, but only 100 is supported])
 439   fi
 440 
 441   if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
 442     AC_MSG_CHECKING([cygwin release])
 443     CYGWIN_VERSION=`$UNAME -r`
 444     AC_MSG_RESULT([$CYGWIN_VERSION])
 445     WINDOWS_ENV_VENDOR='cygwin'
 446     WINDOWS_ENV_VERSION="$CYGWIN_VERSION"
 447 
 448     CYGWIN_VERSION_OLD=`$ECHO $CYGWIN_VERSION | $GREP -e '^1\.[0-6]'`
 449     if test "x$CYGWIN_VERSION_OLD" != x; then
 450       AC_MSG_NOTICE([Your cygwin is too old. You are running $CYGWIN_VERSION, but at least cygwin 1.7 is required. Please upgrade.])
 451       AC_MSG_ERROR([Cannot continue])
 452     fi


 461     AC_MSG_RESULT([$CYGWIN_ROOT_PATH])
 462     WINDOWS_ENV_ROOT_PATH="$CYGWIN_ROOT_PATH"
 463     test_cygdrive_prefix=`$ECHO $CYGWIN_ROOT_PATH | $GREP ^/cygdrive/`
 464     if test "x$test_cygdrive_prefix" = x; then
 465       AC_MSG_ERROR([Your cygdrive prefix is not /cygdrive. This is currently not supported. Change with mount -c.])
 466     fi
 467   elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
 468     AC_MSG_CHECKING([msys release])
 469     MSYS_VERSION=`$UNAME -r`
 470     AC_MSG_RESULT([$MSYS_VERSION])
 471 
 472     WINDOWS_ENV_VENDOR='msys'
 473     WINDOWS_ENV_VERSION="$MSYS_VERSION"
 474 
 475     AC_MSG_CHECKING([msys root directory as unix-style path])
 476     # The cmd output ends with Windows line endings (CR/LF), the grep command will strip that away
 477     MSYS_ROOT_PATH=`cd / ; cmd /c cd | $GREP ".*"`
 478     BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(MSYS_ROOT_PATH)
 479     AC_MSG_RESULT([$MSYS_ROOT_PATH])
 480     WINDOWS_ENV_ROOT_PATH="$MSYS_ROOT_PATH"
 481   elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.wsl"; then
 482     AC_MSG_CHECKING([Windows version])
 483     # m4 replaces [ and ] so we use @<:@ and @:>@ instead
 484     WINDOWS_VERSION=`$CMD /c ver.exe | $EGREP -o '(@<:@0-9@:>@+\.)+@<:@0-9@:>@+'`
 485     AC_MSG_RESULT([$WINDOWS_VERSION])
 486 
 487     AC_MSG_CHECKING([WSL kernel version])
 488     WSL_KERNEL_VERSION=`$UNAME -v`
 489     AC_MSG_RESULT([$WSL_KERNEL_VERSION])
 490 
 491     AC_MSG_CHECKING([WSL kernel release])
 492     WSL_KERNEL_RELEASE=`$UNAME -r`
 493     AC_MSG_RESULT([$WSL_KERNEL_RELEASE])
 494 
 495     AC_MSG_CHECKING([WSL distribution])
 496     WSL_DISTRIBUTION=`$LSB_RELEASE -d | sed 's/Description:\t//'`
 497     AC_MSG_RESULT([$WSL_DISTRIBUTION])
 498 
 499     WINDOWS_ENV_VENDOR='WSL'
 500     WINDOWS_ENV_VERSION="$WSL_DISTRIBUTION $WSL_KERNEL_VERSION $WSL_KERNEL_RELEASE (on Windows build $WINDOWS_VERSION)"
 501   else
 502     AC_MSG_ERROR([Unknown Windows environment. Neither cygwin, msys, nor wsl was detected.])
 503   fi
 504 
 505   # Test if windows or unix (cygwin/msys) find is first in path.
 506   AC_MSG_CHECKING([what kind of 'find' is first on the PATH])
 507   FIND_BINARY_OUTPUT=`find --version 2>&1`
 508   if test "x`echo $FIND_BINARY_OUTPUT | $GREP GNU`" != x; then
 509     AC_MSG_RESULT([unix style])
 510   elif test "x`echo $FIND_BINARY_OUTPUT | $GREP FIND`" != x; then
 511     AC_MSG_RESULT([Windows])
 512     AC_MSG_NOTICE([Your path contains Windows tools (C:\Windows\system32) before your unix (cygwin or msys) tools.])
 513     AC_MSG_NOTICE([This will not work. Please correct and make sure /usr/bin (or similar) is first in path.])
 514     AC_MSG_ERROR([Cannot continue])
 515   else
 516     AC_MSG_RESULT([unknown])
 517     AC_MSG_WARN([It seems that your find utility is non-standard.])
 518   fi
 519 ])
 520 
 521 AC_DEFUN_ONCE([BASIC_COMPILE_FIXPATH],
 522 [
 523   # When using cygwin or msys, we need a wrapper binary that renames
 524   # /cygdrive/c/ arguments into c:/ arguments and peeks into
 525   # @files and rewrites these too! This wrapper binary is
 526   # called fixpath.
 527   FIXPATH=
 528   if test "x$OPENJDK_BUILD_OS" = xwindows; then
 529     AC_MSG_CHECKING([if fixpath can be created])
 530     FIXPATH_SRC="$TOPDIR/make/src/native/fixpath.c"
 531     FIXPATH_BIN="$CONFIGURESUPPORT_OUTPUTDIR/bin/fixpath.exe"
 532     FIXPATH_DIR="$CONFIGURESUPPORT_OUTPUTDIR/fixpath"
 533     if test "x$OPENJDK_BUILD_OS_ENV" = xwindows.cygwin; then
 534       # Important to keep the .exe suffix on Cygwin for Hotspot makefiles
 535       FIXPATH="$FIXPATH_BIN -c"
 536     elif test "x$OPENJDK_BUILD_OS_ENV" = xwindows.msys; then
 537       # Take all collected prefixes and turn them into a -m/c/foo@/c/bar@... command line
 538       # @ was chosen as separator to minimize risk of other tools messing around with it
 539       all_unique_prefixes=`echo "${all_fixpath_prefixes@<:@@@:>@}" \
 540           | tr ' ' '\n' | $GREP '^/./' | $SORT | $UNIQ`
 541       fixpath_argument_list=`echo $all_unique_prefixes  | tr ' ' '@'`
 542       FIXPATH="$FIXPATH_BIN -m$fixpath_argument_list"
 543     elif test "x$OPENJDK_BUILD_OS_ENV" = xwindows.wsl; then
 544       FIXPATH="$FIXPATH_BIN -w"
 545     fi
 546     FIXPATH_SRC_W="$FIXPATH_SRC"
 547     FIXPATH_BIN_W="$FIXPATH_BIN"
 548     BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH([FIXPATH_SRC_W])
 549     BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH([FIXPATH_BIN_W])
 550     $RM -rf $FIXPATH_BIN $FIXPATH_DIR
 551     $MKDIR -p $FIXPATH_DIR $CONFIGURESUPPORT_OUTPUTDIR/bin
 552     cd $FIXPATH_DIR
 553     $CC $FIXPATH_SRC_W -Fe$FIXPATH_BIN_W > $FIXPATH_DIR/fixpath1.log 2>&1
 554     cd $CONFIGURE_START_DIR
 555 
 556     if test ! -x $FIXPATH_BIN; then
 557       AC_MSG_RESULT([no])
 558       cat $FIXPATH_DIR/fixpath1.log
 559       AC_MSG_ERROR([Could not create $FIXPATH_BIN])
 560     fi
 561     AC_MSG_RESULT([yes])
 562 
 563     if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.wsl"; then
 564       OLD_WSLENV="$WSLENV"
 565       WSLENV=`$ECHO $WSLENV | $SED 's/PATH\/l://'`
 566       BASIC_APPEND_TO_PATH(WSLENV, "FIXPATH_PATH")
 567       export WSLENV
 568       export FIXPATH_PATH=$VS_PATH_WINDOWS
 569       AC_MSG_NOTICE([FIXPATH_PATH is $FIXPATH_PATH])
 570       AC_MSG_NOTICE([Rewriting WSLENV from $OLD_WSLENV to $WSLENV])
 571     fi
 572 
 573     AC_MSG_CHECKING([if fixpath.exe works])
 574     cd $FIXPATH_DIR
 575     $FIXPATH $CC $FIXPATH_SRC -Fe$FIXPATH_DIR/fixpath2.exe \
 576         > $FIXPATH_DIR/fixpath2.log 2>&1
 577     cd $CONFIGURE_START_DIR
 578     if test ! -x $FIXPATH_DIR/fixpath2.exe; then
 579       AC_MSG_RESULT([no])
 580       cat $FIXPATH_DIR/fixpath2.log
 581       AC_MSG_ERROR([fixpath did not work!])
 582     fi
 583     AC_MSG_RESULT([yes])
 584 
 585     FIXPATH_DETACH_FLAG="--detach"
 586   fi
 587 
 588   AC_SUBST(FIXPATH)
 589   AC_SUBST(FIXPATH_DETACH_FLAG)
 590 ])


  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 AC_DEFUN([BASIC_WINDOWS_REWRITE_AS_UNIX_PATH],
  27 [
  28   windows_path="[$]$1"
  29   if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
  30     unix_path=`$CYGPATH -u "$windows_path"`
  31     $1="$unix_path"
  32   elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
  33     unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'`
  34     $1="$unix_path"







  35   fi
  36 ])
  37 
  38 AC_DEFUN([BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH],
  39 [
  40   unix_path="[$]$1"
  41   if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
  42     windows_path=`$CYGPATH -m "$unix_path"`
  43     $1="$windows_path"
  44   elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
  45     windows_path=`cmd //c echo $unix_path`
  46     $1="$windows_path"



  47   fi
  48 ])
  49 
  50 # Helper function which possibly converts a path using DOS-style short mode.
  51 # If so, the updated path is stored in $new_path.
  52 # $1: The path to check
  53 AC_DEFUN([BASIC_MAKE_WINDOWS_SPACE_SAFE_CYGWIN],
  54 [
  55   input_path="$1"
  56   # Check if we need to convert this using DOS-style short mode. If the path
  57   # contains just simple characters, use it. Otherwise (spaces, weird characters),
  58   # take no chances and rewrite it.
  59   # Note: m4 eats our [], so we need to use @<:@ and @:>@ instead.
  60   has_forbidden_chars=`$ECHO "$input_path" | $GREP @<:@^-._/a-zA-Z0-9@:>@`
  61   if test "x$has_forbidden_chars" != x; then
  62     # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \)
  63     shortmode_path=`$CYGPATH -s -m -a "$input_path"`
  64     path_after_shortmode=`$CYGPATH -u "$shortmode_path"`
  65     if test "x$path_after_shortmode" != "x$input_to_shortpath"; then
  66       # Going to short mode and back again did indeed matter. Since short mode is


  83   fi
  84 ])
  85 
  86 # Helper function which possibly converts a path using DOS-style short mode.
  87 # If so, the updated path is stored in $new_path.
  88 # $1: The path to check
  89 AC_DEFUN([BASIC_MAKE_WINDOWS_SPACE_SAFE_MSYS],
  90 [
  91   input_path="$1"
  92   # Check if we need to convert this using DOS-style short mode. If the path
  93   # contains just simple characters, use it. Otherwise (spaces, weird characters),
  94   # take no chances and rewrite it.
  95   # Note: m4 eats our [], so we need to use @<:@ and @:>@ instead.
  96   has_forbidden_chars=`$ECHO "$input_path" | $GREP @<:@^-_/:a-zA-Z0-9@:>@`
  97   if test "x$has_forbidden_chars" != x; then
  98     # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \)
  99     new_path=`cmd /c "for %A in (\"$input_path\") do @echo %~sA"|$TR \\\\\\\\ / | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
 100   fi
 101 ])
 102 

























 103 # FIXME: The BASIC_FIXUP_*_CYGWIN/MSYS is most likely too convoluted
 104 # and could probably be heavily simplified. However, all changes in this
 105 # area tend to need lot of testing in different scenarios, and in lack of
 106 # proper unit testing, cleaning this up has not been deemed worth the effort
 107 # at the moment.
 108 
 109 AC_DEFUN([BASIC_FIXUP_PATH_CYGWIN],
 110 [
 111   # Input might be given as Windows format, start by converting to
 112   # unix format.
 113   path="[$]$1"
 114   new_path=`$CYGPATH -u "$path"`
 115 
 116   # Cygwin tries to hide some aspects of the Windows file system, such that binaries are
 117   # named .exe but called without that suffix. Therefore, "foo" and "foo.exe" are considered
 118   # the same file, most of the time (as in "test -f"). But not when running cygpath -s, then
 119   # "foo.exe" is OK but "foo" is an error.
 120   #
 121   # This test is therefore slightly more accurate than "test -f" to check for file precense.
 122   # It is also a way to make sure we got the proper file name for the real test later on.


 140 [
 141   path="[$]$1"
 142   has_colon=`$ECHO $path | $GREP ^.:`
 143   new_path="$path"
 144   if test "x$has_colon" = x; then
 145     # Not in mixed or Windows style, start by that.
 146     new_path=`cmd //c echo $path`
 147   fi
 148 
 149   BASIC_MAKE_WINDOWS_SPACE_SAFE_MSYS([$new_path])
 150   BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(new_path)
 151   if test "x$path" != "x$new_path"; then
 152     $1="$new_path"
 153     AC_MSG_NOTICE([Rewriting $1 to "$new_path"])
 154   fi
 155 
 156   # Save the first 10 bytes of this path to the storage, so fixpath can work.
 157   all_fixpath_prefixes=("${all_fixpath_prefixes@<:@@@:>@}" "${new_path:0:10}")
 158 ])
 159 

















 160 AC_DEFUN([BASIC_FIXUP_EXECUTABLE_CYGWIN],
 161 [
 162   # First separate the path from the arguments. This will split at the first
 163   # space.
 164   complete="[$]$1"
 165   path="${complete%% *}"
 166   tmp="$complete EOL"
 167   arguments="${tmp#* }"
 168 
 169   # Input might be given as Windows format, start by converting to
 170   # unix format.
 171   new_path=`$CYGPATH -u "$path"`
 172 
 173   # Now try to locate executable using which
 174   new_path=`$WHICH "$new_path" 2> /dev/null`
 175   # bat and cmd files are not always considered executable in cygwin causing which
 176   # to not find them
 177   if test "x$new_path" = x \
 178       && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \
 179       && test "x`$LS \"$path\" 2>/dev/null`" != x; then


 288 
 289   # Now new_path has a complete unix path to the binary
 290   if test "x`$ECHO $new_path | $GREP ^/bin/`" != x; then
 291     # Keep paths in /bin as-is, but remove trailing .exe if any
 292     new_path="${new_path/%.exe/}"
 293     # Do not save /bin paths to all_fixpath_prefixes!
 294   else
 295     # Not in mixed or Windows style, start by that.
 296     new_path=`cmd //c echo $new_path`
 297     BASIC_MAKE_WINDOWS_SPACE_SAFE_MSYS([$new_path])
 298     # Output is in $new_path
 299     BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(new_path)
 300     # remove trailing .exe if any
 301     new_path="${new_path/%.exe/}"
 302 
 303     # Save the first 10 bytes of this path to the storage, so fixpath can work.
 304     all_fixpath_prefixes=("${all_fixpath_prefixes@<:@@@:>@}" "${new_path:0:10}")
 305   fi
 306 ])
 307 









































































 308 # Setup basic configuration paths, and platform-specific stuff related to PATHs.
 309 AC_DEFUN([BASIC_CHECK_PATHS_WINDOWS],
 310 [
 311   SRC_ROOT_LENGTH=`$THEPWDCMD -L|$WC -m`
 312   if test $SRC_ROOT_LENGTH -gt 100; then
 313     AC_MSG_ERROR([Your base path is too long. It is $SRC_ROOT_LENGTH characters long, but only 100 is supported])
 314   fi
 315 
 316   if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
 317     AC_MSG_CHECKING([cygwin release])
 318     CYGWIN_VERSION=`$UNAME -r`
 319     AC_MSG_RESULT([$CYGWIN_VERSION])
 320     WINDOWS_ENV_VENDOR='cygwin'
 321     WINDOWS_ENV_VERSION="$CYGWIN_VERSION"
 322 
 323     CYGWIN_VERSION_OLD=`$ECHO $CYGWIN_VERSION | $GREP -e '^1\.[0-6]'`
 324     if test "x$CYGWIN_VERSION_OLD" != x; then
 325       AC_MSG_NOTICE([Your cygwin is too old. You are running $CYGWIN_VERSION, but at least cygwin 1.7 is required. Please upgrade.])
 326       AC_MSG_ERROR([Cannot continue])
 327     fi


 336     AC_MSG_RESULT([$CYGWIN_ROOT_PATH])
 337     WINDOWS_ENV_ROOT_PATH="$CYGWIN_ROOT_PATH"
 338     test_cygdrive_prefix=`$ECHO $CYGWIN_ROOT_PATH | $GREP ^/cygdrive/`
 339     if test "x$test_cygdrive_prefix" = x; then
 340       AC_MSG_ERROR([Your cygdrive prefix is not /cygdrive. This is currently not supported. Change with mount -c.])
 341     fi
 342   elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
 343     AC_MSG_CHECKING([msys release])
 344     MSYS_VERSION=`$UNAME -r`
 345     AC_MSG_RESULT([$MSYS_VERSION])
 346 
 347     WINDOWS_ENV_VENDOR='msys'
 348     WINDOWS_ENV_VERSION="$MSYS_VERSION"
 349 
 350     AC_MSG_CHECKING([msys root directory as unix-style path])
 351     # The cmd output ends with Windows line endings (CR/LF), the grep command will strip that away
 352     MSYS_ROOT_PATH=`cd / ; cmd /c cd | $GREP ".*"`
 353     BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(MSYS_ROOT_PATH)
 354     AC_MSG_RESULT([$MSYS_ROOT_PATH])
 355     WINDOWS_ENV_ROOT_PATH="$MSYS_ROOT_PATH"




















 356   else
 357     AC_MSG_ERROR([Unknown Windows environment. Neither cygwin nor msys was detected.])
 358   fi
 359 
 360   # Test if windows or unix (cygwin/msys) find is first in path.
 361   AC_MSG_CHECKING([what kind of 'find' is first on the PATH])
 362   FIND_BINARY_OUTPUT=`find --version 2>&1`
 363   if test "x`echo $FIND_BINARY_OUTPUT | $GREP GNU`" != x; then
 364     AC_MSG_RESULT([unix style])
 365   elif test "x`echo $FIND_BINARY_OUTPUT | $GREP FIND`" != x; then
 366     AC_MSG_RESULT([Windows])
 367     AC_MSG_NOTICE([Your path contains Windows tools (C:\Windows\system32) before your unix (cygwin or msys) tools.])
 368     AC_MSG_NOTICE([This will not work. Please correct and make sure /usr/bin (or similar) is first in path.])
 369     AC_MSG_ERROR([Cannot continue])
 370   else
 371     AC_MSG_RESULT([unknown])
 372     AC_MSG_WARN([It seems that your find utility is non-standard.])
 373   fi
 374 ])
 375 
 376 AC_DEFUN_ONCE([BASIC_COMPILE_FIXPATH],
 377 [
 378   # When using cygwin or msys, we need a wrapper binary that renames
 379   # /cygdrive/c/ arguments into c:/ arguments and peeks into
 380   # @files and rewrites these too! This wrapper binary is
 381   # called fixpath.
 382   FIXPATH=
 383   if test "x$OPENJDK_BUILD_OS" = xwindows; then
 384     AC_MSG_CHECKING([if fixpath can be created])
 385     FIXPATH_SRC="$TOPDIR/make/src/native/fixpath.c"
 386     FIXPATH_BIN="$CONFIGURESUPPORT_OUTPUTDIR/bin/fixpath.exe"
 387     FIXPATH_DIR="$CONFIGURESUPPORT_OUTPUTDIR/fixpath"
 388     if test "x$OPENJDK_BUILD_OS_ENV" = xwindows.cygwin; then
 389       # Important to keep the .exe suffix on Cygwin for Hotspot makefiles
 390       FIXPATH="$FIXPATH_BIN -c"
 391     elif test "x$OPENJDK_BUILD_OS_ENV" = xwindows.msys; then
 392       # Take all collected prefixes and turn them into a -m/c/foo@/c/bar@... command line
 393       # @ was chosen as separator to minimize risk of other tools messing around with it
 394       all_unique_prefixes=`echo "${all_fixpath_prefixes@<:@@@:>@}" \
 395           | tr ' ' '\n' | $GREP '^/./' | $SORT | $UNIQ`
 396       fixpath_argument_list=`echo $all_unique_prefixes  | tr ' ' '@'`
 397       FIXPATH="$FIXPATH_BIN -m$fixpath_argument_list"


 398     fi
 399     FIXPATH_SRC_W="$FIXPATH_SRC"
 400     FIXPATH_BIN_W="$FIXPATH_BIN"
 401     BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH([FIXPATH_SRC_W])
 402     BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH([FIXPATH_BIN_W])
 403     $RM -rf $FIXPATH_BIN $FIXPATH_DIR
 404     $MKDIR -p $FIXPATH_DIR $CONFIGURESUPPORT_OUTPUTDIR/bin
 405     cd $FIXPATH_DIR
 406     $CC $FIXPATH_SRC_W -Fe$FIXPATH_BIN_W > $FIXPATH_DIR/fixpath1.log 2>&1
 407     cd $CURDIR
 408 
 409     if test ! -x $FIXPATH_BIN; then
 410       AC_MSG_RESULT([no])
 411       cat $FIXPATH_DIR/fixpath1.log
 412       AC_MSG_ERROR([Could not create $FIXPATH_BIN])
 413     fi
 414     AC_MSG_RESULT([yes])











 415     AC_MSG_CHECKING([if fixpath.exe works])
 416     cd $FIXPATH_DIR
 417     $FIXPATH $CC $FIXPATH_SRC -Fe$FIXPATH_DIR/fixpath2.exe \
 418         > $FIXPATH_DIR/fixpath2.log 2>&1
 419     cd $CURDIR
 420     if test ! -x $FIXPATH_DIR/fixpath2.exe; then
 421       AC_MSG_RESULT([no])
 422       cat $FIXPATH_DIR/fixpath2.log
 423       AC_MSG_ERROR([fixpath did not work!])
 424     fi
 425     AC_MSG_RESULT([yes])
 426 
 427     FIXPATH_DETACH_FLAG="--detach"
 428   fi
 429 
 430   AC_SUBST(FIXPATH)
 431   AC_SUBST(FIXPATH_DETACH_FLAG)
 432 ])
< prev index next >