common/autoconf/basics.m4

changeset 0
75a576e87639
child 1133
50aaf272884f
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/common/autoconf/basics.m4	Wed Apr 27 01:39:08 2016 +0800
     1.3 @@ -0,0 +1,749 @@
     1.4 +#
     1.5 +# Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
     1.6 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 +#
     1.8 +# This code is free software; you can redistribute it and/or modify it
     1.9 +# under the terms of the GNU General Public License version 2 only, as
    1.10 +# published by the Free Software Foundation.  Oracle designates this
    1.11 +# particular file as subject to the "Classpath" exception as provided
    1.12 +# by Oracle in the LICENSE file that accompanied this code.
    1.13 +#
    1.14 +# This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 +# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 +# version 2 for more details (a copy is included in the LICENSE file that
    1.18 +# accompanied this code).
    1.19 +#
    1.20 +# You should have received a copy of the GNU General Public License version
    1.21 +# 2 along with this work; if not, write to the Free Software Foundation,
    1.22 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 +#
    1.24 +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.25 +# or visit www.oracle.com if you need additional information or have any
    1.26 +# questions.
    1.27 +#
    1.28 +
    1.29 +# Test if $1 is a valid argument to $3 (often is $JAVA passed as $3)
    1.30 +# If so, then append $1 to $2 \
    1.31 +# Also set JVM_ARG_OK to true/false depending on outcome.
    1.32 +AC_DEFUN([ADD_JVM_ARG_IF_OK],
    1.33 +[
    1.34 +  $ECHO "Check if jvm arg is ok: $1" >&AS_MESSAGE_LOG_FD
    1.35 +  $ECHO "Command: $3 $1 -version" >&AS_MESSAGE_LOG_FD
    1.36 +  OUTPUT=`$3 $1 -version 2>&1`
    1.37 +  FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn`
    1.38 +  FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""`
    1.39 +  if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
    1.40 +    $2="[$]$2 $1"
    1.41 +    JVM_ARG_OK=true
    1.42 +  else
    1.43 +    $ECHO "Arg failed:" >&AS_MESSAGE_LOG_FD
    1.44 +    $ECHO "$OUTPUT" >&AS_MESSAGE_LOG_FD
    1.45 +    JVM_ARG_OK=false
    1.46 +  fi
    1.47 +])
    1.48 +
    1.49 +# Appends a string to a path variable, only adding the : when needed.
    1.50 +AC_DEFUN([BASIC_APPEND_TO_PATH],
    1.51 +[
    1.52 +  if test "x[$]$1" = x; then
    1.53 +    $1="$2"
    1.54 +  else
    1.55 +    $1="[$]$1:$2"
    1.56 +  fi
    1.57 +])
    1.58 +
    1.59 +# This will make sure the given variable points to a full and proper
    1.60 +# path. This means:
    1.61 +# 1) There will be no spaces in the path. On posix platforms,
    1.62 +#    spaces in the path will result in an error. On Windows,
    1.63 +#    the path will be rewritten using short-style to be space-free.
    1.64 +# 2) The path will be absolute, and it will be in unix-style (on
    1.65 +#     cygwin).
    1.66 +# $1: The name of the variable to fix
    1.67 +AC_DEFUN([BASIC_FIXUP_PATH],
    1.68 +[
    1.69 +  if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
    1.70 +    BASIC_FIXUP_PATH_CYGWIN($1)
    1.71 +  elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
    1.72 +    BASIC_FIXUP_PATH_MSYS($1)
    1.73 +  else
    1.74 +    # We're on a posix platform. Hooray! :)
    1.75 +    path="[$]$1"
    1.76 +    has_space=`$ECHO "$path" | $GREP " "`
    1.77 +    if test "x$has_space" != x; then
    1.78 +      AC_MSG_NOTICE([The path of $1, which resolves as "$path", is invalid.])
    1.79 +      AC_MSG_ERROR([Spaces are not allowed in this path.])
    1.80 +    fi
    1.81 +
    1.82 +    # Use eval to expand a potential ~
    1.83 +    eval path="$path"
    1.84 +    if test ! -f "$path" && test ! -d "$path"; then
    1.85 +      AC_MSG_ERROR([The path of $1, which resolves as "$path", is not found.])
    1.86 +    fi
    1.87 +
    1.88 +    $1="`cd "$path"; $THEPWDCMD -L`"
    1.89 +  fi
    1.90 +])
    1.91 +
    1.92 +# This will make sure the given variable points to a executable
    1.93 +# with a full and proper path. This means:
    1.94 +# 1) There will be no spaces in the path. On posix platforms,
    1.95 +#    spaces in the path will result in an error. On Windows,
    1.96 +#    the path will be rewritten using short-style to be space-free.
    1.97 +# 2) The path will be absolute, and it will be in unix-style (on
    1.98 +#     cygwin).
    1.99 +# Any arguments given to the executable is preserved.
   1.100 +# If the input variable does not have a directory specification, then
   1.101 +# it need to be in the PATH.
   1.102 +# $1: The name of the variable to fix
   1.103 +AC_DEFUN([BASIC_FIXUP_EXECUTABLE],
   1.104 +[
   1.105 +  if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
   1.106 +    BASIC_FIXUP_EXECUTABLE_CYGWIN($1)
   1.107 +  elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
   1.108 +    BASIC_FIXUP_EXECUTABLE_MSYS($1)
   1.109 +  else
   1.110 +    # We're on a posix platform. Hooray! :)
   1.111 +    # First separate the path from the arguments. This will split at the first
   1.112 +    # space.
   1.113 +    complete="[$]$1"
   1.114 +    path="${complete%% *}"
   1.115 +    tmp="$complete EOL"
   1.116 +    arguments="${tmp#* }"
   1.117 +
   1.118 +    # Cannot rely on the command "which" here since it doesn't always work.
   1.119 +    is_absolute_path=`$ECHO "$path" | $GREP ^/`
   1.120 +    if test -z "$is_absolute_path"; then
   1.121 +      # Path to executable is not absolute. Find it.
   1.122 +      IFS_save="$IFS"
   1.123 +      IFS=:
   1.124 +      for p in $PATH; do
   1.125 +        if test -f "$p/$path" && test -x "$p/$path"; then
   1.126 +          new_path="$p/$path"
   1.127 +          break
   1.128 +        fi
   1.129 +      done
   1.130 +      IFS="$IFS_save"
   1.131 +    else
   1.132 +      AC_MSG_NOTICE([Resolving $1 (as $path) failed, using $path directly.])
   1.133 +      new_path="$path"
   1.134 +    fi
   1.135 +
   1.136 +    if test "x$new_path" = x; then
   1.137 +      AC_MSG_NOTICE([The path of $1, which resolves as "$complete", is not found.])
   1.138 +      has_space=`$ECHO "$complete" | $GREP " "`
   1.139 +      if test "x$has_space" != x; then
   1.140 +        AC_MSG_NOTICE([This might be caused by spaces in the path, which is not allowed.])
   1.141 +      fi
   1.142 +      AC_MSG_ERROR([Cannot locate the the path of $1])
   1.143 +    fi
   1.144 +  fi
   1.145 +
   1.146 +  # Now join together the path and the arguments once again
   1.147 +  if test "x$arguments" != xEOL; then
   1.148 +    new_complete="$new_path ${arguments% *}"
   1.149 +  else
   1.150 +    new_complete="$new_path"
   1.151 +  fi
   1.152 +
   1.153 +  if test "x$complete" != "x$new_complete"; then
   1.154 +    $1="$new_complete"
   1.155 +    AC_MSG_NOTICE([Rewriting $1 to "$new_complete"])
   1.156 +  fi
   1.157 +])
   1.158 +
   1.159 +AC_DEFUN([BASIC_REMOVE_SYMBOLIC_LINKS],
   1.160 +[
   1.161 +  if test "x$OPENJDK_BUILD_OS" != xwindows; then
   1.162 +    # Follow a chain of symbolic links. Use readlink
   1.163 +    # where it exists, else fall back to horribly
   1.164 +    # complicated shell code.
   1.165 +    if test "x$READLINK_TESTED" != yes; then
   1.166 +      # On MacOSX there is a readlink tool with a different
   1.167 +      # purpose than the GNU readlink tool. Check the found readlink.
   1.168 +      ISGNU=`$READLINK --version 2>&1 | $GREP GNU`
   1.169 +      if test "x$ISGNU" = x; then
   1.170 +        # A readlink that we do not know how to use.
   1.171 +        # Are there other non-GNU readlinks out there?
   1.172 +        READLINK_TESTED=yes
   1.173 +        READLINK=
   1.174 +      fi
   1.175 +    fi
   1.176 +
   1.177 +    if test "x$READLINK" != x; then
   1.178 +      $1=`$READLINK -f [$]$1`
   1.179 +    else
   1.180 +      # Save the current directory for restoring afterwards
   1.181 +      STARTDIR=$PWD
   1.182 +      COUNTER=0
   1.183 +      sym_link_dir=`$DIRNAME [$]$1`
   1.184 +      sym_link_file=`$BASENAME [$]$1`
   1.185 +      cd $sym_link_dir
   1.186 +      # Use -P flag to resolve symlinks in directories.
   1.187 +      cd `$THEPWDCMD -P`
   1.188 +      sym_link_dir=`$THEPWDCMD -P`
   1.189 +      # Resolve file symlinks
   1.190 +      while test $COUNTER -lt 20; do
   1.191 +        ISLINK=`$LS -l $sym_link_dir/$sym_link_file | $GREP '\->' | $SED -e 's/.*-> \(.*\)/\1/'`
   1.192 +        if test "x$ISLINK" == x; then
   1.193 +          # This is not a symbolic link! We are done!
   1.194 +          break
   1.195 +        fi
   1.196 +        # Again resolve directory symlinks since the target of the just found
   1.197 +        # link could be in a different directory
   1.198 +        cd `$DIRNAME $ISLINK`
   1.199 +        sym_link_dir=`$THEPWDCMD -P`
   1.200 +        sym_link_file=`$BASENAME $ISLINK`
   1.201 +        let COUNTER=COUNTER+1
   1.202 +      done
   1.203 +      cd $STARTDIR
   1.204 +      $1=$sym_link_dir/$sym_link_file
   1.205 +    fi
   1.206 +  fi
   1.207 +])
   1.208 +
   1.209 +# Register a --with argument but mark it as deprecated
   1.210 +# $1: The name of the with argument to deprecate, not including --with-
   1.211 +AC_DEFUN([BASIC_DEPRECATED_ARG_WITH],
   1.212 +[
   1.213 +  AC_ARG_WITH($1, [AS_HELP_STRING([--with-$1],
   1.214 +      [Deprecated. Option is kept for backwards compatibility and is ignored])],
   1.215 +      [AC_MSG_WARN([Option --with-$1 is deprecated and will be ignored.])])
   1.216 +])
   1.217 +
   1.218 +# Register a --enable argument but mark it as deprecated
   1.219 +# $1: The name of the with argument to deprecate, not including --enable-
   1.220 +# $2: The name of the argument to deprecate, in shell variable style (i.e. with _ instead of -)
   1.221 +AC_DEFUN([BASIC_DEPRECATED_ARG_ENABLE],
   1.222 +[
   1.223 +  AC_ARG_ENABLE($1, [AS_HELP_STRING([--enable-$1],
   1.224 +      [Deprecated. Option is kept for backwards compatibility and is ignored])])
   1.225 +  if test "x$enable_$2" != x; then
   1.226 +    AC_MSG_WARN([Option --enable-$1 is deprecated and will be ignored.])
   1.227 +  fi
   1.228 +])
   1.229 +
   1.230 +AC_DEFUN_ONCE([BASIC_INIT],
   1.231 +[
   1.232 +  # Save the original command line. This is passed to us by the wrapper configure script.
   1.233 +  AC_SUBST(CONFIGURE_COMMAND_LINE)
   1.234 +  DATE_WHEN_CONFIGURED=`LANG=C date`
   1.235 +  AC_SUBST(DATE_WHEN_CONFIGURED)
   1.236 +  AC_MSG_NOTICE([Configuration created at $DATE_WHEN_CONFIGURED.])
   1.237 +  AC_MSG_NOTICE([configure script generated at timestamp $DATE_WHEN_GENERATED.])
   1.238 +])
   1.239 +
   1.240 +# Test that variable $1 denoting a program is not empty. If empty, exit with an error.
   1.241 +# $1: variable to check
   1.242 +# $2: executable name to print in warning (optional)
   1.243 +AC_DEFUN([BASIC_CHECK_NONEMPTY],
   1.244 +[
   1.245 +  if test "x[$]$1" = x; then
   1.246 +    if test "x$2" = x; then
   1.247 +      PROG_NAME=translit($1,A-Z,a-z)
   1.248 +    else
   1.249 +      PROG_NAME=$2
   1.250 +    fi
   1.251 +    AC_MSG_NOTICE([Could not find $PROG_NAME!])
   1.252 +    AC_MSG_ERROR([Cannot continue])
   1.253 +  fi
   1.254 +])
   1.255 +
   1.256 +# Does AC_PATH_PROG followed by BASIC_CHECK_NONEMPTY.
   1.257 +# Arguments as AC_PATH_PROG:
   1.258 +# $1: variable to set
   1.259 +# $2: executable name to look for
   1.260 +AC_DEFUN([BASIC_REQUIRE_PROG],
   1.261 +[
   1.262 +  AC_PATH_PROGS($1, $2)
   1.263 +  BASIC_CHECK_NONEMPTY($1, $2)
   1.264 +])
   1.265 +
   1.266 +# Setup the most fundamental tools that relies on not much else to set up,
   1.267 +# but is used by much of the early bootstrap code.
   1.268 +AC_DEFUN_ONCE([BASIC_SETUP_FUNDAMENTAL_TOOLS],
   1.269 +[
   1.270 +
   1.271 +  # Start with tools that do not need have cross compilation support
   1.272 +  # and can be expected to be found in the default PATH. These tools are
   1.273 +  # used by configure. Nor are these tools expected to be found in the
   1.274 +  # devkit from the builddeps server either, since they are
   1.275 +  # needed to download the devkit.
   1.276 +
   1.277 +  # First are all the simple required tools.
   1.278 +  BASIC_REQUIRE_PROG(BASENAME, basename)
   1.279 +  BASIC_REQUIRE_PROG(BASH, bash)
   1.280 +  BASIC_REQUIRE_PROG(CAT, cat)
   1.281 +  BASIC_REQUIRE_PROG(CHMOD, chmod)
   1.282 +  BASIC_REQUIRE_PROG(CMP, cmp)
   1.283 +  BASIC_REQUIRE_PROG(COMM, comm)
   1.284 +  BASIC_REQUIRE_PROG(CP, cp)
   1.285 +  BASIC_REQUIRE_PROG(CPIO, cpio)
   1.286 +  BASIC_REQUIRE_PROG(CUT, cut)
   1.287 +  BASIC_REQUIRE_PROG(DATE, date)
   1.288 +  BASIC_REQUIRE_PROG(DIFF, [gdiff diff])
   1.289 +  BASIC_REQUIRE_PROG(DIRNAME, dirname)
   1.290 +  BASIC_REQUIRE_PROG(ECHO, echo)
   1.291 +  BASIC_REQUIRE_PROG(EXPR, expr)
   1.292 +  BASIC_REQUIRE_PROG(FILE, file)
   1.293 +  BASIC_REQUIRE_PROG(FIND, find)
   1.294 +  BASIC_REQUIRE_PROG(HEAD, head)
   1.295 +  BASIC_REQUIRE_PROG(LN, ln)
   1.296 +  BASIC_REQUIRE_PROG(LS, ls)
   1.297 +  BASIC_REQUIRE_PROG(MKDIR, mkdir)
   1.298 +  BASIC_REQUIRE_PROG(MKTEMP, mktemp)
   1.299 +  BASIC_REQUIRE_PROG(MV, mv)
   1.300 +  BASIC_REQUIRE_PROG(PRINTF, printf)
   1.301 +  BASIC_REQUIRE_PROG(RM, rm)
   1.302 +  BASIC_REQUIRE_PROG(SH, sh)
   1.303 +  BASIC_REQUIRE_PROG(SORT, sort)
   1.304 +  BASIC_REQUIRE_PROG(TAIL, tail)
   1.305 +  BASIC_REQUIRE_PROG(TAR, tar)
   1.306 +  BASIC_REQUIRE_PROG(TEE, tee)
   1.307 +  BASIC_REQUIRE_PROG(TOUCH, touch)
   1.308 +  BASIC_REQUIRE_PROG(TR, tr)
   1.309 +  BASIC_REQUIRE_PROG(UNAME, uname)
   1.310 +  BASIC_REQUIRE_PROG(UNIQ, uniq)
   1.311 +  BASIC_REQUIRE_PROG(WC, wc)
   1.312 +  BASIC_REQUIRE_PROG(WHICH, which)
   1.313 +  BASIC_REQUIRE_PROG(XARGS, xargs)
   1.314 +
   1.315 +  # Then required tools that require some special treatment.
   1.316 +  AC_PROG_AWK
   1.317 +  BASIC_CHECK_NONEMPTY(AWK)
   1.318 +  AC_PROG_GREP
   1.319 +  BASIC_CHECK_NONEMPTY(GREP)
   1.320 +  AC_PROG_EGREP
   1.321 +  BASIC_CHECK_NONEMPTY(EGREP)
   1.322 +  AC_PROG_FGREP
   1.323 +  BASIC_CHECK_NONEMPTY(FGREP)
   1.324 +  AC_PROG_SED
   1.325 +  BASIC_CHECK_NONEMPTY(SED)
   1.326 +
   1.327 +  AC_PATH_PROGS(NAWK, [nawk gawk awk])
   1.328 +  BASIC_CHECK_NONEMPTY(NAWK)
   1.329 +
   1.330 +  # Always force rm.
   1.331 +  RM="$RM -f"
   1.332 +
   1.333 +  # pwd behaves differently on various platforms and some don't support the -L flag.
   1.334 +  # Always use the bash builtin pwd to get uniform behavior.
   1.335 +  THEPWDCMD=pwd
   1.336 +
   1.337 +  # These are not required on all platforms
   1.338 +  AC_PATH_PROG(CYGPATH, cygpath)
   1.339 +  AC_PATH_PROG(READLINK, readlink)
   1.340 +  AC_PATH_PROG(DF, df)
   1.341 +  AC_PATH_PROG(SETFILE, SetFile)
   1.342 +])
   1.343 +
   1.344 +# Setup basic configuration paths, and platform-specific stuff related to PATHs.
   1.345 +AC_DEFUN_ONCE([BASIC_SETUP_PATHS],
   1.346 +[
   1.347 +  # Locate the directory of this script.
   1.348 +  SCRIPT="[$]0"
   1.349 +  AUTOCONF_DIR=`cd \`$DIRNAME $SCRIPT\`; $THEPWDCMD -L`
   1.350 +
   1.351 +  # Where is the source? It is located two levels above the configure script.
   1.352 +  CURDIR="$PWD"
   1.353 +  cd "$AUTOCONF_DIR/../.."
   1.354 +  SRC_ROOT="`$THEPWDCMD -L`"
   1.355 +
   1.356 +  if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
   1.357 +    PATH_SEP=";"
   1.358 +    BASIC_CHECK_PATHS_WINDOWS
   1.359 +  else
   1.360 +    PATH_SEP=":"
   1.361 +  fi
   1.362 +
   1.363 +  AC_SUBST(SRC_ROOT)
   1.364 +  AC_SUBST(PATH_SEP)
   1.365 +  cd "$CURDIR"
   1.366 +
   1.367 +  BASIC_FIXUP_PATH(SRC_ROOT)
   1.368 +  BASIC_FIXUP_PATH(CURDIR)
   1.369 +
   1.370 +  if test "x$OPENJDK_BUILD_OS" = "xsolaris"; then
   1.371 +    # Add extra search paths on solaris for utilities like ar and as etc...
   1.372 +    PATH="$PATH:/usr/ccs/bin:/usr/sfw/bin:/opt/csw/bin"
   1.373 +  fi
   1.374 +
   1.375 +  # You can force the sys-root if the sys-root encoded into the cross compiler tools
   1.376 +  # is not correct.
   1.377 +  AC_ARG_WITH(sys-root, [AS_HELP_STRING([--with-sys-root],
   1.378 +      [pass this sys-root to the compilers and tools (for cross-compiling)])])
   1.379 +
   1.380 +  if test "x$with_sys_root" != x; then
   1.381 +    SYS_ROOT=$with_sys_root
   1.382 +  else
   1.383 +    SYS_ROOT=/
   1.384 +  fi
   1.385 +  AC_SUBST(SYS_ROOT)
   1.386 +
   1.387 +  AC_ARG_WITH([tools-dir], [AS_HELP_STRING([--with-tools-dir],
   1.388 +      [search this directory for compilers and tools (for cross-compiling)])],
   1.389 +      [TOOLS_DIR=$with_tools_dir]
   1.390 +  )
   1.391 +
   1.392 +  AC_ARG_WITH([devkit], [AS_HELP_STRING([--with-devkit],
   1.393 +      [use this directory as base for tools-dir and sys-root (for cross-compiling)])],
   1.394 +      [
   1.395 +        if test "x$with_sys_root" != x; then
   1.396 +          AC_MSG_ERROR([Cannot specify both --with-devkit and --with-sys-root at the same time])
   1.397 +        fi
   1.398 +        BASIC_FIXUP_PATH([with_devkit])
   1.399 +        BASIC_APPEND_TO_PATH([TOOLS_DIR],$with_devkit/bin)
   1.400 +        if test -d "$with_devkit/$host_alias/libc"; then
   1.401 +          SYS_ROOT=$with_devkit/$host_alias/libc
   1.402 +        elif test -d "$with_devkit/$host/sys-root"; then
   1.403 +          SYS_ROOT=$with_devkit/$host/sys-root
   1.404 +        fi
   1.405 +      ])
   1.406 +])
   1.407 +
   1.408 +AC_DEFUN_ONCE([BASIC_SETUP_OUTPUT_DIR],
   1.409 +[
   1.410 +
   1.411 +  AC_ARG_WITH(conf-name, [AS_HELP_STRING([--with-conf-name],
   1.412 +      [use this as the name of the configuration @<:@generated from important configuration options@:>@])],
   1.413 +      [ CONF_NAME=${with_conf_name} ])
   1.414 +
   1.415 +  # Test from where we are running configure, in or outside of src root.
   1.416 +  if test "x$CURDIR" = "x$SRC_ROOT" || test "x$CURDIR" = "x$SRC_ROOT/common" \
   1.417 +      || test "x$CURDIR" = "x$SRC_ROOT/common/autoconf" \
   1.418 +      || test "x$CURDIR" = "x$SRC_ROOT/make" ; then
   1.419 +    # We are running configure from the src root.
   1.420 +    # Create a default ./build/target-variant-debuglevel output root.
   1.421 +    if test "x${CONF_NAME}" = x; then
   1.422 +      CONF_NAME="${OPENJDK_TARGET_OS}-${OPENJDK_TARGET_CPU}-${JDK_VARIANT}-${ANDED_JVM_VARIANTS}-${DEBUG_LEVEL}"
   1.423 +    fi
   1.424 +    OUTPUT_ROOT="$SRC_ROOT/build/${CONF_NAME}"
   1.425 +    $MKDIR -p "$OUTPUT_ROOT"
   1.426 +    if test ! -d "$OUTPUT_ROOT"; then
   1.427 +      AC_MSG_ERROR([Could not create build directory $OUTPUT_ROOT])
   1.428 +    fi
   1.429 +  else
   1.430 +    # We are running configure from outside of the src dir.
   1.431 +    # Then use the current directory as output dir!
   1.432 +    # If configuration is situated in normal build directory, just use the build
   1.433 +    # directory name as configuration name, otherwise use the complete path.
   1.434 +    if test "x${CONF_NAME}" = x; then
   1.435 +      CONF_NAME=`$ECHO $CURDIR | $SED -e "s!^${SRC_ROOT}/build/!!"`
   1.436 +    fi
   1.437 +    OUTPUT_ROOT="$CURDIR"
   1.438 +
   1.439 +    # WARNING: This might be a bad thing to do. You need to be sure you want to
   1.440 +    # have a configuration in this directory. Do some sanity checks!
   1.441 +
   1.442 +    if test ! -e "$OUTPUT_ROOT/spec.gmk"; then
   1.443 +      # If we have a spec.gmk, we have run here before and we are OK. Otherwise, check for
   1.444 +      # other files
   1.445 +      files_present=`$LS $OUTPUT_ROOT`
   1.446 +      # Configure has already touched config.log and confdefs.h in the current dir when this check
   1.447 +      # is performed.
   1.448 +      filtered_files=`$ECHO "$files_present" | $SED -e 's/config.log//g' -e 's/confdefs.h//g' -e 's/ //g' \
   1.449 +      | $TR -d '\n'`
   1.450 +      if test "x$filtered_files" != x; then
   1.451 +        AC_MSG_NOTICE([Current directory is $CURDIR.])
   1.452 +        AC_MSG_NOTICE([Since this is not the source root, configure will output the configuration here])
   1.453 +        AC_MSG_NOTICE([(as opposed to creating a configuration in <src_root>/build/<conf-name>).])
   1.454 +        AC_MSG_NOTICE([However, this directory is not empty. This is not allowed, since it could])
   1.455 +        AC_MSG_NOTICE([seriously mess up just about everything.])
   1.456 +        AC_MSG_NOTICE([Try 'cd $SRC_ROOT' and restart configure])
   1.457 +        AC_MSG_NOTICE([(or create a new empty directory and cd to it).])
   1.458 +        AC_MSG_ERROR([Will not continue creating configuration in $CURDIR])
   1.459 +      fi
   1.460 +    fi
   1.461 +  fi
   1.462 +  AC_MSG_CHECKING([what configuration name to use])
   1.463 +  AC_MSG_RESULT([$CONF_NAME])
   1.464 +
   1.465 +  BASIC_FIXUP_PATH(OUTPUT_ROOT)
   1.466 +
   1.467 +  AC_SUBST(SPEC, $OUTPUT_ROOT/spec.gmk)
   1.468 +  AC_SUBST(CONF_NAME, $CONF_NAME)
   1.469 +  AC_SUBST(OUTPUT_ROOT, $OUTPUT_ROOT)
   1.470 +
   1.471 +  # Most of the probed defines are put into config.h
   1.472 +  AC_CONFIG_HEADERS([$OUTPUT_ROOT/config.h:$AUTOCONF_DIR/config.h.in])
   1.473 +  # The spec.gmk file contains all variables for the make system.
   1.474 +  AC_CONFIG_FILES([$OUTPUT_ROOT/spec.gmk:$AUTOCONF_DIR/spec.gmk.in])
   1.475 +  # The hotspot-spec.gmk file contains legacy variables for the hotspot make system.
   1.476 +  AC_CONFIG_FILES([$OUTPUT_ROOT/hotspot-spec.gmk:$AUTOCONF_DIR/hotspot-spec.gmk.in])
   1.477 +  # The bootcycle-spec.gmk file contains support for boot cycle builds.
   1.478 +  AC_CONFIG_FILES([$OUTPUT_ROOT/bootcycle-spec.gmk:$AUTOCONF_DIR/bootcycle-spec.gmk.in])
   1.479 +  # The compare.sh is used to compare the build output to other builds.
   1.480 +  AC_CONFIG_FILES([$OUTPUT_ROOT/compare.sh:$AUTOCONF_DIR/compare.sh.in])
   1.481 +  # Spec.sh is currently used by compare-objects.sh
   1.482 +  AC_CONFIG_FILES([$OUTPUT_ROOT/spec.sh:$AUTOCONF_DIR/spec.sh.in])
   1.483 +  # The generated Makefile knows where the spec.gmk is and where the source is.
   1.484 +  # You can run make from the OUTPUT_ROOT, or from the top-level Makefile
   1.485 +  # which will look for generated configurations
   1.486 +  AC_CONFIG_FILES([$OUTPUT_ROOT/Makefile:$AUTOCONF_DIR/Makefile.in])
   1.487 +
   1.488 +  # Save the arguments given to us
   1.489 +  echo "$CONFIGURE_COMMAND_LINE" > $OUTPUT_ROOT/configure-arguments
   1.490 +])
   1.491 +
   1.492 +AC_DEFUN_ONCE([BASIC_SETUP_LOGGING],
   1.493 +[
   1.494 +  # Setup default logging of stdout and stderr to build.log in the output root.
   1.495 +  BUILD_LOG='$(OUTPUT_ROOT)/build.log'
   1.496 +  BUILD_LOG_PREVIOUS='$(OUTPUT_ROOT)/build.log.old'
   1.497 +  BUILD_LOG_WRAPPER='$(BASH) $(SRC_ROOT)/common/bin/logger.sh $(BUILD_LOG)'
   1.498 +  AC_SUBST(BUILD_LOG)
   1.499 +  AC_SUBST(BUILD_LOG_PREVIOUS)
   1.500 +  AC_SUBST(BUILD_LOG_WRAPPER)
   1.501 +])
   1.502 +
   1.503 +
   1.504 +#%%% Simple tools %%%
   1.505 +
   1.506 +# Check if we have found a usable version of make
   1.507 +# $1: the path to a potential make binary (or empty)
   1.508 +# $2: the description on how we found this
   1.509 +AC_DEFUN([BASIC_CHECK_MAKE_VERSION],
   1.510 +[
   1.511 +  MAKE_CANDIDATE="$1"
   1.512 +  DESCRIPTION="$2"
   1.513 +  if test "x$MAKE_CANDIDATE" != x; then
   1.514 +    AC_MSG_NOTICE([Testing potential make at $MAKE_CANDIDATE, found using $DESCRIPTION])
   1.515 +    MAKE_VERSION_STRING=`$MAKE_CANDIDATE --version | $HEAD -n 1`
   1.516 +    IS_GNU_MAKE=`$ECHO $MAKE_VERSION_STRING | $GREP 'GNU Make'`
   1.517 +    if test "x$IS_GNU_MAKE" = x; then
   1.518 +      AC_MSG_NOTICE([Found potential make at $MAKE_CANDIDATE, however, this is not GNU Make. Ignoring.])
   1.519 +    else
   1.520 +      IS_MODERN_MAKE=`$ECHO $MAKE_VERSION_STRING | $GREP -e '3\.8[[12]]' -e '4\.'`
   1.521 +      if test "x$IS_MODERN_MAKE" = x; then
   1.522 +        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.523 +      else
   1.524 +        if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
   1.525 +          if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
   1.526 +            MAKE_EXPECTED_ENV='cygwin'
   1.527 +          elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
   1.528 +            MAKE_EXPECTED_ENV='msys'
   1.529 +          else
   1.530 +            AC_MSG_ERROR([Unknown Windows environment])
   1.531 +          fi
   1.532 +          MAKE_BUILT_FOR=`$MAKE_CANDIDATE --version | $GREP -i 'built for'`
   1.533 +          IS_MAKE_CORRECT_ENV=`$ECHO $MAKE_BUILT_FOR | $GREP $MAKE_EXPECTED_ENV`
   1.534 +        else
   1.535 +          # Not relevant for non-Windows
   1.536 +          IS_MAKE_CORRECT_ENV=true
   1.537 +        fi
   1.538 +        if test "x$IS_MAKE_CORRECT_ENV" = x; then
   1.539 +          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.540 +        else
   1.541 +          FOUND_MAKE=$MAKE_CANDIDATE
   1.542 +          BASIC_FIXUP_EXECUTABLE(FOUND_MAKE)
   1.543 +        fi
   1.544 +      fi
   1.545 +    fi
   1.546 +  fi
   1.547 +])
   1.548 +
   1.549 +# Goes looking for a usable version of GNU make.
   1.550 +AC_DEFUN([BASIC_CHECK_GNU_MAKE],
   1.551 +[
   1.552 +  # We need to find a recent version of GNU make. Especially on Solaris, this can be tricky.
   1.553 +  if test "x$MAKE" != x; then
   1.554 +    # User has supplied a make, test it.
   1.555 +    if test ! -f "$MAKE"; then
   1.556 +      AC_MSG_ERROR([The specified make (by MAKE=$MAKE) is not found.])
   1.557 +    fi
   1.558 +    BASIC_CHECK_MAKE_VERSION("$MAKE", [user supplied MAKE=$MAKE])
   1.559 +    if test "x$FOUND_MAKE" = x; then
   1.560 +      AC_MSG_ERROR([The specified make (by MAKE=$MAKE) is not GNU make 3.81 or newer.])
   1.561 +    fi
   1.562 +  else
   1.563 +    # Try our hardest to locate a correct version of GNU make
   1.564 +    AC_PATH_PROGS(CHECK_GMAKE, gmake)
   1.565 +    BASIC_CHECK_MAKE_VERSION("$CHECK_GMAKE", [gmake in PATH])
   1.566 +
   1.567 +    if test "x$FOUND_MAKE" = x; then
   1.568 +      AC_PATH_PROGS(CHECK_MAKE, make)
   1.569 +      BASIC_CHECK_MAKE_VERSION("$CHECK_MAKE", [make in PATH])
   1.570 +    fi
   1.571 +
   1.572 +    if test "x$FOUND_MAKE" = x; then
   1.573 +      if test "x$TOOLS_DIR" != x; then
   1.574 +        # We have a tools-dir, check that as well before giving up.
   1.575 +        OLD_PATH=$PATH
   1.576 +        PATH=$TOOLS_DIR:$PATH
   1.577 +        AC_PATH_PROGS(CHECK_TOOLSDIR_GMAKE, gmake)
   1.578 +        BASIC_CHECK_MAKE_VERSION("$CHECK_TOOLSDIR_GMAKE", [gmake in tools-dir])
   1.579 +        if test "x$FOUND_MAKE" = x; then
   1.580 +          AC_PATH_PROGS(CHECK_TOOLSDIR_MAKE, make)
   1.581 +          BASIC_CHECK_MAKE_VERSION("$CHECK_TOOLSDIR_MAKE", [make in tools-dir])
   1.582 +        fi
   1.583 +        PATH=$OLD_PATH
   1.584 +      fi
   1.585 +    fi
   1.586 +
   1.587 +    if test "x$FOUND_MAKE" = x; then
   1.588 +      AC_MSG_ERROR([Cannot find GNU make 3.81 or newer! Please put it in the path, or add e.g. MAKE=/opt/gmake3.81/make as argument to configure.])
   1.589 +    fi
   1.590 +  fi
   1.591 +
   1.592 +  MAKE=$FOUND_MAKE
   1.593 +  AC_SUBST(MAKE)
   1.594 +  AC_MSG_NOTICE([Using GNU make 3.81 (or later) at $FOUND_MAKE (version: $MAKE_VERSION_STRING)])
   1.595 +])
   1.596 +
   1.597 +AC_DEFUN([BASIC_CHECK_FIND_DELETE],
   1.598 +[
   1.599 +  # Test if find supports -delete
   1.600 +  AC_MSG_CHECKING([if find supports -delete])
   1.601 +  FIND_DELETE="-delete"
   1.602 +
   1.603 +  DELETEDIR=`$MKTEMP -d tmp.XXXXXXXXXX` || (echo Could not create temporary directory!; exit $?)
   1.604 +
   1.605 +  echo Hejsan > $DELETEDIR/TestIfFindSupportsDelete
   1.606 +
   1.607 +  TEST_DELETE=`$FIND "$DELETEDIR" -name TestIfFindSupportsDelete $FIND_DELETE 2>&1`
   1.608 +  if test -f $DELETEDIR/TestIfFindSupportsDelete; then
   1.609 +    # No, it does not.
   1.610 +    rm $DELETEDIR/TestIfFindSupportsDelete
   1.611 +    FIND_DELETE="-exec rm \{\} \+"
   1.612 +    AC_MSG_RESULT([no])
   1.613 +  else
   1.614 +    AC_MSG_RESULT([yes])
   1.615 +  fi
   1.616 +  rmdir $DELETEDIR
   1.617 +  AC_SUBST(FIND_DELETE)
   1.618 +])
   1.619 +
   1.620 +AC_DEFUN_ONCE([BASIC_SETUP_COMPLEX_TOOLS],
   1.621 +[
   1.622 +  BASIC_CHECK_GNU_MAKE
   1.623 +
   1.624 +  BASIC_CHECK_FIND_DELETE
   1.625 +
   1.626 +  # These tools might not be installed by default,
   1.627 +  # need hint on how to install them.
   1.628 +  BASIC_REQUIRE_PROG(UNZIP, unzip)
   1.629 +  BASIC_REQUIRE_PROG(ZIP, zip)
   1.630 +
   1.631 +  # Non-required basic tools
   1.632 +
   1.633 +  AC_PATH_PROG(LDD, ldd)
   1.634 +  if test "x$LDD" = "x"; then
   1.635 +    # List shared lib dependencies is used for
   1.636 +    # debug output and checking for forbidden dependencies.
   1.637 +    # We can build without it.
   1.638 +    LDD="true"
   1.639 +  fi
   1.640 +  AC_PATH_PROG(OTOOL, otool)
   1.641 +  if test "x$OTOOL" = "x"; then
   1.642 +    OTOOL="true"
   1.643 +  fi
   1.644 +  AC_PATH_PROGS(READELF, [readelf greadelf])
   1.645 +  AC_PATH_PROG(HG, hg)
   1.646 +  AC_PATH_PROG(STAT, stat)
   1.647 +  AC_PATH_PROG(TIME, time)
   1.648 +  # Check if it's GNU time
   1.649 +  IS_GNU_TIME=`$TIME --version 2>&1 | $GREP 'GNU time'`
   1.650 +  if test "x$IS_GNU_TIME" != x; then
   1.651 +    IS_GNU_TIME=yes
   1.652 +  else
   1.653 +    IS_GNU_TIME=no
   1.654 +  fi
   1.655 +  AC_SUBST(IS_GNU_TIME)
   1.656 +
   1.657 +  if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
   1.658 +    BASIC_REQUIRE_PROG(COMM, comm)
   1.659 +  fi
   1.660 +
   1.661 +  if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
   1.662 +    BASIC_REQUIRE_PROG(DSYMUTIL, dsymutil)
   1.663 +    BASIC_REQUIRE_PROG(XATTR, xattr)
   1.664 +    AC_PATH_PROG(CODESIGN, codesign)
   1.665 +    if test "x$CODESIGN" != "x"; then
   1.666 +      # Verify that the openjdk_codesign certificate is present
   1.667 +      AC_MSG_CHECKING([if openjdk_codesign certificate is present])
   1.668 +      rm -f codesign-testfile
   1.669 +      touch codesign-testfile
   1.670 +      codesign -s openjdk_codesign codesign-testfile 2>&AS_MESSAGE_LOG_FD >&AS_MESSAGE_LOG_FD || CODESIGN=
   1.671 +      rm -f codesign-testfile
   1.672 +      if test "x$CODESIGN" = x; then
   1.673 +        AC_MSG_RESULT([no])
   1.674 +      else
   1.675 +        AC_MSG_RESULT([yes])
   1.676 +      fi
   1.677 +    fi
   1.678 +  fi
   1.679 +])
   1.680 +
   1.681 +# Check if build directory is on local disk. If not possible to determine,
   1.682 +# we prefer to claim it's local.
   1.683 +# Argument 1: directory to test
   1.684 +# Argument 2: what to do if it is on local disk
   1.685 +# Argument 3: what to do otherwise (remote disk or failure)
   1.686 +AC_DEFUN([BASIC_CHECK_DIR_ON_LOCAL_DISK],
   1.687 +[
   1.688 +  # df -l lists only local disks; if the given directory is not found then
   1.689 +  # a non-zero exit code is given
   1.690 +  if test "x$DF" = x; then
   1.691 +    if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
   1.692 +      # msys does not have df; use Windows "net use" instead.
   1.693 +      IS_NETWORK_DISK=`net use | grep \`pwd -W | cut -d ":" -f 1 | tr a-z A-Z\`:`
   1.694 +      if test "x$IS_NETWORK_DISK" = x; then
   1.695 +        $2
   1.696 +      else
   1.697 +        $3
   1.698 +      fi
   1.699 +    else
   1.700 +      # No df here, say it's local
   1.701 +      $2
   1.702 +    fi
   1.703 +  else
   1.704 +    if $DF -l $1 > /dev/null 2>&1; then
   1.705 +      $2
   1.706 +    else
   1.707 +      $3
   1.708 +    fi
   1.709 +  fi
   1.710 +])
   1.711 +
   1.712 +# Check that source files have basic read permissions set. This might
   1.713 +# not be the case in cygwin in certain conditions.
   1.714 +AC_DEFUN_ONCE([BASIC_CHECK_SRC_PERMS],
   1.715 +[
   1.716 +  if test x"$OPENJDK_BUILD_OS" = xwindows; then
   1.717 +    file_to_test="$SRC_ROOT/LICENSE"
   1.718 +    if test `$STAT -c '%a' "$file_to_test"` -lt 400; then
   1.719 +      AC_MSG_ERROR([Bad file permissions on src files. This is usually caused by cloning the repositories with a non cygwin hg in a directory not created in cygwin.])
   1.720 +    fi
   1.721 +  fi
   1.722 +])
   1.723 +
   1.724 +AC_DEFUN_ONCE([BASIC_TEST_USABILITY_ISSUES],
   1.725 +[
   1.726 +  AC_MSG_CHECKING([if build directory is on local disk])
   1.727 +  BASIC_CHECK_DIR_ON_LOCAL_DISK($OUTPUT_ROOT,
   1.728 +      [OUTPUT_DIR_IS_LOCAL="yes"],
   1.729 +      [OUTPUT_DIR_IS_LOCAL="no"])
   1.730 +  AC_MSG_RESULT($OUTPUT_DIR_IS_LOCAL)
   1.731 +
   1.732 +  BASIC_CHECK_SRC_PERMS
   1.733 +
   1.734 +  # Check if the user has any old-style ALT_ variables set.
   1.735 +  FOUND_ALT_VARIABLES=`env | grep ^ALT_`
   1.736 +
   1.737 +  # Before generating output files, test if they exist. If they do, this is a reconfigure.
   1.738 +  # Since we can't properly handle the dependencies for this, warn the user about the situation
   1.739 +  if test -e $OUTPUT_ROOT/spec.gmk; then
   1.740 +    IS_RECONFIGURE=yes
   1.741 +  else
   1.742 +    IS_RECONFIGURE=no
   1.743 +  fi
   1.744 +
   1.745 +  if test -e $SRC_ROOT/build/.hide-configure-performance-hints; then
   1.746 +    HIDE_PERFORMANCE_HINTS=yes
   1.747 +  else
   1.748 +    HIDE_PERFORMANCE_HINTS=no
   1.749 +    # Hide it the next time around...
   1.750 +    $TOUCH $SRC_ROOT/build/.hide-configure-performance-hints > /dev/null 2>&1
   1.751 +  fi
   1.752 +])

mercurial