common/autoconf/toolchain.m4
changeset 23166 4cdccd29406c
parent 23161 85635b5bf0a6
child 23428 3c8a05bf4656
--- a/common/autoconf/toolchain.m4	Thu Feb 27 10:35:05 2014 -0800
+++ b/common/autoconf/toolchain.m4	Fri Mar 07 10:48:18 2014 -0800
@@ -96,8 +96,27 @@
   # Use indirect variable referencing
   toolchain_var_name=VALID_TOOLCHAINS_$OPENJDK_BUILD_OS
   VALID_TOOLCHAINS=${!toolchain_var_name}
-  # First toolchain type in the list is the default
-  DEFAULT_TOOLCHAIN=${VALID_TOOLCHAINS%% *}
+
+  if test "x$OPENJDK_TARGET_OS" = xmacosx; then
+    # On Mac OS X, default toolchain to clang after Xcode 5
+    XCODE_VERSION_OUTPUT=`xcodebuild -version 2>&1 | $HEAD -n 1`
+    $ECHO "$XCODE_VERSION_OUTPUT" | $GREP "Xcode " > /dev/null
+    if test $? -ne 0; then
+      AC_MSG_ERROR([Failed to determine Xcode version.])
+    fi
+    XCODE_MAJOR_VERSION=`$ECHO $XCODE_VERSION_OUTPUT | \
+        $SED -e 's/^Xcode \(@<:@1-9@:>@@<:@0-9.@:>@*\)/\1/' | \
+        $CUT -f 1 -d .`
+    AC_MSG_NOTICE([Xcode major version: $XCODE_MAJOR_VERSION])
+    if test $XCODE_MAJOR_VERSION -ge 5; then
+        DEFAULT_TOOLCHAIN="clang"
+    else
+        DEFAULT_TOOLCHAIN="gcc"
+    fi
+  else
+    # First toolchain type in the list is the default
+    DEFAULT_TOOLCHAIN=${VALID_TOOLCHAINS%% *}
+  fi
   
   if test "x$with_toolchain_type" = xlist; then
     # List all toolchains