common/autoconf/basics.m4

changeset 2204
0e87966d7ff1
parent 2203
28b247535e18
child 2205
54eb4c29ece4
     1.1 --- a/common/autoconf/basics.m4	Sun Mar 18 15:15:36 2018 -0700
     1.2 +++ b/common/autoconf/basics.m4	Tue Mar 20 09:19:10 2018 -0700
     1.3 @@ -236,35 +236,119 @@
     1.4  
     1.5  # Test that variable $1 denoting a program is not empty. If empty, exit with an error.
     1.6  # $1: variable to check
     1.7 -# $2: executable name to print in warning (optional)
     1.8  AC_DEFUN([BASIC_CHECK_NONEMPTY],
     1.9  [
    1.10    if test "x[$]$1" = x; then
    1.11 -    if test "x$2" = x; then
    1.12 -      PROG_NAME=translit($1,A-Z,a-z)
    1.13 -    else
    1.14 -      PROG_NAME=$2
    1.15 -    fi
    1.16 -    AC_MSG_NOTICE([Could not find $PROG_NAME!])
    1.17 -    AC_MSG_ERROR([Cannot continue])
    1.18 +    AC_MSG_ERROR([Could not find required tool for $1])
    1.19    fi
    1.20  ])
    1.21  
    1.22 -# Does AC_PATH_PROG followed by BASIC_CHECK_NONEMPTY.
    1.23 -# Arguments as AC_PATH_PROG:
    1.24 +# Check that there are no unprocessed overridden variables left.
    1.25 +# If so, they are an incorrect argument and we will exit with an error.
    1.26 +AC_DEFUN([BASIC_CHECK_LEFTOVER_OVERRIDDEN],
    1.27 +[
    1.28 +  if test "x$CONFIGURE_OVERRIDDEN_VARIABLES" != x; then
    1.29 +    # Replace the separating ! with spaces before presenting for end user.
    1.30 +    unknown_variables=${CONFIGURE_OVERRIDDEN_VARIABLES//!/ }
    1.31 +    AC_MSG_ERROR([The following variables are unknown to configure: $unknown_variables])
    1.32 +  fi
    1.33 +])
    1.34 +
    1.35 +# Setup a tool for the given variable. If correctly specified by the user, 
    1.36 +# use that value, otherwise search for the tool using the supplied code snippet.
    1.37  # $1: variable to set
    1.38 -# $2: executable name to look for
    1.39 -AC_DEFUN([BASIC_REQUIRE_PROG],
    1.40 +# $2: code snippet to call to look for the tool
    1.41 +AC_DEFUN([BASIC_SETUP_TOOL],
    1.42  [
    1.43 -  AC_PATH_PROGS($1, $2)
    1.44 -  BASIC_CHECK_NONEMPTY($1, $2)
    1.45 +  # Publish this variable in the help.
    1.46 +  AC_ARG_VAR($1, [Override default value for $1])
    1.47 +
    1.48 +  if test "x[$]$1" = x; then
    1.49 +    # The variable is not set by user, try to locate tool using the code snippet
    1.50 +    $2
    1.51 +  else
    1.52 +    # The variable is set, but is it from the command line or the environment?
    1.53 +
    1.54 +    # Try to remove the string !$1! from our list.
    1.55 +    try_remove_var=${CONFIGURE_OVERRIDDEN_VARIABLES//!$1!/}
    1.56 +    if test "x$try_remove_var" = "x$CONFIGURE_OVERRIDDEN_VARIABLES"; then
    1.57 +      # If it failed, the variable was not from the command line. Ignore it,
    1.58 +      # but warn the user (except for BASH, which is always set by the calling BASH).
    1.59 +      if test "x$1" != xBASH; then
    1.60 +        AC_MSG_WARN([Ignoring value of $1 from the environment. Use command line variables instead.])
    1.61 +      fi
    1.62 +      # Try to locate tool using the code snippet
    1.63 +      $2
    1.64 +    else
    1.65 +      # If it succeeded, then it was overridden by the user. We will use it
    1.66 +      # for the tool.
    1.67 +
    1.68 +      # First remove it from the list of overridden variables, so we can test
    1.69 +      # for unknown variables in the end.
    1.70 +      CONFIGURE_OVERRIDDEN_VARIABLES="$try_remove_var"
    1.71 +
    1.72 +      # Check if the provided tool contains a complete path.
    1.73 +      tool_specified="[$]$1"
    1.74 +      tool_basename="${tool_specified##*/}"
    1.75 +      if test "x$tool_basename" = "x$tool_specified"; then
    1.76 +        # A command without a complete path is provided, search $PATH.
    1.77 +        AC_MSG_NOTICE([Will search for user supplied tool $1=$tool_basename])
    1.78 +        AC_PATH_PROG($1, $tool_basename)
    1.79 +        if test "x[$]$1" = x; then
    1.80 +          AC_MSG_ERROR([User supplied tool $tool_basename could not be found])
    1.81 +        fi
    1.82 +      else
    1.83 +        # Otherwise we believe it is a complete path. Use it as it is.
    1.84 +        AC_MSG_NOTICE([Will use user supplied tool $1=$tool_specified])
    1.85 +        AC_MSG_CHECKING([for $1])
    1.86 +        if test ! -x "$tool_specified"; then
    1.87 +          AC_MSG_RESULT([not found])
    1.88 +          AC_MSG_ERROR([User supplied tool $1=$tool_specified does not exist or is not executable])
    1.89 +        fi
    1.90 +        AC_MSG_RESULT([$tool_specified])
    1.91 +      fi
    1.92 +    fi
    1.93 +  fi
    1.94 +])
    1.95 +
    1.96 +# Call BASIC_SETUP_TOOL with AC_PATH_PROGS to locate the tool
    1.97 +# $1: variable to set
    1.98 +# $2: executable name (or list of names) to look for
    1.99 +AC_DEFUN([BASIC_PATH_PROGS],
   1.100 +[
   1.101 +  BASIC_SETUP_TOOL($1, [AC_PATH_PROGS($1, $2)])
   1.102 +])
   1.103 +
   1.104 +# Call BASIC_SETUP_TOOL with AC_CHECK_TOOLS to locate the tool
   1.105 +# $1: variable to set
   1.106 +# $2: executable name (or list of names) to look for
   1.107 +AC_DEFUN([BASIC_CHECK_TOOLS],
   1.108 +[
   1.109 +  BASIC_SETUP_TOOL($1, [AC_CHECK_TOOLS($1, $2)])
   1.110 +])
   1.111 +
   1.112 +# Like BASIC_PATH_PROGS but fails if no tool was found.
   1.113 +# $1: variable to set
   1.114 +# $2: executable name (or list of names) to look for
   1.115 +AC_DEFUN([BASIC_REQUIRE_PROGS],
   1.116 +[
   1.117 +  BASIC_PATH_PROGS($1, $2)
   1.118 +  BASIC_CHECK_NONEMPTY($1)
   1.119 +])
   1.120 +
   1.121 +# Like BASIC_SETUP_TOOL but fails if no tool was found.
   1.122 +# $1: variable to set
   1.123 +# $2: autoconf macro to call to look for the special tool
   1.124 +AC_DEFUN([BASIC_REQUIRE_SPECIAL],
   1.125 +[
   1.126 +  BASIC_SETUP_TOOL($1, [$2])
   1.127 +  BASIC_CHECK_NONEMPTY($1)
   1.128  ])
   1.129  
   1.130  # Setup the most fundamental tools that relies on not much else to set up,
   1.131  # but is used by much of the early bootstrap code.
   1.132  AC_DEFUN_ONCE([BASIC_SETUP_FUNDAMENTAL_TOOLS],
   1.133  [
   1.134 -
   1.135    # Start with tools that do not need have cross compilation support
   1.136    # and can be expected to be found in the default PATH. These tools are
   1.137    # used by configure. Nor are these tools expected to be found in the
   1.138 @@ -272,57 +356,50 @@
   1.139    # needed to download the devkit.
   1.140  
   1.141    # First are all the simple required tools.
   1.142 -  BASIC_REQUIRE_PROG(BASENAME, basename)
   1.143 -  BASIC_REQUIRE_PROG(BASH, bash)
   1.144 -  BASIC_REQUIRE_PROG(CAT, cat)
   1.145 -  BASIC_REQUIRE_PROG(CHMOD, chmod)
   1.146 -  BASIC_REQUIRE_PROG(CMP, cmp)
   1.147 -  BASIC_REQUIRE_PROG(COMM, comm)
   1.148 -  BASIC_REQUIRE_PROG(CP, cp)
   1.149 -  BASIC_REQUIRE_PROG(CPIO, cpio)
   1.150 -  BASIC_REQUIRE_PROG(CUT, cut)
   1.151 -  BASIC_REQUIRE_PROG(DATE, date)
   1.152 -  BASIC_REQUIRE_PROG(DIFF, [gdiff diff])
   1.153 -  BASIC_REQUIRE_PROG(DIRNAME, dirname)
   1.154 -  BASIC_REQUIRE_PROG(ECHO, echo)
   1.155 -  BASIC_REQUIRE_PROG(EXPR, expr)
   1.156 -  BASIC_REQUIRE_PROG(FILE, file)
   1.157 -  BASIC_REQUIRE_PROG(FIND, find)
   1.158 -  BASIC_REQUIRE_PROG(HEAD, head)
   1.159 -  BASIC_REQUIRE_PROG(LN, ln)
   1.160 -  BASIC_REQUIRE_PROG(LS, ls)
   1.161 -  BASIC_REQUIRE_PROG(MKDIR, mkdir)
   1.162 -  BASIC_REQUIRE_PROG(MKTEMP, mktemp)
   1.163 -  BASIC_REQUIRE_PROG(MV, mv)
   1.164 -  BASIC_REQUIRE_PROG(PRINTF, printf)
   1.165 -  BASIC_REQUIRE_PROG(RM, rm)
   1.166 -  BASIC_REQUIRE_PROG(SH, sh)
   1.167 -  BASIC_REQUIRE_PROG(SORT, sort)
   1.168 -  BASIC_REQUIRE_PROG(TAIL, tail)
   1.169 -  BASIC_REQUIRE_PROG(TAR, tar)
   1.170 -  BASIC_REQUIRE_PROG(TEE, tee)
   1.171 -  BASIC_REQUIRE_PROG(TOUCH, touch)
   1.172 -  BASIC_REQUIRE_PROG(TR, tr)
   1.173 -  BASIC_REQUIRE_PROG(UNAME, uname)
   1.174 -  BASIC_REQUIRE_PROG(UNIQ, uniq)
   1.175 -  BASIC_REQUIRE_PROG(WC, wc)
   1.176 -  BASIC_REQUIRE_PROG(WHICH, which)
   1.177 -  BASIC_REQUIRE_PROG(XARGS, xargs)
   1.178 +  BASIC_REQUIRE_PROGS(BASENAME, basename)
   1.179 +  BASIC_REQUIRE_PROGS(BASH, bash)
   1.180 +  BASIC_REQUIRE_PROGS(CAT, cat)
   1.181 +  BASIC_REQUIRE_PROGS(CHMOD, chmod)
   1.182 +  BASIC_REQUIRE_PROGS(CMP, cmp)
   1.183 +  BASIC_REQUIRE_PROGS(COMM, comm)
   1.184 +  BASIC_REQUIRE_PROGS(CP, cp)
   1.185 +  BASIC_REQUIRE_PROGS(CPIO, cpio)
   1.186 +  BASIC_REQUIRE_PROGS(CUT, cut)
   1.187 +  BASIC_REQUIRE_PROGS(DATE, date)
   1.188 +  BASIC_REQUIRE_PROGS(DIFF, [gdiff diff])
   1.189 +  BASIC_REQUIRE_PROGS(DIRNAME, dirname)
   1.190 +  BASIC_REQUIRE_PROGS(ECHO, echo)
   1.191 +  BASIC_REQUIRE_PROGS(EXPR, expr)
   1.192 +  BASIC_REQUIRE_PROGS(FILE, file)
   1.193 +  BASIC_REQUIRE_PROGS(FIND, find)
   1.194 +  BASIC_REQUIRE_PROGS(HEAD, head)
   1.195 +  BASIC_REQUIRE_PROGS(LN, ln)
   1.196 +  BASIC_REQUIRE_PROGS(LS, ls)
   1.197 +  BASIC_REQUIRE_PROGS(MKDIR, mkdir)
   1.198 +  BASIC_REQUIRE_PROGS(MKTEMP, mktemp)
   1.199 +  BASIC_REQUIRE_PROGS(MV, mv)
   1.200 +  BASIC_REQUIRE_PROGS(NAWK, [nawk gawk awk])
   1.201 +  BASIC_REQUIRE_PROGS(PRINTF, printf)
   1.202 +  BASIC_REQUIRE_PROGS(RM, rm)
   1.203 +  BASIC_REQUIRE_PROGS(SH, sh)
   1.204 +  BASIC_REQUIRE_PROGS(SORT, sort)
   1.205 +  BASIC_REQUIRE_PROGS(TAIL, tail)
   1.206 +  BASIC_REQUIRE_PROGS(TAR, tar)
   1.207 +  BASIC_REQUIRE_PROGS(TEE, tee)
   1.208 +  BASIC_REQUIRE_PROGS(TOUCH, touch)
   1.209 +  BASIC_REQUIRE_PROGS(TR, tr)
   1.210 +  BASIC_REQUIRE_PROGS(UNAME, uname)
   1.211 +  BASIC_REQUIRE_PROGS(UNIQ, uniq)
   1.212 +  BASIC_REQUIRE_PROGS(WC, wc)
   1.213 +  BASIC_REQUIRE_PROGS(WHICH, which)
   1.214 +  BASIC_REQUIRE_PROGS(XARGS, xargs)
   1.215  
   1.216    # Then required tools that require some special treatment.
   1.217 -  AC_PROG_AWK
   1.218 -  BASIC_CHECK_NONEMPTY(AWK)
   1.219 -  AC_PROG_GREP
   1.220 -  BASIC_CHECK_NONEMPTY(GREP)
   1.221 -  AC_PROG_EGREP
   1.222 -  BASIC_CHECK_NONEMPTY(EGREP)
   1.223 -  AC_PROG_FGREP
   1.224 -  BASIC_CHECK_NONEMPTY(FGREP)
   1.225 -  AC_PROG_SED
   1.226 -  BASIC_CHECK_NONEMPTY(SED)
   1.227 -
   1.228 -  AC_PATH_PROGS(NAWK, [nawk gawk awk])
   1.229 -  BASIC_CHECK_NONEMPTY(NAWK)
   1.230 +  BASIC_REQUIRE_SPECIAL(AWK, [AC_PROG_AWK])
   1.231 +  BASIC_REQUIRE_SPECIAL(GREP, [AC_PROG_GREP])
   1.232 +  BASIC_REQUIRE_SPECIAL(EGREP, [AC_PROG_EGREP])
   1.233 +  BASIC_REQUIRE_SPECIAL(FGREP, [AC_PROG_FGREP])
   1.234 +  BASIC_REQUIRE_SPECIAL(SED, [AC_PROG_SED])
   1.235  
   1.236    # Always force rm.
   1.237    RM="$RM -f"
   1.238 @@ -332,10 +409,10 @@
   1.239    THEPWDCMD=pwd
   1.240  
   1.241    # These are not required on all platforms
   1.242 -  AC_PATH_PROG(CYGPATH, cygpath)
   1.243 -  AC_PATH_PROG(READLINK, readlink)
   1.244 -  AC_PATH_PROG(DF, df)
   1.245 -  AC_PATH_PROG(SETFILE, SetFile)
   1.246 +  BASIC_PATH_PROGS(CYGPATH, cygpath)
   1.247 +  BASIC_PATH_PROGS(READLINK, [greadlink readlink])
   1.248 +  BASIC_PATH_PROGS(DF, df)
   1.249 +  BASIC_PATH_PROGS(SETFILE, SetFile)
   1.250  ])
   1.251  
   1.252  # Setup basic configuration paths, and platform-specific stuff related to PATHs.
   1.253 @@ -628,22 +705,22 @@
   1.254  
   1.255    # These tools might not be installed by default,
   1.256    # need hint on how to install them.
   1.257 -  BASIC_REQUIRE_PROG(UNZIP, unzip)
   1.258 -  BASIC_REQUIRE_PROG(ZIP, zip)
   1.259 +  BASIC_REQUIRE_PROGS(UNZIP, unzip)
   1.260 +  BASIC_REQUIRE_PROGS(ZIP, zip)
   1.261  
   1.262    # Non-required basic tools
   1.263  
   1.264 -  AC_PATH_PROG(LDD, ldd)
   1.265 +  BASIC_PATH_PROGS(LDD, ldd)
   1.266    if test "x$LDD" = "x"; then
   1.267      # List shared lib dependencies is used for
   1.268      # debug output and checking for forbidden dependencies.
   1.269      # We can build without it.
   1.270      LDD="true"
   1.271    fi
   1.272 -  AC_PATH_PROGS(READELF, [readelf greadelf])
   1.273 -  AC_PATH_PROG(HG, hg)
   1.274 -  AC_PATH_PROG(STAT, stat)
   1.275 -  AC_PATH_PROG(TIME, time)
   1.276 +  BASIC_PATH_PROGS(READELF, [readelf greadelf])
   1.277 +  BASIC_PATH_PROGS(HG, hg)
   1.278 +  BASIC_PATH_PROGS(STAT, stat)
   1.279 +  BASIC_PATH_PROGS(TIME, time)
   1.280    # Check if it's GNU time
   1.281    IS_GNU_TIME=`$TIME --version 2>&1 | $GREP 'GNU time'`
   1.282    if test "x$IS_GNU_TIME" != x; then
   1.283 @@ -654,13 +731,13 @@
   1.284    AC_SUBST(IS_GNU_TIME)
   1.285  
   1.286    if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
   1.287 -    BASIC_REQUIRE_PROG(COMM, comm)
   1.288 +    BASIC_REQUIRE_PROGS(COMM, comm)
   1.289    fi
   1.290  
   1.291    if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
   1.292 -    BASIC_REQUIRE_PROG(DSYMUTIL, dsymutil)
   1.293 -    BASIC_REQUIRE_PROG(XATTR, xattr)
   1.294 -    AC_PATH_PROG(CODESIGN, codesign)
   1.295 +    BASIC_REQUIRE_PROGS(DSYMUTIL, dsymutil)
   1.296 +    BASIC_REQUIRE_PROGS(XATTR, xattr)
   1.297 +    BASIC_PATH_PROGS(CODESIGN, codesign)
   1.298      if test "x$CODESIGN" != "x"; then
   1.299        # Verify that the openjdk_codesign certificate is present
   1.300        AC_MSG_CHECKING([if openjdk_codesign certificate is present])
   1.301 @@ -722,6 +799,9 @@
   1.302  
   1.303  AC_DEFUN_ONCE([BASIC_TEST_USABILITY_ISSUES],
   1.304  [
   1.305 +  # Did user specify any unknown variables?
   1.306 +  BASIC_CHECK_LEFTOVER_OVERRIDDEN
   1.307 +
   1.308    AC_MSG_CHECKING([if build directory is on local disk])
   1.309    BASIC_CHECK_DIR_ON_LOCAL_DISK($OUTPUT_ROOT,
   1.310        [OUTPUT_DIR_IS_LOCAL="yes"],

mercurial