1 #
   2 # Copyright (c) 2011, 2020, 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 #
  25 
  26 # Setup basic configuration paths, and platform-specific stuff related to PATHs.
  27 AC_DEFUN([BASIC_CHECK_PATHS_WINDOWS],
  28 [
  29   SRC_ROOT_LENGTH=`$THEPWDCMD -L|$WC -m`
  30   if test $SRC_ROOT_LENGTH -gt 100; then
  31     AC_MSG_ERROR([Your base path is too long. It is $SRC_ROOT_LENGTH characters long, but only 100 is supported])
  32   fi
  33 
  34   AC_MSG_CHECKING([Windows version])
  35   # Additional [] needed to keep m4 from mangling shell constructs.
  36   [ WINDOWS_VERSION=`$CMD /c ver.exe | $EGREP -o '([0-9]+\.)+[0-9]+'` ]
  37   AC_MSG_RESULT([$WINDOWS_VERSION])
  38 
  39   if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
  40     AC_MSG_CHECKING([cygwin release])
  41     CYGWIN_RELEASE=`$UNAME -r`
  42     AC_MSG_RESULT([$CYGWIN_RELEASE])
  43 
  44     AC_MSG_CHECKING([cygwin version])
  45     CYGWIN_VERSION=`$UNAME -v`
  46     AC_MSG_RESULT([$CYGWIN_VERSION])
  47 
  48     # Additional [] needed to keep m4 from mangling shell constructs.
  49     [ CYGWIN_VERSION_OLD=`$ECHO $CYGWIN_RELEASE | $GREP -e '^1\.[0-6]'` ]
  50     if test "x$CYGWIN_VERSION_OLD" != x; then
  51       AC_MSG_NOTICE([Your cygwin is too old. You are running $CYGWIN_RELEASE, but at least cygwin 1.7 is required. Please upgrade.])
  52       AC_MSG_ERROR([Cannot continue])
  53     fi
  54 
  55     WINDOWS_ENV_VENDOR='cygwin'
  56     WINDOWS_ENV_VERSION="$CYGWIN_RELEASE, $CYGWIN_VERSION"
  57 
  58     if test "x$CYGPATH" = x; then
  59       AC_MSG_ERROR([Something is wrong with your cygwin installation since I cannot find cygpath.exe in your path])
  60     fi
  61     AC_MSG_CHECKING([cygwin root directory as unix-style path])
  62     # The cmd output ends with Windows line endings (CR/LF)
  63     cygwin_winpath_root=`cd / ; cmd /c cd | $TR -d '\r\n'`
  64     # Force cygpath to report the proper root by including a trailing space, and then stripping it off again.
  65     CYGWIN_ROOT_PATH=`$CYGPATH -u "$cygwin_winpath_root " | $CUT -f 1 -d " "`
  66     AC_MSG_RESULT([$CYGWIN_ROOT_PATH])
  67     WINDOWS_ENV_ROOT_PATH="$CYGWIN_ROOT_PATH"
  68     test_cygdrive_prefix=`$ECHO $CYGWIN_ROOT_PATH | $GREP ^/cygdrive/`
  69     if test "x$test_cygdrive_prefix" = x; then
  70       AC_MSG_ERROR([Your cygdrive prefix is not /cygdrive. This is currently not supported. Change with mount -c.])
  71     fi
  72   elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
  73     AC_MSG_CHECKING([msys release])
  74     MSYS_RELEASE=`$UNAME -r`
  75     AC_MSG_RESULT([$MSYS_RELEASE])
  76 
  77     AC_MSG_CHECKING([msys version])
  78     MSYS_VERSION=`$UNAME -v`
  79     AC_MSG_RESULT([$MSYS_VERSION])
  80 
  81     WINDOWS_ENV_VENDOR='msys'
  82     WINDOWS_ENV_VERSION="$MSYS_RELEASE, $MSYS_VERSION"
  83 
  84     AC_MSG_CHECKING([msys root directory as unix-style path])
  85     # The cmd output ends with Windows line endings (CR/LF), the grep command will strip that away
  86     MSYS_ROOT_PATH=`cd / ; cmd /c cd | $GREP ".*"`
  87     UTIL_REWRITE_AS_UNIX_PATH(MSYS_ROOT_PATH)
  88     AC_MSG_RESULT([$MSYS_ROOT_PATH])
  89     WINDOWS_ENV_ROOT_PATH="$MSYS_ROOT_PATH"
  90   elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.wsl"; then
  91 
  92     AC_MSG_CHECKING([WSL kernel version])
  93     WSL_KERNEL_VERSION=`$UNAME -v`
  94     AC_MSG_RESULT([$WSL_KERNEL_VERSION])
  95 
  96     AC_MSG_CHECKING([WSL kernel release])
  97     WSL_KERNEL_RELEASE=`$UNAME -r`
  98     AC_MSG_RESULT([$WSL_KERNEL_RELEASE])
  99 
 100     AC_MSG_CHECKING([WSL distribution])
 101     WSL_DISTRIBUTION=`$LSB_RELEASE -d | sed 's/Description:\t//'`
 102     AC_MSG_RESULT([$WSL_DISTRIBUTION])
 103 
 104     WINDOWS_ENV_VENDOR='wsl'
 105     WINDOWS_ENV_VERSION="$WSL_KERNEL_RELEASE, $WSL_KERNEL_VERSION ($WSL_DISTRIBUTION)"
 106   else
 107     AC_MSG_ERROR([Unknown Windows environment. Neither cygwin, msys, nor wsl was detected.])
 108   fi
 109 
 110   # Test if windows or unix (cygwin/msys) find is first in path.
 111   AC_MSG_CHECKING([what kind of 'find' is first on the PATH])
 112   FIND_BINARY_OUTPUT=`find --version 2>&1`
 113   if test "x`echo $FIND_BINARY_OUTPUT | $GREP GNU`" != x; then
 114     AC_MSG_RESULT([unix style])
 115   elif test "x`echo $FIND_BINARY_OUTPUT | $GREP FIND`" != x; then
 116     AC_MSG_RESULT([Windows])
 117     AC_MSG_NOTICE([Your path contains Windows tools (C:\Windows\system32) before your unix (cygwin or msys) tools.])
 118     AC_MSG_NOTICE([This will not work. Please correct and make sure /usr/bin (or similar) is first in path.])
 119     AC_MSG_ERROR([Cannot continue])
 120   else
 121     AC_MSG_RESULT([unknown])
 122     AC_MSG_WARN([It seems that your find utility is non-standard.])
 123   fi
 124 ])
 125 
 126 AC_DEFUN_ONCE([BASIC_COMPILE_FIXPATH],
 127 [
 128   # When using cygwin or msys, we need a wrapper binary that renames
 129   # /cygdrive/c/ arguments into c:/ arguments and peeks into
 130   # @files and rewrites these too! This wrapper binary is
 131   # called fixpath.
 132   FIXPATH=
 133   if test "x$OPENJDK_BUILD_OS" = xwindows; then
 134     AC_MSG_CHECKING([if fixpath can be created])
 135     FIXPATH_SRC="$TOPDIR/make/src/native/fixpath.c"
 136     FIXPATH_BIN="$CONFIGURESUPPORT_OUTPUTDIR/bin/fixpath.exe"
 137     FIXPATH_DIR="$CONFIGURESUPPORT_OUTPUTDIR/fixpath"
 138     if test "x$OPENJDK_BUILD_OS_ENV" = xwindows.cygwin; then
 139       # Important to keep the .exe suffix on Cygwin for Hotspot makefiles
 140       FIXPATH="$FIXPATH_BIN -c"
 141     elif test "x$OPENJDK_BUILD_OS_ENV" = xwindows.msys; then
 142       # Take all collected prefixes and turn them into a -m/c/foo@/c/bar@... command line
 143       # @ was chosen as separator to minimize risk of other tools messing around with it
 144       all_unique_prefixes=`echo "${all_fixpath_prefixes@<:@@@:>@}" \
 145           | tr ' ' '\n' | $GREP '^/./' | $SORT | $UNIQ`
 146       fixpath_argument_list=`echo $all_unique_prefixes  | tr ' ' '@'`
 147       FIXPATH="$FIXPATH_BIN -m$fixpath_argument_list"
 148     elif test "x$OPENJDK_BUILD_OS_ENV" = xwindows.wsl; then
 149       FIXPATH="$FIXPATH_BIN -w"
 150     fi
 151     $RM -rf $FIXPATH_BIN $FIXPATH_DIR
 152     $MKDIR -p $FIXPATH_DIR $CONFIGURESUPPORT_OUTPUTDIR/bin
 153     FIXPATH_SRC_W="$FIXPATH_SRC"
 154     FIXPATH_BIN_W="$FIXPATH_BIN"
 155     UTIL_REWRITE_AS_WINDOWS_MIXED_PATH([FIXPATH_SRC_W])
 156     UTIL_REWRITE_AS_WINDOWS_MIXED_PATH([FIXPATH_BIN_W])
 157     cd $FIXPATH_DIR
 158     $CC $FIXPATH_SRC_W -Fe$FIXPATH_BIN_W > $FIXPATH_DIR/fixpath1.log 2>&1
 159     cd $CONFIGURE_START_DIR
 160 
 161     if test ! -x $FIXPATH_BIN; then
 162       AC_MSG_RESULT([no])
 163       cat $FIXPATH_DIR/fixpath1.log
 164       AC_MSG_ERROR([Could not create $FIXPATH_BIN])
 165     fi
 166     AC_MSG_RESULT([yes])
 167 
 168     if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.wsl"; then
 169       OLD_WSLENV="$WSLENV"
 170       WSLENV=`$ECHO $WSLENV | $SED 's/PATH\/l://'`
 171       UTIL_APPEND_TO_PATH(WSLENV, "FIXPATH_PATH")
 172       export WSLENV
 173       export FIXPATH_PATH=$VS_PATH_WINDOWS
 174       AC_MSG_NOTICE([FIXPATH_PATH is $FIXPATH_PATH])
 175       AC_MSG_NOTICE([Rewriting WSLENV from $OLD_WSLENV to $WSLENV])
 176     fi
 177 
 178     AC_MSG_CHECKING([if fixpath.exe works])
 179     cd $FIXPATH_DIR
 180     $FIXPATH $CC $FIXPATH_SRC -Fe$FIXPATH_DIR/fixpath2.exe \
 181         > $FIXPATH_DIR/fixpath2.log 2>&1
 182     cd $CONFIGURE_START_DIR
 183     if test ! -x $FIXPATH_DIR/fixpath2.exe; then
 184       AC_MSG_RESULT([no])
 185       cat $FIXPATH_DIR/fixpath2.log
 186       AC_MSG_ERROR([fixpath did not work!])
 187     fi
 188     AC_MSG_RESULT([yes])
 189 
 190     FIXPATH_DETACH_FLAG="--detach"
 191   fi
 192 
 193   AC_SUBST(FIXPATH)
 194   AC_SUBST(FIXPATH_DETACH_FLAG)
 195 ])