< prev index next >

common/autoconf/toolchain.m4

Print this page


   1 #
   2 # Copyright (c) 2011, 2015, 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 # Setup a number of variables describing how native output files are
  54 # named on this platform/toolchain.
  55 AC_DEFUN([TOOLCHAIN_SETUP_FILENAME_PATTERNS],
  56 [
  57   # Define filename patterns
  58   if test "x$OPENJDK_TARGET_OS" = xwindows; then
  59     LIBRARY_PREFIX=
  60     SHARED_LIBRARY_SUFFIX='.dll'
  61     STATIC_LIBRARY_SUFFIX='.lib'
  62     SHARED_LIBRARY='[$]1.dll'


  90 
  91   AC_SUBST(LIBRARY_PREFIX)
  92   AC_SUBST(SHARED_LIBRARY_SUFFIX)
  93   AC_SUBST(STATIC_LIBRARY_SUFFIX)
  94   AC_SUBST(SHARED_LIBRARY)
  95   AC_SUBST(STATIC_LIBRARY)
  96   AC_SUBST(OBJ_SUFFIX)
  97   AC_SUBST(EXE_SUFFIX)
  98 ])
  99 
 100 # Determine which toolchain type to use, and make sure it is valid for this
 101 # platform. Setup various information about the selected toolchain.
 102 AC_DEFUN_ONCE([TOOLCHAIN_DETERMINE_TOOLCHAIN_TYPE],
 103 [
 104   AC_ARG_WITH(toolchain-type, [AS_HELP_STRING([--with-toolchain-type],
 105       [the toolchain type (or family) to use, use '--help' to show possible values @<:@platform dependent@:>@])])
 106 
 107   # Use indirect variable referencing
 108   toolchain_var_name=VALID_TOOLCHAINS_$OPENJDK_BUILD_OS
 109   VALID_TOOLCHAINS=${!toolchain_var_name}




 110 
 111   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 112     if test -n "$XCODEBUILD"; then
 113       # On Mac OS X, default toolchain to clang after Xcode 5
 114       XCODE_VERSION_OUTPUT=`"$XCODEBUILD" -version 2>&1 | $HEAD -n 1`
 115       $ECHO "$XCODE_VERSION_OUTPUT" | $GREP "Xcode " > /dev/null
 116       if test $? -ne 0; then
 117         AC_MSG_ERROR([Failed to determine Xcode version.])
 118       fi
 119       XCODE_MAJOR_VERSION=`$ECHO $XCODE_VERSION_OUTPUT | \
 120           $SED -e 's/^Xcode \(@<:@1-9@:>@@<:@0-9.@:>@*\)/\1/' | \
 121           $CUT -f 1 -d .`
 122       AC_MSG_NOTICE([Xcode major version: $XCODE_MAJOR_VERSION])
 123       if test $XCODE_MAJOR_VERSION -ge 5; then
 124           DEFAULT_TOOLCHAIN="clang"
 125       else
 126           DEFAULT_TOOLCHAIN="gcc"
 127       fi
 128     else
 129       # If Xcode is not installed, but the command line tools are


 585     BASIC_PATH_PROGS(NM, nm)
 586     BASIC_FIXUP_EXECUTABLE(NM)
 587     BASIC_PATH_PROGS(GNM, gnm)
 588     BASIC_FIXUP_EXECUTABLE(GNM)
 589   elif test "x$OPENJDK_TARGET_OS" != xwindows; then
 590     # FIXME: we should unify this with the solaris case above.
 591     BASIC_CHECK_TOOLS(STRIP, strip)
 592     BASIC_FIXUP_EXECUTABLE(STRIP)
 593     if test "x$TOOLCHAIN_TYPE" = xgcc; then
 594       BASIC_CHECK_TOOLS(NM, nm gcc-nm)
 595     else
 596       BASIC_CHECK_TOOLS(NM, nm)
 597     fi
 598     BASIC_FIXUP_EXECUTABLE(NM)
 599     GNM="$NM"
 600     AC_SUBST(GNM)
 601   fi
 602 
 603   # objcopy is used for moving debug symbols to separate files when
 604   # full debug symbols are enabled.
 605   if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux; then
 606     BASIC_CHECK_TOOLS(OBJCOPY, [gobjcopy objcopy])
 607     # Only call fixup if objcopy was found.
 608     if test -n "$OBJCOPY"; then
 609       BASIC_FIXUP_EXECUTABLE(OBJCOPY)
 610       if test "x$OPENJDK_BUILD_OS" = xsolaris; then
 611         # objcopy prior to 2.21.1 on solaris is broken and is not usable.
 612         # Rewrite objcopy version output to VALID_VERSION or BAD_VERSION.
 613         # - version number is last blank separate word on first line
 614         # - version number formats that have been seen:
 615         #   - <major>.<minor>
 616         #   - <major>.<minor>.<micro>
 617         OBJCOPY_VERSION=`$OBJCOPY --version | $HEAD -n 1`
 618         # The outer [ ] is to prevent m4 from eating the [] in the sed expression.
 619         [ OBJCOPY_VERSION_CHECK=`$ECHO $OBJCOPY_VERSION | $SED -n \
 620               -e 's/.* //' \
 621               -e '/^[01]\./b bad' \
 622               -e '/^2\./{' \
 623               -e '  s/^2\.//' \
 624               -e '  /^[0-9]$/b bad' \
 625               -e '  /^[0-9]\./b bad' \


   1 #
   2 # Copyright (c) 2011, 2016, 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_bsd="clang gcc"
  44 VALID_TOOLCHAINS_aix="xlc"
  45 VALID_TOOLCHAINS_windows="microsoft"
  46 
  47 # Toolchain descriptions
  48 TOOLCHAIN_DESCRIPTION_clang="clang/LLVM"
  49 TOOLCHAIN_DESCRIPTION_gcc="GNU Compiler Collection"
  50 TOOLCHAIN_DESCRIPTION_microsoft="Microsoft Visual Studio"
  51 TOOLCHAIN_DESCRIPTION_solstudio="Oracle Solaris Studio"
  52 TOOLCHAIN_DESCRIPTION_xlc="IBM XL C/C++"
  53 
  54 # Setup a number of variables describing how native output files are
  55 # named on this platform/toolchain.
  56 AC_DEFUN([TOOLCHAIN_SETUP_FILENAME_PATTERNS],
  57 [
  58   # Define filename patterns
  59   if test "x$OPENJDK_TARGET_OS" = xwindows; then
  60     LIBRARY_PREFIX=
  61     SHARED_LIBRARY_SUFFIX='.dll'
  62     STATIC_LIBRARY_SUFFIX='.lib'
  63     SHARED_LIBRARY='[$]1.dll'


  91 
  92   AC_SUBST(LIBRARY_PREFIX)
  93   AC_SUBST(SHARED_LIBRARY_SUFFIX)
  94   AC_SUBST(STATIC_LIBRARY_SUFFIX)
  95   AC_SUBST(SHARED_LIBRARY)
  96   AC_SUBST(STATIC_LIBRARY)
  97   AC_SUBST(OBJ_SUFFIX)
  98   AC_SUBST(EXE_SUFFIX)
  99 ])
 100 
 101 # Determine which toolchain type to use, and make sure it is valid for this
 102 # platform. Setup various information about the selected toolchain.
 103 AC_DEFUN_ONCE([TOOLCHAIN_DETERMINE_TOOLCHAIN_TYPE],
 104 [
 105   AC_ARG_WITH(toolchain-type, [AS_HELP_STRING([--with-toolchain-type],
 106       [the toolchain type (or family) to use, use '--help' to show possible values @<:@platform dependent@:>@])])
 107 
 108   # Use indirect variable referencing
 109   toolchain_var_name=VALID_TOOLCHAINS_$OPENJDK_BUILD_OS
 110   VALID_TOOLCHAINS=${!toolchain_var_name}
 111   if test "x$VALID_TOOLCHAINS" = x; then
 112     # For portability, assume gcc and clang for unknown platforms
 113     VALID_TOOLCHAINS="gcc clang"
 114   fi
 115 
 116   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 117     if test -n "$XCODEBUILD"; then
 118       # On Mac OS X, default toolchain to clang after Xcode 5
 119       XCODE_VERSION_OUTPUT=`"$XCODEBUILD" -version 2>&1 | $HEAD -n 1`
 120       $ECHO "$XCODE_VERSION_OUTPUT" | $GREP "Xcode " > /dev/null
 121       if test $? -ne 0; then
 122         AC_MSG_ERROR([Failed to determine Xcode version.])
 123       fi
 124       XCODE_MAJOR_VERSION=`$ECHO $XCODE_VERSION_OUTPUT | \
 125           $SED -e 's/^Xcode \(@<:@1-9@:>@@<:@0-9.@:>@*\)/\1/' | \
 126           $CUT -f 1 -d .`
 127       AC_MSG_NOTICE([Xcode major version: $XCODE_MAJOR_VERSION])
 128       if test $XCODE_MAJOR_VERSION -ge 5; then
 129           DEFAULT_TOOLCHAIN="clang"
 130       else
 131           DEFAULT_TOOLCHAIN="gcc"
 132       fi
 133     else
 134       # If Xcode is not installed, but the command line tools are


 590     BASIC_PATH_PROGS(NM, nm)
 591     BASIC_FIXUP_EXECUTABLE(NM)
 592     BASIC_PATH_PROGS(GNM, gnm)
 593     BASIC_FIXUP_EXECUTABLE(GNM)
 594   elif test "x$OPENJDK_TARGET_OS" != xwindows; then
 595     # FIXME: we should unify this with the solaris case above.
 596     BASIC_CHECK_TOOLS(STRIP, strip)
 597     BASIC_FIXUP_EXECUTABLE(STRIP)
 598     if test "x$TOOLCHAIN_TYPE" = xgcc; then
 599       BASIC_CHECK_TOOLS(NM, nm gcc-nm)
 600     else
 601       BASIC_CHECK_TOOLS(NM, nm)
 602     fi
 603     BASIC_FIXUP_EXECUTABLE(NM)
 604     GNM="$NM"
 605     AC_SUBST(GNM)
 606   fi
 607 
 608   # objcopy is used for moving debug symbols to separate files when
 609   # full debug symbols are enabled.
 610   if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux || test "x$OPENJDK_TARGET_OS" = xbsd; then
 611     BASIC_CHECK_TOOLS(OBJCOPY, [gobjcopy objcopy])
 612     # Only call fixup if objcopy was found.
 613     if test -n "$OBJCOPY"; then
 614       BASIC_FIXUP_EXECUTABLE(OBJCOPY)
 615       if test "x$OPENJDK_BUILD_OS" = xsolaris; then
 616         # objcopy prior to 2.21.1 on solaris is broken and is not usable.
 617         # Rewrite objcopy version output to VALID_VERSION or BAD_VERSION.
 618         # - version number is last blank separate word on first line
 619         # - version number formats that have been seen:
 620         #   - <major>.<minor>
 621         #   - <major>.<minor>.<micro>
 622         OBJCOPY_VERSION=`$OBJCOPY --version | $HEAD -n 1`
 623         # The outer [ ] is to prevent m4 from eating the [] in the sed expression.
 624         [ OBJCOPY_VERSION_CHECK=`$ECHO $OBJCOPY_VERSION | $SED -n \
 625               -e 's/.* //' \
 626               -e '/^[01]\./b bad' \
 627               -e '/^2\./{' \
 628               -e '  s/^2\.//' \
 629               -e '  /^[0-9]$/b bad' \
 630               -e '  /^[0-9]\./b bad' \


< prev index next >