common/autoconf/toolchain.m4

changeset 1304
c27cb0ab944f
parent 978
c5a60709f587
child 1328
0785e45b19c8
     1.1 --- a/common/autoconf/toolchain.m4	Mon Dec 29 19:40:17 2014 -0800
     1.2 +++ b/common/autoconf/toolchain.m4	Tue Jan 20 13:29:10 2015 -0800
     1.3 @@ -1,5 +1,5 @@
     1.4  #
     1.5 -# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
     1.6 +# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
     1.7  # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8  #
     1.9  # This code is free software; you can redistribute it and/or modify it
    1.10 @@ -254,6 +254,86 @@
    1.11      PATH=$TOOLS_DIR:$PATH
    1.12    fi
    1.13  
    1.14 +  # Before we locate the compilers, we need to sanitize the Xcode build environment
    1.15 +  if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
    1.16 +    # determine path to Xcode developer directory
    1.17 +    # can be empty in which case all the tools will rely on a sane Xcode 4 installation
    1.18 +    SET_DEVELOPER_DIR=
    1.19 +
    1.20 +    if test -n "$XCODE_PATH"; then
    1.21 +      DEVELOPER_DIR="$XCODE_PATH"/Contents/Developer
    1.22 +    fi
    1.23 +
    1.24 +    # DEVELOPER_DIR could also be provided directly
    1.25 +    AC_MSG_CHECKING([Determining if we need to set DEVELOPER_DIR])
    1.26 +    if test -n "$DEVELOPER_DIR"; then
    1.27 +      if test ! -d "$DEVELOPER_DIR"; then
    1.28 +        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])
    1.29 +      fi
    1.30 +      if test ! -f "$DEVELOPER_DIR"/usr/bin/xcodebuild; then
    1.31 +        AC_MSG_ERROR([Xcode Developer path is not valid: $DEVELOPER_DIR, it must point to Contents/Developer inside an Xcode application bundle])
    1.32 +      fi
    1.33 +      # make it visible to all the tools immediately
    1.34 +      export DEVELOPER_DIR
    1.35 +      SET_DEVELOPER_DIR="export DEVELOPER_DIR := $DEVELOPER_DIR"
    1.36 +      AC_MSG_RESULT([yes ($DEVELOPER_DIR)])
    1.37 +    else
    1.38 +      AC_MSG_RESULT([no])
    1.39 +    fi
    1.40 +    AC_SUBST(SET_DEVELOPER_DIR)
    1.41 +
    1.42 +    AC_PATH_PROG(XCODEBUILD, xcodebuild)
    1.43 +    if test -z "$XCODEBUILD"; then
    1.44 +      AC_MSG_ERROR([The xcodebuild tool was not found, the Xcode command line tools are required to build on Mac OS X])
    1.45 +    fi
    1.46 +
    1.47 +    # Fail-fast: verify we're building on Xcode 4, we cannot build with Xcode 5 or later
    1.48 +    XCODE_VERSION=`$XCODEBUILD -version | grep '^Xcode ' | sed 's/Xcode //'`
    1.49 +    XC_VERSION_PARTS=( ${XCODE_VERSION//./ } )
    1.50 +    if test ! "${XC_VERSION_PARTS[[0]]}" = "4"; then
    1.51 +      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.])
    1.52 +    fi
    1.53 +
    1.54 +    # Some versions of Xcode 5 command line tools install gcc and g++ as symlinks to
    1.55 +    # clang and clang++, which will break the build. So handle that here if we need to.
    1.56 +    if test -L "/usr/bin/gcc" -o -L "/usr/bin/g++"; then
    1.57 +      # use xcrun to find the real gcc and add it's directory to PATH
    1.58 +      # then autoconf magic will find it
    1.59 +      AC_MSG_NOTICE([Found gcc symlinks to clang in /usr/bin, adding path to real gcc to PATH])
    1.60 +      XCODE_BIN_PATH=$(dirname `xcrun -find gcc`)
    1.61 +      PATH="$XCODE_BIN_PATH":$PATH
    1.62 +    fi
    1.63 +
    1.64 +    # Determine appropriate SDKPATH, don't use SDKROOT as it interferes with the stub tools
    1.65 +    AC_MSG_CHECKING([Determining Xcode SDK path])
    1.66 +    # allow SDKNAME to be set to override the default SDK selection
    1.67 +    SDKPATH=`"$XCODEBUILD" -sdk ${SDKNAME:-macosx} -version | grep '^Path: ' | sed 's/Path: //'`
    1.68 +    if test -n "$SDKPATH"; then
    1.69 +      AC_MSG_RESULT([$SDKPATH])
    1.70 +    else
    1.71 +      AC_MSG_RESULT([(none, will use system headers and frameworks)])
    1.72 +    fi
    1.73 +    AC_SUBST(SDKPATH)
    1.74 +
    1.75 +    # Perform a basic sanity test
    1.76 +    if test ! -f "$SDKPATH/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h"; then
    1.77 +      AC_MSG_ERROR([Unable to find required framework headers, provide a valid path to Xcode 4 using --with-xcode-path])
    1.78 +    fi
    1.79 +
    1.80 +    # if SDKPATH is non-empty then we need to add -isysroot and -iframework for gcc and g++
    1.81 +    if test -n "$SDKPATH"; then
    1.82 +      # We need -isysroot <path> and -iframework<path>/System/Library/Frameworks
    1.83 +      CFLAGS_JDK="${CFLAGS_JDK} -isysroot \"$SDKPATH\" -iframework\"$SDKPATH/System/Library/Frameworks\""
    1.84 +      CXXFLAGS_JDK="${CXXFLAGS_JDK} -isysroot \"$SDKPATH\" -iframework\"$SDKPATH/System/Library/Frameworks\""
    1.85 +      LDFLAGS_JDK="${LDFLAGS_JDK} -isysroot \"$SDKPATH\" -iframework\"$SDKPATH/System/Library/Frameworks\""
    1.86 +    fi
    1.87 +    
    1.88 +    # These always need to be set, or we can't find the frameworks embedded in JavaVM.framework
    1.89 +    # setting this here means it doesn't have to be peppered throughout the forest
    1.90 +    CFLAGS_JDK="$CFLAGS_JDK -F\"$SDKPATH/System/Library/Frameworks/JavaVM.framework/Frameworks\""
    1.91 +    CXXFLAGS_JDK="$CXXFLAGS_JDK -F\"$SDKPATH/System/Library/Frameworks/JavaVM.framework/Frameworks\""
    1.92 +    LDFLAGS_JDK="$LDFLAGS_JDK -F\"$SDKPATH/System/Library/Frameworks/JavaVM.framework/Frameworks\""
    1.93 +  fi
    1.94  
    1.95    ### Locate C compiler (CC)
    1.96  
    1.97 @@ -477,6 +557,10 @@
    1.98      AC_PATH_PROG(MCS, mcs)
    1.99      BASIC_FIXUP_EXECUTABLE(MCS)
   1.100    elif test "x$OPENJDK_TARGET_OS" != xwindows; then
   1.101 +    AC_PATH_PROG(OTOOL, otool)
   1.102 +    if test "x$OTOOL" = "x"; then
   1.103 +      OTOOL="true"
   1.104 +    fi
   1.105      AC_CHECK_TOOL(NM, nm)
   1.106      BASIC_FIXUP_EXECUTABLE(NM)
   1.107      GNM="$NM"
   1.108 @@ -501,11 +585,6 @@
   1.109      BASIC_FIXUP_EXECUTABLE(OBJDUMP)
   1.110    fi
   1.111  
   1.112 -  if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
   1.113 -    AC_PATH_PROG(LIPO, lipo)
   1.114 -    BASIC_FIXUP_EXECUTABLE(LIPO)
   1.115 -  fi
   1.116 -
   1.117    TOOLCHAIN_SETUP_JTREG
   1.118  
   1.119    # Restore old path without tools dir

mercurial