basics.m4 revision 862:9e177e7fc438
1176187Srafan# 2176187Srafan# Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. 3176187Srafan# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4176187Srafan# 5176187Srafan# This code is free software; you can redistribute it and/or modify it 6176187Srafan# under the terms of the GNU General Public License version 2 only, as 7176187Srafan# published by the Free Software Foundation. Oracle designates this 8176187Srafan# particular file as subject to the "Classpath" exception as provided 9176187Srafan# by Oracle in the LICENSE file that accompanied this code. 10176187Srafan# 11176187Srafan# This code is distributed in the hope that it will be useful, but WITHOUT 12176187Srafan# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13176187Srafan# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14176187Srafan# version 2 for more details (a copy is included in the LICENSE file that 15176187Srafan# accompanied this code). 16176187Srafan# 17176187Srafan# You should have received a copy of the GNU General Public License version 18176187Srafan# 2 along with this work; if not, write to the Free Software Foundation, 19176187Srafan# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20176187Srafan# 21176187Srafan# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22176187Srafan# or visit www.oracle.com if you need additional information or have any 23176187Srafan# questions. 24176187Srafan# 25176187Srafan 26176187Srafan# Test if $1 is a valid argument to $3 (often is $JAVA passed as $3) 27176187Srafan# If so, then append $1 to $2 \ 28176187Srafan# Also set JVM_ARG_OK to true/false depending on outcome. 29176187SrafanAC_DEFUN([ADD_JVM_ARG_IF_OK], 30176187Srafan[ 31176187Srafan $ECHO "Check if jvm arg is ok: $1" >&AS_MESSAGE_LOG_FD 32176187Srafan $ECHO "Command: $3 $1 -version" >&AS_MESSAGE_LOG_FD 33176187Srafan OUTPUT=`$3 $1 -version 2>&1` 34176187Srafan FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn` 35176187Srafan FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""` 36176187Srafan if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then 37176187Srafan $2="[$]$2 $1" 38176187Srafan JVM_ARG_OK=true 39176187Srafan else 40176187Srafan $ECHO "Arg failed:" >&AS_MESSAGE_LOG_FD 41176187Srafan $ECHO "$OUTPUT" >&AS_MESSAGE_LOG_FD 42176187Srafan JVM_ARG_OK=false 43176187Srafan fi 44176187Srafan]) 45176187Srafan 46176187Srafan# Appends a string to a path variable, only adding the : when needed. 47176187SrafanAC_DEFUN([BASIC_APPEND_TO_PATH], 48176187Srafan[ 49176187Srafan if test "x[$]$1" = x; then 50176187Srafan $1="$2" 51176187Srafan else 52176187Srafan $1="[$]$1:$2" 53176187Srafan fi 54176187Srafan]) 55176187Srafan 56176187Srafan# This will make sure the given variable points to a full and proper 57176187Srafan# path. This means: 58176187Srafan# 1) There will be no spaces in the path. On posix platforms, 59176187Srafan# spaces in the path will result in an error. On Windows, 60176187Srafan# the path will be rewritten using short-style to be space-free. 61176187Srafan# 2) The path will be absolute, and it will be in unix-style (on 62176187Srafan# cygwin). 63176187Srafan# $1: The name of the variable to fix 64176187SrafanAC_DEFUN([BASIC_FIXUP_PATH], 65176187Srafan[ 66176187Srafan if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then 67176187Srafan BASIC_FIXUP_PATH_CYGWIN($1) 68176187Srafan elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then 69176187Srafan BASIC_FIXUP_PATH_MSYS($1) 70176187Srafan else 71176187Srafan # We're on a posix platform. Hooray! :) 72176187Srafan path="[$]$1" 73176187Srafan has_space=`$ECHO "$path" | $GREP " "` 74176187Srafan if test "x$has_space" != x; then 75176187Srafan AC_MSG_NOTICE([The path of $1, which resolves as "$path", is invalid.]) 76176187Srafan AC_MSG_ERROR([Spaces are not allowed in this path.]) 77176187Srafan fi 78176187Srafan 79176187Srafan # Use eval to expand a potential ~ 80176187Srafan eval path="$path" 81176187Srafan if test ! -f "$path" && test ! -d "$path"; then 82176187Srafan AC_MSG_ERROR([The path of $1, which resolves as "$path", is not found.]) 83176187Srafan fi 84176187Srafan 85176187Srafan $1="`cd "$path"; $THEPWDCMD -L`" 86176187Srafan fi 87176187Srafan]) 88176187Srafan 89176187Srafan# This will make sure the given variable points to a executable 90176187Srafan# with a full and proper path. This means: 91176187Srafan# 1) There will be no spaces in the path. On posix platforms, 92176187Srafan# spaces in the path will result in an error. On Windows, 93176187Srafan# the path will be rewritten using short-style to be space-free. 94176187Srafan# 2) The path will be absolute, and it will be in unix-style (on 95176187Srafan# cygwin). 96176187Srafan# Any arguments given to the executable is preserved. 97176187Srafan# If the input variable does not have a directory specification, then 98176187Srafan# it need to be in the PATH. 99176187Srafan# $1: The name of the variable to fix 100176187SrafanAC_DEFUN([BASIC_FIXUP_EXECUTABLE], 101176187Srafan[ 102176187Srafan if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then 103176187Srafan BASIC_FIXUP_EXECUTABLE_CYGWIN($1) 104176187Srafan elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then 105176187Srafan BASIC_FIXUP_EXECUTABLE_MSYS($1) 106176187Srafan else 107176187Srafan # We're on a posix platform. Hooray! :) 108176187Srafan # First separate the path from the arguments. This will split at the first 109176187Srafan # space. 110176187Srafan complete="[$]$1" 111176187Srafan path="${complete%% *}" 112176187Srafan tmp="$complete EOL" 113176187Srafan arguments="${tmp#* }" 114176187Srafan 115176187Srafan # Cannot rely on the command "which" here since it doesn't always work. 116176187Srafan is_absolute_path=`$ECHO "$path" | $GREP ^/` 117176187Srafan if test -z "$is_absolute_path"; then 118176187Srafan # Path to executable is not absolute. Find it. 119176187Srafan IFS_save="$IFS" 120176187Srafan IFS=: 121176187Srafan for p in $PATH; do 122176187Srafan if test -f "$p/$path" && test -x "$p/$path"; then 123176187Srafan new_path="$p/$path" 124176187Srafan break 125176187Srafan fi 126176187Srafan done 127176187Srafan IFS="$IFS_save" 128176187Srafan else 129176187Srafan AC_MSG_NOTICE([Resolving $1 (as $path) failed, using $path directly.]) 130176187Srafan new_path="$path" 131176187Srafan fi 132176187Srafan 133176187Srafan if test "x$new_path" = x; then 134176187Srafan AC_MSG_NOTICE([The path of $1, which resolves as "$complete", is not found.]) 135176187Srafan has_space=`$ECHO "$complete" | $GREP " "` 136176187Srafan if test "x$has_space" != x; then 137176187Srafan AC_MSG_NOTICE([This might be caused by spaces in the path, which is not allowed.]) 138176187Srafan fi 139176187Srafan AC_MSG_ERROR([Cannot locate the the path of $1]) 140176187Srafan fi 141176187Srafan fi 142176187Srafan 143176187Srafan # Now join together the path and the arguments once again 144176187Srafan if test "x$arguments" != xEOL; then 145176187Srafan new_complete="$new_path ${arguments% *}" 146176187Srafan else 147176187Srafan new_complete="$new_path" 148176187Srafan fi 149176187Srafan 150176187Srafan if test "x$complete" != "x$new_complete"; then 151176187Srafan $1="$new_complete" 152176187Srafan AC_MSG_NOTICE([Rewriting $1 to "$new_complete"]) 153176187Srafan fi 154176187Srafan]) 155176187Srafan 156176187SrafanAC_DEFUN([BASIC_REMOVE_SYMBOLIC_LINKS], 157176187Srafan[ 158176187Srafan if test "x$OPENJDK_BUILD_OS" != xwindows; then 159176187Srafan # Follow a chain of symbolic links. Use readlink 160176187Srafan # where it exists, else fall back to horribly 161176187Srafan # complicated shell code. 162176187Srafan if test "x$READLINK_TESTED" != yes; then 163176187Srafan # On MacOSX there is a readlink tool with a different 164176187Srafan # purpose than the GNU readlink tool. Check the found readlink. 165176187Srafan ISGNU=`$READLINK --version 2>&1 | $GREP GNU` 166176187Srafan if test "x$ISGNU" = x; then 167176187Srafan # A readlink that we do not know how to use. 168176187Srafan # Are there other non-GNU readlinks out there? 169176187Srafan READLINK_TESTED=yes 170176187Srafan READLINK= 171176187Srafan fi 172176187Srafan fi 173176187Srafan 174176187Srafan if test "x$READLINK" != x; then 175176187Srafan $1=`$READLINK -f [$]$1` 176176187Srafan else 177176187Srafan # Save the current directory for restoring afterwards 178176187Srafan STARTDIR=$PWD 179176187Srafan COUNTER=0 180176187Srafan sym_link_dir=`$DIRNAME [$]$1` 181176187Srafan sym_link_file=`$BASENAME [$]$1` 182176187Srafan cd $sym_link_dir 183176187Srafan # Use -P flag to resolve symlinks in directories. 184176187Srafan cd `$THEPWDCMD -P` 185176187Srafan sym_link_dir=`$THEPWDCMD -P` 186176187Srafan # Resolve file symlinks 187176187Srafan while test $COUNTER -lt 20; do 188176187Srafan ISLINK=`$LS -l $sym_link_dir/$sym_link_file | $GREP '\->' | $SED -e 's/.*-> \(.*\)/\1/'` 189176187Srafan if test "x$ISLINK" == x; then 190176187Srafan # This is not a symbolic link! We are done! 191176187Srafan break 192176187Srafan fi 193176187Srafan # Again resolve directory symlinks since the target of the just found 194176187Srafan # link could be in a different directory 195176187Srafan cd `$DIRNAME $ISLINK` 196176187Srafan sym_link_dir=`$THEPWDCMD -P` 197176187Srafan sym_link_file=`$BASENAME $ISLINK` 198176187Srafan let COUNTER=COUNTER+1 199176187Srafan done 200176187Srafan cd $STARTDIR 201176187Srafan $1=$sym_link_dir/$sym_link_file 202176187Srafan fi 203176187Srafan fi 204176187Srafan]) 205176187Srafan 206176187Srafan# Register a --with argument but mark it as deprecated 207176187Srafan# $1: The name of the with argument to deprecate, not including --with- 208176187SrafanAC_DEFUN([BASIC_DEPRECATED_ARG_WITH], 209176187Srafan[ 210176187Srafan AC_ARG_WITH($1, [AS_HELP_STRING([--with-$1], 211176187Srafan [Deprecated. Option is kept for backwards compatibility and is ignored])], 212176187Srafan [AC_MSG_WARN([Option --with-$1 is deprecated and will be ignored.])]) 213176187Srafan]) 214176187Srafan 215176187Srafan# Register a --enable argument but mark it as deprecated 216176187Srafan# $1: The name of the with argument to deprecate, not including --enable- 217176187Srafan# $2: The name of the argument to deprecate, in shell variable style (i.e. with _ instead of -) 218176187SrafanAC_DEFUN([BASIC_DEPRECATED_ARG_ENABLE], 219176187Srafan[ 220176187Srafan AC_ARG_ENABLE($1, [AS_HELP_STRING([--enable-$1], 221176187Srafan [Deprecated. Option is kept for backwards compatibility and is ignored])]) 222176187Srafan if test "x$enable_$2" != x; then 223176187Srafan AC_MSG_WARN([Option --enable-$1 is deprecated and will be ignored.]) 224176187Srafan fi 225176187Srafan]) 226176187Srafan 227176187SrafanAC_DEFUN_ONCE([BASIC_INIT], 228176187Srafan[ 229176187Srafan # Save the original command line. This is passed to us by the wrapper configure script. 230176187Srafan AC_SUBST(CONFIGURE_COMMAND_LINE) 231176187Srafan DATE_WHEN_CONFIGURED=`LANG=C date` 232176187Srafan AC_SUBST(DATE_WHEN_CONFIGURED) 233176187Srafan AC_MSG_NOTICE([Configuration created at $DATE_WHEN_CONFIGURED.]) 234176187Srafan AC_MSG_NOTICE([configure script generated at timestamp $DATE_WHEN_GENERATED.]) 235176187Srafan]) 236176187Srafan 237176187Srafan# Test that variable $1 denoting a program is not empty. If empty, exit with an error. 238176187Srafan# $1: variable to check 239176187Srafan# $2: executable name to print in warning (optional) 240176187SrafanAC_DEFUN([BASIC_CHECK_NONEMPTY], 241176187Srafan[ 242176187Srafan if test "x[$]$1" = x; then 243176187Srafan if test "x$2" = x; then 244176187Srafan PROG_NAME=translit($1,A-Z,a-z) 245176187Srafan else 246176187Srafan PROG_NAME=$2 247176187Srafan fi 248176187Srafan AC_MSG_NOTICE([Could not find $PROG_NAME!]) 249176187Srafan AC_MSG_ERROR([Cannot continue]) 250176187Srafan fi 251176187Srafan]) 252176187Srafan 253176187Srafan# Does AC_PATH_PROG followed by BASIC_CHECK_NONEMPTY. 254176187Srafan# Arguments as AC_PATH_PROG: 255176187Srafan# $1: variable to set 256176187Srafan# $2: executable name to look for 257176187SrafanAC_DEFUN([BASIC_REQUIRE_PROG], 258176187Srafan[ 259176187Srafan AC_PATH_PROGS($1, $2) 260176187Srafan BASIC_CHECK_NONEMPTY($1, $2) 261176187Srafan]) 262176187Srafan 263176187Srafan# Setup the most fundamental tools that relies on not much else to set up, 264176187Srafan# but is used by much of the early bootstrap code. 265176187SrafanAC_DEFUN_ONCE([BASIC_SETUP_FUNDAMENTAL_TOOLS], 266176187Srafan[ 267176187Srafan 268176187Srafan # Start with tools that do not need have cross compilation support 269176187Srafan # and can be expected to be found in the default PATH. These tools are 270176187Srafan # used by configure. Nor are these tools expected to be found in the 271176187Srafan # devkit from the builddeps server either, since they are 272176187Srafan # needed to download the devkit. 273176187Srafan 274176187Srafan # First are all the simple required tools. 275176187Srafan BASIC_REQUIRE_PROG(BASENAME, basename) 276176187Srafan BASIC_REQUIRE_PROG(BASH, bash) 277176187Srafan BASIC_REQUIRE_PROG(CAT, cat) 278176187Srafan BASIC_REQUIRE_PROG(CHMOD, chmod) 279176187Srafan BASIC_REQUIRE_PROG(CMP, cmp) 280176187Srafan BASIC_REQUIRE_PROG(COMM, comm) 281176187Srafan BASIC_REQUIRE_PROG(CP, cp) 282176187Srafan BASIC_REQUIRE_PROG(CPIO, cpio) 283176187Srafan BASIC_REQUIRE_PROG(CUT, cut) 284176187Srafan BASIC_REQUIRE_PROG(DATE, date) 285176187Srafan BASIC_REQUIRE_PROG(DIFF, [gdiff diff]) 286176187Srafan BASIC_REQUIRE_PROG(DIRNAME, dirname) 287176187Srafan BASIC_REQUIRE_PROG(ECHO, echo) 288176187Srafan BASIC_REQUIRE_PROG(EXPR, expr) 289176187Srafan BASIC_REQUIRE_PROG(FILE, file) 290176187Srafan BASIC_REQUIRE_PROG(FIND, find) 291176187Srafan BASIC_REQUIRE_PROG(HEAD, head) 292176187Srafan BASIC_REQUIRE_PROG(LN, ln) 293176187Srafan BASIC_REQUIRE_PROG(LS, ls) 294176187Srafan BASIC_REQUIRE_PROG(MKDIR, mkdir) 295176187Srafan BASIC_REQUIRE_PROG(MKTEMP, mktemp) 296176187Srafan BASIC_REQUIRE_PROG(MV, mv) 297176187Srafan BASIC_REQUIRE_PROG(PRINTF, printf) 298176187Srafan BASIC_REQUIRE_PROG(RM, rm) 299176187Srafan BASIC_REQUIRE_PROG(SH, sh) 300176187Srafan BASIC_REQUIRE_PROG(SORT, sort) 301176187Srafan BASIC_REQUIRE_PROG(TAIL, tail) 302176187Srafan BASIC_REQUIRE_PROG(TAR, tar) 303176187Srafan BASIC_REQUIRE_PROG(TEE, tee) 304176187Srafan BASIC_REQUIRE_PROG(TOUCH, touch) 305176187Srafan BASIC_REQUIRE_PROG(TR, tr) 306176187Srafan BASIC_REQUIRE_PROG(UNAME, uname) 307176187Srafan BASIC_REQUIRE_PROG(UNIQ, uniq) 308176187Srafan BASIC_REQUIRE_PROG(WC, wc) 309176187Srafan BASIC_REQUIRE_PROG(WHICH, which) 310176187Srafan BASIC_REQUIRE_PROG(XARGS, xargs) 311176187Srafan 312176187Srafan # Then required tools that require some special treatment. 313176187Srafan AC_PROG_AWK 314176187Srafan BASIC_CHECK_NONEMPTY(AWK) 315176187Srafan AC_PROG_GREP 316176187Srafan BASIC_CHECK_NONEMPTY(GREP) 317176187Srafan AC_PROG_EGREP 318176187Srafan BASIC_CHECK_NONEMPTY(EGREP) 319176187Srafan AC_PROG_FGREP 320176187Srafan BASIC_CHECK_NONEMPTY(FGREP) 321176187Srafan AC_PROG_SED 322176187Srafan BASIC_CHECK_NONEMPTY(SED) 323176187Srafan 324176187Srafan AC_PATH_PROGS(NAWK, [nawk gawk awk]) 325176187Srafan BASIC_CHECK_NONEMPTY(NAWK) 326176187Srafan 327176187Srafan # Always force rm. 328176187Srafan RM="$RM -f" 329176187Srafan 330176187Srafan # pwd behaves differently on various platforms and some don't support the -L flag. 331176187Srafan # Always use the bash builtin pwd to get uniform behavior. 332176187Srafan THEPWDCMD=pwd 333176187Srafan 334176187Srafan # These are not required on all platforms 335176187Srafan AC_PATH_PROG(CYGPATH, cygpath) 336176187Srafan AC_PATH_PROG(READLINK, readlink) 337176187Srafan AC_PATH_PROG(DF, df) 338176187Srafan AC_PATH_PROG(SETFILE, SetFile) 339176187Srafan]) 340176187Srafan 341176187Srafan# Setup basic configuration paths, and platform-specific stuff related to PATHs. 342176187SrafanAC_DEFUN_ONCE([BASIC_SETUP_PATHS], 343176187Srafan[ 344176187Srafan # Locate the directory of this script. 345176187Srafan SCRIPT="[$]0" 346176187Srafan AUTOCONF_DIR=`cd \`$DIRNAME $SCRIPT\`; $THEPWDCMD -L` 347176187Srafan 348176187Srafan # Where is the source? It is located two levels above the configure script. 349176187Srafan CURDIR="$PWD" 350176187Srafan cd "$AUTOCONF_DIR/../.." 351176187Srafan SRC_ROOT="`$THEPWDCMD -L`" 352176187Srafan 353176187Srafan if test "x$OPENJDK_TARGET_OS" = "xwindows"; then 354176187Srafan PATH_SEP=";" 355176187Srafan BASIC_CHECK_PATHS_WINDOWS 356176187Srafan else 357176187Srafan PATH_SEP=":" 358176187Srafan fi 359176187Srafan 360176187Srafan AC_SUBST(SRC_ROOT) 361176187Srafan AC_SUBST(PATH_SEP) 362176187Srafan cd "$CURDIR" 363176187Srafan 364176187Srafan BASIC_FIXUP_PATH(SRC_ROOT) 365176187Srafan BASIC_FIXUP_PATH(CURDIR) 366176187Srafan 367176187Srafan if test "x$OPENJDK_BUILD_OS" = "xsolaris"; then 368176187Srafan # Add extra search paths on solaris for utilities like ar and as etc... 369176187Srafan PATH="$PATH:/usr/ccs/bin:/usr/sfw/bin:/opt/csw/bin" 370176187Srafan fi 371176187Srafan 372176187Srafan # You can force the sys-root if the sys-root encoded into the cross compiler tools 373176187Srafan # is not correct. 374176187Srafan AC_ARG_WITH(sys-root, [AS_HELP_STRING([--with-sys-root], 375176187Srafan [pass this sys-root to the compilers and tools (for cross-compiling)])]) 376176187Srafan 377176187Srafan if test "x$with_sys_root" != x; then 378176187Srafan SYS_ROOT=$with_sys_root 379176187Srafan else 380176187Srafan SYS_ROOT=/ 381176187Srafan fi 382176187Srafan AC_SUBST(SYS_ROOT) 383176187Srafan 384176187Srafan AC_ARG_WITH([tools-dir], [AS_HELP_STRING([--with-tools-dir], 385176187Srafan [search this directory for compilers and tools (for cross-compiling)])], 386176187Srafan [TOOLS_DIR=$with_tools_dir] 387176187Srafan ) 388176187Srafan 389176187Srafan AC_ARG_WITH([devkit], [AS_HELP_STRING([--with-devkit], 390176187Srafan [use this directory as base for tools-dir and sys-root (for cross-compiling)])], 391176187Srafan [ 392176187Srafan if test "x$with_sys_root" != x; then 393176187Srafan AC_MSG_ERROR([Cannot specify both --with-devkit and --with-sys-root at the same time]) 394176187Srafan fi 395176187Srafan BASIC_FIXUP_PATH([with_devkit]) 396176187Srafan BASIC_APPEND_TO_PATH([TOOLS_DIR],$with_devkit/bin) 397176187Srafan if test -d "$with_devkit/$host_alias/libc"; then 398176187Srafan SYS_ROOT=$with_devkit/$host_alias/libc 399176187Srafan elif test -d "$with_devkit/$host/sys-root"; then 400176187Srafan SYS_ROOT=$with_devkit/$host/sys-root 401176187Srafan fi 402176187Srafan ]) 403176187Srafan]) 404176187Srafan 405176187SrafanAC_DEFUN_ONCE([BASIC_SETUP_OUTPUT_DIR], 406176187Srafan[ 407176187Srafan 408176187Srafan AC_ARG_WITH(conf-name, [AS_HELP_STRING([--with-conf-name], 409176187Srafan [use this as the name of the configuration @<:@generated from important configuration options@:>@])], 410176187Srafan [ CONF_NAME=${with_conf_name} ]) 411176187Srafan 412176187Srafan # Test from where we are running configure, in or outside of src root. 413176187Srafan if test "x$CURDIR" = "x$SRC_ROOT" || test "x$CURDIR" = "x$SRC_ROOT/common" \ 414176187Srafan || test "x$CURDIR" = "x$SRC_ROOT/common/autoconf" \ 415176187Srafan || test "x$CURDIR" = "x$SRC_ROOT/common/makefiles" ; then 416176187Srafan # We are running configure from the src root. 417176187Srafan # Create a default ./build/target-variant-debuglevel output root. 418176187Srafan if test "x${CONF_NAME}" = x; then 419176187Srafan CONF_NAME="${OPENJDK_TARGET_OS}-${OPENJDK_TARGET_CPU}-${JDK_VARIANT}-${ANDED_JVM_VARIANTS}-${DEBUG_LEVEL}" 420176187Srafan fi 421176187Srafan OUTPUT_ROOT="$SRC_ROOT/build/${CONF_NAME}" 422176187Srafan $MKDIR -p "$OUTPUT_ROOT" 423176187Srafan if test ! -d "$OUTPUT_ROOT"; then 424176187Srafan AC_MSG_ERROR([Could not create build directory $OUTPUT_ROOT]) 425176187Srafan fi 426176187Srafan else 427176187Srafan # We are running configure from outside of the src dir. 428176187Srafan # Then use the current directory as output dir! 429176187Srafan # If configuration is situated in normal build directory, just use the build 430176187Srafan # directory name as configuration name, otherwise use the complete path. 431176187Srafan if test "x${CONF_NAME}" = x; then 432176187Srafan CONF_NAME=`$ECHO $CURDIR | $SED -e "s!^${SRC_ROOT}/build/!!"` 433176187Srafan fi 434176187Srafan OUTPUT_ROOT="$CURDIR" 435176187Srafan 436176187Srafan # WARNING: This might be a bad thing to do. You need to be sure you want to 437176187Srafan # have a configuration in this directory. Do some sanity checks! 438176187Srafan 439176187Srafan if test ! -e "$OUTPUT_ROOT/spec.gmk"; then 440176187Srafan # If we have a spec.gmk, we have run here before and we are OK. Otherwise, check for 441176187Srafan # other files 442176187Srafan files_present=`$LS $OUTPUT_ROOT` 443176187Srafan # Configure has already touched config.log and confdefs.h in the current dir when this check 444176187Srafan # is performed. 445176187Srafan filtered_files=`$ECHO "$files_present" | $SED -e 's/config.log//g' -e 's/confdefs.h//g' -e 's/ //g' \ 446176187Srafan | $TR -d '\n'` 447176187Srafan if test "x$filtered_files" != x; then 448176187Srafan AC_MSG_NOTICE([Current directory is $CURDIR.]) 449176187Srafan AC_MSG_NOTICE([Since this is not the source root, configure will output the configuration here]) 450176187Srafan AC_MSG_NOTICE([(as opposed to creating a configuration in <src_root>/build/<conf-name>).]) 451176187Srafan AC_MSG_NOTICE([However, this directory is not empty. This is not allowed, since it could]) 452176187Srafan AC_MSG_NOTICE([seriously mess up just about everything.]) 453176187Srafan AC_MSG_NOTICE([Try 'cd $SRC_ROOT' and restart configure]) 454176187Srafan AC_MSG_NOTICE([(or create a new empty directory and cd to it).]) 455176187Srafan AC_MSG_ERROR([Will not continue creating configuration in $CURDIR]) 456176187Srafan fi 457176187Srafan fi 458176187Srafan fi 459176187Srafan AC_MSG_CHECKING([what configuration name to use]) 460176187Srafan AC_MSG_RESULT([$CONF_NAME]) 461176187Srafan 462176187Srafan BASIC_FIXUP_PATH(OUTPUT_ROOT) 463176187Srafan 464176187Srafan AC_SUBST(SPEC, $OUTPUT_ROOT/spec.gmk) 465176187Srafan AC_SUBST(CONF_NAME, $CONF_NAME) 466176187Srafan AC_SUBST(OUTPUT_ROOT, $OUTPUT_ROOT) 467176187Srafan 468176187Srafan # Most of the probed defines are put into config.h 469176187Srafan AC_CONFIG_HEADERS([$OUTPUT_ROOT/config.h:$AUTOCONF_DIR/config.h.in]) 470176187Srafan # The spec.gmk file contains all variables for the make system. 471176187Srafan AC_CONFIG_FILES([$OUTPUT_ROOT/spec.gmk:$AUTOCONF_DIR/spec.gmk.in]) 472176187Srafan # The hotspot-spec.gmk file contains legacy variables for the hotspot make system. 473176187Srafan AC_CONFIG_FILES([$OUTPUT_ROOT/hotspot-spec.gmk:$AUTOCONF_DIR/hotspot-spec.gmk.in]) 474176187Srafan # The bootcycle-spec.gmk file contains support for boot cycle builds. 475176187Srafan AC_CONFIG_FILES([$OUTPUT_ROOT/bootcycle-spec.gmk:$AUTOCONF_DIR/bootcycle-spec.gmk.in]) 476176187Srafan # The compare.sh is used to compare the build output to other builds. 477176187Srafan AC_CONFIG_FILES([$OUTPUT_ROOT/compare.sh:$AUTOCONF_DIR/compare.sh.in]) 478176187Srafan # Spec.sh is currently used by compare-objects.sh 479176187Srafan AC_CONFIG_FILES([$OUTPUT_ROOT/spec.sh:$AUTOCONF_DIR/spec.sh.in]) 480176187Srafan # The generated Makefile knows where the spec.gmk is and where the source is. 481176187Srafan # You can run make from the OUTPUT_ROOT, or from the top-level Makefile 482176187Srafan # which will look for generated configurations 483176187Srafan AC_CONFIG_FILES([$OUTPUT_ROOT/Makefile:$AUTOCONF_DIR/Makefile.in]) 484176187Srafan 485176187Srafan # Save the arguments given to us 486176187Srafan echo "$CONFIGURE_COMMAND_LINE" > $OUTPUT_ROOT/configure-arguments 487176187Srafan]) 488176187Srafan 489176187SrafanAC_DEFUN_ONCE([BASIC_SETUP_LOGGING], 490176187Srafan[ 491176187Srafan # Setup default logging of stdout and stderr to build.log in the output root. 492176187Srafan BUILD_LOG='$(OUTPUT_ROOT)/build.log' 493176187Srafan BUILD_LOG_PREVIOUS='$(OUTPUT_ROOT)/build.log.old' 494176187Srafan BUILD_LOG_WRAPPER='$(BASH) $(SRC_ROOT)/common/bin/logger.sh $(BUILD_LOG)' 495176187Srafan AC_SUBST(BUILD_LOG) 496176187Srafan AC_SUBST(BUILD_LOG_PREVIOUS) 497176187Srafan AC_SUBST(BUILD_LOG_WRAPPER) 498176187Srafan]) 499176187Srafan 500176187Srafan 501176187Srafan#%%% Simple tools %%% 502176187Srafan 503176187Srafan# Check if we have found a usable version of make 504176187Srafan# $1: the path to a potential make binary (or empty) 505176187Srafan# $2: the description on how we found this 506176187SrafanAC_DEFUN([BASIC_CHECK_MAKE_VERSION], 507176187Srafan[ 508176187Srafan MAKE_CANDIDATE="$1" 509176187Srafan DESCRIPTION="$2" 510176187Srafan if test "x$MAKE_CANDIDATE" != x; then 511176187Srafan AC_MSG_NOTICE([Testing potential make at $MAKE_CANDIDATE, found using $DESCRIPTION]) 512176187Srafan MAKE_VERSION_STRING=`$MAKE_CANDIDATE --version | $HEAD -n 1` 513176187Srafan IS_GNU_MAKE=`$ECHO $MAKE_VERSION_STRING | $GREP 'GNU Make'` 514176187Srafan if test "x$IS_GNU_MAKE" = x; then 515176187Srafan AC_MSG_NOTICE([Found potential make at $MAKE_CANDIDATE, however, this is not GNU Make. Ignoring.]) 516176187Srafan else 517176187Srafan IS_MODERN_MAKE=`$ECHO $MAKE_VERSION_STRING | $GREP '\(3\.8[[12]]\)\|\(4\.\)'` 518176187Srafan if test "x$IS_MODERN_MAKE" = x; then 519176187Srafan AC_MSG_NOTICE([Found GNU make at $MAKE_CANDIDATE, however this is not version 3.81 or later. (it is: $MAKE_VERSION_STRING). Ignoring.]) 520176187Srafan else 521176187Srafan if test "x$OPENJDK_BUILD_OS" = "xwindows"; then 522176187Srafan if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then 523176187Srafan MAKE_EXPECTED_ENV='cygwin' 524176187Srafan elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then 525176187Srafan MAKE_EXPECTED_ENV='msys' 526176187Srafan else 527176187Srafan AC_MSG_ERROR([Unknown Windows environment]) 528176187Srafan fi 529176187Srafan MAKE_BUILT_FOR=`$MAKE_CANDIDATE --version | $GREP -i 'built for'` 530176187Srafan IS_MAKE_CORRECT_ENV=`$ECHO $MAKE_BUILT_FOR | $GREP $MAKE_EXPECTED_ENV` 531176187Srafan else 532176187Srafan # Not relevant for non-Windows 533176187Srafan IS_MAKE_CORRECT_ENV=true 534176187Srafan fi 535176187Srafan if test "x$IS_MAKE_CORRECT_ENV" = x; then 536176187Srafan 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.]) 537176187Srafan else 538176187Srafan FOUND_MAKE=$MAKE_CANDIDATE 539176187Srafan BASIC_FIXUP_EXECUTABLE(FOUND_MAKE) 540176187Srafan fi 541176187Srafan fi 542176187Srafan fi 543176187Srafan fi 544176187Srafan]) 545176187Srafan 546176187Srafan# Goes looking for a usable version of GNU make. 547176187SrafanAC_DEFUN([BASIC_CHECK_GNU_MAKE], 548176187Srafan[ 549176187Srafan # We need to find a recent version of GNU make. Especially on Solaris, this can be tricky. 550176187Srafan if test "x$MAKE" != x; then 551176187Srafan # User has supplied a make, test it. 552176187Srafan if test ! -f "$MAKE"; then 553176187Srafan AC_MSG_ERROR([The specified make (by MAKE=$MAKE) is not found.]) 554176187Srafan fi 555176187Srafan BASIC_CHECK_MAKE_VERSION("$MAKE", [user supplied MAKE=$MAKE]) 556176187Srafan if test "x$FOUND_MAKE" = x; then 557176187Srafan AC_MSG_ERROR([The specified make (by MAKE=$MAKE) is not GNU make 3.81 or newer.]) 558176187Srafan fi 559176187Srafan else 560176187Srafan # Try our hardest to locate a correct version of GNU make 561176187Srafan AC_PATH_PROGS(CHECK_GMAKE, gmake) 562176187Srafan BASIC_CHECK_MAKE_VERSION("$CHECK_GMAKE", [gmake in PATH]) 563176187Srafan 564176187Srafan if test "x$FOUND_MAKE" = x; then 565176187Srafan AC_PATH_PROGS(CHECK_MAKE, make) 566176187Srafan BASIC_CHECK_MAKE_VERSION("$CHECK_MAKE", [make in PATH]) 567176187Srafan fi 568176187Srafan 569176187Srafan if test "x$FOUND_MAKE" = x; then 570176187Srafan if test "x$TOOLS_DIR" != x; then 571176187Srafan # We have a tools-dir, check that as well before giving up. 572176187Srafan OLD_PATH=$PATH 573176187Srafan PATH=$TOOLS_DIR:$PATH 574176187Srafan AC_PATH_PROGS(CHECK_TOOLSDIR_GMAKE, gmake) 575176187Srafan BASIC_CHECK_MAKE_VERSION("$CHECK_TOOLSDIR_GMAKE", [gmake in tools-dir]) 576176187Srafan if test "x$FOUND_MAKE" = x; then 577176187Srafan AC_PATH_PROGS(CHECK_TOOLSDIR_MAKE, make) 578176187Srafan BASIC_CHECK_MAKE_VERSION("$CHECK_TOOLSDIR_MAKE", [make in tools-dir]) 579176187Srafan fi 580176187Srafan PATH=$OLD_PATH 581176187Srafan fi 582176187Srafan fi 583176187Srafan 584176187Srafan if test "x$FOUND_MAKE" = x; then 585176187Srafan 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.]) 586176187Srafan fi 587176187Srafan fi 588176187Srafan 589176187Srafan MAKE=$FOUND_MAKE 590176187Srafan AC_SUBST(MAKE) 591176187Srafan AC_MSG_NOTICE([Using GNU make 3.81 (or later) at $FOUND_MAKE (version: $MAKE_VERSION_STRING)]) 592176187Srafan]) 593176187Srafan 594176187SrafanAC_DEFUN([BASIC_CHECK_FIND_DELETE], 595176187Srafan[ 596176187Srafan # Test if find supports -delete 597176187Srafan AC_MSG_CHECKING([if find supports -delete]) 598176187Srafan FIND_DELETE="-delete" 599176187Srafan 600176187Srafan DELETEDIR=`$MKTEMP -d tmp.XXXXXXXXXX` || (echo Could not create temporary directory!; exit $?) 601176187Srafan 602176187Srafan echo Hejsan > $DELETEDIR/TestIfFindSupportsDelete 603176187Srafan 604176187Srafan TEST_DELETE=`$FIND "$DELETEDIR" -name TestIfFindSupportsDelete $FIND_DELETE 2>&1` 605176187Srafan if test -f $DELETEDIR/TestIfFindSupportsDelete; then 606176187Srafan # No, it does not. 607176187Srafan rm $DELETEDIR/TestIfFindSupportsDelete 608176187Srafan FIND_DELETE="-exec rm \{\} \+" 609176187Srafan AC_MSG_RESULT([no]) 610176187Srafan else 611176187Srafan AC_MSG_RESULT([yes]) 612176187Srafan fi 613176187Srafan rmdir $DELETEDIR 614176187Srafan AC_SUBST(FIND_DELETE) 615176187Srafan]) 616176187Srafan 617176187SrafanAC_DEFUN_ONCE([BASIC_SETUP_COMPLEX_TOOLS], 618176187Srafan[ 619176187Srafan BASIC_CHECK_GNU_MAKE 620176187Srafan 621176187Srafan BASIC_CHECK_FIND_DELETE 622176187Srafan 623176187Srafan # These tools might not be installed by default, 624176187Srafan # need hint on how to install them. 625176187Srafan BASIC_REQUIRE_PROG(UNZIP, unzip) 626176187Srafan BASIC_REQUIRE_PROG(ZIP, zip) 627176187Srafan 628176187Srafan # Non-required basic tools 629176187Srafan 630176187Srafan AC_PATH_PROG(LDD, ldd) 631176187Srafan if test "x$LDD" = "x"; then 632176187Srafan # List shared lib dependencies is used for 633176187Srafan # debug output and checking for forbidden dependencies. 634176187Srafan # We can build without it. 635176187Srafan LDD="true" 636176187Srafan fi 637176187Srafan AC_PATH_PROG(OTOOL, otool) 638176187Srafan if test "x$OTOOL" = "x"; then 639176187Srafan OTOOL="true" 640176187Srafan fi 641176187Srafan AC_PATH_PROGS(READELF, [readelf greadelf]) 642176187Srafan AC_PATH_PROG(HG, hg) 643176187Srafan AC_PATH_PROG(STAT, stat) 644176187Srafan AC_PATH_PROG(TIME, time) 645176187Srafan # Check if it's GNU time 646176187Srafan IS_GNU_TIME=`$TIME --version 2>&1 | $GREP 'GNU time'` 647176187Srafan if test "x$IS_GNU_TIME" != x; then 648176187Srafan IS_GNU_TIME=yes 649176187Srafan else 650176187Srafan IS_GNU_TIME=no 651176187Srafan fi 652176187Srafan AC_SUBST(IS_GNU_TIME) 653176187Srafan 654176187Srafan if test "x$OPENJDK_TARGET_OS" = "xwindows"; then 655176187Srafan BASIC_REQUIRE_PROG(COMM, comm) 656176187Srafan fi 657176187Srafan 658176187Srafan if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then 659176187Srafan BASIC_REQUIRE_PROG(DSYMUTIL, dsymutil) 660176187Srafan BASIC_REQUIRE_PROG(XATTR, xattr) 661176187Srafan AC_PATH_PROG(CODESIGN, codesign) 662176187Srafan if test "x$CODESIGN" != "x"; then 663176187Srafan # Verify that the openjdk_codesign certificate is present 664176187Srafan AC_MSG_CHECKING([if openjdk_codesign certificate is present]) 665176187Srafan rm -f codesign-testfile 666176187Srafan touch codesign-testfile 667176187Srafan codesign -s openjdk_codesign codesign-testfile 2>&AS_MESSAGE_LOG_FD >&AS_MESSAGE_LOG_FD || CODESIGN= 668176187Srafan rm -f codesign-testfile 669176187Srafan if test "x$CODESIGN" = x; then 670176187Srafan AC_MSG_RESULT([no]) 671176187Srafan else 672176187Srafan AC_MSG_RESULT([yes]) 673176187Srafan fi 674176187Srafan fi 675176187Srafan fi 676176187Srafan]) 677176187Srafan 678176187Srafan# Check if build directory is on local disk. If not possible to determine, 679176187Srafan# we prefer to claim it's local. 680176187Srafan# Argument 1: directory to test 681176187Srafan# Argument 2: what to do if it is on local disk 682176187Srafan# Argument 3: what to do otherwise (remote disk or failure) 683176187SrafanAC_DEFUN([BASIC_CHECK_DIR_ON_LOCAL_DISK], 684176187Srafan[ 685176187Srafan # df -l lists only local disks; if the given directory is not found then 686176187Srafan # a non-zero exit code is given 687176187Srafan if test "x$DF" = x; then 688176187Srafan if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then 689176187Srafan # msys does not have df; use Windows "net use" instead. 690176187Srafan IS_NETWORK_DISK=`net use | grep \`pwd -W | cut -d ":" -f 1 | tr a-z A-Z\`:` 691176187Srafan if test "x$IS_NETWORK_DISK" = x; then 692176187Srafan $2 693176187Srafan else 694176187Srafan $3 695176187Srafan fi 696176187Srafan else 697176187Srafan # No df here, say it's local 698176187Srafan $2 699176187Srafan fi 700176187Srafan else 701176187Srafan if $DF -l $1 > /dev/null 2>&1; then 702176187Srafan $2 703176187Srafan else 704176187Srafan $3 705176187Srafan fi 706176187Srafan fi 707176187Srafan]) 708176187Srafan 709176187Srafan# Check that source files have basic read permissions set. This might 710176187Srafan# not be the case in cygwin in certain conditions. 711176187SrafanAC_DEFUN_ONCE([BASIC_CHECK_SRC_PERMS], 712176187Srafan[ 713176187Srafan if test x"$OPENJDK_BUILD_OS" = xwindows; then 714176187Srafan file_to_test="$SRC_ROOT/LICENSE" 715176187Srafan if test `$STAT -c '%a' "$file_to_test"` -lt 400; then 716176187Srafan 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.]) 717176187Srafan fi 718176187Srafan fi 719176187Srafan]) 720176187Srafan 721176187SrafanAC_DEFUN_ONCE([BASIC_TEST_USABILITY_ISSUES], 722176187Srafan[ 723176187Srafan AC_MSG_CHECKING([if build directory is on local disk]) 724176187Srafan BASIC_CHECK_DIR_ON_LOCAL_DISK($OUTPUT_ROOT, 725176187Srafan [OUTPUT_DIR_IS_LOCAL="yes"], 726176187Srafan [OUTPUT_DIR_IS_LOCAL="no"]) 727176187Srafan AC_MSG_RESULT($OUTPUT_DIR_IS_LOCAL) 728176187Srafan 729176187Srafan BASIC_CHECK_SRC_PERMS 730176187Srafan 731176187Srafan # Check if the user has any old-style ALT_ variables set. 732176187Srafan FOUND_ALT_VARIABLES=`env | grep ^ALT_` 733176187Srafan 734176187Srafan # Before generating output files, test if they exist. If they do, this is a reconfigure. 735176187Srafan # Since we can't properly handle the dependencies for this, warn the user about the situation 736176187Srafan if test -e $OUTPUT_ROOT/spec.gmk; then 737176187Srafan IS_RECONFIGURE=yes 738176187Srafan else 739176187Srafan IS_RECONFIGURE=no 740176187Srafan fi 741176187Srafan 742176187Srafan if test -e $SRC_ROOT/build/.hide-configure-performance-hints; then 743176187Srafan HIDE_PERFORMANCE_HINTS=yes 744176187Srafan else 745176187Srafan HIDE_PERFORMANCE_HINTS=no 746176187Srafan # Hide it the next time around... 747176187Srafan $TOUCH $SRC_ROOT/build/.hide-configure-performance-hints > /dev/null 2>&1 748176187Srafan fi 749176187Srafan]) 750176187Srafan