1 #
   2 # Copyright (c) 2011, 2018, 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 
  26 ########################################################################
  27 # This file is responsible for detecting, verifying and setting up the 
  28 # toolchain, i.e. the compiler, linker and related utilities. It will setup 
  29 # proper paths to the binaries, but it will not setup any flags.
  30 #
  31 # The binaries used is determined by the toolchain type, which is the family of 
  32 # compilers and related tools that are used.
  33 ########################################################################
  34 
  35 
  36 # All valid toolchains, regardless of platform (used by help.m4)
  37 VALID_TOOLCHAINS_all="gcc clang solstudio xlc microsoft"
  38 
  39 # These toolchains are valid on different platforms
  40 VALID_TOOLCHAINS_linux="gcc clang"
  41 VALID_TOOLCHAINS_solaris="solstudio"
  42 VALID_TOOLCHAINS_macosx="gcc clang"
  43 VALID_TOOLCHAINS_aix="xlc"
  44 VALID_TOOLCHAINS_windows="microsoft"
  45 
  46 # Toolchain descriptions
  47 TOOLCHAIN_DESCRIPTION_clang="clang/LLVM"
  48 TOOLCHAIN_DESCRIPTION_gcc="GNU Compiler Collection"
  49 TOOLCHAIN_DESCRIPTION_microsoft="Microsoft Visual Studio"
  50 TOOLCHAIN_DESCRIPTION_solstudio="Oracle Solaris Studio"
  51 TOOLCHAIN_DESCRIPTION_xlc="IBM XL C/C++"
  52 
  53 # Prepare the system so that TOOLCHAIN_CHECK_COMPILER_VERSION can be called.
  54 # Must have CC_VERSION_NUMBER and CXX_VERSION_NUMBER.
  55 # $1 - optional variable prefix for compiler and version variables (BUILD_)
  56 # $2 - optional variable prefix for comparable variable (OPENJDK_BUILD_)
  57 AC_DEFUN([TOOLCHAIN_PREPARE_FOR_VERSION_COMPARISONS],
  58 [
  59   if test "x$CC_VERSION" != "x$CXX_VERSION"; then
  60     AC_MSG_WARN([C and C++ compiler has different version numbers, $CC_VERSION vs $CXX_VERSION.])
  61     AC_MSG_WARN([This typically indicates a broken setup, and is not supported])
  62   fi
  63 
  64   # We only check CC_VERSION since we assume CXX_VERSION is equal.
  65   if [ [[ "$CC_VERSION" =~ (.*\.){3} ]] ]; then
  66     AC_MSG_WARN([C compiler version number has more than three parts (X.Y.Z): $CC_VERSION. Comparisons might be wrong.])
  67   fi
  68 
  69   if [ [[  "$CC_VERSION" =~ [0-9]{6} ]] ]; then
  70     AC_MSG_WARN([C compiler version number has a part larger than 99999: $CC_VERSION. Comparisons might be wrong.])
  71   fi
  72 
  73   $2COMPARABLE_ACTUAL_VERSION=`$AWK -F. '{ printf("%05d%05d%05d\n", [$]1, [$]2, [$]3) }' <<< "$CC_VERSION"`
  74 ])
  75 
  76 # Check if the configured compiler (C and C++) is of a specific version or
  77 # newer. TOOLCHAIN_PREPARE_FOR_VERSION_COMPARISONS must have been called before.
  78 #
  79 # Arguments:
  80 #   $1:   The version string to check against the found version
  81 #   $2:   block to run if the compiler is at least this version (>=)
  82 #   $3:   block to run if the compiler is older than this version (<)
  83 AC_DEFUN([TOOLCHAIN_CHECK_COMPILER_VERSION],
  84 [
  85   REFERENCE_VERSION=$1
  86 
  87   if [ [[ "$REFERENCE_VERSION" =~ (.*\.){3} ]] ]; then
  88     AC_MSG_ERROR([Internal error: Cannot compare to $REFERENCE_VERSION, only three parts (X.Y.Z) is supported])
  89   fi
  90 
  91   if [ [[ "$REFERENCE_VERSION" =~ [0-9]{6} ]] ]; then
  92     AC_MSG_ERROR([Internal error: Cannot compare to $REFERENCE_VERSION, only parts < 99999 is supported])
  93   fi
  94 
  95   # Version comparison method inspired by http://stackoverflow.com/a/24067243
  96   COMPARABLE_REFERENCE_VERSION=`$AWK -F. '{ printf("%05d%05d%05d\n", [$]1, [$]2, [$]3) }' <<< "$REFERENCE_VERSION"`
  97 
  98   if test $COMPARABLE_ACTUAL_VERSION -ge $COMPARABLE_REFERENCE_VERSION ; then
  99     m4_ifval([$2], [$2], [:])
 100   else
 101     m4_ifval([$3], [$3], [:])
 102   fi
 103 ])
 104 
 105 
 106 # Setup a number of variables describing how native output files are
 107 # named on this platform/toolchain.
 108 AC_DEFUN([TOOLCHAIN_SETUP_FILENAME_PATTERNS],
 109 [
 110   # Define filename patterns
 111   if test "x$OPENJDK_TARGET_OS" = xwindows; then
 112     LIBRARY_PREFIX=
 113     SHARED_LIBRARY_SUFFIX='.dll'
 114     STATIC_LIBRARY_SUFFIX='.lib'
 115     SHARED_LIBRARY='[$]1.dll'
 116     STATIC_LIBRARY='[$]1.lib'
 117     OBJ_SUFFIX='.obj'
 118     EXE_SUFFIX='.exe'
 119   else
 120     LIBRARY_PREFIX=lib
 121     SHARED_LIBRARY_SUFFIX='.so'
 122     STATIC_LIBRARY_SUFFIX='.a'
 123     SHARED_LIBRARY='lib[$]1.so'
 124     STATIC_LIBRARY='lib[$]1.a'
 125     OBJ_SUFFIX='.o'
 126     EXE_SUFFIX=''
 127     if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 128       SHARED_LIBRARY='lib[$]1.dylib'
 129       SHARED_LIBRARY_SUFFIX='.dylib'
 130     fi
 131   fi
 132 
 133   AC_SUBST(LIBRARY_PREFIX)
 134   AC_SUBST(SHARED_LIBRARY_SUFFIX)
 135   AC_SUBST(STATIC_LIBRARY_SUFFIX)
 136   AC_SUBST(SHARED_LIBRARY)
 137   AC_SUBST(STATIC_LIBRARY)
 138   AC_SUBST(OBJ_SUFFIX)
 139   AC_SUBST(EXE_SUFFIX)  
 140 ])
 141 
 142 # Determine which toolchain type to use, and make sure it is valid for this
 143 # platform. Setup various information about the selected toolchain.
 144 AC_DEFUN_ONCE([TOOLCHAIN_DETERMINE_TOOLCHAIN_TYPE],
 145 [
 146   AC_ARG_WITH(toolchain-type, [AS_HELP_STRING([--with-toolchain-type],
 147       [the toolchain type (or family) to use, use '--help' to show possible values @<:@platform dependent@:>@])])
 148 
 149   # Use indirect variable referencing
 150   toolchain_var_name=VALID_TOOLCHAINS_$OPENJDK_BUILD_OS
 151   VALID_TOOLCHAINS=${!toolchain_var_name}
 152   # First toolchain type in the list is the default
 153   DEFAULT_TOOLCHAIN=${VALID_TOOLCHAINS%% *}
 154 
 155   if test "x$with_toolchain_type" = xlist; then
 156     # List all toolchains
 157     AC_MSG_NOTICE([The following toolchains are valid on this platform:])
 158     for toolchain in $VALID_TOOLCHAINS; do
 159       toolchain_var_name=TOOLCHAIN_DESCRIPTION_$toolchain
 160       TOOLCHAIN_DESCRIPTION=${!toolchain_var_name}
 161       $PRINTF "  %-10s  %s\n" $toolchain "$TOOLCHAIN_DESCRIPTION"
 162     done
 163     
 164     exit 0
 165   elif test "x$with_toolchain_type" != x; then
 166     # User override; check that it is valid
 167     if test "x${VALID_TOOLCHAINS/$with_toolchain_type/}" = "x${VALID_TOOLCHAINS}"; then
 168       AC_MSG_NOTICE([Toolchain type $with_toolchain_type is not valid on this platform.])
 169       AC_MSG_NOTICE([Valid toolchains: $VALID_TOOLCHAINS.])
 170       AC_MSG_ERROR([Cannot continue.])
 171     fi
 172     TOOLCHAIN_TYPE=$with_toolchain_type
 173   else
 174     # No flag given, use default
 175     TOOLCHAIN_TYPE=$DEFAULT_TOOLCHAIN
 176   fi
 177   AC_SUBST(TOOLCHAIN_TYPE)
 178 
 179   TOOLCHAIN_CC_BINARY_clang="clang"
 180   TOOLCHAIN_CC_BINARY_gcc="gcc"
 181   TOOLCHAIN_CC_BINARY_microsoft="cl"
 182   TOOLCHAIN_CC_BINARY_solstudio="cc"
 183   TOOLCHAIN_CC_BINARY_xlc="xlc_r"
 184 
 185   TOOLCHAIN_CXX_BINARY_clang="clang++"
 186   TOOLCHAIN_CXX_BINARY_gcc="g++"
 187   TOOLCHAIN_CXX_BINARY_microsoft="cl"
 188   TOOLCHAIN_CXX_BINARY_solstudio="CC"
 189   TOOLCHAIN_CXX_BINARY_xlc="xlC_r"
 190 
 191   # Use indirect variable referencing
 192   toolchain_var_name=TOOLCHAIN_DESCRIPTION_$TOOLCHAIN_TYPE
 193   TOOLCHAIN_DESCRIPTION=${!toolchain_var_name}
 194   toolchain_var_name=TOOLCHAIN_CC_BINARY_$TOOLCHAIN_TYPE
 195   TOOLCHAIN_CC_BINARY=${!toolchain_var_name}
 196   toolchain_var_name=TOOLCHAIN_CXX_BINARY_$TOOLCHAIN_TYPE
 197   TOOLCHAIN_CXX_BINARY=${!toolchain_var_name}
 198 
 199   TOOLCHAIN_SETUP_FILENAME_PATTERNS
 200 
 201   if test "x$TOOLCHAIN_TYPE" = "x$DEFAULT_TOOLCHAIN"; then
 202     AC_MSG_NOTICE([Using default toolchain $TOOLCHAIN_TYPE ($TOOLCHAIN_DESCRIPTION)])
 203   else
 204     AC_MSG_NOTICE([Using user selected toolchain $TOOLCHAIN_TYPE ($TOOLCHAIN_DESCRIPTION). Default toolchain is $DEFAULT_TOOLCHAIN.])
 205   fi 
 206 ])
 207 
 208 # Before we start detecting the toolchain executables, we might need some 
 209 # special setup, e.g. additional paths etc.
 210 AC_DEFUN_ONCE([TOOLCHAIN_PRE_DETECTION],
 211 [
 212   # FIXME: Is this needed?
 213   AC_LANG(C++)
 214 
 215   # Store the CFLAGS etal passed to the configure script.
 216   ORG_CFLAGS="$CFLAGS"
 217   ORG_CXXFLAGS="$CXXFLAGS"
 218   ORG_OBJCFLAGS="$OBJCFLAGS"
 219 
 220   # autoconf magic only relies on PATH, so update it if tools dir is specified
 221   OLD_PATH="$PATH"
 222 
 223   # On Windows, we need to detect the visual studio installation first.
 224   # This will change the PATH, but we need to keep that new PATH even 
 225   # after toolchain detection is done, since the compiler (on x86) uses
 226   # it for DLL resolution in runtime.
 227   if test "x$OPENJDK_BUILD_OS" = "xwindows" \
 228       && test "x$TOOLCHAIN_TYPE" = "xmicrosoft"; then
 229     TOOLCHAIN_SETUP_VISUAL_STUDIO_ENV
 230     # Reset path to VS_PATH. It will include everything that was on PATH at the time we
 231     # ran TOOLCHAIN_SETUP_VISUAL_STUDIO_ENV.
 232     PATH="$VS_PATH"
 233     # The microsoft toolchain also requires INCLUDE and LIB to be set.
 234     export INCLUDE="$VS_INCLUDE"
 235     export LIB="$VS_LIB"
 236   fi
 237 
 238   # Before we locate the compilers, we need to sanitize the Xcode build environment
 239   if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
 240     # determine path to Xcode developer directory
 241     # can be empty in which case all the tools will rely on a sane Xcode 4 installation
 242     SET_DEVELOPER_DIR=
 243 
 244     if test -n "$XCODE_PATH"; then
 245       DEVELOPER_DIR="$XCODE_PATH"/Contents/Developer
 246     fi
 247 
 248     # DEVELOPER_DIR could also be provided directly
 249     AC_MSG_CHECKING([Determining if we need to set DEVELOPER_DIR])
 250     if test -n "$DEVELOPER_DIR"; then
 251       if test ! -d "$DEVELOPER_DIR"; then
 252         AC_MSG_ERROR([Xcode Developer path does not exist: $DEVELOPER_DIR, please provide a path to the Xcode 4 application bundle using --with-xcode-path])
 253       fi
 254       if test ! -f "$DEVELOPER_DIR"/usr/bin/xcodebuild; then
 255         AC_MSG_ERROR([Xcode Developer path is not valid: $DEVELOPER_DIR, it must point to Contents/Developer inside an Xcode application bundle])
 256       fi
 257       # make it visible to all the tools immediately
 258       export DEVELOPER_DIR
 259       SET_DEVELOPER_DIR="export DEVELOPER_DIR := $DEVELOPER_DIR"
 260       AC_MSG_RESULT([yes ($DEVELOPER_DIR)])
 261     else
 262       AC_MSG_RESULT([no])
 263     fi
 264     AC_SUBST(SET_DEVELOPER_DIR)
 265 
 266     AC_PATH_PROG(XCODEBUILD, xcodebuild)
 267     if test -z "$XCODEBUILD"; then
 268       AC_MSG_ERROR([The xcodebuild tool was not found, the Xcode command line tools are required to build on Mac OS X])
 269     fi
 270 
 271     # Fail-fast: verify we're building on Xcode 4, we cannot build with Xcode 5 or later
 272     XCODE_VERSION=`$XCODEBUILD -version | grep '^Xcode ' | sed 's/Xcode //'`
 273     XC_VERSION_PARTS=( ${XCODE_VERSION//./ } )
 274     if test ! "${XC_VERSION_PARTS[[0]]}" = "4"; then
 275       AC_MSG_ERROR([Xcode 4 is required to build JDK 8, the version found was $XCODE_VERSION. Use --with-xcode-path to specify the location of Xcode 4 or make Xcode 4 active by using xcode-select.])
 276     fi
 277 
 278     # Some versions of Xcode 5 command line tools install gcc and g++ as symlinks to
 279     # clang and clang++, which will break the build. So handle that here if we need to.
 280     if test -L "/usr/bin/gcc" -o -L "/usr/bin/g++"; then
 281       # use xcrun to find the real gcc and add it's directory to PATH
 282       # then autoconf magic will find it
 283       AC_MSG_NOTICE([Found gcc symlinks to clang in /usr/bin, adding path to real gcc to PATH])
 284       XCODE_BIN_PATH=$(dirname `xcrun -find gcc`)
 285       PATH="$XCODE_BIN_PATH":$PATH
 286     fi
 287 
 288     # Determine appropriate SDKPATH, don't use SDKROOT as it interferes with the stub tools
 289     AC_MSG_CHECKING([Determining Xcode SDK path])
 290     # allow SDKNAME to be set to override the default SDK selection
 291     SDKPATH=`"$XCODEBUILD" -sdk ${SDKNAME:-macosx} -version | grep '^Path: ' | sed 's/Path: //'`
 292     if test -n "$SDKPATH"; then
 293       AC_MSG_RESULT([$SDKPATH])
 294     else
 295       AC_MSG_RESULT([(none, will use system headers and frameworks)])
 296     fi
 297     AC_SUBST(SDKPATH)
 298 
 299     # Perform a basic sanity test
 300     if test ! -f "$SDKPATH/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h"; then
 301       AC_MSG_ERROR([Unable to find required framework headers, provide a valid path to Xcode 4 using --with-xcode-path])
 302     fi
 303 
 304     # if SDKPATH is non-empty then we need to add -isysroot and -iframework for gcc and g++
 305     if test -n "$SDKPATH"; then
 306       # We need -isysroot <path> and -iframework<path>/System/Library/Frameworks
 307       CFLAGS_JDK="${CFLAGS_JDK} -isysroot \"$SDKPATH\" -iframework\"$SDKPATH/System/Library/Frameworks\""
 308       CXXFLAGS_JDK="${CXXFLAGS_JDK} -isysroot \"$SDKPATH\" -iframework\"$SDKPATH/System/Library/Frameworks\""
 309       LDFLAGS_JDK="${LDFLAGS_JDK} -isysroot \"$SDKPATH\" -iframework\"$SDKPATH/System/Library/Frameworks\""
 310     fi
 311     
 312     # These always need to be set, or we can't find the frameworks embedded in JavaVM.framework
 313     # setting this here means it doesn't have to be peppered throughout the forest
 314     CFLAGS_JDK="$CFLAGS_JDK -F\"$SDKPATH/System/Library/Frameworks/JavaVM.framework/Frameworks\""
 315     CXXFLAGS_JDK="$CXXFLAGS_JDK -F\"$SDKPATH/System/Library/Frameworks/JavaVM.framework/Frameworks\""
 316     LDFLAGS_JDK="$LDFLAGS_JDK -F\"$SDKPATH/System/Library/Frameworks/JavaVM.framework/Frameworks\""
 317   fi
 318 
 319   # For solaris we really need solaris tools, and not the GNU equivalent.
 320   # The build tools on Solaris reside in /usr/ccs (C Compilation System),
 321   # so add that to path before starting to probe.
 322   # FIXME: This was originally only done for AS,NM,GNM,STRIP,MCS,OBJCOPY,OBJDUMP.
 323   if test "x$OPENJDK_BUILD_OS" = xsolaris; then
 324     PATH="/usr/ccs/bin:$PATH"
 325   fi
 326 
 327   # Finally add TOOLCHAIN_PATH at the beginning, to allow --with-tools-dir to 
 328   # override all other locations.
 329   if test "x$TOOLCHAIN_PATH" != x; then
 330     PATH=$TOOLCHAIN_PATH:$PATH
 331   fi
 332 ])
 333 
 334 # Restore path, etc
 335 AC_DEFUN_ONCE([TOOLCHAIN_POST_DETECTION],
 336 [
 337   # Restore old path, except for the microsoft toolchain, which requires VS_PATH
 338   # to remain in place. Otherwise the compiler will not work in some situations
 339   # in later configure checks.
 340   if test "x$TOOLCHAIN_TYPE" != "xmicrosoft"; then
 341     PATH="$OLD_PATH"
 342   fi
 343 
 344   # Restore the flags to the user specified values.
 345   # This is necessary since AC_PROG_CC defaults CFLAGS to "-g -O2"
 346   CFLAGS="$ORG_CFLAGS"
 347   CXXFLAGS="$ORG_CXXFLAGS"
 348   OBJCFLAGS="$ORG_OBJCFLAGS"
 349 ])
 350 
 351 # Check if a compiler is of the toolchain type we expect, and save the version
 352 # information from it. If the compiler does not match the expected type,
 353 # this function will abort using AC_MSG_ERROR. If it matches, the version will
 354 # be stored in CC_VERSION_NUMBER/CXX_VERSION_NUMBER (as a dotted number), and
 355 # the full version string in CC_VERSION_STRING/CXX_VERSION_STRING.
 356 #
 357 # $1 = compiler to test (CC or CXX)
 358 # $2 = human readable name of compiler (C or C++)
 359 AC_DEFUN([TOOLCHAIN_EXTRACT_COMPILER_VERSION],
 360 [
 361   COMPILER=[$]$1
 362   COMPILER_NAME=$2
 363 
 364   if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 365     # cc -V output typically looks like
 366     #     cc: Sun C 5.12 Linux_i386 2011/11/16
 367     COMPILER_VERSION_OUTPUT=`$COMPILER -V 2>&1`
 368     # Check that this is likely to be the Solaris Studio cc.
 369     $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "^.*: Sun $COMPILER_NAME" > /dev/null
 370     if test $? -ne 0; then
 371       ALT_VERSION_OUTPUT=`$COMPILER --version 2>&1`
 372       AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required $TOOLCHAIN_TYPE compiler.])
 373       AC_MSG_NOTICE([The result from running with -V was: "$COMPILER_VERSION_OUTPUT"])
 374       AC_MSG_NOTICE([The result from running with --version was: "$ALT_VERSION_OUTPUT"])
 375       AC_MSG_ERROR([A $TOOLCHAIN_TYPE compiler is required. Try setting --with-tools-dir.])
 376     fi
 377     # Remove usage instructions (if present), and
 378     # collapse compiler output into a single line
 379     COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT | \
 380         $SED -e 's/ *@<:@Uu@:>@sage:.*//'`
 381     COMPILER_VERSION_NUMBER=`$ECHO $COMPILER_VERSION_OUTPUT | \
 382         $SED -e "s/^.*@<:@ ,\t@:>@$COMPILER_NAME@<:@ ,\t@:>@\(@<:@1-9@:>@\.@<:@0-9@:>@@<:@0-9@:>@*\).*/\1/"`
 383   elif test  "x$TOOLCHAIN_TYPE" = xxlc; then
 384     # xlc -qversion output typically looks like
 385     #     IBM XL C/C++ for AIX, V11.1 (5724-X13)
 386     #     Version: 11.01.0000.0015
 387     COMPILER_VERSION_OUTPUT=`$COMPILER -qversion 2>&1`
 388     # Check that this is likely to be the IBM XL C compiler.
 389     $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "IBM XL C" > /dev/null
 390     if test $? -ne 0; then
 391       ALT_VERSION_OUTPUT=`$COMPILER --version 2>&1`
 392       AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required $TOOLCHAIN_TYPE compiler.])
 393       AC_MSG_NOTICE([The result from running with -qversion was: "$COMPILER_VERSION_OUTPUT"])
 394       AC_MSG_NOTICE([The result from running with --version was: "$ALT_VERSION_OUTPUT"])
 395       AC_MSG_ERROR([A $TOOLCHAIN_TYPE compiler is required. Try setting --with-tools-dir.])
 396     fi
 397     # Collapse compiler output into a single line
 398     COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT`
 399     COMPILER_VERSION_NUMBER=`$ECHO $COMPILER_VERSION_OUTPUT | \
 400         $SED -e 's/^.*, V\(@<:@1-9@:>@@<:@0-9.@:>@*\).*$/\1/'`
 401   elif test  "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 402     # There is no specific version flag, but all output starts with a version string.
 403     # First line typically looks something like:
 404     # Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01 for 80x86
 405     COMPILER_VERSION_OUTPUT=`$COMPILER 2>&1 | $HEAD -n 1 | $TR -d '\r'`
 406     # Check that this is likely to be Microsoft CL.EXE.
 407     $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "Microsoft.*Compiler" > /dev/null
 408     if test $? -ne 0; then
 409       AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required $TOOLCHAIN_TYPE compiler.])
 410       AC_MSG_NOTICE([The result from running it was: "$COMPILER_VERSION_OUTPUT"])
 411       AC_MSG_ERROR([A $TOOLCHAIN_TYPE compiler is required. Try setting --with-tools-dir.])
 412     fi
 413     # Collapse compiler output into a single line
 414     COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT`
 415     COMPILER_VERSION_NUMBER=`$ECHO $COMPILER_VERSION_OUTPUT | \
 416         $SED -e 's/^.*ersion.\(@<:@1-9@:>@@<:@0-9.@:>@*\) .*$/\1/'`
 417   elif test  "x$TOOLCHAIN_TYPE" = xgcc; then
 418     # gcc --version output typically looks like
 419     #     gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
 420     #     Copyright (C) 2013 Free Software Foundation, Inc.
 421     #     This is free software; see the source for copying conditions.  There is NO
 422     #     warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 423     COMPILER_VERSION_OUTPUT=`$COMPILER --version 2>&1`
 424     # Check that this is likely to be GCC.
 425     $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "Free Software Foundation" > /dev/null
 426     if test $? -ne 0; then
 427       AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required $TOOLCHAIN_TYPE compiler.])
 428       AC_MSG_NOTICE([The result from running with --version was: "$COMPILER_VERSION"])
 429       AC_MSG_ERROR([A $TOOLCHAIN_TYPE compiler is required. Try setting --with-tools-dir.])
 430     fi
 431     # Remove Copyright and legalese from version string, and
 432     # collapse into a single line
 433     COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT | \
 434         $SED -e 's/ *Copyright .*//'`
 435     COMPILER_VERSION_NUMBER=`$ECHO $COMPILER_VERSION_OUTPUT | \
 436         $SED -e 's/^.* \(@<:@1-9@:>@\.@<:@0-9.@:>@*\) .*$/\1/'`
 437   elif test  "x$TOOLCHAIN_TYPE" = xclang; then
 438     # clang --version output typically looks like
 439     #    Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
 440     #    clang version 3.3 (tags/RELEASE_33/final)
 441     # or
 442     #    Debian clang version 3.2-7ubuntu1 (tags/RELEASE_32/final) (based on LLVM 3.2)
 443     #    Target: x86_64-pc-linux-gnu
 444     #    Thread model: posix
 445     COMPILER_VERSION_OUTPUT=`$COMPILER --version 2>&1`
 446     # Check that this is likely to be clang
 447     $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "clang" > /dev/null
 448     if test $? -ne 0; then
 449       AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required $TOOLCHAIN_TYPE compiler.])
 450       AC_MSG_NOTICE([The result from running with --version was: "$COMPILER_VERSION_OUTPUT"])
 451       AC_MSG_ERROR([A $TOOLCHAIN_TYPE compiler is required. Try setting --with-tools-dir.])
 452     fi
 453     # Collapse compiler output into a single line
 454     COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT`
 455     COMPILER_VERSION_NUMBER=`$ECHO $COMPILER_VERSION_OUTPUT | \
 456         $SED -e 's/^.*clang version \(@<:@1-9@:>@@<:@0-9.@:>@*\).*$/\1/'`
 457 
 458   else
 459       AC_MSG_ERROR([Unknown toolchain type $TOOLCHAIN_TYPE.])
 460   fi
 461   # This sets CC_VERSION_NUMBER or CXX_VERSION_NUMBER. (This comment is a grep marker)
 462   $1_VERSION_NUMBER="$COMPILER_VERSION_NUMBER"
 463   # This sets CC_VERSION_STRING or CXX_VERSION_STRING. (This comment is a grep marker)
 464   $1_VERSION_STRING="$COMPILER_VERSION_STRING"
 465 
 466   AC_MSG_NOTICE([Using $TOOLCHAIN_TYPE $COMPILER_NAME compiler version $COMPILER_VERSION_NUMBER @<:@$COMPILER_VERSION_STRING@:>@])
 467 ])
 468 
 469 
 470 # Try to locate the given C or C++ compiler in the path, or otherwise.
 471 #
 472 # $1 = compiler to test (CC or CXX)
 473 # $2 = human readable name of compiler (C or C++)
 474 # $3 = list of compiler names to search for
 475 AC_DEFUN([TOOLCHAIN_FIND_COMPILER],
 476 [
 477   COMPILER_NAME=$2
 478   SEARCH_LIST="$3"
 479 
 480   if test "x[$]$1" != x; then
 481     # User has supplied compiler name already, always let that override.
 482     AC_MSG_NOTICE([Will use user supplied compiler $1=[$]$1])
 483     if test "x`basename [$]$1`" = "x[$]$1"; then
 484       # A command without a complete path is provided, search $PATH.
 485       
 486       AC_PATH_PROGS(POTENTIAL_$1, [$]$1)
 487       if test "x$POTENTIAL_$1" != x; then
 488         $1=$POTENTIAL_$1
 489       else
 490         AC_MSG_ERROR([User supplied compiler $1=[$]$1 could not be found])
 491       fi
 492     else
 493       # Otherwise it might already be a complete path
 494       if test ! -x "[$]$1"; then
 495         AC_MSG_ERROR([User supplied compiler $1=[$]$1 does not exist])
 496       fi
 497     fi
 498   else
 499     # No user supplied value. Locate compiler ourselves.
 500 
 501     # If we are cross compiling, assume cross compilation tools follows the
 502     # cross compilation standard where they are prefixed with the autoconf
 503     # standard name for the target. For example the binary
 504     # i686-sun-solaris2.10-gcc will cross compile for i686-sun-solaris2.10.
 505     # If we are not cross compiling, then the default compiler name will be
 506     # used.
 507 
 508     $1=
 509     # If TOOLCHAIN_PATH is set, check for all compiler names in there first
 510     # before checking the rest of the PATH.
 511     # FIXME: Now that we prefix the TOOLS_DIR to the PATH in the PRE_DETECTION
 512     # step, this should not be necessary.
 513     if test -n "$TOOLCHAIN_PATH"; then
 514       PATH_save="$PATH"
 515       PATH="$TOOLCHAIN_PATH"
 516       AC_PATH_PROGS(TOOLCHAIN_PATH_$1, $SEARCH_LIST)
 517       $1=$TOOLCHAIN_PATH_$1
 518       PATH="$PATH_save"
 519     fi
 520 
 521     # AC_PATH_PROGS can't be run multiple times with the same variable,
 522     # so create a new name for this run.
 523     if test "x[$]$1" = x; then
 524       AC_PATH_PROGS(POTENTIAL_$1, $3)
 525       $1=$POTENTIAL_$1
 526     fi
 527 
 528     if test "x[$]$1" = x; then
 529       HELP_MSG_MISSING_DEPENDENCY([devkit])
 530       AC_MSG_ERROR([Could not find a $COMPILER_NAME compiler. $HELP_MSG])
 531     fi
 532   fi
 533 
 534   # Now we have a compiler binary in $1. Make sure it's okay.
 535   BASIC_FIXUP_EXECUTABLE($1)
 536   TEST_COMPILER="[$]$1"
 537   # Don't remove symbolic links on AIX because 'xlc_r' and 'xlC_r' may all be links
 538   # to 'xlc' but it is crucial that we invoke the compiler with the right name!
 539   if test "x$OPENJDK_BUILD_OS" != xaix; then
 540     # FIXME: This test should not be needed anymore; we don't do that for any platform.
 541     AC_MSG_CHECKING([resolved symbolic links for $1])
 542     BASIC_REMOVE_SYMBOLIC_LINKS(TEST_COMPILER)
 543     AC_MSG_RESULT([$TEST_COMPILER])
 544   fi
 545   AC_MSG_CHECKING([if $1 is disguised ccache])
 546 
 547   COMPILER_BASENAME=`$BASENAME "$TEST_COMPILER"`
 548   if test "x$COMPILER_BASENAME" = "xccache"; then
 549     AC_MSG_RESULT([yes, trying to find proper $COMPILER_NAME compiler])
 550     # We /usr/lib/ccache in the path, so cc is a symlink to /usr/bin/ccache.
 551     # We want to control ccache invocation ourselves, so ignore this cc and try
 552     # searching again.
 553 
 554     # Remove the path to the fake ccache cc from the PATH
 555     RETRY_COMPILER_SAVED_PATH="$PATH"
 556     COMPILER_DIRNAME=`$DIRNAME [$]$1`
 557     PATH="`$ECHO $PATH | $SED -e "s,$COMPILER_DIRNAME,,g" -e "s,::,:,g" -e "s,^:,,g"`"
 558 
 559     # Try again looking for our compiler
 560     AC_CHECK_TOOLS(PROPER_COMPILER_$1, $3)
 561     BASIC_FIXUP_EXECUTABLE(PROPER_COMPILER_$1)
 562     PATH="$RETRY_COMPILER_SAVED_PATH"
 563 
 564     AC_MSG_CHECKING([for resolved symbolic links for $1])
 565     BASIC_REMOVE_SYMBOLIC_LINKS(PROPER_COMPILER_$1)
 566     AC_MSG_RESULT([$PROPER_COMPILER_$1])
 567     $1="$PROPER_COMPILER_$1"
 568   else
 569     AC_MSG_RESULT([no, keeping $1])
 570   fi
 571 
 572   TOOLCHAIN_EXTRACT_COMPILER_VERSION([$1], [$COMPILER_NAME])
 573 ])
 574 
 575 # Detect the core components of the toolchain, i.e. the compilers (CC and CXX),
 576 # preprocessor (CPP and CXXCPP), the linker (LD), the assembler (AS) and the
 577 # archiver (AR). Verify that the compilers are correct according to the
 578 # toolchain type.
 579 AC_DEFUN_ONCE([TOOLCHAIN_DETECT_TOOLCHAIN_CORE],
 580 [
 581   #
 582   # Setup the compilers (CC and CXX)
 583   #
 584   TOOLCHAIN_FIND_COMPILER([CC], [C], $TOOLCHAIN_CC_BINARY)
 585   # Now that we have resolved CC ourself, let autoconf have its go at it
 586   AC_PROG_CC([$CC])
 587 
 588   TOOLCHAIN_FIND_COMPILER([CXX], [C++], $TOOLCHAIN_CXX_BINARY)
 589   # Now that we have resolved CXX ourself, let autoconf have its go at it
 590   AC_PROG_CXX([$CXX])
 591 
 592   # This is the compiler version number on the form X.Y[.Z]
 593   AC_SUBST(CC_VERSION_NUMBER)
 594   AC_SUBST(CXX_VERSION_NUMBER)
 595 
 596   TOOLCHAIN_PREPARE_FOR_VERSION_COMPARISONS
 597 
 598   #
 599   # Setup the preprocessor (CPP and CXXCPP)
 600   #
 601   AC_PROG_CPP
 602   BASIC_FIXUP_EXECUTABLE(CPP)
 603   AC_PROG_CXXCPP
 604   BASIC_FIXUP_EXECUTABLE(CXXCPP)
 605 
 606   #
 607   # Setup the linker (LD)
 608   #
 609   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 610     # In the Microsoft toolchain we have a separate LD command "link".
 611     # Make sure we reject /usr/bin/link (as determined in CYGWIN_LINK), which is
 612     # a cygwin program for something completely different.
 613     AC_CHECK_PROG([LD], [link],[link],,, [$CYGWIN_LINK])
 614     BASIC_FIXUP_EXECUTABLE(LD)
 615     # Verify that we indeed succeeded with this trick.
 616     AC_MSG_CHECKING([if the found link.exe is actually the Visual Studio linker])
 617     "$LD" --version > /dev/null
 618     if test $? -eq 0 ; then
 619       AC_MSG_RESULT([no])
 620       AC_MSG_ERROR([This is the Cygwin link tool. Please check your PATH and rerun configure.])
 621     else
 622       AC_MSG_RESULT([yes])
 623     fi
 624     LDCXX="$LD"
 625   else
 626     # All other toolchains use the compiler to link.
 627     LD="$CC"
 628     LDCXX="$CXX"
 629   fi
 630   AC_SUBST(LD)
 631   # FIXME: it should be CXXLD, according to standard (cf CXXCPP)
 632   AC_SUBST(LDCXX)
 633 
 634   #
 635   # Setup the assembler (AS)
 636   #
 637   if test "x$OPENJDK_TARGET_OS" = xsolaris; then
 638     # FIXME: should this really be solaris, or solstudio?
 639     BASIC_PATH_PROGS(AS, as)
 640     BASIC_FIXUP_EXECUTABLE(AS)
 641   else
 642     # FIXME: is this correct for microsoft?
 643     AS="$CC -c"
 644   fi
 645   AC_SUBST(AS)
 646 
 647   #
 648   # Setup the archiver (AR)
 649   #
 650   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 651     # The corresponding ar tool is lib.exe (used to create static libraries)
 652     AC_CHECK_PROG([AR], [lib],[lib],,,)
 653   else
 654     BASIC_CHECK_TOOLS(AR, ar)
 655   fi
 656   BASIC_FIXUP_EXECUTABLE(AR)
 657 ])
 658 
 659 # Setup additional tools that is considered a part of the toolchain, but not the
 660 # core part. Many of these are highly platform-specific and do not exist,
 661 # and/or are not needed on all platforms.
 662 AC_DEFUN_ONCE([TOOLCHAIN_DETECT_TOOLCHAIN_EXTRA],
 663 [
 664   if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
 665     AC_PROG_OBJC
 666     BASIC_FIXUP_EXECUTABLE(OBJC)
 667     BASIC_PATH_PROGS(LIPO, lipo)
 668     BASIC_FIXUP_EXECUTABLE(LIPO)
 669   else
 670     OBJC=
 671   fi
 672 
 673   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 674     AC_CHECK_PROG([MT], [mt], [mt],,, [/usr/bin/mt])
 675     BASIC_FIXUP_EXECUTABLE(MT)
 676     # Setup the resource compiler (RC)
 677     AC_CHECK_PROG([RC], [rc], [rc],,, [/usr/bin/rc])
 678     BASIC_FIXUP_EXECUTABLE(RC)
 679     AC_CHECK_PROG([DUMPBIN], [dumpbin], [dumpbin],,,)
 680     BASIC_FIXUP_EXECUTABLE(DUMPBIN)
 681     # We need to check for 'msbuild.exe' because at the place where we expect to
 682     # find 'msbuild.exe' there's also a directory called 'msbuild' and configure
 683     # won't find the 'msbuild.exe' executable in that case (and the
 684     # 'ac_executable_extensions' is unusable due to performance reasons).
 685     # Notice that we intentionally don't fix up the path to MSBUILD because we
 686     # will call it in a DOS shell during freetype detection on Windows (see
 687     # 'LIB_SETUP_FREETYPE' in "libraries.m4"
 688     AC_CHECK_PROG([MSBUILD], [msbuild.exe], [msbuild.exe],,,)
 689   fi
 690 
 691   if test "x$OPENJDK_TARGET_OS" = xsolaris; then
 692     BASIC_PATH_PROGS(STRIP, strip)
 693     BASIC_FIXUP_EXECUTABLE(STRIP)
 694     BASIC_PATH_PROGS(NM, nm)
 695     BASIC_FIXUP_EXECUTABLE(NM)
 696     BASIC_PATH_PROGS(GNM, gnm)
 697     BASIC_FIXUP_EXECUTABLE(GNM)
 698 
 699     BASIC_PATH_PROGS(MCS, mcs)
 700     BASIC_FIXUP_EXECUTABLE(MCS)
 701   elif test "x$OPENJDK_TARGET_OS" != xwindows; then
 702     # FIXME: we should unify this with the solaris case above.
 703     BASIC_CHECK_TOOLS(STRIP, strip)
 704     BASIC_FIXUP_EXECUTABLE(STRIP)
 705     AC_PATH_PROG(OTOOL, otool)
 706     if test "x$OTOOL" = "x"; then
 707       OTOOL="true"
 708     fi
 709     BASIC_CHECK_TOOLS(NM, nm)
 710     BASIC_FIXUP_EXECUTABLE(NM)
 711     GNM="$NM"
 712     AC_SUBST(GNM)
 713   fi
 714 
 715   # objcopy is used for moving debug symbols to separate files when
 716   # full debug symbols are enabled.
 717   if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux; then
 718     BASIC_CHECK_TOOLS(OBJCOPY, [gobjcopy objcopy])
 719     # Only call fixup if objcopy was found.
 720     if test -n "$OBJCOPY"; then
 721       BASIC_FIXUP_EXECUTABLE(OBJCOPY)
 722     fi
 723   fi
 724 
 725   BASIC_CHECK_TOOLS(OBJDUMP, [gobjdump objdump])
 726   if test "x$OBJDUMP" != x; then
 727     # Only used for compare.sh; we can live without it. BASIC_FIXUP_EXECUTABLE
 728     # bails if argument is missing.
 729     BASIC_FIXUP_EXECUTABLE(OBJDUMP)
 730   fi
 731 ])
 732 
 733 # Setup the build tools (i.e, the compiler and linker used to build programs
 734 # that should be run on the build platform, not the target platform, as a build
 735 # helper). Since the non-cross-compile case uses the normal, target compilers
 736 # for this, we can only do this after these have been setup.
 737 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_BUILD_COMPILERS],
 738 [
 739   if test "x$COMPILE_TYPE" = "xcross"; then
 740     # Now we need to find a C/C++ compiler that can build executables for the
 741     # build platform. We can't use the AC_PROG_CC macro, since it can only be
 742     # used once. Also, we need to do this without adding a tools dir to the
 743     # path, otherwise we might pick up cross-compilers which don't use standard
 744     # naming.
 745 
 746     # FIXME: we should list the discovered compilers as an exclude pattern!
 747     # If we do that, we can do this detection before POST_DETECTION, and still
 748     # find the build compilers in the tools dir, if needed.
 749     BASIC_PATH_PROGS(BUILD_CC, [cl cc gcc])
 750     BASIC_FIXUP_EXECUTABLE(BUILD_CC)
 751     BASIC_PATH_PROGS(BUILD_CXX, [cl CC g++])
 752     BASIC_FIXUP_EXECUTABLE(BUILD_CXX)
 753     BASIC_PATH_PROGS(BUILD_LD, ld)
 754     BASIC_FIXUP_EXECUTABLE(BUILD_LD)
 755   else
 756     # If we are not cross compiling, use the normal target compilers for
 757     # building the build platform executables.
 758     BUILD_CC="$CC"
 759     BUILD_CXX="$CXX"
 760     BUILD_LD="$LD"
 761   fi
 762 ])
 763 
 764 # Setup legacy variables that are still needed as alternative ways to refer to
 765 # parts of the toolchain.
 766 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_LEGACY],
 767 [
 768   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 769     # For hotspot, we need these in Windows mixed path,
 770     # so rewrite them all. Need added .exe suffix.
 771     HOTSPOT_CXX="$CXX.exe"
 772     HOTSPOT_LD="$LD.exe"
 773     HOTSPOT_MT="$MT.exe"
 774     HOTSPOT_RC="$RC.exe"
 775     BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(HOTSPOT_CXX)
 776     BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(HOTSPOT_LD)
 777     BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(HOTSPOT_MT)
 778     BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(HOTSPOT_RC)
 779     AC_SUBST(HOTSPOT_MT)
 780     AC_SUBST(HOTSPOT_RC)
 781   else
 782     HOTSPOT_CXX="$CXX"
 783     HOTSPOT_LD="$LD"
 784   fi
 785   AC_SUBST(HOTSPOT_CXX)
 786   AC_SUBST(HOTSPOT_LD)
 787 
 788   if test  "x$TOOLCHAIN_TYPE" = xclang; then
 789     USE_CLANG=true
 790   fi
 791   AC_SUBST(USE_CLANG)
 792 
 793   # LDEXE is the linker to use, when creating executables. Not really used.
 794   # FIXME: These should just be removed!
 795   LDEXE="$LD"
 796   LDEXECXX="$LDCXX"
 797   AC_SUBST(LDEXE)
 798   AC_SUBST(LDEXECXX)
 799 ])
 800 
 801 # Do some additional checks on the detected tools.
 802 AC_DEFUN_ONCE([TOOLCHAIN_MISC_CHECKS],
 803  [
 804   # The package path is used only on macosx?
 805   # FIXME: clean this up, and/or move it elsewhere.
 806   PACKAGE_PATH=/opt/local
 807   AC_SUBST(PACKAGE_PATH)
 808 
 809   # Check for extra potential brokenness.
 810   if test  "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 811     # On Windows, double-check that we got the right compiler.
 812     CC_VERSION_OUTPUT=`$CC 2>&1 | $HEAD -n 1 | $TR -d '\r'`
 813     COMPILER_CPU_TEST=`$ECHO $CC_VERSION_OUTPUT | $SED -n "s/^.* \(.*\)$/\1/p"`
 814     if test "x$OPENJDK_TARGET_CPU" = "xx86"; then
 815       if test "x$COMPILER_CPU_TEST" != "x80x86" -a "x$COMPILER_CPU_TEST" != "xx86"; then
 816         AC_MSG_ERROR([Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for "$COMPILER_CPU_TEST"; expected "80x86" or "x86".])
 817       fi
 818     elif test "x$OPENJDK_TARGET_CPU" = "xx86_64"; then
 819       if test "x$COMPILER_CPU_TEST" != "xx64"; then
 820         AC_MSG_ERROR([Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for "$COMPILER_CPU_TEST"; expected "x64".])
 821       fi
 822     fi
 823   fi
 824 
 825   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 826     # If this is a --hash-style=gnu system, use --hash-style=both, why?
 827     HAS_GNU_HASH=`$CC -dumpspecs 2>/dev/null | $GREP 'hash-style=gnu'`
 828     # This is later checked when setting flags.
 829   fi
 830 
 831   # Check for broken SuSE 'ld' for which 'Only anonymous version tag is allowed
 832   # in executable.'
 833   USING_BROKEN_SUSE_LD=no
 834   if test "x$OPENJDK_TARGET_OS" = xlinux && test "x$TOOLCHAIN_TYPE" = xgcc; then
 835     AC_MSG_CHECKING([for broken SuSE 'ld' which only understands anonymous version tags in executables])
 836     echo "SUNWprivate_1.1 { local: *; };" > version-script.map
 837     echo "int main() { }" > main.c
 838     if $CXX -Xlinker -version-script=version-script.map main.c 2>&AS_MESSAGE_LOG_FD >&AS_MESSAGE_LOG_FD; then
 839       AC_MSG_RESULT(no)
 840       USING_BROKEN_SUSE_LD=no
 841     else
 842       AC_MSG_RESULT(yes)
 843       USING_BROKEN_SUSE_LD=yes
 844     fi
 845     rm -rf version-script.map main.c
 846   fi
 847   AC_SUBST(USING_BROKEN_SUSE_LD)
 848 ])
 849 
 850 # Setup the JTReg Regression Test Harness.
 851 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_JTREG],
 852 [
 853   AC_ARG_WITH(jtreg, [AS_HELP_STRING([--with-jtreg],
 854       [Regression Test Harness @<:@probed@:>@])],
 855       [],
 856       [with_jtreg=no])
 857 
 858   if test "x$with_jtreg" = xno; then
 859     # jtreg disabled
 860     AC_MSG_CHECKING([for jtreg])
 861     AC_MSG_RESULT(no)
 862   else
 863     if test "x$with_jtreg" != xyes; then
 864       # with path specified.
 865       JT_HOME="$with_jtreg"
 866     fi
 867 
 868     if test "x$JT_HOME" != x; then
 869       AC_MSG_CHECKING([for jtreg])
 870 
 871       # use JT_HOME enviroment var.
 872       BASIC_FIXUP_PATH([JT_HOME])
 873 
 874       # jtreg win32 script works for everybody
 875       JTREGEXE="$JT_HOME/bin/jtreg"
 876 
 877       if test ! -f "$JTREGEXE"; then
 878         AC_MSG_ERROR([JTReg executable does not exist: $JTREGEXE])
 879       fi
 880 
 881       AC_MSG_RESULT($JTREGEXE)
 882     else
 883       # try to find jtreg on path
 884       BASIC_REQUIRE_PROGS(JTREGEXE, jtreg)
 885       JT_HOME="`$DIRNAME $JTREGEXE`"
 886     fi
 887   fi
 888 
 889   AC_SUBST(JT_HOME)
 890   AC_SUBST(JTREGEXE)
 891 ])
 892