annotate common/autoconf/basics.m4 @ 909:37d2736caf46

Merge
author lana
date Wed, 30 Oct 2013 13:41:36 -0700
parents 067355edfbf8 dfbc93f26f38
children a667caba1e84
rev   line source
erikj@457 1 #
erikj@560 2 # Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
erikj@457 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
erikj@457 4 #
erikj@457 5 # This code is free software; you can redistribute it and/or modify it
erikj@457 6 # under the terms of the GNU General Public License version 2 only, as
erikj@457 7 # published by the Free Software Foundation. Oracle designates this
erikj@457 8 # particular file as subject to the "Classpath" exception as provided
erikj@457 9 # by Oracle in the LICENSE file that accompanied this code.
erikj@457 10 #
erikj@457 11 # This code is distributed in the hope that it will be useful, but WITHOUT
erikj@457 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
erikj@457 13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
erikj@457 14 # version 2 for more details (a copy is included in the LICENSE file that
erikj@457 15 # accompanied this code).
erikj@457 16 #
erikj@457 17 # You should have received a copy of the GNU General Public License version
erikj@457 18 # 2 along with this work; if not, write to the Free Software Foundation,
erikj@457 19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
erikj@457 20 #
erikj@457 21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
erikj@457 22 # or visit www.oracle.com if you need additional information or have any
erikj@457 23 # questions.
erikj@457 24 #
erikj@457 25
erikj@715 26 # Test if $1 is a valid argument to $3 (often is $JAVA passed as $3)
ihse@844 27 # If so, then append $1 to $2 \
erikj@715 28 # Also set JVM_ARG_OK to true/false depending on outcome.
erikj@457 29 AC_DEFUN([ADD_JVM_ARG_IF_OK],
erikj@457 30 [
ihse@844 31 $ECHO "Check if jvm arg is ok: $1" >&AS_MESSAGE_LOG_FD
ihse@844 32 $ECHO "Command: $3 $1 -version" >&AS_MESSAGE_LOG_FD
ihse@844 33 OUTPUT=`$3 $1 -version 2>&1`
ihse@844 34 FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn`
ihse@844 35 FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""`
ihse@844 36 if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
ihse@844 37 $2="[$]$2 $1"
ihse@844 38 JVM_ARG_OK=true
ihse@844 39 else
ihse@844 40 $ECHO "Arg failed:" >&AS_MESSAGE_LOG_FD
ihse@844 41 $ECHO "$OUTPUT" >&AS_MESSAGE_LOG_FD
ihse@844 42 JVM_ARG_OK=false
ihse@844 43 fi
erikj@457 44 ])
erikj@457 45
erikj@749 46 # Appends a string to a path variable, only adding the : when needed.
erikj@749 47 AC_DEFUN([BASIC_APPEND_TO_PATH],
erikj@749 48 [
erikj@749 49 if test "x[$]$1" = x; then
erikj@749 50 $1="$2"
erikj@749 51 else
erikj@749 52 $1="[$]$1:$2"
erikj@749 53 fi
erikj@749 54 ])
erikj@749 55
ohair@492 56 # This will make sure the given variable points to a full and proper
ohair@492 57 # path. This means:
ohair@492 58 # 1) There will be no spaces in the path. On posix platforms,
ohair@492 59 # spaces in the path will result in an error. On Windows,
ohair@492 60 # the path will be rewritten using short-style to be space-free.
ohair@492 61 # 2) The path will be absolute, and it will be in unix-style (on
ohair@492 62 # cygwin).
ohair@492 63 # $1: The name of the variable to fix
ohair@492 64 AC_DEFUN([BASIC_FIXUP_PATH],
erikj@457 65 [
ohair@492 66 if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
ohair@492 67 BASIC_FIXUP_PATH_CYGWIN($1)
ohair@492 68 elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
ohair@492 69 BASIC_FIXUP_PATH_MSYS($1)
ohair@492 70 else
ohair@492 71 # We're on a posix platform. Hooray! :)
ohair@492 72 path="[$]$1"
ohair@492 73 has_space=`$ECHO "$path" | $GREP " "`
ohair@492 74 if test "x$has_space" != x; then
ohair@492 75 AC_MSG_NOTICE([The path of $1, which resolves as "$path", is invalid.])
ohair@492 76 AC_MSG_ERROR([Spaces are not allowed in this path.])
erikj@457 77 fi
erikj@716 78
erikj@716 79 # Use eval to expand a potential ~
erikj@716 80 eval path="$path"
erikj@716 81 if test ! -f "$path" && test ! -d "$path"; then
erikj@716 82 AC_MSG_ERROR([The path of $1, which resolves as "$path", is not found.])
erikj@716 83 fi
erikj@716 84
ihse@844 85 $1="`cd "$path"; $THEPWDCMD -L`"
ohair@492 86 fi
erikj@457 87 ])
erikj@457 88
ohair@492 89 # This will make sure the given variable points to a executable
ohair@492 90 # with a full and proper path. This means:
ohair@492 91 # 1) There will be no spaces in the path. On posix platforms,
ohair@492 92 # spaces in the path will result in an error. On Windows,
ohair@492 93 # the path will be rewritten using short-style to be space-free.
ohair@492 94 # 2) The path will be absolute, and it will be in unix-style (on
ohair@492 95 # cygwin).
ohair@492 96 # Any arguments given to the executable is preserved.
ohair@492 97 # If the input variable does not have a directory specification, then
ohair@492 98 # it need to be in the PATH.
ohair@492 99 # $1: The name of the variable to fix
ohair@492 100 AC_DEFUN([BASIC_FIXUP_EXECUTABLE],
erikj@457 101 [
ohair@492 102 if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
ohair@492 103 BASIC_FIXUP_EXECUTABLE_CYGWIN($1)
ohair@492 104 elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
ohair@492 105 BASIC_FIXUP_EXECUTABLE_MSYS($1)
ohair@492 106 else
ohair@492 107 # We're on a posix platform. Hooray! :)
ohair@492 108 # First separate the path from the arguments. This will split at the first
ohair@492 109 # space.
ohair@492 110 complete="[$]$1"
ohair@492 111 path="${complete%% *}"
ohair@492 112 tmp="$complete EOL"
ohair@492 113 arguments="${tmp#* }"
ohair@492 114
erikj@537 115 # Cannot rely on the command "which" here since it doesn't always work.
erikj@537 116 is_absolute_path=`$ECHO "$path" | $GREP ^/`
erikj@537 117 if test -z "$is_absolute_path"; then
erikj@537 118 # Path to executable is not absolute. Find it.
erikj@537 119 IFS_save="$IFS"
erikj@537 120 IFS=:
erikj@537 121 for p in $PATH; do
erikj@537 122 if test -f "$p/$path" && test -x "$p/$path"; then
erikj@537 123 new_path="$p/$path"
erikj@537 124 break
erikj@537 125 fi
erikj@537 126 done
erikj@537 127 IFS="$IFS_save"
erikj@537 128 else
erikj@537 129 AC_MSG_NOTICE([Resolving $1 (as $path) failed, using $path directly.])
erikj@537 130 new_path="$path"
erikj@537 131 fi
ihse@844 132
ohair@492 133 if test "x$new_path" = x; then
ihse@844 134 AC_MSG_NOTICE([The path of $1, which resolves as "$complete", is not found.])
ihse@844 135 has_space=`$ECHO "$complete" | $GREP " "`
ihse@844 136 if test "x$has_space" != x; then
ihse@844 137 AC_MSG_NOTICE([This might be caused by spaces in the path, which is not allowed.])
ohair@492 138 fi
ihse@844 139 AC_MSG_ERROR([Cannot locate the the path of $1])
ihse@844 140 fi
ohair@492 141 fi
ohair@492 142
ihse@844 143 # Now join together the path and the arguments once again
ihse@844 144 if test "x$arguments" != xEOL; then
ihse@844 145 new_complete="$new_path ${arguments% *}"
ihse@844 146 else
ihse@844 147 new_complete="$new_path"
ihse@844 148 fi
ohair@492 149
ohair@492 150 if test "x$complete" != "x$new_complete"; then
ihse@844 151 $1="$new_complete"
ihse@844 152 AC_MSG_NOTICE([Rewriting $1 to "$new_complete"])
ihse@844 153 fi
erikj@457 154 ])
erikj@457 155
ohair@492 156 AC_DEFUN([BASIC_REMOVE_SYMBOLIC_LINKS],
erikj@457 157 [
ihse@844 158 if test "x$OPENJDK_BUILD_OS" != xwindows; then
ihse@844 159 # Follow a chain of symbolic links. Use readlink
ihse@844 160 # where it exists, else fall back to horribly
ihse@844 161 # complicated shell code.
ihse@844 162 if test "x$READLINK_TESTED" != yes; then
ihse@844 163 # On MacOSX there is a readlink tool with a different
ihse@844 164 # purpose than the GNU readlink tool. Check the found readlink.
ihse@844 165 ISGNU=`$READLINK --version 2>&1 | $GREP GNU`
ihse@844 166 if test "x$ISGNU" = x; then
ihse@844 167 # A readlink that we do not know how to use.
ihse@844 168 # Are there other non-GNU readlinks out there?
ihse@844 169 READLINK_TESTED=yes
ihse@844 170 READLINK=
ihse@844 171 fi
ihse@844 172 fi
ihse@844 173
ihse@844 174 if test "x$READLINK" != x; then
ihse@844 175 $1=`$READLINK -f [$]$1`
ihse@844 176 else
ihse@844 177 # Save the current directory for restoring afterwards
ihse@844 178 STARTDIR=$PWD
ihse@844 179 COUNTER=0
ihse@844 180 sym_link_dir=`$DIRNAME [$]$1`
ihse@844 181 sym_link_file=`$BASENAME [$]$1`
ihse@844 182 cd $sym_link_dir
ihse@844 183 # Use -P flag to resolve symlinks in directories.
ihse@844 184 cd `$THEPWDCMD -P`
ihse@844 185 sym_link_dir=`$THEPWDCMD -P`
ihse@844 186 # Resolve file symlinks
ihse@844 187 while test $COUNTER -lt 20; do
ihse@844 188 ISLINK=`$LS -l $sym_link_dir/$sym_link_file | $GREP '\->' | $SED -e 's/.*-> \(.*\)/\1/'`
ihse@844 189 if test "x$ISLINK" == x; then
ihse@844 190 # This is not a symbolic link! We are done!
ihse@844 191 break
erikj@457 192 fi
ihse@844 193 # Again resolve directory symlinks since the target of the just found
ihse@844 194 # link could be in a different directory
ihse@844 195 cd `$DIRNAME $ISLINK`
ihse@844 196 sym_link_dir=`$THEPWDCMD -P`
ihse@844 197 sym_link_file=`$BASENAME $ISLINK`
ihse@844 198 let COUNTER=COUNTER+1
ihse@844 199 done
ihse@844 200 cd $STARTDIR
ihse@844 201 $1=$sym_link_dir/$sym_link_file
erikj@457 202 fi
ihse@844 203 fi
erikj@457 204 ])
erikj@457 205
ihse@806 206 # Register a --with argument but mark it as deprecated
ihse@806 207 # $1: The name of the with argument to deprecate, not including --with-
ihse@806 208 AC_DEFUN([BASIC_DEPRECATED_ARG_WITH],
ihse@806 209 [
ihse@806 210 AC_ARG_WITH($1, [AS_HELP_STRING([--with-$1],
ihse@806 211 [Deprecated. Option is kept for backwards compatibility and is ignored])],
ihse@806 212 [AC_MSG_WARN([Option --with-$1 is deprecated and will be ignored.])])
ihse@806 213 ])
ihse@806 214
ihse@868 215 # Register a --enable argument but mark it as deprecated
ihse@868 216 # $1: The name of the with argument to deprecate, not including --enable-
ihse@868 217 # $2: The name of the argument to deprecate, in shell variable style (i.e. with _ instead of -)
ihse@868 218 AC_DEFUN([BASIC_DEPRECATED_ARG_ENABLE],
ihse@868 219 [
ihse@868 220 AC_ARG_ENABLE($1, [AS_HELP_STRING([--enable-$1],
ihse@868 221 [Deprecated. Option is kept for backwards compatibility and is ignored])])
ihse@868 222 if test "x$enable_$2" != x; then
ihse@868 223 AC_MSG_WARN([Option --enable-$1 is deprecated and will be ignored.])
ihse@868 224 fi
ihse@868 225 ])
ihse@868 226
erikj@457 227 AC_DEFUN_ONCE([BASIC_INIT],
erikj@457 228 [
ihse@844 229 # Save the original command line. This is passed to us by the wrapper configure script.
ihse@844 230 AC_SUBST(CONFIGURE_COMMAND_LINE)
ihse@844 231 DATE_WHEN_CONFIGURED=`LANG=C date`
ihse@844 232 AC_SUBST(DATE_WHEN_CONFIGURED)
ihse@844 233 AC_MSG_NOTICE([Configuration created at $DATE_WHEN_CONFIGURED.])
ihse@844 234 AC_MSG_NOTICE([configure script generated at timestamp $DATE_WHEN_GENERATED.])
ohair@492 235 ])
ohair@492 236
ohair@492 237 # Test that variable $1 denoting a program is not empty. If empty, exit with an error.
ohair@492 238 # $1: variable to check
ohair@492 239 # $2: executable name to print in warning (optional)
ohair@492 240 AC_DEFUN([BASIC_CHECK_NONEMPTY],
ohair@492 241 [
ihse@844 242 if test "x[$]$1" = x; then
ihse@844 243 if test "x$2" = x; then
ihse@844 244 PROG_NAME=translit($1,A-Z,a-z)
ihse@844 245 else
ihse@844 246 PROG_NAME=$2
ohair@492 247 fi
ihse@844 248 AC_MSG_NOTICE([Could not find $PROG_NAME!])
ihse@844 249 AC_MSG_ERROR([Cannot continue])
ihse@844 250 fi
ohair@492 251 ])
ohair@492 252
ohair@492 253 # Does AC_PATH_PROG followed by BASIC_CHECK_NONEMPTY.
ohair@492 254 # Arguments as AC_PATH_PROG:
ohair@492 255 # $1: variable to set
ohair@492 256 # $2: executable name to look for
ohair@492 257 AC_DEFUN([BASIC_REQUIRE_PROG],
ohair@492 258 [
ihse@844 259 AC_PATH_PROGS($1, $2)
ihse@844 260 BASIC_CHECK_NONEMPTY($1, $2)
ohair@492 261 ])
ohair@492 262
ohair@492 263 # Setup the most fundamental tools that relies on not much else to set up,
ohair@492 264 # but is used by much of the early bootstrap code.
ohair@492 265 AC_DEFUN_ONCE([BASIC_SETUP_FUNDAMENTAL_TOOLS],
ohair@492 266 [
ohair@492 267
ihse@844 268 # Start with tools that do not need have cross compilation support
ihse@844 269 # and can be expected to be found in the default PATH. These tools are
ihse@844 270 # used by configure. Nor are these tools expected to be found in the
ihse@844 271 # devkit from the builddeps server either, since they are
ihse@844 272 # needed to download the devkit.
ohair@492 273
ihse@844 274 # First are all the simple required tools.
ihse@844 275 BASIC_REQUIRE_PROG(BASENAME, basename)
ihse@844 276 BASIC_REQUIRE_PROG(BASH, bash)
ihse@844 277 BASIC_REQUIRE_PROG(CAT, cat)
ihse@844 278 BASIC_REQUIRE_PROG(CHMOD, chmod)
ihse@844 279 BASIC_REQUIRE_PROG(CMP, cmp)
ihse@844 280 BASIC_REQUIRE_PROG(COMM, comm)
ihse@844 281 BASIC_REQUIRE_PROG(CP, cp)
ihse@844 282 BASIC_REQUIRE_PROG(CPIO, cpio)
ihse@844 283 BASIC_REQUIRE_PROG(CUT, cut)
ihse@844 284 BASIC_REQUIRE_PROG(DATE, date)
ihse@844 285 BASIC_REQUIRE_PROG(DIFF, [gdiff diff])
ihse@844 286 BASIC_REQUIRE_PROG(DIRNAME, dirname)
ihse@844 287 BASIC_REQUIRE_PROG(ECHO, echo)
ihse@844 288 BASIC_REQUIRE_PROG(EXPR, expr)
ihse@844 289 BASIC_REQUIRE_PROG(FILE, file)
ihse@844 290 BASIC_REQUIRE_PROG(FIND, find)
ihse@844 291 BASIC_REQUIRE_PROG(HEAD, head)
ihse@844 292 BASIC_REQUIRE_PROG(LN, ln)
ihse@844 293 BASIC_REQUIRE_PROG(LS, ls)
ihse@844 294 BASIC_REQUIRE_PROG(MKDIR, mkdir)
ihse@844 295 BASIC_REQUIRE_PROG(MKTEMP, mktemp)
ihse@844 296 BASIC_REQUIRE_PROG(MV, mv)
ihse@844 297 BASIC_REQUIRE_PROG(PRINTF, printf)
ihse@844 298 BASIC_REQUIRE_PROG(RM, rm)
ihse@844 299 BASIC_REQUIRE_PROG(SH, sh)
ihse@844 300 BASIC_REQUIRE_PROG(SORT, sort)
ihse@844 301 BASIC_REQUIRE_PROG(TAIL, tail)
ihse@844 302 BASIC_REQUIRE_PROG(TAR, tar)
ihse@844 303 BASIC_REQUIRE_PROG(TEE, tee)
ihse@844 304 BASIC_REQUIRE_PROG(TOUCH, touch)
ihse@844 305 BASIC_REQUIRE_PROG(TR, tr)
ihse@844 306 BASIC_REQUIRE_PROG(UNAME, uname)
ihse@844 307 BASIC_REQUIRE_PROG(UNIQ, uniq)
ihse@844 308 BASIC_REQUIRE_PROG(WC, wc)
ihse@844 309 BASIC_REQUIRE_PROG(WHICH, which)
ihse@844 310 BASIC_REQUIRE_PROG(XARGS, xargs)
ohair@492 311
ihse@844 312 # Then required tools that require some special treatment.
ihse@844 313 AC_PROG_AWK
ihse@844 314 BASIC_CHECK_NONEMPTY(AWK)
ihse@844 315 AC_PROG_GREP
ihse@844 316 BASIC_CHECK_NONEMPTY(GREP)
ihse@844 317 AC_PROG_EGREP
ihse@844 318 BASIC_CHECK_NONEMPTY(EGREP)
ihse@844 319 AC_PROG_FGREP
ihse@844 320 BASIC_CHECK_NONEMPTY(FGREP)
ihse@844 321 AC_PROG_SED
ihse@844 322 BASIC_CHECK_NONEMPTY(SED)
ohair@492 323
ihse@844 324 AC_PATH_PROGS(NAWK, [nawk gawk awk])
ihse@844 325 BASIC_CHECK_NONEMPTY(NAWK)
ohair@492 326
ihse@844 327 # Always force rm.
ihse@844 328 RM="$RM -f"
ohair@492 329
ihse@844 330 # pwd behaves differently on various platforms and some don't support the -L flag.
ihse@844 331 # Always use the bash builtin pwd to get uniform behavior.
ihse@844 332 THEPWDCMD=pwd
erikj@724 333
ihse@844 334 # These are not required on all platforms
ihse@844 335 AC_PATH_PROG(CYGPATH, cygpath)
ihse@844 336 AC_PATH_PROG(READLINK, readlink)
ihse@844 337 AC_PATH_PROG(DF, df)
ihse@844 338 AC_PATH_PROG(SETFILE, SetFile)
ohair@476 339 ])
erikj@457 340
ohair@476 341 # Setup basic configuration paths, and platform-specific stuff related to PATHs.
ohair@476 342 AC_DEFUN_ONCE([BASIC_SETUP_PATHS],
ohair@476 343 [
ihse@844 344 # Locate the directory of this script.
ihse@844 345 SCRIPT="[$]0"
ihse@844 346 AUTOCONF_DIR=`cd \`$DIRNAME $SCRIPT\`; $THEPWDCMD -L`
erikj@457 347
ihse@844 348 # Where is the source? It is located two levels above the configure script.
ihse@844 349 CURDIR="$PWD"
ihse@844 350 cd "$AUTOCONF_DIR/../.."
ihse@844 351 SRC_ROOT="`$THEPWDCMD -L`"
ohair@492 352
ihse@844 353 if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
ihse@844 354 PATH_SEP=";"
ihse@844 355 BASIC_CHECK_PATHS_WINDOWS
ihse@844 356 else
ihse@844 357 PATH_SEP=":"
ihse@844 358 fi
ohair@492 359
ihse@844 360 AC_SUBST(SRC_ROOT)
ihse@844 361 AC_SUBST(PATH_SEP)
ihse@844 362 cd "$CURDIR"
erikj@457 363
ihse@844 364 BASIC_FIXUP_PATH(SRC_ROOT)
ihse@844 365 BASIC_FIXUP_PATH(CURDIR)
erikj@457 366
ihse@844 367 if test "x$OPENJDK_BUILD_OS" = "xsolaris"; then
erikj@457 368 # Add extra search paths on solaris for utilities like ar and as etc...
erikj@457 369 PATH="$PATH:/usr/ccs/bin:/usr/sfw/bin:/opt/csw/bin"
ihse@844 370 fi
erikj@457 371
ihse@844 372 # You can force the sys-root if the sys-root encoded into the cross compiler tools
ihse@844 373 # is not correct.
ihse@844 374 AC_ARG_WITH(sys-root, [AS_HELP_STRING([--with-sys-root],
ihse@844 375 [pass this sys-root to the compilers and tools (for cross-compiling)])])
ohair@476 376
ihse@844 377 if test "x$with_sys_root" != x; then
ihse@844 378 SYS_ROOT=$with_sys_root
ihse@844 379 else
ihse@844 380 SYS_ROOT=/
ihse@844 381 fi
ihse@844 382 AC_SUBST(SYS_ROOT)
ohair@476 383
ihse@844 384 AC_ARG_WITH([tools-dir], [AS_HELP_STRING([--with-tools-dir],
ihse@844 385 [search this directory for compilers and tools (for cross-compiling)])],
ihse@844 386 [TOOLS_DIR=$with_tools_dir]
ihse@844 387 )
ohair@476 388
ihse@844 389 AC_ARG_WITH([devkit], [AS_HELP_STRING([--with-devkit],
ihse@844 390 [use this directory as base for tools-dir and sys-root (for cross-compiling)])],
ihse@844 391 [
ihse@844 392 if test "x$with_sys_root" != x; then
ihse@844 393 AC_MSG_ERROR([Cannot specify both --with-devkit and --with-sys-root at the same time])
ihse@844 394 fi
ihse@844 395 BASIC_FIXUP_PATH([with_devkit])
ihse@844 396 BASIC_APPEND_TO_PATH([TOOLS_DIR],$with_devkit/bin)
ihse@844 397 if test -d "$with_devkit/$host_alias/libc"; then
ihse@844 398 SYS_ROOT=$with_devkit/$host_alias/libc
ihse@844 399 elif test -d "$with_devkit/$host/sys-root"; then
ihse@844 400 SYS_ROOT=$with_devkit/$host/sys-root
ihse@844 401 fi
ihse@844 402 ])
erikj@457 403 ])
erikj@457 404
erikj@457 405 AC_DEFUN_ONCE([BASIC_SETUP_OUTPUT_DIR],
erikj@457 406 [
erikj@457 407
ihse@844 408 AC_ARG_WITH(conf-name, [AS_HELP_STRING([--with-conf-name],
ihse@844 409 [use this as the name of the configuration @<:@generated from important configuration options@:>@])],
ihse@844 410 [ CONF_NAME=${with_conf_name} ])
erikj@457 411
ihse@844 412 # Test from where we are running configure, in or outside of src root.
ihse@844 413 if test "x$CURDIR" = "x$SRC_ROOT" || test "x$CURDIR" = "x$SRC_ROOT/common" \
ihse@844 414 || test "x$CURDIR" = "x$SRC_ROOT/common/autoconf" \
ihse@844 415 || test "x$CURDIR" = "x$SRC_ROOT/common/makefiles" ; then
erikj@457 416 # We are running configure from the src root.
erikj@457 417 # Create a default ./build/target-variant-debuglevel output root.
erikj@457 418 if test "x${CONF_NAME}" = x; then
ihse@844 419 CONF_NAME="${OPENJDK_TARGET_OS}-${OPENJDK_TARGET_CPU}-${JDK_VARIANT}-${ANDED_JVM_VARIANTS}-${DEBUG_LEVEL}"
erikj@457 420 fi
erikj@457 421 OUTPUT_ROOT="$SRC_ROOT/build/${CONF_NAME}"
ohair@492 422 $MKDIR -p "$OUTPUT_ROOT"
erikj@457 423 if test ! -d "$OUTPUT_ROOT"; then
ihse@844 424 AC_MSG_ERROR([Could not create build directory $OUTPUT_ROOT])
erikj@457 425 fi
ihse@844 426 else
erikj@457 427 # We are running configure from outside of the src dir.
erikj@457 428 # Then use the current directory as output dir!
erikj@457 429 # If configuration is situated in normal build directory, just use the build
erikj@457 430 # directory name as configuration name, otherwise use the complete path.
erikj@457 431 if test "x${CONF_NAME}" = x; then
ihse@844 432 CONF_NAME=`$ECHO $CURDIR | $SED -e "s!^${SRC_ROOT}/build/!!"`
erikj@457 433 fi
erikj@457 434 OUTPUT_ROOT="$CURDIR"
ihse@493 435
ihse@493 436 # WARNING: This might be a bad thing to do. You need to be sure you want to
ihse@493 437 # have a configuration in this directory. Do some sanity checks!
ihse@493 438
ihse@493 439 if test ! -e "$OUTPUT_ROOT/spec.gmk"; then
ihse@493 440 # If we have a spec.gmk, we have run here before and we are OK. Otherwise, check for
ihse@493 441 # other files
ihse@493 442 files_present=`$LS $OUTPUT_ROOT`
ihse@844 443 # Configure has already touched config.log and confdefs.h in the current dir when this check
erikj@500 444 # is performed.
erikj@500 445 filtered_files=`$ECHO "$files_present" | $SED -e 's/config.log//g' -e 's/confdefs.h//g' -e 's/ //g' \
ihse@844 446 | $TR -d '\n'`
erikj@500 447 if test "x$filtered_files" != x; then
ihse@493 448 AC_MSG_NOTICE([Current directory is $CURDIR.])
ihse@493 449 AC_MSG_NOTICE([Since this is not the source root, configure will output the configuration here])
ihse@493 450 AC_MSG_NOTICE([(as opposed to creating a configuration in <src_root>/build/<conf-name>).])
ihse@493 451 AC_MSG_NOTICE([However, this directory is not empty. This is not allowed, since it could])
ihse@493 452 AC_MSG_NOTICE([seriously mess up just about everything.])
ihse@493 453 AC_MSG_NOTICE([Try 'cd $SRC_ROOT' and restart configure])
ihse@493 454 AC_MSG_NOTICE([(or create a new empty directory and cd to it).])
ihse@493 455 AC_MSG_ERROR([Will not continue creating configuration in $CURDIR])
ihse@493 456 fi
ihse@493 457 fi
ihse@844 458 fi
ihse@844 459 AC_MSG_CHECKING([what configuration name to use])
ihse@844 460 AC_MSG_RESULT([$CONF_NAME])
erikj@457 461
ihse@844 462 BASIC_FIXUP_PATH(OUTPUT_ROOT)
erikj@457 463
ihse@844 464 AC_SUBST(SPEC, $OUTPUT_ROOT/spec.gmk)
ihse@844 465 AC_SUBST(CONF_NAME, $CONF_NAME)
ihse@844 466 AC_SUBST(OUTPUT_ROOT, $OUTPUT_ROOT)
erikj@457 467
ihse@844 468 # Most of the probed defines are put into config.h
ihse@844 469 AC_CONFIG_HEADERS([$OUTPUT_ROOT/config.h:$AUTOCONF_DIR/config.h.in])
ihse@844 470 # The spec.gmk file contains all variables for the make system.
ihse@844 471 AC_CONFIG_FILES([$OUTPUT_ROOT/spec.gmk:$AUTOCONF_DIR/spec.gmk.in])
ihse@844 472 # The hotspot-spec.gmk file contains legacy variables for the hotspot make system.
ihse@844 473 AC_CONFIG_FILES([$OUTPUT_ROOT/hotspot-spec.gmk:$AUTOCONF_DIR/hotspot-spec.gmk.in])
ihse@844 474 # The bootcycle-spec.gmk file contains support for boot cycle builds.
ihse@844 475 AC_CONFIG_FILES([$OUTPUT_ROOT/bootcycle-spec.gmk:$AUTOCONF_DIR/bootcycle-spec.gmk.in])
ihse@844 476 # The compare.sh is used to compare the build output to other builds.
ihse@844 477 AC_CONFIG_FILES([$OUTPUT_ROOT/compare.sh:$AUTOCONF_DIR/compare.sh.in])
ihse@844 478 # Spec.sh is currently used by compare-objects.sh
ihse@844 479 AC_CONFIG_FILES([$OUTPUT_ROOT/spec.sh:$AUTOCONF_DIR/spec.sh.in])
ihse@844 480 # The generated Makefile knows where the spec.gmk is and where the source is.
ihse@844 481 # You can run make from the OUTPUT_ROOT, or from the top-level Makefile
ihse@844 482 # which will look for generated configurations
ihse@844 483 AC_CONFIG_FILES([$OUTPUT_ROOT/Makefile:$AUTOCONF_DIR/Makefile.in])
erikj@457 484
ihse@844 485 # Save the arguments given to us
ihse@844 486 echo "$CONFIGURE_COMMAND_LINE" > $OUTPUT_ROOT/configure-arguments
erikj@457 487 ])
erikj@457 488
erikj@457 489 AC_DEFUN_ONCE([BASIC_SETUP_LOGGING],
erikj@457 490 [
ihse@844 491 # Setup default logging of stdout and stderr to build.log in the output root.
ihse@844 492 BUILD_LOG='$(OUTPUT_ROOT)/build.log'
ihse@844 493 BUILD_LOG_PREVIOUS='$(OUTPUT_ROOT)/build.log.old'
ihse@844 494 BUILD_LOG_WRAPPER='$(BASH) $(SRC_ROOT)/common/bin/logger.sh $(BUILD_LOG)'
ihse@844 495 AC_SUBST(BUILD_LOG)
ihse@844 496 AC_SUBST(BUILD_LOG_PREVIOUS)
ihse@844 497 AC_SUBST(BUILD_LOG_WRAPPER)
erikj@457 498 ])
erikj@457 499
erikj@457 500
erikj@457 501 #%%% Simple tools %%%
erikj@457 502
ohair@476 503 # Check if we have found a usable version of make
ohair@476 504 # $1: the path to a potential make binary (or empty)
ohair@476 505 # $2: the description on how we found this
ohair@476 506 AC_DEFUN([BASIC_CHECK_MAKE_VERSION],
ohair@476 507 [
ohair@476 508 MAKE_CANDIDATE="$1"
ohair@476 509 DESCRIPTION="$2"
ohair@476 510 if test "x$MAKE_CANDIDATE" != x; then
ohair@476 511 AC_MSG_NOTICE([Testing potential make at $MAKE_CANDIDATE, found using $DESCRIPTION])
ohair@476 512 MAKE_VERSION_STRING=`$MAKE_CANDIDATE --version | $HEAD -n 1`
ohair@476 513 IS_GNU_MAKE=`$ECHO $MAKE_VERSION_STRING | $GREP 'GNU Make'`
ohair@476 514 if test "x$IS_GNU_MAKE" = x; then
ohair@476 515 AC_MSG_NOTICE([Found potential make at $MAKE_CANDIDATE, however, this is not GNU Make. Ignoring.])
ohair@476 516 else
vinnie@908 517 IS_MODERN_MAKE=`$ECHO $MAKE_VERSION_STRING | $GREP -e '3\.8[[12]]' -e '4\.'`
ohair@476 518 if test "x$IS_MODERN_MAKE" = x; then
ohair@476 519 AC_MSG_NOTICE([Found GNU make at $MAKE_CANDIDATE, however this is not version 3.81 or later. (it is: $MAKE_VERSION_STRING). Ignoring.])
ohair@492 520 else
ohair@492 521 if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
ohair@492 522 if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
ohair@492 523 MAKE_EXPECTED_ENV='cygwin'
ohair@492 524 elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
ohair@492 525 MAKE_EXPECTED_ENV='msys'
ohair@492 526 else
ohair@492 527 AC_MSG_ERROR([Unknown Windows environment])
ohair@492 528 fi
ohair@492 529 MAKE_BUILT_FOR=`$MAKE_CANDIDATE --version | $GREP -i 'built for'`
ohair@492 530 IS_MAKE_CORRECT_ENV=`$ECHO $MAKE_BUILT_FOR | $GREP $MAKE_EXPECTED_ENV`
ohair@492 531 else
ohair@492 532 # Not relevant for non-Windows
ohair@492 533 IS_MAKE_CORRECT_ENV=true
ohair@492 534 fi
ohair@492 535 if test "x$IS_MAKE_CORRECT_ENV" = x; then
ohair@492 536 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.])
ohair@492 537 else
ohair@492 538 FOUND_MAKE=$MAKE_CANDIDATE
ohair@492 539 BASIC_FIXUP_EXECUTABLE(FOUND_MAKE)
ohair@492 540 fi
ohair@476 541 fi
ohair@476 542 fi
ohair@476 543 fi
ohair@476 544 ])
ohair@476 545
ohair@476 546 # Goes looking for a usable version of GNU make.
ohair@476 547 AC_DEFUN([BASIC_CHECK_GNU_MAKE],
ohair@476 548 [
ohair@476 549 # We need to find a recent version of GNU make. Especially on Solaris, this can be tricky.
ohair@476 550 if test "x$MAKE" != x; then
ohair@476 551 # User has supplied a make, test it.
ohair@476 552 if test ! -f "$MAKE"; then
ohair@476 553 AC_MSG_ERROR([The specified make (by MAKE=$MAKE) is not found.])
ohair@476 554 fi
ohair@492 555 BASIC_CHECK_MAKE_VERSION("$MAKE", [user supplied MAKE=$MAKE])
ohair@476 556 if test "x$FOUND_MAKE" = x; then
ohair@476 557 AC_MSG_ERROR([The specified make (by MAKE=$MAKE) is not GNU make 3.81 or newer.])
ohair@476 558 fi
ohair@476 559 else
ohair@476 560 # Try our hardest to locate a correct version of GNU make
ohair@476 561 AC_PATH_PROGS(CHECK_GMAKE, gmake)
ohair@476 562 BASIC_CHECK_MAKE_VERSION("$CHECK_GMAKE", [gmake in PATH])
ohair@476 563
ohair@476 564 if test "x$FOUND_MAKE" = x; then
ohair@476 565 AC_PATH_PROGS(CHECK_MAKE, make)
ohair@476 566 BASIC_CHECK_MAKE_VERSION("$CHECK_MAKE", [make in PATH])
ohair@476 567 fi
ohair@476 568
ohair@476 569 if test "x$FOUND_MAKE" = x; then
ohair@476 570 if test "x$TOOLS_DIR" != x; then
ohair@476 571 # We have a tools-dir, check that as well before giving up.
ohair@476 572 OLD_PATH=$PATH
ohair@476 573 PATH=$TOOLS_DIR:$PATH
ohair@476 574 AC_PATH_PROGS(CHECK_TOOLSDIR_GMAKE, gmake)
ohair@476 575 BASIC_CHECK_MAKE_VERSION("$CHECK_TOOLSDIR_GMAKE", [gmake in tools-dir])
ohair@476 576 if test "x$FOUND_MAKE" = x; then
ohair@476 577 AC_PATH_PROGS(CHECK_TOOLSDIR_MAKE, make)
ohair@476 578 BASIC_CHECK_MAKE_VERSION("$CHECK_TOOLSDIR_MAKE", [make in tools-dir])
ohair@476 579 fi
ohair@476 580 PATH=$OLD_PATH
ohair@476 581 fi
ohair@476 582 fi
ohair@476 583
ohair@476 584 if test "x$FOUND_MAKE" = x; then
ohair@476 585 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.])
ohair@476 586 fi
ohair@476 587 fi
ohair@476 588
ohair@476 589 MAKE=$FOUND_MAKE
ohair@476 590 AC_SUBST(MAKE)
ohair@476 591 AC_MSG_NOTICE([Using GNU make 3.81 (or later) at $FOUND_MAKE (version: $MAKE_VERSION_STRING)])
ohair@476 592 ])
ohair@476 593
erikj@457 594 AC_DEFUN([BASIC_CHECK_FIND_DELETE],
erikj@457 595 [
ihse@844 596 # Test if find supports -delete
ihse@844 597 AC_MSG_CHECKING([if find supports -delete])
ihse@844 598 FIND_DELETE="-delete"
erikj@457 599
ihse@844 600 DELETEDIR=`$MKTEMP -d tmp.XXXXXXXXXX` || (echo Could not create temporary directory!; exit $?)
erikj@457 601
ihse@844 602 echo Hejsan > $DELETEDIR/TestIfFindSupportsDelete
erikj@457 603
ihse@844 604 TEST_DELETE=`$FIND "$DELETEDIR" -name TestIfFindSupportsDelete $FIND_DELETE 2>&1`
ihse@844 605 if test -f $DELETEDIR/TestIfFindSupportsDelete; then
ihse@844 606 # No, it does not.
ihse@844 607 rm $DELETEDIR/TestIfFindSupportsDelete
ihse@844 608 FIND_DELETE="-exec rm \{\} \+"
ihse@844 609 AC_MSG_RESULT([no])
ihse@844 610 else
ihse@844 611 AC_MSG_RESULT([yes])
ihse@844 612 fi
ihse@844 613 rmdir $DELETEDIR
ihse@844 614 AC_SUBST(FIND_DELETE)
erikj@457 615 ])
erikj@457 616
ohair@492 617 AC_DEFUN_ONCE([BASIC_SETUP_COMPLEX_TOOLS],
erikj@457 618 [
ihse@844 619 BASIC_CHECK_GNU_MAKE
ohair@476 620
ihse@844 621 BASIC_CHECK_FIND_DELETE
ohair@476 622
ihse@844 623 # These tools might not be installed by default,
ihse@844 624 # need hint on how to install them.
ihse@844 625 BASIC_REQUIRE_PROG(UNZIP, unzip)
ihse@844 626 BASIC_REQUIRE_PROG(ZIP, zip)
erikj@457 627
ihse@844 628 # Non-required basic tools
ohair@476 629
ihse@844 630 AC_PATH_PROG(LDD, ldd)
ihse@844 631 if test "x$LDD" = "x"; then
erikj@457 632 # List shared lib dependencies is used for
erikj@457 633 # debug output and checking for forbidden dependencies.
erikj@457 634 # We can build without it.
erikj@457 635 LDD="true"
ihse@844 636 fi
ihse@844 637 AC_PATH_PROG(OTOOL, otool)
ihse@844 638 if test "x$OTOOL" = "x"; then
ihse@844 639 OTOOL="true"
ihse@844 640 fi
ihse@844 641 AC_PATH_PROGS(READELF, [readelf greadelf])
ihse@844 642 AC_PATH_PROG(HG, hg)
ihse@844 643 AC_PATH_PROG(STAT, stat)
ihse@844 644 AC_PATH_PROG(TIME, time)
ihse@844 645 # Check if it's GNU time
ihse@844 646 IS_GNU_TIME=`$TIME --version 2>&1 | $GREP 'GNU time'`
ihse@844 647 if test "x$IS_GNU_TIME" != x; then
ihse@844 648 IS_GNU_TIME=yes
ihse@844 649 else
ihse@844 650 IS_GNU_TIME=no
ihse@844 651 fi
ihse@844 652 AC_SUBST(IS_GNU_TIME)
ohair@492 653
ihse@844 654 if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
ihse@844 655 BASIC_REQUIRE_PROG(COMM, comm)
ihse@844 656 fi
erikj@668 657
ihse@844 658 if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
dcubed@879 659 BASIC_REQUIRE_PROG(DSYMUTIL, dsymutil)
ihse@844 660 BASIC_REQUIRE_PROG(XATTR, xattr)
ihse@844 661 AC_PATH_PROG(CODESIGN, codesign)
ihse@844 662 if test "x$CODESIGN" != "x"; then
ihse@844 663 # Verify that the openjdk_codesign certificate is present
ihse@844 664 AC_MSG_CHECKING([if openjdk_codesign certificate is present])
ihse@844 665 rm -f codesign-testfile
ihse@844 666 touch codesign-testfile
ihse@844 667 codesign -s openjdk_codesign codesign-testfile 2>&AS_MESSAGE_LOG_FD >&AS_MESSAGE_LOG_FD || CODESIGN=
ihse@844 668 rm -f codesign-testfile
ihse@844 669 if test "x$CODESIGN" = x; then
ihse@844 670 AC_MSG_RESULT([no])
ihse@844 671 else
ihse@844 672 AC_MSG_RESULT([yes])
ihse@844 673 fi
erikj@723 674 fi
erikj@723 675 fi
erikj@457 676 ])
erikj@457 677
ohair@492 678 # Check if build directory is on local disk. If not possible to determine,
ohair@492 679 # we prefer to claim it's local.
erikj@457 680 # Argument 1: directory to test
erikj@457 681 # Argument 2: what to do if it is on local disk
erikj@457 682 # Argument 3: what to do otherwise (remote disk or failure)
erikj@457 683 AC_DEFUN([BASIC_CHECK_DIR_ON_LOCAL_DISK],
erikj@457 684 [
ihse@844 685 # df -l lists only local disks; if the given directory is not found then
ihse@844 686 # a non-zero exit code is given
ohair@492 687 if test "x$DF" = x; then
ohair@492 688 if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
ohair@492 689 # msys does not have df; use Windows "net use" instead.
ohair@492 690 IS_NETWORK_DISK=`net use | grep \`pwd -W | cut -d ":" -f 1 | tr a-z A-Z\`:`
ohair@492 691 if test "x$IS_NETWORK_DISK" = x; then
ohair@492 692 $2
ohair@492 693 else
ohair@492 694 $3
ohair@492 695 fi
ohair@492 696 else
ohair@492 697 # No df here, say it's local
ohair@492 698 $2
ohair@492 699 fi
ohair@492 700 else
ohair@492 701 if $DF -l $1 > /dev/null 2>&1; then
ohair@492 702 $2
ohair@492 703 else
ohair@492 704 $3
ohair@492 705 fi
ohair@492 706 fi
erikj@457 707 ])
erikj@457 708
erikj@554 709 # Check that source files have basic read permissions set. This might
erikj@554 710 # not be the case in cygwin in certain conditions.
erikj@554 711 AC_DEFUN_ONCE([BASIC_CHECK_SRC_PERMS],
erikj@554 712 [
erikj@554 713 if test x"$OPENJDK_BUILD_OS" = xwindows; then
erikj@554 714 file_to_test="$SRC_ROOT/LICENSE"
erikj@554 715 if test `$STAT -c '%a' "$file_to_test"` -lt 400; then
erikj@554 716 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.])
erikj@554 717 fi
erikj@554 718 fi
erikj@554 719 ])
erikj@554 720
erikj@457 721 AC_DEFUN_ONCE([BASIC_TEST_USABILITY_ISSUES],
erikj@457 722 [
ihse@844 723 AC_MSG_CHECKING([if build directory is on local disk])
ihse@844 724 BASIC_CHECK_DIR_ON_LOCAL_DISK($OUTPUT_ROOT,
ihse@844 725 [OUTPUT_DIR_IS_LOCAL="yes"],
ihse@844 726 [OUTPUT_DIR_IS_LOCAL="no"])
ihse@844 727 AC_MSG_RESULT($OUTPUT_DIR_IS_LOCAL)
erikj@457 728
ihse@844 729 BASIC_CHECK_SRC_PERMS
erikj@457 730
ihse@844 731 # Check if the user has any old-style ALT_ variables set.
ihse@844 732 FOUND_ALT_VARIABLES=`env | grep ^ALT_`
erikj@554 733
ihse@844 734 # Before generating output files, test if they exist. If they do, this is a reconfigure.
ihse@844 735 # Since we can't properly handle the dependencies for this, warn the user about the situation
ihse@844 736 if test -e $OUTPUT_ROOT/spec.gmk; then
ihse@844 737 IS_RECONFIGURE=yes
ihse@844 738 else
ihse@844 739 IS_RECONFIGURE=no
ihse@844 740 fi
erikj@457 741
ihse@844 742 if test -e $SRC_ROOT/build/.hide-configure-performance-hints; then
ihse@844 743 HIDE_PERFORMANCE_HINTS=yes
ihse@844 744 else
ihse@844 745 HIDE_PERFORMANCE_HINTS=no
ihse@844 746 # Hide it the next time around...
ihse@844 747 $TOUCH $SRC_ROOT/build/.hide-configure-performance-hints > /dev/null 2>&1
ihse@844 748 fi
erikj@457 749 ])