common/autoconf/basics.m4

Tue, 18 Sep 2012 11:29:16 -0700

author
ohair
date
Tue, 18 Sep 2012 11:29:16 -0700
changeset 478
2ba6f4da4bf3
parent 459
3156dff953b1
child 494
e64f2cb57d05
permissions
-rw-r--r--

7197849: Update new build-infra makefiles
Reviewed-by: ihse, erikj, ohrstrom, tbell

erikj@459 1 #
erikj@459 2 # Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
erikj@459 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
erikj@459 4 #
erikj@459 5 # This code is free software; you can redistribute it and/or modify it
erikj@459 6 # under the terms of the GNU General Public License version 2 only, as
erikj@459 7 # published by the Free Software Foundation. Oracle designates this
erikj@459 8 # particular file as subject to the "Classpath" exception as provided
erikj@459 9 # by Oracle in the LICENSE file that accompanied this code.
erikj@459 10 #
erikj@459 11 # This code is distributed in the hope that it will be useful, but WITHOUT
erikj@459 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
erikj@459 13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
erikj@459 14 # version 2 for more details (a copy is included in the LICENSE file that
erikj@459 15 # accompanied this code).
erikj@459 16 #
erikj@459 17 # You should have received a copy of the GNU General Public License version
erikj@459 18 # 2 along with this work; if not, write to the Free Software Foundation,
erikj@459 19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
erikj@459 20 #
erikj@459 21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
erikj@459 22 # or visit www.oracle.com if you need additional information or have any
erikj@459 23 # questions.
erikj@459 24 #
erikj@459 25
erikj@459 26 AC_DEFUN([ADD_JVM_ARG_IF_OK],
erikj@459 27 [
erikj@459 28 # Test if $1 is a valid argument to $3 (often is $JAVA passed as $3)
erikj@459 29 # If so, then append $1 to $2
erikj@459 30 FOUND_WARN=`$3 $1 -version 2>&1 | grep -i warn`
erikj@459 31 FOUND_VERSION=`$3 $1 -version 2>&1 | grep " version \""`
erikj@459 32 if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
erikj@459 33 $2="[$]$2 $1"
erikj@459 34 fi
erikj@459 35 ])
erikj@459 36
ohair@478 37 AC_DEFUN([SET_FULL_PATH],
erikj@459 38 [
erikj@459 39 # Translate "gcc -E" into "`which gcc` -E" ie
erikj@459 40 # extract the full path to the binary and at the
erikj@459 41 # same time maintain any arguments passed to it.
erikj@459 42 # The command MUST exist in the path, or else!
erikj@459 43 tmp="[$]$1"
erikj@459 44 car="${tmp%% *}"
erikj@459 45 tmp="[$]$1 EOL"
erikj@459 46 cdr="${tmp#* }"
erikj@459 47 # On windows we want paths without spaces.
erikj@459 48 if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
ohair@478 49 SET_FULL_PATH_SPACESAFE(car)
erikj@459 50 else
erikj@459 51 # "which" is not portable, but is used here
erikj@459 52 # because we know that the command exists!
erikj@459 53 car=`which $car`
erikj@459 54 fi
erikj@459 55 if test "x$cdr" != xEOL; then
erikj@459 56 $1="$car ${cdr% *}"
erikj@459 57 else
erikj@459 58 $1="$car"
erikj@459 59 fi
erikj@459 60 ])
erikj@459 61
erikj@459 62 AC_DEFUN([SPACESAFE],
erikj@459 63 [
erikj@459 64 # Fail with message $2 if var $1 contains a path with no spaces in it.
erikj@459 65 # Unless on Windows, where we can rewrite the path.
erikj@459 66 HAS_SPACE=`echo "[$]$1" | grep " "`
erikj@459 67 if test "x$HAS_SPACE" != x; then
erikj@459 68 if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
ohair@478 69 # First convert it to DOS-style, short mode (no spaces)
erikj@459 70 $1=`$CYGPATH -s -m -a "[$]$1"`
ohair@478 71 # Now it's case insensitive; let's make it lowercase to improve readability
ohair@478 72 $1=`$ECHO "[$]$1" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvqxyz'`
ohair@478 73 # Now convert it back to Unix-stile (cygpath)
ohair@478 74 $1=`$CYGPATH -u "[$]$1"`
erikj@459 75 else
erikj@459 76 AC_MSG_ERROR([You cannot have spaces in $2! "[$]$1"])
erikj@459 77 fi
erikj@459 78 fi
erikj@459 79 ])
erikj@459 80
ohair@478 81 AC_DEFUN([SET_FULL_PATH_SPACESAFE],
erikj@459 82 [
erikj@459 83 # Translate long cygdrive or C:\sdfsf path
erikj@459 84 # into a short mixed mode path that has no
erikj@459 85 # spaces in it.
erikj@459 86 tmp="[$]$1"
erikj@459 87
erikj@459 88 if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
erikj@459 89 tmp=`$CYGPATH -u "[$]$1"`
erikj@459 90 tmp=`which "$tmp"`
erikj@459 91 # If file exists with .exe appended, that's the real filename
erikj@459 92 # and cygpath needs that to convert to short style path.
erikj@459 93 if test -f "${tmp}.exe"; then
erikj@459 94 tmp="${tmp}.exe"
erikj@459 95 elif test -f "${tmp}.cmd"; then
erikj@459 96 tmp="${tmp}.cmd"
erikj@459 97 fi
erikj@459 98 # Convert to C:/ mixed style path without spaces.
erikj@459 99 tmp=`$CYGPATH -s -m "$tmp"`
erikj@459 100 fi
erikj@459 101 $1="$tmp"
erikj@459 102 ])
erikj@459 103
erikj@459 104 AC_DEFUN([REMOVE_SYMBOLIC_LINKS],
erikj@459 105 [
erikj@459 106 if test "x$OPENJDK_BUILD_OS" != xwindows; then
erikj@459 107 # Follow a chain of symbolic links. Use readlink
erikj@459 108 # where it exists, else fall back to horribly
erikj@459 109 # complicated shell code.
erikj@459 110 AC_PATH_PROG(READLINK, readlink)
erikj@459 111 if test "x$READLINK_TESTED" != yes; then
erikj@459 112 # On MacOSX there is a readlink tool with a different
erikj@459 113 # purpose than the GNU readlink tool. Check the found readlink.
erikj@459 114 ISGNU=`$READLINK --help 2>&1 | grep GNU`
erikj@459 115 if test "x$ISGNU" = x; then
erikj@459 116 # A readlink that we do not know how to use.
erikj@459 117 # Are there other non-GNU readlinks out there?
erikj@459 118 READLINK_TESTED=yes
erikj@459 119 READLINK=
erikj@459 120 fi
erikj@459 121 fi
erikj@459 122
erikj@459 123 if test "x$READLINK" != x; then
erikj@459 124 $1=`$READLINK -f [$]$1`
erikj@459 125 else
erikj@459 126 STARTDIR=$PWD
erikj@459 127 COUNTER=0
erikj@459 128 DIR=`dirname [$]$1`
erikj@459 129 FIL=`basename [$]$1`
erikj@459 130 while test $COUNTER -lt 20; do
erikj@459 131 ISLINK=`ls -l $DIR/$FIL | grep '\->' | sed -e 's/.*-> \(.*\)/\1/'`
erikj@459 132 if test "x$ISLINK" == x; then
erikj@459 133 # This is not a symbolic link! We are done!
erikj@459 134 break
erikj@459 135 fi
erikj@459 136 # The link might be relative! We have to use cd to travel safely.
erikj@459 137 cd $DIR
erikj@459 138 cd `dirname $ISLINK`
erikj@459 139 DIR=`pwd`
erikj@459 140 FIL=`basename $ISLINK`
erikj@459 141 let COUNTER=COUNTER+1
erikj@459 142 done
erikj@459 143 cd $STARTDIR
erikj@459 144 $1=$DIR/$FIL
erikj@459 145 fi
erikj@459 146 fi
erikj@459 147 ])
erikj@459 148
erikj@459 149 AC_DEFUN_ONCE([BASIC_INIT],
erikj@459 150 [
erikj@459 151 # Save the original command line. This is passed to us by the wrapper configure script.
erikj@459 152 AC_SUBST(CONFIGURE_COMMAND_LINE)
erikj@459 153 DATE_WHEN_CONFIGURED=`LANG=C date`
erikj@459 154 AC_SUBST(DATE_WHEN_CONFIGURED)
ohair@478 155 ])
erikj@459 156
ohair@478 157 # Setup basic configuration paths, and platform-specific stuff related to PATHs.
ohair@478 158 AC_DEFUN_ONCE([BASIC_SETUP_PATHS],
ohair@478 159 [
erikj@459 160 # Locate the directory of this script.
erikj@459 161 SCRIPT="[$]0"
ohair@478 162 REMOVE_SYMBOLIC_LINKS(SCRIPT)
erikj@459 163 AUTOCONF_DIR=`dirname [$]0`
erikj@459 164
erikj@459 165 # Where is the source? It is located two levels above the configure script.
erikj@459 166 CURDIR="$PWD"
erikj@459 167 cd "$AUTOCONF_DIR/../.."
erikj@459 168 SRC_ROOT="`pwd`"
erikj@459 169 if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
erikj@459 170 SRC_ROOT_LENGTH=`pwd|wc -m`
erikj@459 171 if test $SRC_ROOT_LENGTH -gt 100; then
erikj@459 172 AC_MSG_ERROR([Your base path is too long. It is $SRC_ROOT_LENGTH characters long, but only 100 is supported])
erikj@459 173 fi
erikj@459 174 fi
erikj@459 175 AC_SUBST(SRC_ROOT)
erikj@459 176 cd "$CURDIR"
erikj@459 177
erikj@459 178 SPACESAFE(SRC_ROOT,[the path to the source root])
erikj@459 179 SPACESAFE(CURDIR,[the path to the current directory])
erikj@459 180
erikj@459 181 if test "x$OPENJDK_BUILD_OS" = "xsolaris"; then
erikj@459 182 # Add extra search paths on solaris for utilities like ar and as etc...
erikj@459 183 PATH="$PATH:/usr/ccs/bin:/usr/sfw/bin:/opt/csw/bin"
erikj@459 184 fi
erikj@459 185
erikj@459 186 # For cygwin we need cygpath first, since it is used everywhere.
erikj@459 187 AC_PATH_PROG(CYGPATH, cygpath)
erikj@459 188 PATH_SEP=":"
erikj@459 189 if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
erikj@459 190 if test "x$CYGPATH" = x; then
erikj@459 191 AC_MSG_ERROR([Something is wrong with your cygwin installation since I cannot find cygpath.exe in your path])
erikj@459 192 fi
erikj@459 193 PATH_SEP=";"
erikj@459 194 fi
erikj@459 195 AC_SUBST(PATH_SEP)
ohair@478 196
ohair@478 197 # You can force the sys-root if the sys-root encoded into the cross compiler tools
ohair@478 198 # is not correct.
ohair@478 199 AC_ARG_WITH(sys-root, [AS_HELP_STRING([--with-sys-root],
ohair@478 200 [pass this sys-root to the compilers and linker (useful if the sys-root encoded in
ohair@478 201 the cross compiler tools is incorrect)])])
ohair@478 202
ohair@478 203 if test "x$with_sys_root" != x; then
ohair@478 204 SYS_ROOT=$with_sys_root
ohair@478 205 else
ohair@478 206 SYS_ROOT=/
ohair@478 207 fi
ohair@478 208 AC_SUBST(SYS_ROOT)
ohair@478 209
ohair@478 210 AC_ARG_WITH([tools-dir], [AS_HELP_STRING([--with-tools-dir],
ohair@478 211 [search this directory for (cross-compiling) compilers and tools])], [TOOLS_DIR=$with_tools_dir])
ohair@478 212
ohair@478 213 AC_ARG_WITH([devkit], [AS_HELP_STRING([--with-devkit],
ohair@478 214 [use this directory as base for tools-dir and sys-root (for cross-compiling)])],
ohair@478 215 [
ohair@478 216 if test "x$with_sys_root" != x; then
ohair@478 217 AC_MSG_ERROR([Cannot specify both --with-devkit and --with-sys-root at the same time])
ohair@478 218 fi
ohair@478 219 if test "x$with_tools_dir" != x; then
ohair@478 220 AC_MSG_ERROR([Cannot specify both --with-devkit and --with-tools-dir at the same time])
ohair@478 221 fi
ohair@478 222 TOOLS_DIR=$with_devkit/bin
ohair@478 223 SYS_ROOT=$with_devkit/$host_alias/libc
ohair@478 224 ])
ohair@478 225
erikj@459 226 ])
erikj@459 227
erikj@459 228 AC_DEFUN_ONCE([BASIC_SETUP_OUTPUT_DIR],
erikj@459 229 [
erikj@459 230
erikj@459 231 AC_ARG_WITH(conf-name, [AS_HELP_STRING([--with-conf-name],
erikj@459 232 [use this as the name of the configuration, overriding the generated default])],
erikj@459 233 [ CONF_NAME=${with_conf_name} ])
erikj@459 234
erikj@459 235 # Test from where we are running configure, in or outside of src root.
erikj@459 236 if test "x$CURDIR" = "x$SRC_ROOT" || test "x$CURDIR" = "x$SRC_ROOT/common" || test "x$CURDIR" = "x$SRC_ROOT/common/autoconf" || test "x$CURDIR" = "x$SRC_ROOT/common/makefiles" ; then
erikj@459 237 # We are running configure from the src root.
erikj@459 238 # Create a default ./build/target-variant-debuglevel output root.
erikj@459 239 if test "x${CONF_NAME}" = x; then
erikj@459 240 CONF_NAME="${OPENJDK_TARGET_OS}-${OPENJDK_TARGET_CPU}-${JDK_VARIANT}-${ANDED_JVM_VARIANTS}-${DEBUG_LEVEL}"
erikj@459 241 fi
erikj@459 242 OUTPUT_ROOT="$SRC_ROOT/build/${CONF_NAME}"
erikj@459 243 mkdir -p "$OUTPUT_ROOT"
erikj@459 244 if test ! -d "$OUTPUT_ROOT"; then
erikj@459 245 AC_MSG_ERROR([Could not create build directory $OUTPUT_ROOT])
erikj@459 246 fi
erikj@459 247 else
erikj@459 248 # We are running configure from outside of the src dir.
erikj@459 249 # Then use the current directory as output dir!
erikj@459 250 # If configuration is situated in normal build directory, just use the build
erikj@459 251 # directory name as configuration name, otherwise use the complete path.
erikj@459 252 if test "x${CONF_NAME}" = x; then
erikj@459 253 CONF_NAME=`$ECHO $CURDIR | $SED -e "s!^${SRC_ROOT}/build/!!"`
erikj@459 254 fi
erikj@459 255 OUTPUT_ROOT="$CURDIR"
erikj@459 256 fi
erikj@459 257
erikj@459 258 SPACESAFE(OUTPUT_ROOT,[the path to the output root])
erikj@459 259
erikj@459 260 AC_SUBST(SPEC, $OUTPUT_ROOT/spec.gmk)
erikj@459 261 AC_SUBST(CONF_NAME, $CONF_NAME)
erikj@459 262 AC_SUBST(OUTPUT_ROOT, $OUTPUT_ROOT)
erikj@459 263
erikj@459 264 # Most of the probed defines are put into config.h
erikj@459 265 AC_CONFIG_HEADERS([$OUTPUT_ROOT/config.h:$AUTOCONF_DIR/config.h.in])
erikj@459 266 # The spec.gmk file contains all variables for the make system.
erikj@459 267 AC_CONFIG_FILES([$OUTPUT_ROOT/spec.gmk:$AUTOCONF_DIR/spec.gmk.in])
ohair@478 268 # The hotspot-spec.gmk file contains legacy variables for the hotspot make system.
ohair@478 269 AC_CONFIG_FILES([$OUTPUT_ROOT/hotspot-spec.gmk:$AUTOCONF_DIR/hotspot-spec.gmk.in])
ohair@478 270 # The bootcycle-spec.gmk file contains support for boot cycle builds.
ohair@478 271 AC_CONFIG_FILES([$OUTPUT_ROOT/bootcycle-spec.gmk:$AUTOCONF_DIR/bootcycle-spec.gmk.in])
ohair@478 272 # The compare.sh is used to compare the build output to other builds.
ohair@478 273 AC_CONFIG_FILES([$OUTPUT_ROOT/compare.sh:$AUTOCONF_DIR/compare.sh.in])
ohair@478 274 # Spec.sh is currently used by compare-objects.sh
erikj@459 275 AC_CONFIG_FILES([$OUTPUT_ROOT/spec.sh:$AUTOCONF_DIR/spec.sh.in])
erikj@459 276 # The generated Makefile knows where the spec.gmk is and where the source is.
erikj@459 277 # You can run make from the OUTPUT_ROOT, or from the top-level Makefile
erikj@459 278 # which will look for generated configurations
erikj@459 279 AC_CONFIG_FILES([$OUTPUT_ROOT/Makefile:$AUTOCONF_DIR/Makefile.in])
erikj@459 280
erikj@459 281 # Save the arguments given to us
erikj@459 282 echo "$CONFIGURE_COMMAND_LINE" > $OUTPUT_ROOT/configure-arguments
erikj@459 283 ])
erikj@459 284
erikj@459 285 AC_DEFUN_ONCE([BASIC_SETUP_LOGGING],
erikj@459 286 [
erikj@459 287 # Setup default logging of stdout and stderr to build.log in the output root.
erikj@459 288 BUILD_LOG='$(OUTPUT_ROOT)/build.log'
erikj@459 289 BUILD_LOG_PREVIOUS='$(OUTPUT_ROOT)/build.log.old'
erikj@459 290 BUILD_LOG_WRAPPER='$(SH) $(SRC_ROOT)/common/bin/logger.sh $(BUILD_LOG)'
erikj@459 291 AC_SUBST(BUILD_LOG)
erikj@459 292 AC_SUBST(BUILD_LOG_PREVIOUS)
erikj@459 293 AC_SUBST(BUILD_LOG_WRAPPER)
erikj@459 294 ])
erikj@459 295
erikj@459 296
erikj@459 297 #%%% Simple tools %%%
erikj@459 298
ohair@478 299 # Check if we have found a usable version of make
ohair@478 300 # $1: the path to a potential make binary (or empty)
ohair@478 301 # $2: the description on how we found this
ohair@478 302 AC_DEFUN([BASIC_CHECK_MAKE_VERSION],
ohair@478 303 [
ohair@478 304 MAKE_CANDIDATE="$1"
ohair@478 305 DESCRIPTION="$2"
ohair@478 306 if test "x$MAKE_CANDIDATE" != x; then
ohair@478 307 AC_MSG_NOTICE([Testing potential make at $MAKE_CANDIDATE, found using $DESCRIPTION])
ohair@478 308 SET_FULL_PATH(MAKE_CANDIDATE)
ohair@478 309 MAKE_VERSION_STRING=`$MAKE_CANDIDATE --version | $HEAD -n 1`
ohair@478 310 IS_GNU_MAKE=`$ECHO $MAKE_VERSION_STRING | $GREP 'GNU Make'`
ohair@478 311 if test "x$IS_GNU_MAKE" = x; then
ohair@478 312 AC_MSG_NOTICE([Found potential make at $MAKE_CANDIDATE, however, this is not GNU Make. Ignoring.])
ohair@478 313 else
ohair@478 314 IS_MODERN_MAKE=`$ECHO $MAKE_VERSION_STRING | $GREP '3.8[[12346789]]'`
ohair@478 315 if test "x$IS_MODERN_MAKE" = x; then
ohair@478 316 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@478 317 else
ohair@478 318 FOUND_MAKE=$MAKE_CANDIDATE
ohair@478 319 fi
ohair@478 320 fi
ohair@478 321 fi
ohair@478 322 ])
ohair@478 323
ohair@478 324 # Goes looking for a usable version of GNU make.
ohair@478 325 AC_DEFUN([BASIC_CHECK_GNU_MAKE],
ohair@478 326 [
ohair@478 327 # We need to find a recent version of GNU make. Especially on Solaris, this can be tricky.
ohair@478 328 if test "x$MAKE" != x; then
ohair@478 329 # User has supplied a make, test it.
ohair@478 330 if test ! -f "$MAKE"; then
ohair@478 331 AC_MSG_ERROR([The specified make (by MAKE=$MAKE) is not found.])
ohair@478 332 fi
ohair@478 333 BASIC_CHECK_MAKE_VERSION("$MAKE", [user supplied MAKE=])
ohair@478 334 if test "x$FOUND_MAKE" = x; then
ohair@478 335 AC_MSG_ERROR([The specified make (by MAKE=$MAKE) is not GNU make 3.81 or newer.])
ohair@478 336 fi
ohair@478 337 else
ohair@478 338 # Try our hardest to locate a correct version of GNU make
ohair@478 339 AC_PATH_PROGS(CHECK_GMAKE, gmake)
ohair@478 340 BASIC_CHECK_MAKE_VERSION("$CHECK_GMAKE", [gmake in PATH])
ohair@478 341
ohair@478 342 if test "x$FOUND_MAKE" = x; then
ohair@478 343 AC_PATH_PROGS(CHECK_MAKE, make)
ohair@478 344 BASIC_CHECK_MAKE_VERSION("$CHECK_MAKE", [make in PATH])
ohair@478 345 fi
ohair@478 346
ohair@478 347 if test "x$FOUND_MAKE" = x; then
ohair@478 348 if test "x$TOOLS_DIR" != x; then
ohair@478 349 # We have a tools-dir, check that as well before giving up.
ohair@478 350 OLD_PATH=$PATH
ohair@478 351 PATH=$TOOLS_DIR:$PATH
ohair@478 352 AC_PATH_PROGS(CHECK_TOOLSDIR_GMAKE, gmake)
ohair@478 353 BASIC_CHECK_MAKE_VERSION("$CHECK_TOOLSDIR_GMAKE", [gmake in tools-dir])
ohair@478 354 if test "x$FOUND_MAKE" = x; then
ohair@478 355 AC_PATH_PROGS(CHECK_TOOLSDIR_MAKE, make)
ohair@478 356 BASIC_CHECK_MAKE_VERSION("$CHECK_TOOLSDIR_MAKE", [make in tools-dir])
ohair@478 357 fi
ohair@478 358 PATH=$OLD_PATH
ohair@478 359 fi
ohair@478 360 fi
ohair@478 361
ohair@478 362 if test "x$FOUND_MAKE" = x; then
ohair@478 363 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@478 364 fi
ohair@478 365 fi
ohair@478 366
ohair@478 367 MAKE=$FOUND_MAKE
ohair@478 368 AC_SUBST(MAKE)
ohair@478 369 AC_MSG_NOTICE([Using GNU make 3.81 (or later) at $FOUND_MAKE (version: $MAKE_VERSION_STRING)])
ohair@478 370 ])
ohair@478 371
erikj@459 372 AC_DEFUN([BASIC_CHECK_FIND_DELETE],
erikj@459 373 [
erikj@459 374 # Test if find supports -delete
erikj@459 375 AC_MSG_CHECKING([if find supports -delete])
erikj@459 376 FIND_DELETE="-delete"
erikj@459 377
erikj@459 378 DELETEDIR=`mktemp -d tmp.XXXXXXXXXX` || (echo Could not create temporary directory!; exit $?)
erikj@459 379
erikj@459 380 echo Hejsan > $DELETEDIR/TestIfFindSupportsDelete
erikj@459 381
erikj@459 382 TEST_DELETE=`$FIND "$DELETEDIR" -name TestIfFindSupportsDelete $FIND_DELETE 2>&1`
erikj@459 383 if test -f $DELETEDIR/TestIfFindSupportsDelete; then
erikj@459 384 # No, it does not.
erikj@459 385 rm $DELETEDIR/TestIfFindSupportsDelete
erikj@459 386 FIND_DELETE="-exec rm \{\} \+"
erikj@459 387 AC_MSG_RESULT([no])
erikj@459 388 else
erikj@459 389 AC_MSG_RESULT([yes])
erikj@459 390 fi
erikj@459 391 rmdir $DELETEDIR
erikj@459 392 ])
erikj@459 393
ohair@478 394 # Test that variable $1 denoting a program is not empty. If empty, exit with an error.
ohair@478 395 # $1: variable to check
ohair@478 396 # $2: executable name to print in warning (optional)
erikj@459 397 AC_DEFUN([CHECK_NONEMPTY],
erikj@459 398 [
ohair@478 399 if test "x[$]$1" = x; then
ohair@478 400 if test "x$2" = x; then
ohair@478 401 PROG_NAME=translit($1,A-Z,a-z)
ohair@478 402 else
ohair@478 403 PROG_NAME=$2
ohair@478 404 fi
ohair@478 405 AC_MSG_NOTICE([Could not find $PROG_NAME!])
ohair@478 406 AC_MSG_ERROR([Cannot continue])
ohair@478 407 fi
ohair@478 408 ])
ohair@478 409
ohair@478 410 # Does AC_PATH_PROG followed by CHECK_NONEMPTY.
ohair@478 411 # Arguments as AC_PATH_PROG:
ohair@478 412 # $1: variable to set
ohair@478 413 # $2: executable name to look for
ohair@478 414 AC_DEFUN([BASIC_REQUIRE_PROG],
ohair@478 415 [
ohair@478 416 AC_PATH_PROGS($1, $2)
ohair@478 417 CHECK_NONEMPTY($1, $2)
erikj@459 418 ])
erikj@459 419
erikj@459 420 AC_DEFUN_ONCE([BASIC_SETUP_TOOLS],
erikj@459 421 [
erikj@459 422 # Start with tools that do not need have cross compilation support
erikj@459 423 # and can be expected to be found in the default PATH. These tools are
erikj@459 424 # used by configure. Nor are these tools expected to be found in the
erikj@459 425 # devkit from the builddeps server either, since they are
ohair@478 426 # needed to download the devkit.
ohair@478 427
ohair@478 428 # First are all the simple required tools.
ohair@478 429 BASIC_REQUIRE_PROG(BASENAME, basename)
ohair@478 430 BASIC_REQUIRE_PROG(CAT, cat)
ohair@478 431 BASIC_REQUIRE_PROG(CHMOD, chmod)
ohair@478 432 BASIC_REQUIRE_PROG(CMP, cmp)
ohair@478 433 BASIC_REQUIRE_PROG(CP, cp)
ohair@478 434 BASIC_REQUIRE_PROG(CPIO, cpio)
ohair@478 435 BASIC_REQUIRE_PROG(CUT, cut)
ohair@478 436 BASIC_REQUIRE_PROG(DATE, date)
ohair@478 437 BASIC_REQUIRE_PROG(DF, df)
ohair@478 438 BASIC_REQUIRE_PROG(DIFF, [gdiff diff])
ohair@478 439 BASIC_REQUIRE_PROG(ECHO, echo)
ohair@478 440 BASIC_REQUIRE_PROG(EXPR, expr)
ohair@478 441 BASIC_REQUIRE_PROG(FILE, file)
ohair@478 442 BASIC_REQUIRE_PROG(FIND, find)
ohair@478 443 BASIC_REQUIRE_PROG(HEAD, head)
ohair@478 444 BASIC_REQUIRE_PROG(LN, ln)
ohair@478 445 BASIC_REQUIRE_PROG(LS, ls)
ohair@478 446 BASIC_REQUIRE_PROG(MKDIR, mkdir)
ohair@478 447 BASIC_REQUIRE_PROG(MV, mv)
ohair@478 448 BASIC_REQUIRE_PROG(PRINTF, printf)
ohair@478 449 BASIC_REQUIRE_PROG(SH, sh)
ohair@478 450 BASIC_REQUIRE_PROG(SORT, sort)
ohair@478 451 BASIC_REQUIRE_PROG(TAIL, tail)
ohair@478 452 BASIC_REQUIRE_PROG(TAR, tar)
ohair@478 453 BASIC_REQUIRE_PROG(TEE, tee)
ohair@478 454 BASIC_REQUIRE_PROG(TOUCH, touch)
ohair@478 455 BASIC_REQUIRE_PROG(TR, tr)
ohair@478 456 BASIC_REQUIRE_PROG(UNIQ, uniq)
ohair@478 457 BASIC_REQUIRE_PROG(UNZIP, unzip)
ohair@478 458 BASIC_REQUIRE_PROG(WC, wc)
ohair@478 459 BASIC_REQUIRE_PROG(XARGS, xargs)
ohair@478 460 BASIC_REQUIRE_PROG(ZIP, zip)
ohair@478 461
ohair@478 462 # Then required tools that require some special treatment.
erikj@459 463 AC_PROG_AWK
erikj@459 464 CHECK_NONEMPTY(AWK)
ohair@478 465 AC_PROG_GREP
ohair@478 466 CHECK_NONEMPTY(GREP)
erikj@459 467 AC_PROG_EGREP
erikj@459 468 CHECK_NONEMPTY(EGREP)
erikj@459 469 AC_PROG_FGREP
erikj@459 470 CHECK_NONEMPTY(FGREP)
ohair@478 471 AC_PROG_SED
ohair@478 472 CHECK_NONEMPTY(SED)
erikj@459 473
ohair@478 474 AC_PATH_PROGS(NAWK, [nawk gawk awk])
ohair@478 475 CHECK_NONEMPTY(NAWK)
ohair@478 476
ohair@478 477 BASIC_CHECK_GNU_MAKE
ohair@478 478
ohair@478 479 BASIC_REQUIRE_PROG(RM, rm)
ohair@478 480 RM="$RM -f"
ohair@478 481
erikj@459 482 BASIC_CHECK_FIND_DELETE
erikj@459 483 AC_SUBST(FIND_DELETE)
erikj@459 484
ohair@478 485 # Non-required basic tools
ohair@478 486
erikj@459 487 AC_PATH_PROG(THEPWDCMD, pwd)
erikj@459 488 AC_PATH_PROG(LDD, ldd)
erikj@459 489 if test "x$LDD" = "x"; then
erikj@459 490 # List shared lib dependencies is used for
erikj@459 491 # debug output and checking for forbidden dependencies.
erikj@459 492 # We can build without it.
erikj@459 493 LDD="true"
erikj@459 494 fi
erikj@459 495 AC_PATH_PROG(OTOOL, otool)
erikj@459 496 if test "x$OTOOL" = "x"; then
erikj@459 497 OTOOL="true"
erikj@459 498 fi
ohair@478 499 AC_PATH_PROGS(READELF, [readelf greadelf])
ohair@478 500 AC_PATH_PROGS(OBJDUMP, [objdump gobjdump])
erikj@459 501 AC_PATH_PROG(HG, hg)
erikj@459 502 ])
erikj@459 503
erikj@459 504 AC_DEFUN_ONCE([BASIC_COMPILE_UNCYGDRIVE],
erikj@459 505 [
erikj@459 506 # When using cygwin, we need a wrapper binary that renames
erikj@459 507 # /cygdrive/c/ arguments into c:/ arguments and peeks into
erikj@459 508 # @files and rewrites these too! This wrapper binary is
erikj@459 509 # called uncygdrive.exe.
erikj@459 510 UNCYGDRIVE=
erikj@459 511 if test "x$OPENJDK_BUILD_OS" = xwindows; then
erikj@459 512 AC_MSG_CHECKING([if uncygdrive can be created])
erikj@459 513 UNCYGDRIVE_SRC=`$CYGPATH -m $SRC_ROOT/common/src/uncygdrive.c`
erikj@459 514 rm -f $OUTPUT_ROOT/uncygdrive*
erikj@459 515 UNCYGDRIVE=`$CYGPATH -m $OUTPUT_ROOT/uncygdrive.exe`
erikj@459 516 cd $OUTPUT_ROOT
erikj@459 517 $CC $UNCYGDRIVE_SRC /Fe$UNCYGDRIVE > $OUTPUT_ROOT/uncygdrive1.log 2>&1
erikj@459 518 cd $CURDIR
erikj@459 519
erikj@459 520 if test ! -x $OUTPUT_ROOT/uncygdrive.exe; then
erikj@459 521 AC_MSG_RESULT([no])
erikj@459 522 cat $OUTPUT_ROOT/uncygdrive1.log
erikj@459 523 AC_MSG_ERROR([Could not create $OUTPUT_ROOT/uncygdrive.exe])
erikj@459 524 fi
erikj@459 525 AC_MSG_RESULT([$UNCYGDRIVE])
erikj@459 526 AC_MSG_CHECKING([if uncygdrive.exe works])
erikj@459 527 cd $OUTPUT_ROOT
erikj@459 528 $UNCYGDRIVE $CC $SRC_ROOT/common/src/uncygdrive.c /Fe$OUTPUT_ROOT/uncygdrive2.exe > $OUTPUT_ROOT/uncygdrive2.log 2>&1
erikj@459 529 cd $CURDIR
erikj@459 530 if test ! -x $OUTPUT_ROOT/uncygdrive2.exe; then
erikj@459 531 AC_MSG_RESULT([no])
erikj@459 532 cat $OUTPUT_ROOT/uncygdrive2.log
erikj@459 533 AC_MSG_ERROR([Uncygdrive did not work!])
erikj@459 534 fi
erikj@459 535 AC_MSG_RESULT([yes])
erikj@459 536 rm -f $OUTPUT_ROOT/uncygdrive?.??? $OUTPUT_ROOT/uncygdrive.obj
ohair@478 537 # The path to uncygdrive to use should be Unix-style
ohair@478 538 UNCYGDRIVE="$OUTPUT_ROOT/uncygdrive.exe"
erikj@459 539 fi
erikj@459 540
erikj@459 541 AC_SUBST(UNCYGDRIVE)
erikj@459 542 ])
erikj@459 543
erikj@459 544
erikj@459 545 # Check if build directory is on local disk.
erikj@459 546 # Argument 1: directory to test
erikj@459 547 # Argument 2: what to do if it is on local disk
erikj@459 548 # Argument 3: what to do otherwise (remote disk or failure)
erikj@459 549 AC_DEFUN([BASIC_CHECK_DIR_ON_LOCAL_DISK],
erikj@459 550 [
erikj@459 551 # df -l lists only local disks; if the given directory is not found then
erikj@459 552 # a non-zero exit code is given
erikj@459 553 if $DF -l $1 > /dev/null 2>&1; then
erikj@459 554 $2
erikj@459 555 else
erikj@459 556 $3
erikj@459 557 fi
erikj@459 558 ])
erikj@459 559
erikj@459 560 AC_DEFUN_ONCE([BASIC_TEST_USABILITY_ISSUES],
erikj@459 561 [
erikj@459 562
erikj@459 563 AC_MSG_CHECKING([if build directory is on local disk])
erikj@459 564 BASIC_CHECK_DIR_ON_LOCAL_DISK($OUTPUT_ROOT,
erikj@459 565 [OUTPUT_DIR_IS_LOCAL="yes"],
erikj@459 566 [OUTPUT_DIR_IS_LOCAL="no"])
erikj@459 567 AC_MSG_RESULT($OUTPUT_DIR_IS_LOCAL)
erikj@459 568
erikj@459 569 # Check if the user has any old-style ALT_ variables set.
erikj@459 570 FOUND_ALT_VARIABLES=`env | grep ^ALT_`
erikj@459 571
erikj@459 572 # Before generating output files, test if they exist. If they do, this is a reconfigure.
erikj@459 573 # Since we can't properly handle the dependencies for this, warn the user about the situation
erikj@459 574 if test -e $OUTPUT_ROOT/spec.gmk; then
erikj@459 575 IS_RECONFIGURE=yes
erikj@459 576 else
erikj@459 577 IS_RECONFIGURE=no
erikj@459 578 fi
erikj@459 579
erikj@459 580 if test -e $SRC_ROOT/build/.hide-configure-performance-hints; then
erikj@459 581 HIDE_PERFORMANCE_HINTS=yes
erikj@459 582 else
erikj@459 583 HIDE_PERFORMANCE_HINTS=no
erikj@459 584 # Hide it the next time around...
erikj@459 585 $TOUCH $SRC_ROOT/build/.hide-configure-performance-hints > /dev/null 2>&1
erikj@459 586 fi
erikj@459 587
erikj@459 588 ])

mercurial