basics.m4 revision 1484:2038a6987213
1237834Smm# 2237834Smm# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. 3237834Smm# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4237834Smm# 5237834Smm# This code is free software; you can redistribute it and/or modify it 6237834Smm# under the terms of the GNU General Public License version 2 only, as 7237834Smm# published by the Free Software Foundation. Oracle designates this 8237834Smm# particular file as subject to the "Classpath" exception as provided 9237834Smm# by Oracle in the LICENSE file that accompanied this code. 10237834Smm# 11237834Smm# This code is distributed in the hope that it will be useful, but WITHOUT 12237834Smm# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13237834Smm# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14237834Smm# version 2 for more details (a copy is included in the LICENSE file that 15237834Smm# accompanied this code). 16237834Smm# 17237834Smm# You should have received a copy of the GNU General Public License version 18237834Smm# 2 along with this work; if not, write to the Free Software Foundation, 19237834Smm# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20237834Smm# 21237834Smm# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22237834Smm# or visit www.oracle.com if you need additional information or have any 23237834Smm# questions. 24237834Smm# 25237834Smm 26237834Smm# Test if $1 is a valid argument to $3 (often is $JAVA passed as $3) 27237834Smm# If so, then append $1 to $2 \ 28237834Smm# Also set JVM_ARG_OK to true/false depending on outcome. 29237834SmmAC_DEFUN([ADD_JVM_ARG_IF_OK], 30237834Smm[ 31237834Smm $ECHO "Check if jvm arg is ok: $1" >&AS_MESSAGE_LOG_FD 32237834Smm $ECHO "Command: $3 $1 -version" >&AS_MESSAGE_LOG_FD 33237834Smm OUTPUT=`$3 $1 -version 2>&1` 34237834Smm FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn` 35237834Smm FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""` 36237834Smm if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then 37237834Smm $2="[$]$2 $1" 38237834Smm JVM_ARG_OK=true 39237834Smm else 40237834Smm $ECHO "Arg failed:" >&AS_MESSAGE_LOG_FD 41237834Smm $ECHO "$OUTPUT" >&AS_MESSAGE_LOG_FD 42237834Smm JVM_ARG_OK=false 43237834Smm fi 44237834Smm]) 45237834Smm 46237834Smm# Appends a string to a path variable, only adding the : when needed. 47237834SmmAC_DEFUN([BASIC_APPEND_TO_PATH], 48237834Smm[ 49237834Smm if test "x$2" != x; then 50237834Smm if test "x[$]$1" = x; then 51237834Smm $1="$2" 52237834Smm else 53237834Smm $1="[$]$1:$2" 54237834Smm fi 55237834Smm fi 56237834Smm]) 57237834Smm 58237834Smm# Prepends a string to a path variable, only adding the : when needed. 59237834SmmAC_DEFUN([BASIC_PREPEND_TO_PATH], 60237834Smm[ 61237834Smm if test "x$2" != x; then 62237834Smm if test "x[$]$1" = x; then 63237834Smm $1="$2" 64237834Smm else 65237834Smm $1="$2:[$]$1" 66237834Smm fi 67237834Smm fi 68237834Smm]) 69237834Smm 70237834Smm# This will make sure the given variable points to a full and proper 71237834Smm# path. This means: 72237834Smm# 1) There will be no spaces in the path. On unix platforms, 73237834Smm# spaces in the path will result in an error. On Windows, 74237834Smm# the path will be rewritten using short-style to be space-free. 75237834Smm# 2) The path will be absolute, and it will be in unix-style (on 76237834Smm# cygwin). 77237834Smm# $1: The name of the variable to fix 78237834SmmAC_DEFUN([BASIC_FIXUP_PATH], 79237834Smm[ 80237834Smm # Only process if variable expands to non-empty 81237834Smm 82237834Smm if test "x[$]$1" != x; then 83237834Smm if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then 84237834Smm BASIC_FIXUP_PATH_CYGWIN($1) 85237834Smm elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then 86237834Smm BASIC_FIXUP_PATH_MSYS($1) 87237834Smm else 88237834Smm # We're on a unix platform. Hooray! :) 89237834Smm path="[$]$1" 90237834Smm has_space=`$ECHO "$path" | $GREP " "` 91237834Smm if test "x$has_space" != x; then 92237834Smm AC_MSG_NOTICE([The path of $1, which resolves as "$path", is invalid.]) 93237834Smm AC_MSG_ERROR([Spaces are not allowed in this path.]) 94237834Smm fi 95237834Smm 96237834Smm # Use eval to expand a potential ~ 97237834Smm eval path="$path" 98237834Smm if test ! -f "$path" && test ! -d "$path"; then 99237834Smm AC_MSG_ERROR([The path of $1, which resolves as "$path", is not found.]) 100237834Smm fi 101237834Smm 102237834Smm $1="`cd "$path"; $THEPWDCMD -L`" 103237834Smm fi 104237834Smm fi 105237834Smm]) 106237834Smm 107237834Smm# This will make sure the given variable points to a executable 108237834Smm# with a full and proper path. This means: 109237834Smm# 1) There will be no spaces in the path. On unix platforms, 110237834Smm# spaces in the path will result in an error. On Windows, 111237834Smm# the path will be rewritten using short-style to be space-free. 112237834Smm# 2) The path will be absolute, and it will be in unix-style (on 113237834Smm# cygwin). 114237834Smm# Any arguments given to the executable is preserved. 115237834Smm# If the input variable does not have a directory specification, then 116237834Smm# it need to be in the PATH. 117237834Smm# $1: The name of the variable to fix 118237834SmmAC_DEFUN([BASIC_FIXUP_EXECUTABLE], 119237834Smm[ 120237834Smm # Only process if variable expands to non-empty 121237834Smm 122237834Smm if test "x[$]$1" != x; then 123237834Smm if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then 124237834Smm BASIC_FIXUP_EXECUTABLE_CYGWIN($1) 125237834Smm elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then 126237834Smm BASIC_FIXUP_EXECUTABLE_MSYS($1) 127237834Smm else 128237834Smm # We're on a unix platform. Hooray! :) 129237834Smm # First separate the path from the arguments. This will split at the first 130237834Smm # space. 131237834Smm complete="[$]$1" 132237834Smm path="${complete%% *}" 133237834Smm tmp="$complete EOL" 134237834Smm arguments="${tmp#* }" 135237834Smm 136237834Smm # Cannot rely on the command "which" here since it doesn't always work. 137237834Smm is_absolute_path=`$ECHO "$path" | $GREP ^/` 138237834Smm if test -z "$is_absolute_path"; then 139237834Smm # Path to executable is not absolute. Find it. 140237834Smm IFS_save="$IFS" 141237834Smm IFS=: 142237834Smm for p in $PATH; do 143237834Smm if test -f "$p/$path" && test -x "$p/$path"; then 144237834Smm new_path="$p/$path" 145237834Smm break 146237834Smm fi 147237834Smm done 148237834Smm IFS="$IFS_save" 149237834Smm else 150237834Smm # This is an absolute path, we can use it without further modifications. 151237834Smm new_path="$path" 152237834Smm fi 153237834Smm 154237834Smm if test "x$new_path" = x; then 155237834Smm AC_MSG_NOTICE([The path of $1, which resolves as "$complete", is not found.]) 156237834Smm has_space=`$ECHO "$complete" | $GREP " "` 157237834Smm if test "x$has_space" != x; then 158237834Smm AC_MSG_NOTICE([This might be caused by spaces in the path, which is not allowed.]) 159237834Smm fi 160237834Smm AC_MSG_ERROR([Cannot locate the the path of $1]) 161237834Smm fi 162237834Smm fi 163237834Smm 164237834Smm # Now join together the path and the arguments once again 165237834Smm if test "x$arguments" != xEOL; then 166237834Smm new_complete="$new_path ${arguments% *}" 167237834Smm else 168237834Smm new_complete="$new_path" 169237834Smm fi 170237834Smm 171237834Smm if test "x$complete" != "x$new_complete"; then 172237834Smm $1="$new_complete" 173237834Smm AC_MSG_NOTICE([Rewriting $1 to "$new_complete"]) 174237834Smm fi 175237834Smm fi 176237834Smm]) 177237834Smm 178237834SmmAC_DEFUN([BASIC_REMOVE_SYMBOLIC_LINKS], 179237834Smm[ 180237834Smm if test "x$OPENJDK_BUILD_OS" != xwindows; then 181237834Smm # Follow a chain of symbolic links. Use readlink 182237834Smm # where it exists, else fall back to horribly 183237834Smm # complicated shell code. 184237834Smm if test "x$READLINK_TESTED" != yes; then 185237834Smm # On MacOSX there is a readlink tool with a different 186237834Smm # purpose than the GNU readlink tool. Check the found readlink. 187237834Smm ISGNU=`$READLINK --version 2>&1 | $GREP GNU` 188237834Smm if test "x$ISGNU" = x; then 189237834Smm # A readlink that we do not know how to use. 190237834Smm # Are there other non-GNU readlinks out there? 191237834Smm READLINK_TESTED=yes 192237834Smm READLINK= 193237834Smm fi 194237834Smm fi 195237834Smm 196237834Smm if test "x$READLINK" != x; then 197237834Smm $1=`$READLINK -f [$]$1` 198237834Smm else 199237834Smm # Save the current directory for restoring afterwards 200237834Smm STARTDIR=$PWD 201237834Smm COUNTER=0 202237834Smm sym_link_dir=`$DIRNAME [$]$1` 203237834Smm sym_link_file=`$BASENAME [$]$1` 204237834Smm cd $sym_link_dir 205237834Smm # Use -P flag to resolve symlinks in directories. 206237834Smm cd `$THEPWDCMD -P` 207237834Smm sym_link_dir=`$THEPWDCMD -P` 208237834Smm # Resolve file symlinks 209237834Smm while test $COUNTER -lt 20; do 210237834Smm ISLINK=`$LS -l $sym_link_dir/$sym_link_file | $GREP '\->' | $SED -e 's/.*-> \(.*\)/\1/'` 211237834Smm if test "x$ISLINK" == x; then 212237834Smm # This is not a symbolic link! We are done! 213237834Smm break 214237834Smm fi 215237834Smm # Again resolve directory symlinks since the target of the just found 216237834Smm # link could be in a different directory 217237834Smm cd `$DIRNAME $ISLINK` 218237834Smm sym_link_dir=`$THEPWDCMD -P` 219237834Smm sym_link_file=`$BASENAME $ISLINK` 220237834Smm let COUNTER=COUNTER+1 221237834Smm done 222237834Smm cd $STARTDIR 223237834Smm $1=$sym_link_dir/$sym_link_file 224237834Smm fi 225237834Smm fi 226237834Smm]) 227237834Smm 228237834Smm# Register a --with argument but mark it as deprecated 229237834Smm# $1: The name of the with argument to deprecate, not including --with- 230237834SmmAC_DEFUN([BASIC_DEPRECATED_ARG_WITH], 231237834Smm[ 232237834Smm AC_ARG_WITH($1, [AS_HELP_STRING([--with-$1], 233237834Smm [Deprecated. Option is kept for backwards compatibility and is ignored])], 234237834Smm [AC_MSG_WARN([Option --with-$1 is deprecated and will be ignored.])]) 235237834Smm]) 236237834Smm 237237834Smm# Register a --enable argument but mark it as deprecated 238237834Smm# $1: The name of the with argument to deprecate, not including --enable- 239237834Smm# $2: The name of the argument to deprecate, in shell variable style (i.e. with _ instead of -) 240237834SmmAC_DEFUN([BASIC_DEPRECATED_ARG_ENABLE], 241237834Smm[ 242237834Smm AC_ARG_ENABLE($1, [AS_HELP_STRING([--enable-$1], 243237834Smm [Deprecated. Option is kept for backwards compatibility and is ignored])]) 244237834Smm if test "x$enable_$2" != x; then 245237834Smm AC_MSG_WARN([Option --enable-$1 is deprecated and will be ignored.]) 246237834Smm fi 247237834Smm]) 248237834Smm 249237834SmmAC_DEFUN_ONCE([BASIC_INIT], 250237834Smm[ 251237834Smm # Save the original command line. This is passed to us by the wrapper configure script. 252237834Smm AC_SUBST(CONFIGURE_COMMAND_LINE) 253237834Smm # Save the path variable before it gets changed 254237834Smm ORIGINAL_PATH="$PATH" 255237834Smm AC_SUBST(ORIGINAL_PATH) 256237834Smm DATE_WHEN_CONFIGURED=`LANG=C date` 257237834Smm AC_SUBST(DATE_WHEN_CONFIGURED) 258237834Smm AC_MSG_NOTICE([Configuration created at $DATE_WHEN_CONFIGURED.]) 259237834Smm AC_MSG_NOTICE([configure script generated at timestamp $DATE_WHEN_GENERATED.]) 260237834Smm]) 261237834Smm 262237834Smm# Test that variable $1 denoting a program is not empty. If empty, exit with an error. 263237834Smm# $1: variable to check 264237834SmmAC_DEFUN([BASIC_CHECK_NONEMPTY], 265237834Smm[ 266237834Smm if test "x[$]$1" = x; then 267237834Smm AC_MSG_ERROR([Could not find required tool for $1]) 268237834Smm fi 269237834Smm]) 270237834Smm 271237834Smm# Check that there are no unprocessed overridden variables left. 272237834Smm# If so, they are an incorrect argument and we will exit with an error. 273237834SmmAC_DEFUN([BASIC_CHECK_LEFTOVER_OVERRIDDEN], 274237834Smm[ 275237834Smm if test "x$CONFIGURE_OVERRIDDEN_VARIABLES" != x; then 276237834Smm # Replace the separating ! with spaces before presenting for end user. 277237834Smm unknown_variables=${CONFIGURE_OVERRIDDEN_VARIABLES//!/ } 278237834Smm AC_MSG_WARN([The following variables might be unknown to configure: $unknown_variables]) 279237834Smm fi 280237834Smm]) 281237834Smm 282237834Smm# Setup a tool for the given variable. If correctly specified by the user, 283237834Smm# use that value, otherwise search for the tool using the supplied code snippet. 284237834Smm# $1: variable to set 285237834Smm# $2: code snippet to call to look for the tool 286237834SmmAC_DEFUN([BASIC_SETUP_TOOL], 287237834Smm[ 288237834Smm # Publish this variable in the help. 289237834Smm AC_ARG_VAR($1, [Override default value for $1]) 290237834Smm 291237834Smm if test "x[$]$1" = x; then 292237834Smm # The variable is not set by user, try to locate tool using the code snippet 293237834Smm $2 294237834Smm else 295237834Smm # The variable is set, but is it from the command line or the environment? 296237834Smm 297237834Smm # Try to remove the string !$1! from our list. 298237834Smm try_remove_var=${CONFIGURE_OVERRIDDEN_VARIABLES//!$1!/} 299237834Smm if test "x$try_remove_var" = "x$CONFIGURE_OVERRIDDEN_VARIABLES"; then 300237834Smm # If it failed, the variable was not from the command line. Ignore it, 301237834Smm # but warn the user (except for BASH, which is always set by the calling BASH). 302237834Smm if test "x$1" != xBASH; then 303237834Smm AC_MSG_WARN([Ignoring value of $1 from the environment. Use command line variables instead.]) 304237834Smm fi 305237834Smm # Try to locate tool using the code snippet 306237834Smm $2 307237834Smm else 308237834Smm # If it succeeded, then it was overridden by the user. We will use it 309237834Smm # for the tool. 310237834Smm 311237834Smm # First remove it from the list of overridden variables, so we can test 312237834Smm # for unknown variables in the end. 313237834Smm CONFIGURE_OVERRIDDEN_VARIABLES="$try_remove_var" 314237834Smm 315237834Smm # Check if the provided tool contains a complete path. 316237834Smm tool_specified="[$]$1" 317237834Smm tool_basename="${tool_specified##*/}" 318237834Smm if test "x$tool_basename" = "x$tool_specified"; then 319237834Smm # A command without a complete path is provided, search $PATH. 320237834Smm AC_MSG_NOTICE([Will search for user supplied tool $1=$tool_basename]) 321237834Smm AC_PATH_PROG($1, $tool_basename) 322237834Smm if test "x[$]$1" = x; then 323237834Smm AC_MSG_ERROR([User supplied tool $tool_basename could not be found]) 324237834Smm fi 325237834Smm else 326237834Smm # Otherwise we believe it is a complete path. Use it as it is. 327237834Smm AC_MSG_NOTICE([Will use user supplied tool $1=$tool_specified]) 328237834Smm AC_MSG_CHECKING([for $1]) 329237834Smm if test ! -x "$tool_specified"; then 330237834Smm AC_MSG_RESULT([not found]) 331237834Smm AC_MSG_ERROR([User supplied tool $1=$tool_specified does not exist or is not executable]) 332237834Smm fi 333237834Smm AC_MSG_RESULT([$tool_specified]) 334237834Smm fi 335237834Smm fi 336237834Smm fi 337237834Smm]) 338237834Smm 339237834Smm# Call BASIC_SETUP_TOOL with AC_PATH_PROGS to locate the tool 340237834Smm# $1: variable to set 341237834Smm# $2: executable name (or list of names) to look for 342237834SmmAC_DEFUN([BASIC_PATH_PROGS], 343237834Smm[ 344237834Smm BASIC_SETUP_TOOL($1, [AC_PATH_PROGS($1, $2)]) 345237834Smm]) 346237834Smm 347237834Smm# Call BASIC_SETUP_TOOL with AC_CHECK_TOOLS to locate the tool 348237834Smm# $1: variable to set 349237834Smm# $2: executable name (or list of names) to look for 350237834SmmAC_DEFUN([BASIC_CHECK_TOOLS], 351237834Smm[ 352237834Smm BASIC_SETUP_TOOL($1, [AC_CHECK_TOOLS($1, $2)]) 353237834Smm]) 354237834Smm 355237834Smm# Like BASIC_PATH_PROGS but fails if no tool was found. 356237834Smm# $1: variable to set 357237834Smm# $2: executable name (or list of names) to look for 358237834SmmAC_DEFUN([BASIC_REQUIRE_PROGS], 359237834Smm[ 360237834Smm BASIC_PATH_PROGS($1, $2) 361237834Smm BASIC_CHECK_NONEMPTY($1) 362237834Smm]) 363237834Smm 364237834Smm# Like BASIC_SETUP_TOOL but fails if no tool was found. 365237834Smm# $1: variable to set 366237834Smm# $2: autoconf macro to call to look for the special tool 367237834SmmAC_DEFUN([BASIC_REQUIRE_SPECIAL], 368237834Smm[ 369237834Smm BASIC_SETUP_TOOL($1, [$2]) 370237834Smm BASIC_CHECK_NONEMPTY($1) 371237834Smm]) 372237834Smm 373237834Smm# Setup the most fundamental tools that relies on not much else to set up, 374237834Smm# but is used by much of the early bootstrap code. 375237834SmmAC_DEFUN_ONCE([BASIC_SETUP_FUNDAMENTAL_TOOLS], 376237834Smm[ 377237834Smm # Start with tools that do not need have cross compilation support 378237834Smm # and can be expected to be found in the default PATH. These tools are 379237834Smm # used by configure. Nor are these tools expected to be found in the 380237834Smm # devkit from the builddeps server either, since they are 381237834Smm # needed to download the devkit. 382237834Smm 383237834Smm # First are all the simple required tools. 384237834Smm BASIC_REQUIRE_PROGS(BASENAME, basename) 385237834Smm BASIC_REQUIRE_PROGS(BASH, bash) 386237834Smm BASIC_REQUIRE_PROGS(CAT, cat) 387237834Smm BASIC_REQUIRE_PROGS(CHMOD, chmod) 388237834Smm BASIC_REQUIRE_PROGS(CMP, cmp) 389237834Smm BASIC_REQUIRE_PROGS(COMM, comm) 390237834Smm BASIC_REQUIRE_PROGS(CP, cp) 391237834Smm BASIC_REQUIRE_PROGS(CUT, cut) 392237834Smm BASIC_REQUIRE_PROGS(DATE, date) 393237834Smm BASIC_REQUIRE_PROGS(DIFF, [gdiff diff]) 394237834Smm BASIC_REQUIRE_PROGS(DIRNAME, dirname) 395237834Smm BASIC_REQUIRE_PROGS(ECHO, echo) 396237834Smm BASIC_REQUIRE_PROGS(EXPR, expr) 397237834Smm BASIC_REQUIRE_PROGS(FILE, file) 398237834Smm BASIC_REQUIRE_PROGS(FIND, find) 399237834Smm BASIC_REQUIRE_PROGS(HEAD, head) 400237834Smm BASIC_REQUIRE_PROGS(LN, ln) 401237834Smm BASIC_REQUIRE_PROGS(LS, ls) 402237834Smm BASIC_REQUIRE_PROGS(MKDIR, mkdir) 403237834Smm BASIC_REQUIRE_PROGS(MKTEMP, mktemp) 404237834Smm BASIC_REQUIRE_PROGS(MV, mv) 405237834Smm BASIC_REQUIRE_PROGS(NAWK, [nawk gawk awk]) 406237834Smm BASIC_REQUIRE_PROGS(PRINTF, printf) 407237834Smm BASIC_REQUIRE_PROGS(RM, rm) 408237834Smm BASIC_REQUIRE_PROGS(SH, sh) 409237834Smm BASIC_REQUIRE_PROGS(SORT, sort) 410237834Smm BASIC_REQUIRE_PROGS(TAIL, tail) 411237834Smm BASIC_REQUIRE_PROGS(TAR, tar) 412237834Smm BASIC_REQUIRE_PROGS(TEE, tee) 413237834Smm BASIC_REQUIRE_PROGS(TOUCH, touch) 414237834Smm BASIC_REQUIRE_PROGS(TR, tr) 415237834Smm BASIC_REQUIRE_PROGS(UNAME, uname) 416237834Smm BASIC_REQUIRE_PROGS(UNIQ, uniq) 417237834Smm BASIC_REQUIRE_PROGS(WC, wc) 418237834Smm BASIC_REQUIRE_PROGS(WHICH, which) 419237834Smm BASIC_REQUIRE_PROGS(XARGS, xargs) 420237834Smm 421237834Smm # Then required tools that require some special treatment. 422237834Smm BASIC_REQUIRE_SPECIAL(AWK, [AC_PROG_AWK]) 423237834Smm BASIC_REQUIRE_SPECIAL(GREP, [AC_PROG_GREP]) 424237834Smm BASIC_REQUIRE_SPECIAL(EGREP, [AC_PROG_EGREP]) 425237834Smm BASIC_REQUIRE_SPECIAL(FGREP, [AC_PROG_FGREP]) 426237834Smm BASIC_REQUIRE_SPECIAL(SED, [AC_PROG_SED]) 427237834Smm 428237834Smm # Always force rm. 429237834Smm RM="$RM -f" 430237834Smm 431237834Smm # pwd behaves differently on various platforms and some don't support the -L flag. 432237834Smm # Always use the bash builtin pwd to get uniform behavior. 433237834Smm THEPWDCMD=pwd 434237834Smm 435237834Smm # These are not required on all platforms 436237834Smm BASIC_PATH_PROGS(CYGPATH, cygpath) 437237834Smm BASIC_PATH_PROGS(READLINK, [greadlink readlink]) 438237834Smm BASIC_PATH_PROGS(DF, df) 439237834Smm BASIC_PATH_PROGS(SETFILE, SetFile) 440237834Smm BASIC_PATH_PROGS(CPIO, [cpio bsdcpio]) 441237834Smm]) 442237834Smm 443237834Smm# Setup basic configuration paths, and platform-specific stuff related to PATHs. 444237834SmmAC_DEFUN_ONCE([BASIC_SETUP_PATHS], 445237834Smm[ 446237834Smm # Save the current directory this script was started from 447237834Smm CURDIR="$PWD" 448237834Smm 449237834Smm if test "x$OPENJDK_TARGET_OS" = "xwindows"; then 450237834Smm PATH_SEP=";" 451237834Smm BASIC_CHECK_PATHS_WINDOWS 452237834Smm else 453237834Smm PATH_SEP=":" 454237834Smm fi 455237834Smm AC_SUBST(PATH_SEP) 456237834Smm 457237834Smm # We get the top-level directory from the supporting wrappers. 458237834Smm AC_MSG_CHECKING([for top-level directory]) 459237834Smm AC_MSG_RESULT([$TOPDIR]) 460237834Smm AC_SUBST(TOPDIR) 461237834Smm 462237834Smm # Save the original version of TOPDIR for string comparisons 463237834Smm ORIGINAL_TOPDIR="$TOPDIR" 464237834Smm AC_SUBST(ORIGINAL_TOPDIR) 465237834Smm 466237834Smm # We can only call BASIC_FIXUP_PATH after BASIC_CHECK_PATHS_WINDOWS. 467237834Smm BASIC_FIXUP_PATH(CURDIR) 468237834Smm BASIC_FIXUP_PATH(TOPDIR) 469237834Smm # SRC_ROOT is a traditional alias for TOPDIR. 470237834Smm SRC_ROOT=$TOPDIR 471237834Smm 472237834Smm # Calculate a canonical version of TOPDIR for string comparisons 473237834Smm CANONICAL_TOPDIR=$TOPDIR 474237834Smm BASIC_REMOVE_SYMBOLIC_LINKS([CANONICAL_TOPDIR]) 475237834Smm AC_SUBST(CANONICAL_TOPDIR) 476237834Smm 477237834Smm # Locate the directory of this script. 478237834Smm AUTOCONF_DIR=$TOPDIR/common/autoconf 479237834Smm]) 480237834Smm 481237834Smm# Evaluates platform specific overrides for devkit variables. 482237834Smm# $1: Name of variable 483237834SmmAC_DEFUN([BASIC_EVAL_DEVKIT_VARIABLE], 484237834Smm[ 485237834Smm if test "x[$]$1" = x; then 486237834Smm eval $1="\${$1_${OPENJDK_TARGET_CPU}}" 487237834Smm fi 488237834Smm]) 489237834Smm 490237834SmmAC_DEFUN_ONCE([BASIC_SETUP_DEVKIT], 491237834Smm[ 492237834Smm AC_ARG_WITH([devkit], [AS_HELP_STRING([--with-devkit], 493237834Smm [use this devkit for compilers, tools and resources])], 494237834Smm [ 495237834Smm BASIC_FIXUP_PATH([with_devkit]) 496237834Smm DEVKIT_ROOT="$with_devkit" 497237834Smm # Check for a meta data info file in the root of the devkit 498237834Smm if test -f "$DEVKIT_ROOT/devkit.info"; then 499237834Smm . $DEVKIT_ROOT/devkit.info 500237834Smm # This potentially sets the following: 501237834Smm # A descriptive name of the devkit 502237834Smm BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_NAME]) 503237834Smm # Corresponds to --with-extra-path 504237834Smm BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_EXTRA_PATH]) 505237834Smm # Corresponds to --with-toolchain-path 506237834Smm BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_TOOLCHAIN_PATH]) 507237834Smm # Corresponds to --with-sysroot 508237834Smm BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_SYSROOT]) 509237834Smm 510237834Smm # Identifies the Visual Studio version in the devkit 511237834Smm BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_VS_VERSION]) 512237834Smm # The Visual Studio include environment variable 513237834Smm BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_VS_INCLUDE]) 514237834Smm # The Visual Studio lib environment variable 515237834Smm BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_VS_LIB]) 516237834Smm # Corresponds to --with-msvcr-dll 517237834Smm BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_MSVCR_DLL]) 518237834Smm # Corresponds to --with-msvcp-dll 519237834Smm BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_MSVCP_DLL]) 520237834Smm fi 521237834Smm 522237834Smm AC_MSG_CHECKING([for devkit]) 523237834Smm if test "x$DEVKIT_NAME" != x; then 524237834Smm AC_MSG_RESULT([$DEVKIT_NAME in $DEVKIT_ROOT]) 525237834Smm else 526237834Smm AC_MSG_RESULT([$DEVKIT_ROOT]) 527237834Smm fi 528237834Smm 529237834Smm BASIC_PREPEND_TO_PATH([EXTRA_PATH],$DEVKIT_EXTRA_PATH) 530237834Smm 531237834Smm # Fallback default of just /bin if DEVKIT_PATH is not defined 532237834Smm if test "x$DEVKIT_TOOLCHAIN_PATH" = x; then 533237834Smm DEVKIT_TOOLCHAIN_PATH="$DEVKIT_ROOT/bin" 534237834Smm fi 535237834Smm BASIC_PREPEND_TO_PATH([TOOLCHAIN_PATH],$DEVKIT_TOOLCHAIN_PATH) 536237834Smm 537237834Smm # If DEVKIT_SYSROOT is set, use that, otherwise try a couple of known 538237834Smm # places for backwards compatiblity. 539237834Smm if test "x$DEVKIT_SYSROOT" != x; then 540237834Smm SYSROOT="$DEVKIT_SYSROOT" 541237834Smm elif test -d "$DEVKIT_ROOT/$host_alias/libc"; then 542237834Smm SYSROOT="$DEVKIT_ROOT/$host_alias/libc" 543237834Smm elif test -d "$DEVKIT_ROOT/$host/sys-root"; then 544237834Smm SYSROOT="$DEVKIT_ROOT/$host/sys-root" 545237834Smm fi 546237834Smm ] 547237834Smm ) 548237834Smm 549237834Smm # You can force the sysroot if the sysroot encoded into the compiler tools 550237834Smm # is not correct. 551237834Smm AC_ARG_WITH(sys-root, [AS_HELP_STRING([--with-sys-root], 552237834Smm [alias for --with-sysroot for backwards compatability])], 553237834Smm [SYSROOT=$with_sys_root] 554237834Smm ) 555237834Smm 556237834Smm AC_ARG_WITH(sysroot, [AS_HELP_STRING([--with-sysroot], 557237834Smm [use this directory as sysroot])], 558237834Smm [SYSROOT=$with_sysroot] 559237834Smm ) 560237834Smm 561237834Smm AC_ARG_WITH([tools-dir], [AS_HELP_STRING([--with-tools-dir], 562237834Smm [alias for --with-toolchain-path for backwards compatibility])], 563237834Smm [BASIC_PREPEND_TO_PATH([TOOLCHAIN_PATH],$with_tools_dir)] 564237834Smm ) 565237834Smm 566237834Smm AC_ARG_WITH([toolchain-path], [AS_HELP_STRING([--with-toolchain-path], 567237834Smm [prepend these directories when searching for toolchain binaries (compilers etc)])], 568237834Smm [BASIC_PREPEND_TO_PATH([TOOLCHAIN_PATH],$with_toolchain_path)] 569237834Smm ) 570237834Smm 571237834Smm AC_ARG_WITH([extra-path], [AS_HELP_STRING([--with-extra-path], 572237834Smm [prepend these directories to the default path])], 573237834Smm [BASIC_PREPEND_TO_PATH([EXTRA_PATH],$with_extra_path)] 574237834Smm ) 575237834Smm 576237834Smm if test "x$OPENJDK_BUILD_OS" = "xmacosx"; then 577237834Smm # detect if Xcode is installed by running xcodebuild -version 578237834Smm # if no Xcode installed, xcodebuild exits with 1 579237834Smm # if Xcode is installed, even if xcode-select is misconfigured, then it exits with 0 580237834Smm if /usr/bin/xcodebuild -version >/dev/null 2>&1; then 581237834Smm # We need to use xcodebuild in the toolchain dir provided by the user, this will 582237834Smm # fall back on the stub binary in /usr/bin/xcodebuild 583237834Smm AC_PATH_PROG([XCODEBUILD], [xcodebuild], [/usr/bin/xcodebuild], [$TOOLCHAIN_PATH]) 584237834Smm else 585237834Smm # this should result in SYSROOT being empty, unless --with-sysroot is provided 586237834Smm # when only the command line tools are installed there are no SDKs, so headers 587237834Smm # are copied into the system frameworks 588237834Smm XCODEBUILD= 589237834Smm AC_SUBST(XCODEBUILD) 590237834Smm fi 591237834Smm 592237834Smm AC_MSG_CHECKING([for sdk name]) 593237834Smm AC_ARG_WITH([sdk-name], [AS_HELP_STRING([--with-sdk-name], 594237834Smm [use the platform SDK of the given name. @<:@macosx@:>@])], 595237834Smm [SDKNAME=$with_sdk_name] 596237834Smm ) 597237834Smm AC_MSG_RESULT([$SDKNAME]) 598237834Smm 599237834Smm # if toolchain path is specified then don't rely on system headers, they may not compile 600237834Smm HAVE_SYSTEM_FRAMEWORK_HEADERS=0 601237834Smm test -z "$TOOLCHAIN_PATH" && \ 602237834Smm HAVE_SYSTEM_FRAMEWORK_HEADERS=`test ! -f /System/Library/Frameworks/Foundation.framework/Headers/Foundation.h; echo $?` 603237834Smm 604237834Smm if test -z "$SYSROOT"; then 605237834Smm if test -n "$XCODEBUILD"; then 606237834Smm # if we don't have system headers, use default SDK name (last resort) 607237834Smm if test -z "$SDKNAME" -a $HAVE_SYSTEM_FRAMEWORK_HEADERS -eq 0; then 608237834Smm SDKNAME=${SDKNAME:-macosx} 609237834Smm fi 610237834Smm 611237834Smm if test -n "$SDKNAME"; then 612237834Smm # Call xcodebuild to determine SYSROOT 613237834Smm SYSROOT=`"$XCODEBUILD" -sdk $SDKNAME -version | grep '^Path: ' | sed 's/Path: //'` 614237834Smm fi 615237834Smm else 616237834Smm if test $HAVE_SYSTEM_FRAMEWORK_HEADERS -eq 0; then 617237834Smm AC_MSG_ERROR([No xcodebuild tool and no system framework headers found, use --with-sysroot or --with-sdk-name to provide a path to a valid SDK]) 618237834Smm fi 619237834Smm fi 620237834Smm else 621237834Smm # warn user if --with-sdk-name was also set 622237834Smm if test -n "$with_sdk_name"; then 623237834Smm AC_MSG_WARN([Both SYSROOT and --with-sdk-name are set, only SYSROOT will be used]) 624237834Smm fi 625237834Smm fi 626237834Smm 627237834Smm if test $HAVE_SYSTEM_FRAMEWORK_HEADERS -eq 0 -a -z "$SYSROOT"; then 628237834Smm # If no system framework headers, then SYSROOT must be set, or we won't build 629237834Smm AC_MSG_ERROR([Unable to determine SYSROOT and no headers found in /System/Library/Frameworks. Check Xcode configuration, --with-sysroot or --with-sdk-name arguments.]) 630237834Smm fi 631237834Smm 632237834Smm # Perform a basic sanity test 633237834Smm if test ! -f "$SYSROOT/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h"; then 634237834Smm if test -z "$SYSROOT"; then 635237834Smm AC_MSG_ERROR([Unable to find required framework headers, provide a path to an SDK via --with-sysroot or --with-sdk-name and be sure Xcode is installed properly]) 636237834Smm else 637237834Smm AC_MSG_ERROR([Invalid SDK or SYSROOT path, dependent framework headers not found]) 638237834Smm fi 639237834Smm fi 640237834Smm 641237834Smm # set SDKROOT too, Xcode tools will pick it up 642237834Smm AC_SUBST(SDKROOT,$SYSROOT) 643237834Smm fi 644237834Smm 645237834Smm # Prepend the extra path to the global path 646237834Smm BASIC_PREPEND_TO_PATH([PATH],$EXTRA_PATH) 647237834Smm 648237834Smm if test "x$OPENJDK_BUILD_OS" = "xsolaris"; then 649237834Smm # Add extra search paths on solaris for utilities like ar and as etc... 650237834Smm PATH="$PATH:/usr/ccs/bin:/usr/sfw/bin:/opt/csw/bin" 651237834Smm fi 652237834Smm 653237834Smm AC_MSG_CHECKING([for sysroot]) 654237834Smm AC_MSG_RESULT([$SYSROOT]) 655237834Smm AC_MSG_CHECKING([for toolchain path]) 656237834Smm AC_MSG_RESULT([$TOOLCHAIN_PATH]) 657237834Smm AC_MSG_CHECKING([for extra path]) 658237834Smm AC_MSG_RESULT([$EXTRA_PATH]) 659237834Smm]) 660237834Smm 661237834SmmAC_DEFUN_ONCE([BASIC_SETUP_OUTPUT_DIR], 662237834Smm[ 663237834Smm 664237834Smm AC_ARG_WITH(conf-name, [AS_HELP_STRING([--with-conf-name], 665237834Smm [use this as the name of the configuration @<:@generated from important configuration options@:>@])], 666237834Smm [ CONF_NAME=${with_conf_name} ]) 667237834Smm 668237834Smm # Test from where we are running configure, in or outside of src root. 669237834Smm AC_MSG_CHECKING([where to store configuration]) 670237834Smm if test "x$CURDIR" = "x$SRC_ROOT" || test "x$CURDIR" = "x$SRC_ROOT/common" \ 671237834Smm || test "x$CURDIR" = "x$SRC_ROOT/common/autoconf" \ 672237834Smm || test "x$CURDIR" = "x$SRC_ROOT/make" ; then 673237834Smm # We are running configure from the src root. 674237834Smm # Create a default ./build/target-variant-debuglevel output root. 675237834Smm if test "x${CONF_NAME}" = x; then 676237834Smm AC_MSG_RESULT([in default location]) 677237834Smm CONF_NAME="${OPENJDK_TARGET_OS}-${OPENJDK_TARGET_CPU}-${JDK_VARIANT}-${ANDED_JVM_VARIANTS}-${DEBUG_LEVEL}" 678237834Smm else 679237834Smm AC_MSG_RESULT([in build directory with custom name]) 680237834Smm fi 681237834Smm OUTPUT_ROOT="$SRC_ROOT/build/${CONF_NAME}" 682237834Smm $MKDIR -p "$OUTPUT_ROOT" 683237834Smm if test ! -d "$OUTPUT_ROOT"; then 684237834Smm AC_MSG_ERROR([Could not create build directory $OUTPUT_ROOT]) 685237834Smm fi 686237834Smm else 687237834Smm # We are running configure from outside of the src dir. 688237834Smm # Then use the current directory as output dir! 689237834Smm # If configuration is situated in normal build directory, just use the build 690237834Smm # directory name as configuration name, otherwise use the complete path. 691237834Smm if test "x${CONF_NAME}" = x; then 692237834Smm CONF_NAME=`$ECHO $CURDIR | $SED -e "s!^${SRC_ROOT}/build/!!"` 693237834Smm fi 694237834Smm OUTPUT_ROOT="$CURDIR" 695237834Smm AC_MSG_RESULT([in current directory]) 696237834Smm 697237834Smm # WARNING: This might be a bad thing to do. You need to be sure you want to 698237834Smm # have a configuration in this directory. Do some sanity checks! 699237834Smm 700237834Smm if test ! -e "$OUTPUT_ROOT/spec.gmk"; then 701237834Smm # If we have a spec.gmk, we have run here before and we are OK. Otherwise, check for 702237834Smm # other files 703237834Smm files_present=`$LS $OUTPUT_ROOT` 704237834Smm # Configure has already touched config.log and confdefs.h in the current dir when this check 705237834Smm # is performed. 706237834Smm filtered_files=`$ECHO "$files_present" \ 707237834Smm | $SED -e 's/config.log//g' \ 708237834Smm -e 's/configure.log//g' \ 709237834Smm -e 's/confdefs.h//g' \ 710237834Smm -e 's/ //g' \ 711237834Smm | $TR -d '\n'` 712237834Smm if test "x$filtered_files" != x; then 713237834Smm AC_MSG_NOTICE([Current directory is $CURDIR.]) 714237834Smm AC_MSG_NOTICE([Since this is not the source root, configure will output the configuration here]) 715237834Smm AC_MSG_NOTICE([(as opposed to creating a configuration in <src_root>/build/<conf-name>).]) 716237834Smm AC_MSG_NOTICE([However, this directory is not empty. This is not allowed, since it could]) 717237834Smm AC_MSG_NOTICE([seriously mess up just about everything.]) 718237834Smm AC_MSG_NOTICE([Try 'cd $SRC_ROOT' and restart configure]) 719237834Smm AC_MSG_NOTICE([(or create a new empty directory and cd to it).]) 720237834Smm AC_MSG_ERROR([Will not continue creating configuration in $CURDIR]) 721237834Smm fi 722237834Smm fi 723237834Smm fi 724237834Smm AC_MSG_CHECKING([what configuration name to use]) 725237834Smm AC_MSG_RESULT([$CONF_NAME]) 726237834Smm 727237834Smm BASIC_FIXUP_PATH(OUTPUT_ROOT) 728237834Smm 729237834Smm CONFIGURESUPPORT_OUTPUTDIR="$OUTPUT_ROOT/configure-support" 730237834Smm $MKDIR -p "$CONFIGURESUPPORT_OUTPUTDIR" 731237834Smm 732237834Smm AC_SUBST(SPEC, $OUTPUT_ROOT/spec.gmk) 733237834Smm AC_SUBST(CONF_NAME, $CONF_NAME) 734237834Smm AC_SUBST(OUTPUT_ROOT, $OUTPUT_ROOT) 735237834Smm AC_SUBST(CONFIGURESUPPORT_OUTPUTDIR) 736237834Smm 737237834Smm # The spec.gmk file contains all variables for the make system. 738237834Smm AC_CONFIG_FILES([$OUTPUT_ROOT/spec.gmk:$AUTOCONF_DIR/spec.gmk.in]) 739237834Smm # The hotspot-spec.gmk file contains legacy variables for the hotspot make system. 740237834Smm AC_CONFIG_FILES([$OUTPUT_ROOT/hotspot-spec.gmk:$AUTOCONF_DIR/hotspot-spec.gmk.in]) 741237834Smm # The bootcycle-spec.gmk file contains support for boot cycle builds. 742237834Smm AC_CONFIG_FILES([$OUTPUT_ROOT/bootcycle-spec.gmk:$AUTOCONF_DIR/bootcycle-spec.gmk.in]) 743237834Smm # The compare.sh is used to compare the build output to other builds. 744237834Smm AC_CONFIG_FILES([$OUTPUT_ROOT/compare.sh:$AUTOCONF_DIR/compare.sh.in]) 745237834Smm # The generated Makefile knows where the spec.gmk is and where the source is. 746237834Smm # You can run make from the OUTPUT_ROOT, or from the top-level Makefile 747237834Smm # which will look for generated configurations 748237834Smm AC_CONFIG_FILES([$OUTPUT_ROOT/Makefile:$AUTOCONF_DIR/Makefile.in]) 749237834Smm]) 750237834Smm 751237834Smm#%%% Simple tools %%% 752237834Smm 753237834Smm# Check if we have found a usable version of make 754237834Smm# $1: the path to a potential make binary (or empty) 755237834Smm# $2: the description on how we found this 756237834SmmAC_DEFUN([BASIC_CHECK_MAKE_VERSION], 757237834Smm[ 758237834Smm MAKE_CANDIDATE="$1" 759237834Smm DESCRIPTION="$2" 760237834Smm 761237834Smm # On Cygwin, we require a newer version of make than on other platforms 762237834Smm if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then 763237834Smm MAKE_VERSION_EXPR="-e 4\." 764237834Smm MAKE_REQUIRED_VERSION="4.0" 765237834Smm else 766237834Smm MAKE_VERSION_EXPR="-e 3\.8[[12]] -e 4\." 767237834Smm MAKE_REQUIRED_VERSION="3.81" 768237834Smm fi 769237834Smm 770237834Smm if test "x$MAKE_CANDIDATE" != x; then 771237834Smm AC_MSG_NOTICE([Testing potential make at $MAKE_CANDIDATE, found using $DESCRIPTION]) 772237834Smm MAKE_VERSION_STRING=`$MAKE_CANDIDATE --version | $HEAD -n 1` 773237834Smm IS_GNU_MAKE=`$ECHO $MAKE_VERSION_STRING | $GREP 'GNU Make'` 774237834Smm if test "x$IS_GNU_MAKE" = x; then 775237834Smm AC_MSG_NOTICE([Found potential make at $MAKE_CANDIDATE, however, this is not GNU Make. Ignoring.]) 776237834Smm else 777237834Smm IS_MODERN_MAKE=`$ECHO $MAKE_VERSION_STRING | $GREP $MAKE_VERSION_EXPR` 778237834Smm if test "x$IS_MODERN_MAKE" = x; then 779237834Smm AC_MSG_NOTICE([Found GNU make at $MAKE_CANDIDATE, however this is not version $MAKE_REQUIRED_VERSION or later. (it is: $MAKE_VERSION_STRING). Ignoring.]) 780237834Smm else 781237834Smm if test "x$OPENJDK_BUILD_OS" = "xwindows"; then 782237834Smm if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then 783237834Smm MAKE_EXPECTED_ENV='cygwin' 784237834Smm elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then 785237834Smm MAKE_EXPECTED_ENV='msys' 786237834Smm else 787237834Smm AC_MSG_ERROR([Unknown Windows environment]) 788237834Smm fi 789237834Smm MAKE_BUILT_FOR=`$MAKE_CANDIDATE --version | $GREP -i 'built for'` 790237834Smm IS_MAKE_CORRECT_ENV=`$ECHO $MAKE_BUILT_FOR | $GREP $MAKE_EXPECTED_ENV` 791237834Smm else 792237834Smm # Not relevant for non-Windows 793237834Smm IS_MAKE_CORRECT_ENV=true 794237834Smm fi 795237834Smm if test "x$IS_MAKE_CORRECT_ENV" = x; then 796237834Smm 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.]) 797237834Smm else 798237834Smm FOUND_MAKE=$MAKE_CANDIDATE 799237834Smm BASIC_FIXUP_EXECUTABLE(FOUND_MAKE) 800237834Smm fi 801237834Smm fi 802237834Smm fi 803237834Smm fi 804237834Smm]) 805237834Smm 806237834SmmAC_DEFUN([BASIC_CHECK_MAKE_OUTPUT_SYNC], 807237834Smm[ 808237834Smm # Check if make supports the output sync option and if so, setup using it. 809237834Smm AC_MSG_CHECKING([if make --output-sync is supported]) 810237834Smm if $MAKE --version -O > /dev/null 2>&1; then 811237834Smm OUTPUT_SYNC_SUPPORTED=true 812237834Smm AC_MSG_RESULT([yes]) 813237834Smm AC_MSG_CHECKING([for output-sync value]) 814237834Smm AC_ARG_WITH([output-sync], [AS_HELP_STRING([--with-output-sync], 815237834Smm [set make output sync type if supported by make. @<:@recurse@:>@])], 816237834Smm [OUTPUT_SYNC=$with_output_sync]) 817237834Smm if test "x$OUTPUT_SYNC" = "x"; then 818237834Smm OUTPUT_SYNC=none 819237834Smm fi 820237834Smm AC_MSG_RESULT([$OUTPUT_SYNC]) 821237834Smm if ! $MAKE --version -O$OUTPUT_SYNC > /dev/null 2>&1; then 822237834Smm AC_MSG_ERROR([Make did not the support the value $OUTPUT_SYNC as output sync type.]) 823237834Smm fi 824237834Smm else 825237834Smm OUTPUT_SYNC_SUPPORTED=false 826237834Smm AC_MSG_RESULT([no]) 827237834Smm fi 828237834Smm AC_SUBST(OUTPUT_SYNC_SUPPORTED) 829237834Smm AC_SUBST(OUTPUT_SYNC) 830237834Smm]) 831237834Smm 832237834Smm# Goes looking for a usable version of GNU make. 833237834SmmAC_DEFUN([BASIC_CHECK_GNU_MAKE], 834237834Smm[ 835237834Smm # We need to find a recent version of GNU make. Especially on Solaris, this can be tricky. 836237834Smm if test "x$MAKE" != x; then 837237834Smm # User has supplied a make, test it. 838237834Smm if test ! -f "$MAKE"; then 839237834Smm AC_MSG_ERROR([The specified make (by MAKE=$MAKE) is not found.]) 840237834Smm fi 841237834Smm BASIC_CHECK_MAKE_VERSION("$MAKE", [user supplied MAKE=$MAKE]) 842237834Smm if test "x$FOUND_MAKE" = x; then 843237834Smm AC_MSG_ERROR([The specified make (by MAKE=$MAKE) is not GNU make $MAKE_REQUIRED_VERSION or newer.]) 844237834Smm fi 845237834Smm else 846237834Smm # Try our hardest to locate a correct version of GNU make 847237834Smm AC_PATH_PROGS(CHECK_GMAKE, gmake) 848237834Smm BASIC_CHECK_MAKE_VERSION("$CHECK_GMAKE", [gmake in PATH]) 849237834Smm 850237834Smm if test "x$FOUND_MAKE" = x; then 851237834Smm AC_PATH_PROGS(CHECK_MAKE, make) 852237834Smm BASIC_CHECK_MAKE_VERSION("$CHECK_MAKE", [make in PATH]) 853237834Smm fi 854237834Smm 855237834Smm if test "x$FOUND_MAKE" = x; then 856237834Smm if test "x$TOOLCHAIN_PATH" != x; then 857237834Smm # We have a toolchain path, check that as well before giving up. 858237834Smm OLD_PATH=$PATH 859237834Smm PATH=$TOOLCHAIN_PATH:$PATH 860237834Smm AC_PATH_PROGS(CHECK_TOOLSDIR_GMAKE, gmake) 861237834Smm BASIC_CHECK_MAKE_VERSION("$CHECK_TOOLSDIR_GMAKE", [gmake in tools-dir]) 862237834Smm if test "x$FOUND_MAKE" = x; then 863237834Smm AC_PATH_PROGS(CHECK_TOOLSDIR_MAKE, make) 864237834Smm BASIC_CHECK_MAKE_VERSION("$CHECK_TOOLSDIR_MAKE", [make in tools-dir]) 865237834Smm fi 866237834Smm PATH=$OLD_PATH 867237834Smm fi 868237834Smm fi 869237834Smm 870237834Smm if test "x$FOUND_MAKE" = x; then 871237834Smm AC_MSG_ERROR([Cannot find GNU make $MAKE_REQUIRED_VERSION or newer! Please put it in the path, or add e.g. MAKE=/opt/gmake3.81/make as argument to configure.]) 872237834Smm fi 873237834Smm fi 874237834Smm 875237834Smm MAKE=$FOUND_MAKE 876237834Smm AC_SUBST(MAKE) 877237834Smm AC_MSG_NOTICE([Using GNU make at $FOUND_MAKE (version: $MAKE_VERSION_STRING)]) 878237834Smm 879237834Smm BASIC_CHECK_MAKE_OUTPUT_SYNC 880237834Smm]) 881237834Smm 882237834SmmAC_DEFUN([BASIC_CHECK_FIND_DELETE], 883237834Smm[ 884237834Smm # Test if find supports -delete 885237834Smm AC_MSG_CHECKING([if find supports -delete]) 886237834Smm FIND_DELETE="-delete" 887237834Smm 888237834Smm DELETEDIR=`$MKTEMP -d tmp.XXXXXXXXXX` || (echo Could not create temporary directory!; exit $?) 889237834Smm 890237834Smm echo Hejsan > $DELETEDIR/TestIfFindSupportsDelete 891237834Smm 892237834Smm TEST_DELETE=`$FIND "$DELETEDIR" -name TestIfFindSupportsDelete $FIND_DELETE 2>&1` 893237834Smm if test -f $DELETEDIR/TestIfFindSupportsDelete; then 894237834Smm # No, it does not. 895237834Smm rm $DELETEDIR/TestIfFindSupportsDelete 896237834Smm if test "x$OPENJDK_TARGET_OS" = "xaix"; then 897237834Smm # AIX 'find' is buggy if called with '-exec {} \+' and an empty file list 898237834Smm FIND_DELETE="-print | xargs rm" 899237834Smm else 900237834Smm FIND_DELETE="-exec rm \{\} \+" 901237834Smm fi 902237834Smm AC_MSG_RESULT([no]) 903237834Smm else 904237834Smm AC_MSG_RESULT([yes]) 905237834Smm fi 906237834Smm rmdir $DELETEDIR 907237834Smm AC_SUBST(FIND_DELETE) 908237834Smm]) 909237834Smm 910237834SmmAC_DEFUN_ONCE([BASIC_SETUP_COMPLEX_TOOLS], 911237834Smm[ 912237834Smm BASIC_CHECK_GNU_MAKE 913237834Smm 914237834Smm BASIC_CHECK_FIND_DELETE 915237834Smm 916237834Smm # These tools might not be installed by default, 917237834Smm # need hint on how to install them. 918237834Smm BASIC_REQUIRE_PROGS(UNZIP, unzip) 919237834Smm BASIC_REQUIRE_PROGS(ZIP, zip) 920237834Smm 921237834Smm # Non-required basic tools 922237834Smm 923237834Smm BASIC_PATH_PROGS(LDD, ldd) 924237834Smm if test "x$LDD" = "x"; then 925237834Smm # List shared lib dependencies is used for 926237834Smm # debug output and checking for forbidden dependencies. 927237834Smm # We can build without it. 928237834Smm LDD="true" 929237834Smm fi 930237834Smm BASIC_PATH_PROGS(OTOOL, otool) 931237834Smm if test "x$OTOOL" = "x"; then 932237834Smm OTOOL="true" 933237834Smm fi 934237834Smm BASIC_PATH_PROGS(READELF, [greadelf readelf]) 935237834Smm BASIC_PATH_PROGS(HG, hg) 936237834Smm BASIC_PATH_PROGS(STAT, stat) 937237834Smm BASIC_PATH_PROGS(TIME, time) 938237834Smm # Check if it's GNU time 939237834Smm IS_GNU_TIME=`$TIME --version 2>&1 | $GREP 'GNU time'` 940237834Smm if test "x$IS_GNU_TIME" != x; then 941237834Smm IS_GNU_TIME=yes 942237834Smm else 943237834Smm IS_GNU_TIME=no 944237834Smm fi 945237834Smm AC_SUBST(IS_GNU_TIME) 946237834Smm 947237834Smm if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then 948237834Smm BASIC_REQUIRE_PROGS(DSYMUTIL, dsymutil) 949237834Smm BASIC_REQUIRE_PROGS(XATTR, xattr) 950237834Smm BASIC_PATH_PROGS(CODESIGN, codesign) 951237834Smm if test "x$CODESIGN" != "x"; then 952237834Smm # Verify that the openjdk_codesign certificate is present 953237834Smm AC_MSG_CHECKING([if openjdk_codesign certificate is present]) 954237834Smm rm -f codesign-testfile 955237834Smm touch codesign-testfile 956237834Smm codesign -s openjdk_codesign codesign-testfile 2>&AS_MESSAGE_LOG_FD >&AS_MESSAGE_LOG_FD || CODESIGN= 957237834Smm rm -f codesign-testfile 958237834Smm if test "x$CODESIGN" = x; then 959237834Smm AC_MSG_RESULT([no]) 960237834Smm else 961237834Smm AC_MSG_RESULT([yes]) 962237834Smm fi 963237834Smm fi 964237834Smm fi 965237834Smm]) 966237834Smm 967237834Smm# Check if build directory is on local disk. If not possible to determine, 968237834Smm# we prefer to claim it's local. 969237834Smm# Argument 1: directory to test 970237834Smm# Argument 2: what to do if it is on local disk 971237834Smm# Argument 3: what to do otherwise (remote disk or failure) 972237834SmmAC_DEFUN([BASIC_CHECK_DIR_ON_LOCAL_DISK], 973237834Smm[ 974237834Smm # df -l lists only local disks; if the given directory is not found then 975237834Smm # a non-zero exit code is given 976237834Smm if test "x$DF" = x; then 977237834Smm if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then 978237834Smm # msys does not have df; use Windows "net use" instead. 979237834Smm IS_NETWORK_DISK=`net use | grep \`pwd -W | cut -d ":" -f 1 | tr a-z A-Z\`:` 980237834Smm if test "x$IS_NETWORK_DISK" = x; then 981237834Smm $2 982237834Smm else 983237834Smm $3 984237834Smm fi 985237834Smm else 986237834Smm # No df here, say it's local 987237834Smm $2 988237834Smm fi 989237834Smm else 990237834Smm if $DF -l $1 > /dev/null 2>&1; then 991237834Smm $2 992237834Smm else 993237834Smm $3 994237834Smm fi 995237834Smm fi 996237834Smm]) 997237834Smm 998237834Smm# Check that source files have basic read permissions set. This might 999237834Smm# not be the case in cygwin in certain conditions. 1000237834SmmAC_DEFUN_ONCE([BASIC_CHECK_SRC_PERMS], 1001237834Smm[ 1002237834Smm if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then 1003237834Smm file_to_test="$SRC_ROOT/LICENSE" 1004237834Smm if test `$STAT -c '%a' "$file_to_test"` -lt 400; then 1005237834Smm 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.]) 1006237834Smm fi 1007237834Smm fi 1008237834Smm]) 1009237834Smm 1010237834SmmAC_DEFUN_ONCE([BASIC_TEST_USABILITY_ISSUES], 1011237834Smm[ 1012237834Smm # Did user specify any unknown variables? 1013237834Smm BASIC_CHECK_LEFTOVER_OVERRIDDEN 1014237834Smm 1015237834Smm AC_MSG_CHECKING([if build directory is on local disk]) 1016237834Smm BASIC_CHECK_DIR_ON_LOCAL_DISK($OUTPUT_ROOT, 1017237834Smm [OUTPUT_DIR_IS_LOCAL="yes"], 1018237834Smm [OUTPUT_DIR_IS_LOCAL="no"]) 1019237834Smm AC_MSG_RESULT($OUTPUT_DIR_IS_LOCAL) 1020237834Smm 1021237834Smm BASIC_CHECK_SRC_PERMS 1022237834Smm 1023237834Smm # Check if the user has any old-style ALT_ variables set. 1024237834Smm FOUND_ALT_VARIABLES=`env | grep ^ALT_` 1025237834Smm 1026237834Smm # Before generating output files, test if they exist. If they do, this is a reconfigure. 1027237834Smm # Since we can't properly handle the dependencies for this, warn the user about the situation 1028237834Smm if test -e $OUTPUT_ROOT/spec.gmk; then 1029237834Smm IS_RECONFIGURE=yes 1030237834Smm else 1031237834Smm IS_RECONFIGURE=no 1032237834Smm fi 1033237834Smm]) 1034237834Smm 1035237834Smm# Check for support for specific options in bash 1036237834SmmAC_DEFUN_ONCE([BASIC_CHECK_BASH_OPTIONS], 1037237834Smm[ 1038237834Smm # Test if bash supports pipefail. 1039237834Smm AC_MSG_CHECKING([if bash supports pipefail]) 1040237834Smm if ${BASH} -c 'set -o pipefail'; then 1041237834Smm BASH_ARGS="$BASH_ARGS -o pipefail" 1042237834Smm AC_MSG_RESULT([yes]) 1043237834Smm else 1044237834Smm AC_MSG_RESULT([no]) 1045237834Smm fi 1046237834Smm 1047237834Smm AC_MSG_CHECKING([if bash supports errexit (-e)]) 1048237834Smm if ${BASH} -e -c 'true'; then 1049237834Smm BASH_ARGS="$BASH_ARGS -e" 1050237834Smm AC_MSG_RESULT([yes]) 1051237834Smm else 1052237834Smm AC_MSG_RESULT([no]) 1053237834Smm fi 1054237834Smm 1055237834Smm AC_SUBST(BASH_ARGS) 1056237834Smm]) 1057237834Smm 1058237834Smm# Code to run after AC_OUTPUT 1059237834SmmAC_DEFUN_ONCE([BASIC_POST_CONFIG_OUTPUT], 1060237834Smm[ 1061237834Smm # Try to move config.log (generated by autoconf) to the configure-support directory. 1062237834Smm if test -e ./config.log; then 1063237834Smm $MV -f ./config.log "$CONFIGURESUPPORT_OUTPUTDIR/config.log" 2> /dev/null 1064237834Smm fi 1065237834Smm 1066237834Smm # Rotate our log file (configure.log) 1067237834Smm if test -e "$OUTPUT_ROOT/configure.log.old"; then 1068237834Smm $RM -f "$OUTPUT_ROOT/configure.log.old" 1069237834Smm fi 1070237834Smm if test -e "$OUTPUT_ROOT/configure.log"; then 1071237834Smm $MV -f "$OUTPUT_ROOT/configure.log" "$OUTPUT_ROOT/configure.log.old" 2> /dev/null 1072237834Smm fi 1073237834Smm 1074237834Smm # Move configure.log from current directory to the build output root 1075237834Smm if test -e ./configure.log; then 1076237834Smm echo found it 1077237834Smm $MV -f ./configure.log "$OUTPUT_ROOT/configure.log" 2> /dev/null 1078237834Smm fi 1079237834Smm 1080237834Smm # Make the compare script executable 1081237834Smm $CHMOD +x $OUTPUT_ROOT/compare.sh 1082237834Smm]) 1083237834Smm