--- a/common/autoconf/basics.m4 Wed Jun 18 10:54:13 2014 -0700
+++ b/common/autoconf/basics.m4 Wed Jun 18 12:52:13 2014 -0700
@@ -512,7 +512,7 @@
)
AC_ARG_WITH(sysroot, [AS_HELP_STRING([--with-sysroot],
- [use this directory as sysroot)])],
+ [use this directory as sysroot])],
[SYSROOT=$with_sysroot]
)
@@ -531,6 +531,75 @@
[BASIC_PREPEND_TO_PATH([EXTRA_PATH],$with_extra_path)]
)
+ if test "x$OPENJDK_BUILD_OS" = "xmacosx"; then
+ # detect if Xcode is installed by running xcodebuild -version
+ # if no Xcode installed, xcodebuild exits with 1
+ # if Xcode is installed, even if xcode-select is misconfigured, then it exits with 0
+ if /usr/bin/xcodebuild -version >/dev/null 2>&1; then
+ # We need to use xcodebuild in the toolchain dir provided by the user, this will
+ # fall back on the stub binary in /usr/bin/xcodebuild
+ AC_PATH_PROG([XCODEBUILD], [xcodebuild], [/usr/bin/xcodebuild], [$TOOLCHAIN_PATH])
+ else
+ # this should result in SYSROOT being empty, unless --with-sysroot is provided
+ # when only the command line tools are installed there are no SDKs, so headers
+ # are copied into the system frameworks
+ XCODEBUILD=
+ AC_SUBST(XCODEBUILD)
+ fi
+
+ AC_MSG_CHECKING([for sdk name])
+ AC_ARG_WITH([sdk-name], [AS_HELP_STRING([--with-sdk-name],
+ [use the platform SDK of the given name. @<:@macosx@:>@])],
+ [SDKNAME=$with_sdk_name]
+ )
+ AC_MSG_RESULT([$SDKNAME])
+
+ # if toolchain path is specified then don't rely on system headers, they may not compile
+ HAVE_SYSTEM_FRAMEWORK_HEADERS=0
+ test -z "$TOOLCHAIN_PATH" && \
+ HAVE_SYSTEM_FRAMEWORK_HEADERS=`test ! -f /System/Library/Frameworks/Foundation.framework/Headers/Foundation.h; echo $?`
+
+ if test -z "$SYSROOT"; then
+ if test -n "$XCODEBUILD"; then
+ # if we don't have system headers, use default SDK name (last resort)
+ if test -z "$SDKNAME" -a $HAVE_SYSTEM_FRAMEWORK_HEADERS -eq 0; then
+ SDKNAME=${SDKNAME:-macosx}
+ fi
+
+ if test -n "$SDKNAME"; then
+ # Call xcodebuild to determine SYSROOT
+ SYSROOT=`"$XCODEBUILD" -sdk $SDKNAME -version | grep '^Path: ' | sed 's/Path: //'`
+ fi
+ else
+ if test $HAVE_SYSTEM_FRAMEWORK_HEADERS -eq 0; then
+ AC_MSG_ERROR([No xcodebuild tool and no system framework headers found, use --with-sysroot or --with-sdk-name to provide a path to a valid SDK])
+ fi
+ fi
+ else
+ # warn user if --with-sdk-name was also set
+ if test -n "$with_sdk_name"; then
+ AC_MSG_WARN([Both SYSROOT and --with-sdk-name are set, only SYSROOT will be used])
+ fi
+ fi
+
+ if test $HAVE_SYSTEM_FRAMEWORK_HEADERS -eq 0 -a -z "$SYSROOT"; then
+ # If no system framework headers, then SYSROOT must be set, or we won't build
+ AC_MSG_ERROR([Unable to determine SYSROOT and no headers found in /System/Library/Frameworks. Check Xcode configuration, --with-sysroot or --with-sdk-name arguments.])
+ fi
+
+ # Perform a basic sanity test
+ if test ! -f "$SYSROOT/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h"; then
+ if test -z "$SYSROOT"; then
+ AC_MSG_ERROR([Unable to find required framework headers, provide a path to an SDK via --with-sysroot or --with-sdk-name and be sure Xcode is installed properly])
+ else
+ AC_MSG_ERROR([Invalid SDK or SYSROOT path, dependent framework headers not found])
+ fi
+ fi
+
+ # set SDKROOT too, Xcode tools will pick it up
+ AC_SUBST(SDKROOT,$SYSROOT)
+ fi
+
# Prepend the extra path to the global path
BASIC_PREPEND_TO_PATH([PATH],$EXTRA_PATH)