common/autoconf/basics.m4

changeset 494
e64f2cb57d05
parent 478
2ba6f4da4bf3
child 495
e3182741ade2
     1.1 --- a/common/autoconf/basics.m4	Wed Oct 24 13:11:42 2012 -0700
     1.2 +++ b/common/autoconf/basics.m4	Fri Oct 26 14:29:57 2012 -0700
     1.3 @@ -34,84 +34,102 @@
     1.4      fi
     1.5  ])
     1.6  
     1.7 -AC_DEFUN([SET_FULL_PATH],
     1.8 +# This will make sure the given variable points to a full and proper
     1.9 +# path. This means:
    1.10 +# 1) There will be no spaces in the path. On posix platforms,
    1.11 +#    spaces in the path will result in an error. On Windows,
    1.12 +#    the path will be rewritten using short-style to be space-free.
    1.13 +# 2) The path will be absolute, and it will be in unix-style (on
    1.14 +#     cygwin).
    1.15 +# $1: The name of the variable to fix
    1.16 +AC_DEFUN([BASIC_FIXUP_PATH],
    1.17  [
    1.18 -    # Translate "gcc -E" into "`which gcc` -E" ie
    1.19 -    # extract the full path to the binary and at the
    1.20 -    # same time maintain any arguments passed to it.
    1.21 -    # The command MUST exist in the path, or else!
    1.22 -    tmp="[$]$1"
    1.23 -    car="${tmp%% *}"
    1.24 -    tmp="[$]$1 EOL"
    1.25 -    cdr="${tmp#* }"
    1.26 -    # On windows we want paths without spaces.
    1.27 -    if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
    1.28 -        SET_FULL_PATH_SPACESAFE(car)
    1.29 -    else
    1.30 -        # "which" is not portable, but is used here
    1.31 -        # because we know that the command exists!
    1.32 -        car=`which $car`
    1.33 +  if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
    1.34 +    BASIC_FIXUP_PATH_CYGWIN($1)
    1.35 +  elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
    1.36 +    BASIC_FIXUP_PATH_MSYS($1)
    1.37 +  else
    1.38 +    # We're on a posix platform. Hooray! :)
    1.39 +    path="[$]$1"
    1.40 +    
    1.41 +    if test ! -f "$path" && test ! -d "$path"; then
    1.42 +      AC_MSG_ERROR([The path of $1, which resolves as "$path", is not found.])
    1.43      fi
    1.44 -    if test "x$cdr" != xEOL; then
    1.45 -        $1="$car ${cdr% *}"
    1.46 -    else
    1.47 -        $1="$car"
    1.48 +
    1.49 +    has_space=`$ECHO "$path" | $GREP " "`
    1.50 +    if test "x$has_space" != x; then
    1.51 +      AC_MSG_NOTICE([The path of $1, which resolves as "$path", is invalid.])
    1.52 +      AC_MSG_ERROR([Spaces are not allowed in this path.])
    1.53      fi
    1.54 +  fi
    1.55  ])
    1.56  
    1.57 -AC_DEFUN([SPACESAFE],
    1.58 +# This will make sure the given variable points to a executable
    1.59 +# with a full and proper path. This means:
    1.60 +# 1) There will be no spaces in the path. On posix platforms,
    1.61 +#    spaces in the path will result in an error. On Windows,
    1.62 +#    the path will be rewritten using short-style to be space-free.
    1.63 +# 2) The path will be absolute, and it will be in unix-style (on
    1.64 +#     cygwin).
    1.65 +# Any arguments given to the executable is preserved.
    1.66 +# If the input variable does not have a directory specification, then
    1.67 +# it need to be in the PATH.
    1.68 +# $1: The name of the variable to fix
    1.69 +AC_DEFUN([BASIC_FIXUP_EXECUTABLE],
    1.70  [
    1.71 -    # Fail with message $2 if var $1 contains a path with no spaces in it.
    1.72 -    # Unless on Windows, where we can rewrite the path.
    1.73 -    HAS_SPACE=`echo "[$]$1" | grep " "`
    1.74 -    if test "x$HAS_SPACE" != x; then
    1.75 -        if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
    1.76 -            # First convert it to DOS-style, short mode (no spaces)
    1.77 -            $1=`$CYGPATH -s -m -a "[$]$1"`
    1.78 -            # Now it's case insensitive; let's make it lowercase to improve readability
    1.79 -            $1=`$ECHO "[$]$1" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvqxyz'`
    1.80 -            # Now convert it back to Unix-stile (cygpath)
    1.81 -            $1=`$CYGPATH -u "[$]$1"`
    1.82 -        else
    1.83 -            AC_MSG_ERROR([You cannot have spaces in $2! "[$]$1"])
    1.84 +  if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
    1.85 +    BASIC_FIXUP_EXECUTABLE_CYGWIN($1)
    1.86 +  elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
    1.87 +    BASIC_FIXUP_EXECUTABLE_MSYS($1)
    1.88 +  else
    1.89 +    # We're on a posix platform. Hooray! :)
    1.90 +    # First separate the path from the arguments. This will split at the first
    1.91 +    # space.
    1.92 +    complete="[$]$1"
    1.93 +    path="${complete%% *}"
    1.94 +    tmp="$complete EOL"
    1.95 +    arguments="${tmp#* }"
    1.96 +
    1.97 +    new_path=`$WHICH $path 2> /dev/null`
    1.98 +    if test "x$new_path" = x; then
    1.99 +      is_absolute_path=`$ECHO "$path" | $GREP ^/`
   1.100 +      if test "x$is_absolute_path" != x; then
   1.101 +        AC_MSG_NOTICE([Resolving $1 (as $path) with 'which' failed, using $path directly.])
   1.102 +        new_path="$path"
   1.103 +      else
   1.104 +        AC_MSG_NOTICE([The path of $1, which resolves as "$complete", is not found.])
   1.105 +        has_space=`$ECHO "$complete" | $GREP " "`
   1.106 +        if test "x$has_space" != x; then
   1.107 +          AC_MSG_NOTICE([This might be caused by spaces in the path, which is not allowed.])
   1.108          fi
   1.109 +        AC_MSG_ERROR([Cannot locate the the path of $1])
   1.110 +      fi
   1.111      fi
   1.112 +  fi
   1.113 +
   1.114 +  # Now join together the path and the arguments once again
   1.115 +  if test "x$arguments" != xEOL; then
   1.116 +      new_complete="$new_path ${arguments% *}"
   1.117 +  else
   1.118 +      new_complete="$new_path"
   1.119 +  fi
   1.120 +
   1.121 +  if test "x$complete" != "x$new_complete"; then
   1.122 +    $1="$new_complete"
   1.123 +    AC_MSG_NOTICE([Rewriting $1 to "$new_complete"])
   1.124 +  fi
   1.125  ])
   1.126  
   1.127 -AC_DEFUN([SET_FULL_PATH_SPACESAFE],
   1.128 -[
   1.129 -    # Translate long cygdrive or C:\sdfsf path
   1.130 -    # into a short mixed mode path that has no
   1.131 -    # spaces in it.
   1.132 -    tmp="[$]$1"
   1.133 -    
   1.134 -    if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
   1.135 -        tmp=`$CYGPATH -u "[$]$1"`
   1.136 -        tmp=`which "$tmp"`
   1.137 -        # If file exists with .exe appended, that's the real filename
   1.138 -        # and cygpath needs that to convert to short style path.
   1.139 -        if test -f "${tmp}.exe"; then
   1.140 -           tmp="${tmp}.exe"
   1.141 -        elif test -f "${tmp}.cmd"; then
   1.142 -           tmp="${tmp}.cmd"
   1.143 -        fi
   1.144 -        # Convert to C:/ mixed style path without spaces.
   1.145 -         tmp=`$CYGPATH -s -m "$tmp"`
   1.146 -    fi
   1.147 -    $1="$tmp"
   1.148 -])
   1.149 -
   1.150 -AC_DEFUN([REMOVE_SYMBOLIC_LINKS],
   1.151 +AC_DEFUN([BASIC_REMOVE_SYMBOLIC_LINKS],
   1.152  [
   1.153      if test "x$OPENJDK_BUILD_OS" != xwindows; then
   1.154          # Follow a chain of symbolic links. Use readlink
   1.155          # where it exists, else fall back to horribly
   1.156          # complicated shell code.
   1.157 -        AC_PATH_PROG(READLINK, readlink)
   1.158          if test "x$READLINK_TESTED" != yes; then
   1.159              # On MacOSX there is a readlink tool with a different
   1.160              # purpose than the GNU readlink tool. Check the found readlink.
   1.161 -            ISGNU=`$READLINK --help 2>&1 | grep GNU`
   1.162 +            ISGNU=`$READLINK --help 2>&1 | $GREP GNU`
   1.163              if test "x$ISGNU" = x; then
   1.164                   # A readlink that we do not know how to use.
   1.165                   # Are there other non-GNU readlinks out there?
   1.166 @@ -125,23 +143,25 @@
   1.167          else
   1.168              STARTDIR=$PWD
   1.169              COUNTER=0
   1.170 -            DIR=`dirname [$]$1`
   1.171 -            FIL=`basename [$]$1`
   1.172 +            DIR=`$DIRNAME [$]$1`
   1.173 +            FILE=`$BASENAME [$]$1`
   1.174              while test $COUNTER -lt 20; do
   1.175 -                ISLINK=`ls -l $DIR/$FIL | grep '\->' | sed -e 's/.*-> \(.*\)/\1/'`
   1.176 +                ISLINK=`$LS -l $DIR/$FILE | $GREP '\->' | $SED -e 's/.*-> \(.*\)/\1/'`
   1.177                  if test "x$ISLINK" == x; then
   1.178                      # This is not a symbolic link! We are done!
   1.179                      break
   1.180                  fi
   1.181                  # The link might be relative! We have to use cd to travel safely.
   1.182                  cd $DIR
   1.183 -                cd `dirname $ISLINK`
   1.184 -                DIR=`pwd`
   1.185 -                FIL=`basename $ISLINK`
   1.186 +                # ... and we must get the to the absolute path, not one using symbolic links.             
   1.187 +                cd `pwd -P`
   1.188 +                cd `$DIRNAME $ISLINK`
   1.189 +                DIR=`$THEPWDCMD`
   1.190 +                FILE=`$BASENAME $ISLINK`
   1.191                  let COUNTER=COUNTER+1
   1.192              done
   1.193              cd $STARTDIR
   1.194 -            $1=$DIR/$FIL
   1.195 +            $1=$DIR/$FILE
   1.196          fi
   1.197      fi
   1.198  ])
   1.199 @@ -152,6 +172,107 @@
   1.200  AC_SUBST(CONFIGURE_COMMAND_LINE)
   1.201  DATE_WHEN_CONFIGURED=`LANG=C date`
   1.202  AC_SUBST(DATE_WHEN_CONFIGURED)
   1.203 +AC_MSG_NOTICE([Configuration created at $DATE_WHEN_CONFIGURED.])
   1.204 +AC_MSG_NOTICE([configure script generated at timestamp $DATE_WHEN_GENERATED.])
   1.205 +])
   1.206 +
   1.207 +# Test that variable $1 denoting a program is not empty. If empty, exit with an error.
   1.208 +# $1: variable to check
   1.209 +# $2: executable name to print in warning (optional)
   1.210 +AC_DEFUN([BASIC_CHECK_NONEMPTY],
   1.211 +[
   1.212 +    if test "x[$]$1" = x; then
   1.213 +        if test "x$2" = x; then
   1.214 +          PROG_NAME=translit($1,A-Z,a-z)
   1.215 +        else
   1.216 +          PROG_NAME=$2
   1.217 +        fi
   1.218 +        AC_MSG_NOTICE([Could not find $PROG_NAME!])
   1.219 +        AC_MSG_ERROR([Cannot continue])
   1.220 +    fi
   1.221 +])
   1.222 +
   1.223 +# Does AC_PATH_PROG followed by BASIC_CHECK_NONEMPTY.
   1.224 +# Arguments as AC_PATH_PROG:
   1.225 +# $1: variable to set
   1.226 +# $2: executable name to look for
   1.227 +AC_DEFUN([BASIC_REQUIRE_PROG],
   1.228 +[
   1.229 +    AC_PATH_PROGS($1, $2)
   1.230 +    BASIC_CHECK_NONEMPTY($1, $2)
   1.231 +])
   1.232 +
   1.233 +# Setup the most fundamental tools that relies on not much else to set up,
   1.234 +# but is used by much of the early bootstrap code.
   1.235 +AC_DEFUN_ONCE([BASIC_SETUP_FUNDAMENTAL_TOOLS],
   1.236 +[
   1.237 +
   1.238 +# Start with tools that do not need have cross compilation support
   1.239 +# and can be expected to be found in the default PATH. These tools are
   1.240 +# used by configure. Nor are these tools expected to be found in the
   1.241 +# devkit from the builddeps server either, since they are
   1.242 +# needed to download the devkit.
   1.243 +
   1.244 +# First are all the simple required tools.
   1.245 +BASIC_REQUIRE_PROG(BASENAME, basename)
   1.246 +BASIC_REQUIRE_PROG(BASH, bash)
   1.247 +BASIC_REQUIRE_PROG(CAT, cat)
   1.248 +BASIC_REQUIRE_PROG(CHMOD, chmod)
   1.249 +BASIC_REQUIRE_PROG(CMP, cmp)
   1.250 +BASIC_REQUIRE_PROG(CP, cp)
   1.251 +BASIC_REQUIRE_PROG(CUT, cut)
   1.252 +BASIC_REQUIRE_PROG(DATE, date)
   1.253 +BASIC_REQUIRE_PROG(DIFF, [gdiff diff])
   1.254 +BASIC_REQUIRE_PROG(DIRNAME, dirname)
   1.255 +BASIC_REQUIRE_PROG(ECHO, echo)
   1.256 +BASIC_REQUIRE_PROG(EXPR, expr)
   1.257 +BASIC_REQUIRE_PROG(FILE, file)
   1.258 +BASIC_REQUIRE_PROG(FIND, find)
   1.259 +BASIC_REQUIRE_PROG(HEAD, head)
   1.260 +BASIC_REQUIRE_PROG(LN, ln)
   1.261 +BASIC_REQUIRE_PROG(LS, ls)
   1.262 +BASIC_REQUIRE_PROG(MKDIR, mkdir)
   1.263 +BASIC_REQUIRE_PROG(MKTEMP, mktemp)
   1.264 +BASIC_REQUIRE_PROG(MV, mv)
   1.265 +BASIC_REQUIRE_PROG(PRINTF, printf)
   1.266 +BASIC_REQUIRE_PROG(THEPWDCMD, pwd)
   1.267 +BASIC_REQUIRE_PROG(RM, rm)
   1.268 +BASIC_REQUIRE_PROG(SH, sh)
   1.269 +BASIC_REQUIRE_PROG(SORT, sort)
   1.270 +BASIC_REQUIRE_PROG(TAIL, tail)
   1.271 +BASIC_REQUIRE_PROG(TAR, tar)
   1.272 +BASIC_REQUIRE_PROG(TEE, tee)
   1.273 +BASIC_REQUIRE_PROG(TOUCH, touch)
   1.274 +BASIC_REQUIRE_PROG(TR, tr)
   1.275 +BASIC_REQUIRE_PROG(UNAME, uname)
   1.276 +BASIC_REQUIRE_PROG(UNIQ, uniq)
   1.277 +BASIC_REQUIRE_PROG(WC, wc)
   1.278 +BASIC_REQUIRE_PROG(WHICH, which)
   1.279 +BASIC_REQUIRE_PROG(XARGS, xargs)
   1.280 +
   1.281 +# Then required tools that require some special treatment.
   1.282 +AC_PROG_AWK
   1.283 +BASIC_CHECK_NONEMPTY(AWK)
   1.284 +AC_PROG_GREP
   1.285 +BASIC_CHECK_NONEMPTY(GREP)
   1.286 +AC_PROG_EGREP
   1.287 +BASIC_CHECK_NONEMPTY(EGREP)
   1.288 +AC_PROG_FGREP
   1.289 +BASIC_CHECK_NONEMPTY(FGREP)
   1.290 +AC_PROG_SED
   1.291 +BASIC_CHECK_NONEMPTY(SED)
   1.292 +
   1.293 +AC_PATH_PROGS(NAWK, [nawk gawk awk])
   1.294 +BASIC_CHECK_NONEMPTY(NAWK)
   1.295 +
   1.296 +# Always force rm.
   1.297 +RM="$RM -f"
   1.298 +
   1.299 +# These are not required on all platforms
   1.300 +AC_PATH_PROG(CYGPATH, cygpath)
   1.301 +AC_PATH_PROG(READLINK, readlink)
   1.302 +AC_PATH_PROG(DF, df)
   1.303 +AC_PATH_PROG(SETFILE, SetFile)
   1.304  ])
   1.305  
   1.306  # Setup basic configuration paths, and platform-specific stuff related to PATHs.
   1.307 @@ -159,46 +280,37 @@
   1.308  [
   1.309  # Locate the directory of this script.
   1.310  SCRIPT="[$]0"
   1.311 -REMOVE_SYMBOLIC_LINKS(SCRIPT)
   1.312 -AUTOCONF_DIR=`dirname [$]0`
   1.313 +BASIC_REMOVE_SYMBOLIC_LINKS(SCRIPT)
   1.314 +AUTOCONF_DIR=`cd \`$DIRNAME $SCRIPT\`; $THEPWDCMD`
   1.315  
   1.316  # Where is the source? It is located two levels above the configure script.
   1.317  CURDIR="$PWD"
   1.318  cd "$AUTOCONF_DIR/../.."
   1.319  SRC_ROOT="`pwd`"
   1.320 -if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
   1.321 -    SRC_ROOT_LENGTH=`pwd|wc -m`
   1.322 -    if test $SRC_ROOT_LENGTH -gt 100; then
   1.323 -        AC_MSG_ERROR([Your base path is too long. It is $SRC_ROOT_LENGTH characters long, but only 100 is supported])
   1.324 -    fi
   1.325 +
   1.326 +if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
   1.327 +  PATH_SEP=";"
   1.328 +  BASIC_CHECK_PATHS_WINDOWS
   1.329 +else
   1.330 +  PATH_SEP=":"
   1.331  fi
   1.332 +
   1.333  AC_SUBST(SRC_ROOT)
   1.334 +AC_SUBST(PATH_SEP)
   1.335  cd "$CURDIR"
   1.336  
   1.337 -SPACESAFE(SRC_ROOT,[the path to the source root])
   1.338 -SPACESAFE(CURDIR,[the path to the current directory])
   1.339 +BASIC_FIXUP_PATH(SRC_ROOT)
   1.340 +BASIC_FIXUP_PATH(CURDIR)
   1.341  
   1.342  if test "x$OPENJDK_BUILD_OS" = "xsolaris"; then
   1.343      # Add extra search paths on solaris for utilities like ar and as etc...
   1.344      PATH="$PATH:/usr/ccs/bin:/usr/sfw/bin:/opt/csw/bin"
   1.345  fi
   1.346  
   1.347 -# For cygwin we need cygpath first, since it is used everywhere.
   1.348 -AC_PATH_PROG(CYGPATH, cygpath)
   1.349 -PATH_SEP=":"
   1.350 -if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
   1.351 -    if test "x$CYGPATH" = x; then
   1.352 -        AC_MSG_ERROR([Something is wrong with your cygwin installation since I cannot find cygpath.exe in your path])
   1.353 -    fi
   1.354 -    PATH_SEP=";"
   1.355 -fi
   1.356 -AC_SUBST(PATH_SEP)
   1.357 -
   1.358  # You can force the sys-root if the sys-root encoded into the cross compiler tools
   1.359  # is not correct.
   1.360  AC_ARG_WITH(sys-root, [AS_HELP_STRING([--with-sys-root],
   1.361 -  [pass this sys-root to the compilers and linker (useful if the sys-root encoded in
   1.362 -   the cross compiler tools is incorrect)])])
   1.363 +  [pass this sys-root to the compilers and tools (for cross-compiling)])])
   1.364  
   1.365  if test "x$with_sys_root" != x; then
   1.366    SYS_ROOT=$with_sys_root
   1.367 @@ -208,7 +320,7 @@
   1.368  AC_SUBST(SYS_ROOT)
   1.369  
   1.370  AC_ARG_WITH([tools-dir], [AS_HELP_STRING([--with-tools-dir],
   1.371 -  [search this directory for (cross-compiling) compilers and tools])], [TOOLS_DIR=$with_tools_dir])
   1.372 +  [search this directory for compilers and tools (for cross-compiling)])], [TOOLS_DIR=$with_tools_dir])
   1.373  
   1.374  AC_ARG_WITH([devkit], [AS_HELP_STRING([--with-devkit],
   1.375    [use this directory as base for tools-dir and sys-root (for cross-compiling)])],
   1.376 @@ -228,8 +340,9 @@
   1.377  AC_DEFUN_ONCE([BASIC_SETUP_OUTPUT_DIR],
   1.378  [
   1.379  
   1.380 +AC_MSG_CHECKING([what configuration name to use])
   1.381  AC_ARG_WITH(conf-name, [AS_HELP_STRING([--with-conf-name],
   1.382 -	[use this as the name of the configuration, overriding the generated default])],
   1.383 +	[use this as the name of the configuration @<:@generated from important configuration options@:>@])],
   1.384          [ CONF_NAME=${with_conf_name} ])
   1.385  
   1.386  # Test from where we are running configure, in or outside of src root.
   1.387 @@ -240,7 +353,7 @@
   1.388          CONF_NAME="${OPENJDK_TARGET_OS}-${OPENJDK_TARGET_CPU}-${JDK_VARIANT}-${ANDED_JVM_VARIANTS}-${DEBUG_LEVEL}"
   1.389      fi
   1.390      OUTPUT_ROOT="$SRC_ROOT/build/${CONF_NAME}"
   1.391 -    mkdir -p "$OUTPUT_ROOT"
   1.392 +    $MKDIR -p "$OUTPUT_ROOT"
   1.393      if test ! -d "$OUTPUT_ROOT"; then
   1.394          AC_MSG_ERROR([Could not create build directory $OUTPUT_ROOT])
   1.395      fi
   1.396 @@ -254,8 +367,9 @@
   1.397      fi
   1.398      OUTPUT_ROOT="$CURDIR"
   1.399  fi
   1.400 +AC_MSG_RESULT([$CONF_NAME])
   1.401  
   1.402 -SPACESAFE(OUTPUT_ROOT,[the path to the output root])
   1.403 +BASIC_FIXUP_PATH(OUTPUT_ROOT)
   1.404  
   1.405  AC_SUBST(SPEC, $OUTPUT_ROOT/spec.gmk)
   1.406  AC_SUBST(CONF_NAME, $CONF_NAME)
   1.407 @@ -287,7 +401,7 @@
   1.408  # Setup default logging of stdout and stderr to build.log in the output root.
   1.409  BUILD_LOG='$(OUTPUT_ROOT)/build.log'
   1.410  BUILD_LOG_PREVIOUS='$(OUTPUT_ROOT)/build.log.old'
   1.411 -BUILD_LOG_WRAPPER='$(SH) $(SRC_ROOT)/common/bin/logger.sh $(BUILD_LOG)'
   1.412 +BUILD_LOG_WRAPPER='$(BASH) $(SRC_ROOT)/common/bin/logger.sh $(BUILD_LOG)'
   1.413  AC_SUBST(BUILD_LOG)
   1.414  AC_SUBST(BUILD_LOG_PREVIOUS)
   1.415  AC_SUBST(BUILD_LOG_WRAPPER)
   1.416 @@ -305,7 +419,6 @@
   1.417    DESCRIPTION="$2"
   1.418    if test "x$MAKE_CANDIDATE" != x; then
   1.419      AC_MSG_NOTICE([Testing potential make at $MAKE_CANDIDATE, found using $DESCRIPTION])
   1.420 -    SET_FULL_PATH(MAKE_CANDIDATE)
   1.421      MAKE_VERSION_STRING=`$MAKE_CANDIDATE --version | $HEAD -n 1`
   1.422      IS_GNU_MAKE=`$ECHO $MAKE_VERSION_STRING | $GREP 'GNU Make'`
   1.423      if test "x$IS_GNU_MAKE" = x; then
   1.424 @@ -314,8 +427,27 @@
   1.425        IS_MODERN_MAKE=`$ECHO $MAKE_VERSION_STRING | $GREP '3.8[[12346789]]'`
   1.426        if test "x$IS_MODERN_MAKE" = x; then
   1.427          AC_MSG_NOTICE([Found GNU make at $MAKE_CANDIDATE, however this is not version 3.81 or later. (it is: $MAKE_VERSION_STRING). Ignoring.])
   1.428 -      else 
   1.429 -        FOUND_MAKE=$MAKE_CANDIDATE
   1.430 +      else
   1.431 +        if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
   1.432 +          if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
   1.433 +            MAKE_EXPECTED_ENV='cygwin'
   1.434 +          elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
   1.435 +            MAKE_EXPECTED_ENV='msys'
   1.436 +          else
   1.437 +            AC_MSG_ERROR([Unknown Windows environment])
   1.438 +          fi
   1.439 +          MAKE_BUILT_FOR=`$MAKE_CANDIDATE --version | $GREP -i 'built for'`
   1.440 +          IS_MAKE_CORRECT_ENV=`$ECHO $MAKE_BUILT_FOR | $GREP $MAKE_EXPECTED_ENV`
   1.441 +        else
   1.442 +          # Not relevant for non-Windows
   1.443 +          IS_MAKE_CORRECT_ENV=true
   1.444 +        fi
   1.445 +        if test "x$IS_MAKE_CORRECT_ENV" = x; then
   1.446 +          AC_MSG_NOTICE([Found GNU make version $MAKE_VERSION_STRING at $MAKE_CANDIDATE, but it is not for $MAKE_EXPECTED_ENV (it says: $MAKE_BUILT_FOR). Ignoring.])
   1.447 +        else
   1.448 +          FOUND_MAKE=$MAKE_CANDIDATE
   1.449 +          BASIC_FIXUP_EXECUTABLE(FOUND_MAKE)
   1.450 +        fi
   1.451        fi
   1.452      fi
   1.453    fi
   1.454 @@ -330,7 +462,7 @@
   1.455      if test ! -f "$MAKE"; then
   1.456        AC_MSG_ERROR([The specified make (by MAKE=$MAKE) is not found.])
   1.457      fi
   1.458 -    BASIC_CHECK_MAKE_VERSION("$MAKE", [user supplied MAKE=])
   1.459 +    BASIC_CHECK_MAKE_VERSION("$MAKE", [user supplied MAKE=$MAKE])
   1.460      if test "x$FOUND_MAKE" = x; then
   1.461        AC_MSG_ERROR([The specified make (by MAKE=$MAKE) is not GNU make 3.81 or newer.])
   1.462      fi
   1.463 @@ -375,7 +507,7 @@
   1.464      AC_MSG_CHECKING([if find supports -delete])
   1.465      FIND_DELETE="-delete"
   1.466  
   1.467 -    DELETEDIR=`mktemp -d tmp.XXXXXXXXXX` || (echo Could not create temporary directory!; exit $?)
   1.468 +    DELETEDIR=`$MKTEMP -d tmp.XXXXXXXXXX` || (echo Could not create temporary directory!; exit $?)
   1.469  
   1.470      echo Hejsan > $DELETEDIR/TestIfFindSupportsDelete
   1.471  
   1.472 @@ -389,102 +521,22 @@
   1.473          AC_MSG_RESULT([yes])    
   1.474      fi
   1.475      rmdir $DELETEDIR
   1.476 +    AC_SUBST(FIND_DELETE)
   1.477  ])
   1.478  
   1.479 -# Test that variable $1 denoting a program is not empty. If empty, exit with an error.
   1.480 -# $1: variable to check
   1.481 -# $2: executable name to print in warning (optional)
   1.482 -AC_DEFUN([CHECK_NONEMPTY],
   1.483 +AC_DEFUN_ONCE([BASIC_SETUP_COMPLEX_TOOLS],
   1.484  [
   1.485 -    if test "x[$]$1" = x; then
   1.486 -        if test "x$2" = x; then
   1.487 -          PROG_NAME=translit($1,A-Z,a-z)
   1.488 -        else
   1.489 -          PROG_NAME=$2
   1.490 -        fi
   1.491 -        AC_MSG_NOTICE([Could not find $PROG_NAME!])
   1.492 -        AC_MSG_ERROR([Cannot continue])
   1.493 -    fi
   1.494 -])
   1.495 -
   1.496 -# Does AC_PATH_PROG followed by CHECK_NONEMPTY.
   1.497 -# Arguments as AC_PATH_PROG:
   1.498 -# $1: variable to set
   1.499 -# $2: executable name to look for
   1.500 -AC_DEFUN([BASIC_REQUIRE_PROG],
   1.501 -[
   1.502 -    AC_PATH_PROGS($1, $2)
   1.503 -    CHECK_NONEMPTY($1, $2)
   1.504 -])
   1.505 -
   1.506 -AC_DEFUN_ONCE([BASIC_SETUP_TOOLS],
   1.507 -[
   1.508 -# Start with tools that do not need have cross compilation support
   1.509 -# and can be expected to be found in the default PATH. These tools are
   1.510 -# used by configure. Nor are these tools expected to be found in the
   1.511 -# devkit from the builddeps server either, since they are
   1.512 -# needed to download the devkit.
   1.513 -
   1.514 -# First are all the simple required tools.
   1.515 -BASIC_REQUIRE_PROG(BASENAME, basename)
   1.516 -BASIC_REQUIRE_PROG(CAT, cat)
   1.517 -BASIC_REQUIRE_PROG(CHMOD, chmod)
   1.518 -BASIC_REQUIRE_PROG(CMP, cmp)
   1.519 -BASIC_REQUIRE_PROG(CP, cp)
   1.520 -BASIC_REQUIRE_PROG(CPIO, cpio)
   1.521 -BASIC_REQUIRE_PROG(CUT, cut)
   1.522 -BASIC_REQUIRE_PROG(DATE, date)
   1.523 -BASIC_REQUIRE_PROG(DF, df)
   1.524 -BASIC_REQUIRE_PROG(DIFF, [gdiff diff])
   1.525 -BASIC_REQUIRE_PROG(ECHO, echo)
   1.526 -BASIC_REQUIRE_PROG(EXPR, expr)
   1.527 -BASIC_REQUIRE_PROG(FILE, file)
   1.528 -BASIC_REQUIRE_PROG(FIND, find)
   1.529 -BASIC_REQUIRE_PROG(HEAD, head)
   1.530 -BASIC_REQUIRE_PROG(LN, ln)
   1.531 -BASIC_REQUIRE_PROG(LS, ls)
   1.532 -BASIC_REQUIRE_PROG(MKDIR, mkdir)
   1.533 -BASIC_REQUIRE_PROG(MV, mv)
   1.534 -BASIC_REQUIRE_PROG(PRINTF, printf)
   1.535 -BASIC_REQUIRE_PROG(SH, sh)
   1.536 -BASIC_REQUIRE_PROG(SORT, sort)
   1.537 -BASIC_REQUIRE_PROG(TAIL, tail)
   1.538 -BASIC_REQUIRE_PROG(TAR, tar)
   1.539 -BASIC_REQUIRE_PROG(TEE, tee)
   1.540 -BASIC_REQUIRE_PROG(TOUCH, touch)
   1.541 -BASIC_REQUIRE_PROG(TR, tr)
   1.542 -BASIC_REQUIRE_PROG(UNIQ, uniq)
   1.543 -BASIC_REQUIRE_PROG(UNZIP, unzip)
   1.544 -BASIC_REQUIRE_PROG(WC, wc)
   1.545 -BASIC_REQUIRE_PROG(XARGS, xargs)
   1.546 -BASIC_REQUIRE_PROG(ZIP, zip)
   1.547 -
   1.548 -# Then required tools that require some special treatment.
   1.549 -AC_PROG_AWK
   1.550 -CHECK_NONEMPTY(AWK)
   1.551 -AC_PROG_GREP
   1.552 -CHECK_NONEMPTY(GREP)
   1.553 -AC_PROG_EGREP
   1.554 -CHECK_NONEMPTY(EGREP)
   1.555 -AC_PROG_FGREP
   1.556 -CHECK_NONEMPTY(FGREP)
   1.557 -AC_PROG_SED
   1.558 -CHECK_NONEMPTY(SED)
   1.559 -
   1.560 -AC_PATH_PROGS(NAWK, [nawk gawk awk])
   1.561 -CHECK_NONEMPTY(NAWK)
   1.562 -
   1.563  BASIC_CHECK_GNU_MAKE
   1.564  
   1.565 -BASIC_REQUIRE_PROG(RM, rm)
   1.566 -RM="$RM -f"
   1.567 +BASIC_CHECK_FIND_DELETE
   1.568  
   1.569 -BASIC_CHECK_FIND_DELETE
   1.570 -AC_SUBST(FIND_DELETE)
   1.571 +# These tools might not be installed by default, 
   1.572 +# need hint on how to install them.
   1.573 +BASIC_REQUIRE_PROG(UNZIP, unzip)
   1.574 +BASIC_REQUIRE_PROG(ZIP, zip)
   1.575  
   1.576  # Non-required basic tools
   1.577  
   1.578 -AC_PATH_PROG(THEPWDCMD, pwd)
   1.579  AC_PATH_PROG(LDD, ldd)
   1.580  if test "x$LDD" = "x"; then
   1.581      # List shared lib dependencies is used for
   1.582 @@ -497,52 +549,17 @@
   1.583     OTOOL="true"
   1.584  fi
   1.585  AC_PATH_PROGS(READELF, [readelf greadelf])
   1.586 -AC_PATH_PROGS(OBJDUMP, [objdump gobjdump])
   1.587  AC_PATH_PROG(HG, hg)
   1.588 +AC_PATH_PROG(STAT, stat)
   1.589 +AC_PATH_PROG(TIME, time)
   1.590 +
   1.591 +if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
   1.592 +  BASIC_REQUIRE_PROG(COMM, comm)
   1.593 +fi
   1.594  ])
   1.595  
   1.596 -AC_DEFUN_ONCE([BASIC_COMPILE_UNCYGDRIVE],
   1.597 -[
   1.598 -# When using cygwin, we need a wrapper binary that renames
   1.599 -# /cygdrive/c/ arguments into c:/ arguments and peeks into
   1.600 -# @files and rewrites these too! This wrapper binary is
   1.601 -# called uncygdrive.exe.
   1.602 -UNCYGDRIVE=
   1.603 -if test "x$OPENJDK_BUILD_OS" = xwindows; then
   1.604 -    AC_MSG_CHECKING([if uncygdrive can be created])
   1.605 -    UNCYGDRIVE_SRC=`$CYGPATH -m $SRC_ROOT/common/src/uncygdrive.c`
   1.606 -    rm -f $OUTPUT_ROOT/uncygdrive*
   1.607 -    UNCYGDRIVE=`$CYGPATH -m $OUTPUT_ROOT/uncygdrive.exe`
   1.608 -    cd $OUTPUT_ROOT
   1.609 -    $CC $UNCYGDRIVE_SRC /Fe$UNCYGDRIVE > $OUTPUT_ROOT/uncygdrive1.log 2>&1
   1.610 -    cd $CURDIR
   1.611 -
   1.612 -    if test ! -x $OUTPUT_ROOT/uncygdrive.exe; then 
   1.613 -        AC_MSG_RESULT([no])
   1.614 -        cat $OUTPUT_ROOT/uncygdrive1.log
   1.615 -        AC_MSG_ERROR([Could not create $OUTPUT_ROOT/uncygdrive.exe])
   1.616 -    fi
   1.617 -    AC_MSG_RESULT([$UNCYGDRIVE])
   1.618 -    AC_MSG_CHECKING([if uncygdrive.exe works])
   1.619 -    cd $OUTPUT_ROOT
   1.620 -    $UNCYGDRIVE $CC $SRC_ROOT/common/src/uncygdrive.c /Fe$OUTPUT_ROOT/uncygdrive2.exe > $OUTPUT_ROOT/uncygdrive2.log 2>&1 
   1.621 -    cd $CURDIR
   1.622 -    if test ! -x $OUTPUT_ROOT/uncygdrive2.exe; then 
   1.623 -        AC_MSG_RESULT([no])
   1.624 -        cat $OUTPUT_ROOT/uncygdrive2.log
   1.625 -        AC_MSG_ERROR([Uncygdrive did not work!])
   1.626 -    fi
   1.627 -    AC_MSG_RESULT([yes])
   1.628 -    rm -f $OUTPUT_ROOT/uncygdrive?.??? $OUTPUT_ROOT/uncygdrive.obj
   1.629 -    # The path to uncygdrive to use should be Unix-style
   1.630 -    UNCYGDRIVE="$OUTPUT_ROOT/uncygdrive.exe"
   1.631 -fi
   1.632 -
   1.633 -AC_SUBST(UNCYGDRIVE)
   1.634 -])
   1.635 -
   1.636 -
   1.637 -# Check if build directory is on local disk.
   1.638 +# Check if build directory is on local disk. If not possible to determine,
   1.639 +# we prefer to claim it's local.
   1.640  # Argument 1: directory to test
   1.641  # Argument 2: what to do if it is on local disk
   1.642  # Argument 3: what to do otherwise (remote disk or failure)
   1.643 @@ -550,11 +567,26 @@
   1.644  [
   1.645  	# df -l lists only local disks; if the given directory is not found then
   1.646  	# a non-zero exit code is given
   1.647 -	if $DF -l $1 > /dev/null 2>&1; then
   1.648 -          $2
   1.649 -        else
   1.650 -          $3
   1.651 -        fi
   1.652 +  if test "x$DF" = x; then
   1.653 +    if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
   1.654 +      # msys does not have df; use Windows "net use" instead.
   1.655 +      IS_NETWORK_DISK=`net use | grep \`pwd -W | cut -d ":" -f 1 | tr a-z A-Z\`:`
   1.656 +      if test "x$IS_NETWORK_DISK" = x; then
   1.657 +        $2
   1.658 +      else
   1.659 +        $3
   1.660 +      fi
   1.661 +    else
   1.662 +      # No df here, say it's local
   1.663 +      $2
   1.664 +    fi
   1.665 +  else
   1.666 +    if $DF -l $1 > /dev/null 2>&1; then
   1.667 +      $2
   1.668 +    else
   1.669 +      $3
   1.670 +    fi
   1.671 +  fi
   1.672  ])
   1.673  
   1.674  AC_DEFUN_ONCE([BASIC_TEST_USABILITY_ISSUES],

mercurial