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