common/autoconf/toolchain.m4
author simonis
Tue, 19 May 2015 11:06:34 +0200
changeset 30758 97072ce7c6fe
parent 30096 5624d3a52647
child 32462 f236112ab3d0
permissions -rw-r--r--
8080190: PPC64: Fix wrong rotate instructions in the .ad file Reviewed-by: kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
     1
#
29173
ad065cf432e9 8074099: Even with toolchain type clang, OBJC is set to gcc
ihse
parents: 28901
diff changeset
     2
# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
     3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
     4
#
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
     5
# This code is free software; you can redistribute it and/or modify it
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
     6
# under the terms of the GNU General Public License version 2 only, as
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
     7
# published by the Free Software Foundation.  Oracle designates this
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
     8
# particular file as subject to the "Classpath" exception as provided
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
     9
# by Oracle in the LICENSE file that accompanied this code.
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    10
#
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    11
# This code is distributed in the hope that it will be useful, but WITHOUT
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    13
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    14
# version 2 for more details (a copy is included in the LICENSE file that
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    15
# accompanied this code).
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    16
#
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    17
# You should have received a copy of the GNU General Public License version
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    18
# 2 along with this work; if not, write to the Free Software Foundation,
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    19
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    20
#
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    22
# or visit www.oracle.com if you need additional information or have any
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    23
# questions.
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    24
#
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    25
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    26
########################################################################
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
    27
# This file is responsible for detecting, verifying and setting up the
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
    28
# toolchain, i.e. the compiler, linker and related utilities. It will setup
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    29
# proper paths to the binaries, but it will not setup any flags.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    30
#
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
    31
# The binaries used is determined by the toolchain type, which is the family of
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    32
# compilers and related tools that are used.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    33
########################################################################
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    34
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    35
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    36
# All valid toolchains, regardless of platform (used by help.m4)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    37
VALID_TOOLCHAINS_all="gcc clang solstudio xlc microsoft"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    38
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    39
# These toolchains are valid on different platforms
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    40
VALID_TOOLCHAINS_linux="gcc clang"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    41
VALID_TOOLCHAINS_solaris="solstudio"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    42
VALID_TOOLCHAINS_macosx="gcc clang"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    43
VALID_TOOLCHAINS_aix="xlc"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    44
VALID_TOOLCHAINS_windows="microsoft"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    45
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    46
# Toolchain descriptions
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    47
TOOLCHAIN_DESCRIPTION_clang="clang/LLVM"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    48
TOOLCHAIN_DESCRIPTION_gcc="GNU Compiler Collection"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    49
TOOLCHAIN_DESCRIPTION_microsoft="Microsoft Visual Studio"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    50
TOOLCHAIN_DESCRIPTION_solstudio="Oracle Solaris Studio"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    51
TOOLCHAIN_DESCRIPTION_xlc="IBM XL C/C++"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    52
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    53
# Setup a number of variables describing how native output files are
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    54
# named on this platform/toolchain.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    55
AC_DEFUN([TOOLCHAIN_SETUP_FILENAME_PATTERNS],
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    56
[
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    57
  # Define filename patterns
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    58
  if test "x$OPENJDK_TARGET_OS" = xwindows; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    59
    LIBRARY_PREFIX=
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    60
    SHARED_LIBRARY_SUFFIX='.dll'
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    61
    STATIC_LIBRARY_SUFFIX='.lib'
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    62
    SHARED_LIBRARY='[$]1.dll'
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    63
    STATIC_LIBRARY='[$]1.lib'
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    64
    OBJ_SUFFIX='.obj'
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    65
    EXE_SUFFIX='.exe'
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    66
  else
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    67
    LIBRARY_PREFIX=lib
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    68
    SHARED_LIBRARY_SUFFIX='.so'
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    69
    STATIC_LIBRARY_SUFFIX='.a'
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    70
    SHARED_LIBRARY='lib[$]1.so'
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    71
    STATIC_LIBRARY='lib[$]1.a'
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    72
    OBJ_SUFFIX='.o'
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    73
    EXE_SUFFIX=''
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    74
    if test "x$OPENJDK_TARGET_OS" = xmacosx; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    75
      SHARED_LIBRARY='lib[$]1.dylib'
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    76
      SHARED_LIBRARY_SUFFIX='.dylib'
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    77
    fi
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    78
  fi
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    79
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    80
  AC_SUBST(LIBRARY_PREFIX)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    81
  AC_SUBST(SHARED_LIBRARY_SUFFIX)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    82
  AC_SUBST(STATIC_LIBRARY_SUFFIX)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    83
  AC_SUBST(SHARED_LIBRARY)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    84
  AC_SUBST(STATIC_LIBRARY)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    85
  AC_SUBST(OBJ_SUFFIX)
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
    86
  AC_SUBST(EXE_SUFFIX)
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    87
])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    88
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    89
# Determine which toolchain type to use, and make sure it is valid for this
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    90
# platform. Setup various information about the selected toolchain.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    91
AC_DEFUN_ONCE([TOOLCHAIN_DETERMINE_TOOLCHAIN_TYPE],
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    92
[
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    93
  AC_ARG_WITH(toolchain-type, [AS_HELP_STRING([--with-toolchain-type],
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    94
      [the toolchain type (or family) to use, use '--help' to show possible values @<:@platform dependent@:>@])])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    95
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    96
  # Use indirect variable referencing
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    97
  toolchain_var_name=VALID_TOOLCHAINS_$OPENJDK_BUILD_OS
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
    98
  VALID_TOOLCHAINS=${!toolchain_var_name}
23161
85635b5bf0a6 8019470: Changes needed to compile JDK 8 on MacOS with clang compiler
henryjen
parents: 22724
diff changeset
    99
85635b5bf0a6 8019470: Changes needed to compile JDK 8 on MacOS with clang compiler
henryjen
parents: 22724
diff changeset
   100
  if test "x$OPENJDK_TARGET_OS" = xmacosx; then
25034
d9ca34c227b8 8043340: [macosx] Fix hard-wired paths to JavaVM.framework
ddehaven
parents: 24911
diff changeset
   101
    if test -n "$XCODEBUILD"; then
d9ca34c227b8 8043340: [macosx] Fix hard-wired paths to JavaVM.framework
ddehaven
parents: 24911
diff changeset
   102
      # On Mac OS X, default toolchain to clang after Xcode 5
d9ca34c227b8 8043340: [macosx] Fix hard-wired paths to JavaVM.framework
ddehaven
parents: 24911
diff changeset
   103
      XCODE_VERSION_OUTPUT=`"$XCODEBUILD" -version 2>&1 | $HEAD -n 1`
d9ca34c227b8 8043340: [macosx] Fix hard-wired paths to JavaVM.framework
ddehaven
parents: 24911
diff changeset
   104
      $ECHO "$XCODE_VERSION_OUTPUT" | $GREP "Xcode " > /dev/null
d9ca34c227b8 8043340: [macosx] Fix hard-wired paths to JavaVM.framework
ddehaven
parents: 24911
diff changeset
   105
      if test $? -ne 0; then
d9ca34c227b8 8043340: [macosx] Fix hard-wired paths to JavaVM.framework
ddehaven
parents: 24911
diff changeset
   106
        AC_MSG_ERROR([Failed to determine Xcode version.])
d9ca34c227b8 8043340: [macosx] Fix hard-wired paths to JavaVM.framework
ddehaven
parents: 24911
diff changeset
   107
      fi
d9ca34c227b8 8043340: [macosx] Fix hard-wired paths to JavaVM.framework
ddehaven
parents: 24911
diff changeset
   108
      XCODE_MAJOR_VERSION=`$ECHO $XCODE_VERSION_OUTPUT | \
d9ca34c227b8 8043340: [macosx] Fix hard-wired paths to JavaVM.framework
ddehaven
parents: 24911
diff changeset
   109
          $SED -e 's/^Xcode \(@<:@1-9@:>@@<:@0-9.@:>@*\)/\1/' | \
d9ca34c227b8 8043340: [macosx] Fix hard-wired paths to JavaVM.framework
ddehaven
parents: 24911
diff changeset
   110
          $CUT -f 1 -d .`
d9ca34c227b8 8043340: [macosx] Fix hard-wired paths to JavaVM.framework
ddehaven
parents: 24911
diff changeset
   111
      AC_MSG_NOTICE([Xcode major version: $XCODE_MAJOR_VERSION])
d9ca34c227b8 8043340: [macosx] Fix hard-wired paths to JavaVM.framework
ddehaven
parents: 24911
diff changeset
   112
      if test $XCODE_MAJOR_VERSION -ge 5; then
d9ca34c227b8 8043340: [macosx] Fix hard-wired paths to JavaVM.framework
ddehaven
parents: 24911
diff changeset
   113
          DEFAULT_TOOLCHAIN="clang"
d9ca34c227b8 8043340: [macosx] Fix hard-wired paths to JavaVM.framework
ddehaven
parents: 24911
diff changeset
   114
      else
d9ca34c227b8 8043340: [macosx] Fix hard-wired paths to JavaVM.framework
ddehaven
parents: 24911
diff changeset
   115
          DEFAULT_TOOLCHAIN="gcc"
d9ca34c227b8 8043340: [macosx] Fix hard-wired paths to JavaVM.framework
ddehaven
parents: 24911
diff changeset
   116
      fi
23161
85635b5bf0a6 8019470: Changes needed to compile JDK 8 on MacOS with clang compiler
henryjen
parents: 22724
diff changeset
   117
    else
25034
d9ca34c227b8 8043340: [macosx] Fix hard-wired paths to JavaVM.framework
ddehaven
parents: 24911
diff changeset
   118
      # If Xcode is not installed, but the command line tools are
d9ca34c227b8 8043340: [macosx] Fix hard-wired paths to JavaVM.framework
ddehaven
parents: 24911
diff changeset
   119
      # then we can't run xcodebuild. On these systems we should
d9ca34c227b8 8043340: [macosx] Fix hard-wired paths to JavaVM.framework
ddehaven
parents: 24911
diff changeset
   120
      # default to clang
d9ca34c227b8 8043340: [macosx] Fix hard-wired paths to JavaVM.framework
ddehaven
parents: 24911
diff changeset
   121
      DEFAULT_TOOLCHAIN="clang"
23161
85635b5bf0a6 8019470: Changes needed to compile JDK 8 on MacOS with clang compiler
henryjen
parents: 22724
diff changeset
   122
    fi
85635b5bf0a6 8019470: Changes needed to compile JDK 8 on MacOS with clang compiler
henryjen
parents: 22724
diff changeset
   123
  else
85635b5bf0a6 8019470: Changes needed to compile JDK 8 on MacOS with clang compiler
henryjen
parents: 22724
diff changeset
   124
    # First toolchain type in the list is the default
85635b5bf0a6 8019470: Changes needed to compile JDK 8 on MacOS with clang compiler
henryjen
parents: 22724
diff changeset
   125
    DEFAULT_TOOLCHAIN=${VALID_TOOLCHAINS%% *}
85635b5bf0a6 8019470: Changes needed to compile JDK 8 on MacOS with clang compiler
henryjen
parents: 22724
diff changeset
   126
  fi
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   127
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   128
  if test "x$with_toolchain_type" = xlist; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   129
    # List all toolchains
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   130
    AC_MSG_NOTICE([The following toolchains are valid on this platform:])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   131
    for toolchain in $VALID_TOOLCHAINS; do
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   132
      toolchain_var_name=TOOLCHAIN_DESCRIPTION_$toolchain
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   133
      TOOLCHAIN_DESCRIPTION=${!toolchain_var_name}
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   134
      $PRINTF "  %-10s  %s\n" $toolchain "$TOOLCHAIN_DESCRIPTION"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   135
    done
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   136
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   137
    exit 0
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   138
  elif test "x$with_toolchain_type" != x; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   139
    # User override; check that it is valid
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   140
    if test "x${VALID_TOOLCHAINS/$with_toolchain_type/}" = "x${VALID_TOOLCHAINS}"; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   141
      AC_MSG_NOTICE([Toolchain type $with_toolchain_type is not valid on this platform.])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   142
      AC_MSG_NOTICE([Valid toolchains: $VALID_TOOLCHAINS.])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   143
      AC_MSG_ERROR([Cannot continue.])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   144
    fi
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   145
    TOOLCHAIN_TYPE=$with_toolchain_type
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   146
  else
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   147
    # No flag given, use default
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   148
    TOOLCHAIN_TYPE=$DEFAULT_TOOLCHAIN
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   149
  fi
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   150
  AC_SUBST(TOOLCHAIN_TYPE)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   151
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   152
  TOOLCHAIN_CC_BINARY_clang="clang"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   153
  TOOLCHAIN_CC_BINARY_gcc="gcc"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   154
  TOOLCHAIN_CC_BINARY_microsoft="cl"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   155
  TOOLCHAIN_CC_BINARY_solstudio="cc"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   156
  TOOLCHAIN_CC_BINARY_xlc="xlc_r"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   157
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   158
  TOOLCHAIN_CXX_BINARY_clang="clang++"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   159
  TOOLCHAIN_CXX_BINARY_gcc="g++"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   160
  TOOLCHAIN_CXX_BINARY_microsoft="cl"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   161
  TOOLCHAIN_CXX_BINARY_solstudio="CC"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   162
  TOOLCHAIN_CXX_BINARY_xlc="xlC_r"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   163
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   164
  # Use indirect variable referencing
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   165
  toolchain_var_name=TOOLCHAIN_DESCRIPTION_$TOOLCHAIN_TYPE
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   166
  TOOLCHAIN_DESCRIPTION=${!toolchain_var_name}
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   167
  toolchain_var_name=TOOLCHAIN_CC_BINARY_$TOOLCHAIN_TYPE
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   168
  TOOLCHAIN_CC_BINARY=${!toolchain_var_name}
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   169
  toolchain_var_name=TOOLCHAIN_CXX_BINARY_$TOOLCHAIN_TYPE
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   170
  TOOLCHAIN_CXX_BINARY=${!toolchain_var_name}
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   171
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   172
  TOOLCHAIN_SETUP_FILENAME_PATTERNS
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   173
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   174
  if test "x$TOOLCHAIN_TYPE" = "x$DEFAULT_TOOLCHAIN"; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   175
    AC_MSG_NOTICE([Using default toolchain $TOOLCHAIN_TYPE ($TOOLCHAIN_DESCRIPTION)])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   176
  else
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   177
    AC_MSG_NOTICE([Using user selected toolchain $TOOLCHAIN_TYPE ($TOOLCHAIN_DESCRIPTION). Default toolchain is $DEFAULT_TOOLCHAIN.])
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   178
  fi
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   179
])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   180
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   181
# Before we start detecting the toolchain executables, we might need some
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   182
# special setup, e.g. additional paths etc.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   183
AC_DEFUN_ONCE([TOOLCHAIN_PRE_DETECTION],
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   184
[
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   185
  # FIXME: Is this needed?
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   186
  AC_LANG(C++)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   187
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   188
  # Store the CFLAGS etc passed to the configure script.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   189
  ORG_CFLAGS="$CFLAGS"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   190
  ORG_CXXFLAGS="$CXXFLAGS"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   191
30022
362d77fbf008 8078437: Enable use of devkits for Windows
erikj
parents: 29866
diff changeset
   192
  # autoconf magic only relies on PATH, so update it if tools dir is specified
362d77fbf008 8078437: Enable use of devkits for Windows
erikj
parents: 29866
diff changeset
   193
  OLD_PATH="$PATH"
362d77fbf008 8078437: Enable use of devkits for Windows
erikj
parents: 29866
diff changeset
   194
22724
072f729936a9 8035725: Must keep microsoft VS_PATH on PATH after toolchain detection
ihse
parents: 22721
diff changeset
   195
  # On Windows, we need to detect the visual studio installation first.
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   196
  # This will change the PATH, but we need to keep that new PATH even
22724
072f729936a9 8035725: Must keep microsoft VS_PATH on PATH after toolchain detection
ihse
parents: 22721
diff changeset
   197
  # after toolchain detection is done, since the compiler (on x86) uses
072f729936a9 8035725: Must keep microsoft VS_PATH on PATH after toolchain detection
ihse
parents: 22721
diff changeset
   198
  # it for DLL resolution in runtime.
30022
362d77fbf008 8078437: Enable use of devkits for Windows
erikj
parents: 29866
diff changeset
   199
  if test "x$OPENJDK_BUILD_OS" = "xwindows" \
362d77fbf008 8078437: Enable use of devkits for Windows
erikj
parents: 29866
diff changeset
   200
      && test "x$TOOLCHAIN_TYPE" = "xmicrosoft"; then
22724
072f729936a9 8035725: Must keep microsoft VS_PATH on PATH after toolchain detection
ihse
parents: 22721
diff changeset
   201
    TOOLCHAIN_SETUP_VISUAL_STUDIO_ENV
23429
fe4f0848a307 8035751: Clean up Visual Studio detection logic
ihse
parents: 23428
diff changeset
   202
    # Reset path to VS_PATH. It will include everything that was on PATH at the time we
fe4f0848a307 8035751: Clean up Visual Studio detection logic
ihse
parents: 23428
diff changeset
   203
    # ran TOOLCHAIN_SETUP_VISUAL_STUDIO_ENV.
fe4f0848a307 8035751: Clean up Visual Studio detection logic
ihse
parents: 23428
diff changeset
   204
    PATH="$VS_PATH"
fe4f0848a307 8035751: Clean up Visual Studio detection logic
ihse
parents: 23428
diff changeset
   205
    # The microsoft toolchain also requires INCLUDE and LIB to be set.
fe4f0848a307 8035751: Clean up Visual Studio detection logic
ihse
parents: 23428
diff changeset
   206
    export INCLUDE="$VS_INCLUDE"
fe4f0848a307 8035751: Clean up Visual Studio detection logic
ihse
parents: 23428
diff changeset
   207
    export LIB="$VS_LIB"
22724
072f729936a9 8035725: Must keep microsoft VS_PATH on PATH after toolchain detection
ihse
parents: 22721
diff changeset
   208
  fi
072f729936a9 8035725: Must keep microsoft VS_PATH on PATH after toolchain detection
ihse
parents: 22721
diff changeset
   209
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   210
  # For solaris we really need solaris tools, and not the GNU equivalent.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   211
  # The build tools on Solaris reside in /usr/ccs (C Compilation System),
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   212
  # so add that to path before starting to probe.
30096
5624d3a52647 8078046: Remove MCS post-processing on Solaris
ihse
parents: 30022
diff changeset
   213
  # FIXME: This was originally only done for AS,NM,GNM,STRIP,OBJCOPY,OBJDUMP.
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   214
  if test "x$OPENJDK_BUILD_OS" = xsolaris; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   215
    PATH="/usr/ccs/bin:$PATH"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   216
  fi
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   217
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   218
  # Finally add TOOLCHAIN_PATH at the beginning, to allow --with-tools-dir to
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   219
  # override all other locations.
23428
3c8a05bf4656 8038340: Cleanup and fix sysroot and devkit handling on Linux and Solaris
erikj
parents: 23161
diff changeset
   220
  if test "x$TOOLCHAIN_PATH" != x; then
3c8a05bf4656 8038340: Cleanup and fix sysroot and devkit handling on Linux and Solaris
erikj
parents: 23161
diff changeset
   221
    PATH=$TOOLCHAIN_PATH:$PATH
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   222
  fi
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   223
])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   224
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   225
# Restore path, etc
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   226
AC_DEFUN_ONCE([TOOLCHAIN_POST_DETECTION],
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   227
[
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   228
  # Restore old path.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   229
  PATH="$OLD_PATH"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   230
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   231
  # Restore the flags to the user specified values.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   232
  # This is necessary since AC_PROG_CC defaults CFLAGS to "-g -O2"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   233
  CFLAGS="$ORG_CFLAGS"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   234
  CXXFLAGS="$ORG_CXXFLAGS"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   235
])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   236
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   237
# Check if a compiler is of the toolchain type we expect, and save the version
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   238
# information from it. If the compiler does not match the expected type,
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   239
# this function will abort using AC_MSG_ERROR. If it matches, the version will
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   240
# be stored in CC_VERSION_NUMBER/CXX_VERSION_NUMBER (as a dotted number), and
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   241
# the full version string in CC_VERSION_STRING/CXX_VERSION_STRING.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   242
#
14111
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   243
# $1 = compiler to test (CC or CXX)
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   244
# $2 = human readable name of compiler (C or C++)
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   245
AC_DEFUN([TOOLCHAIN_CHECK_COMPILER_VERSION],
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
   246
[
14111
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   247
  COMPILER=[$]$1
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   248
  COMPILER_NAME=$2
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
   249
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   250
  if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   251
    # cc -V output typically looks like
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   252
    #     cc: Sun C 5.12 Linux_i386 2011/11/16
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   253
    COMPILER_VERSION_OUTPUT=`$COMPILER -V 2>&1`
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   254
    # Check that this is likely to be the Solaris Studio cc.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   255
    $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "^.*: Sun $COMPILER_NAME" > /dev/null
14111
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   256
    if test $? -ne 0; then
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   257
      ALT_VERSION_OUTPUT=`$COMPILER --version 2>&1`
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   258
      AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required $TOOLCHAIN_TYPE compiler.])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   259
      AC_MSG_NOTICE([The result from running with -V was: "$COMPILER_VERSION_OUTPUT"])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   260
      AC_MSG_NOTICE([The result from running with --version was: "$ALT_VERSION_OUTPUT"])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   261
      AC_MSG_ERROR([A $TOOLCHAIN_TYPE compiler is required. Try setting --with-tools-dir.])
14111
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   262
    fi
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   263
    # Remove usage instructions (if present), and
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   264
    # collapse compiler output into a single line
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   265
    COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT | \
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   266
        $SED -e 's/ *@<:@Uu@:>@sage:.*//'`
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   267
    COMPILER_VERSION_NUMBER=`$ECHO $COMPILER_VERSION_OUTPUT | \
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   268
        $SED -e "s/^.*@<:@ ,\t@:>@$COMPILER_NAME@<:@ ,\t@:>@\(@<:@1-9@:>@\.@<:@0-9@:>@@<:@0-9@:>@*\).*/\1/"`
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   269
  elif test  "x$TOOLCHAIN_TYPE" = xxlc; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   270
    # xlc -qversion output typically looks like
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   271
    #     IBM XL C/C++ for AIX, V11.1 (5724-X13)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   272
    #     Version: 11.01.0000.0015
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   273
    COMPILER_VERSION_OUTPUT=`$COMPILER -qversion 2>&1`
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   274
    # Check that this is likely to be the IBM XL C compiler.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   275
    $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "IBM XL C" > /dev/null
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   276
    if test $? -ne 0; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   277
      ALT_VERSION_OUTPUT=`$COMPILER --version 2>&1`
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   278
      AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required $TOOLCHAIN_TYPE compiler.])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   279
      AC_MSG_NOTICE([The result from running with -qversion was: "$COMPILER_VERSION_OUTPUT"])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   280
      AC_MSG_NOTICE([The result from running with --version was: "$ALT_VERSION_OUTPUT"])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   281
      AC_MSG_ERROR([A $TOOLCHAIN_TYPE compiler is required. Try setting --with-tools-dir.])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   282
    fi
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   283
    # Collapse compiler output into a single line
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   284
    COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT`
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   285
    COMPILER_VERSION_NUMBER=`$ECHO $COMPILER_VERSION_OUTPUT | \
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   286
        $SED -e 's/^.*, V\(@<:@1-9@:>@@<:@0-9.@:>@*\).*$/\1/'`
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   287
  elif test  "x$TOOLCHAIN_TYPE" = xmicrosoft; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   288
    # There is no specific version flag, but all output starts with a version string.
14111
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   289
    # First line typically looks something like:
20362
5f8289bfda3e 8023611: Win32 and win64: Remove all the WARNINGS in JDK 8 builds for Windows 2008 and MSVS 2010 SP1
tbell
parents: 19763
diff changeset
   290
    # Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01 for 80x86
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   291
    COMPILER_VERSION_OUTPUT=`$COMPILER 2>&1 | $HEAD -n 1 | $TR -d '\r'`
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   292
    # Check that this is likely to be Microsoft CL.EXE.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   293
    $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "Microsoft.*Compiler" > /dev/null
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   294
    if test $? -ne 0; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   295
      AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required $TOOLCHAIN_TYPE compiler.])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   296
      AC_MSG_NOTICE([The result from running it was: "$COMPILER_VERSION_OUTPUT"])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   297
      AC_MSG_ERROR([A $TOOLCHAIN_TYPE compiler is required. Try setting --with-tools-dir.])
14111
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   298
    fi
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   299
    # Collapse compiler output into a single line
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   300
    COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT`
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   301
    COMPILER_VERSION_NUMBER=`$ECHO $COMPILER_VERSION_OUTPUT | \
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   302
        $SED -e 's/^.*ersion.\(@<:@1-9@:>@@<:@0-9.@:>@*\) .*$/\1/'`
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   303
  elif test  "x$TOOLCHAIN_TYPE" = xgcc; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   304
    # gcc --version output typically looks like
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   305
    #     gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   306
    #     Copyright (C) 2013 Free Software Foundation, Inc.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   307
    #     This is free software; see the source for copying conditions.  There is NO
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   308
    #     warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   309
    COMPILER_VERSION_OUTPUT=`$COMPILER --version 2>&1`
14111
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   310
    # Check that this is likely to be GCC.
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   311
    $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "Free Software Foundation" > /dev/null
14111
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   312
    if test $? -ne 0; then
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   313
      AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required $TOOLCHAIN_TYPE compiler.])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   314
      AC_MSG_NOTICE([The result from running with --version was: "$COMPILER_VERSION"])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   315
      AC_MSG_ERROR([A $TOOLCHAIN_TYPE compiler is required. Try setting --with-tools-dir.])
13697
5262b00bc10c 7197849: Update new build-infra makefiles
ohair
parents: 13133
diff changeset
   316
    fi
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   317
    # Remove Copyright and legalese from version string, and
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   318
    # collapse into a single line
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   319
    COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT | \
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   320
        $SED -e 's/ *Copyright .*//'`
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   321
    COMPILER_VERSION_NUMBER=`$ECHO $COMPILER_VERSION_OUTPUT | \
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   322
        $SED -e 's/^.* \(@<:@1-9@:>@\.@<:@0-9.@:>@*\) .*$/\1/'`
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   323
  elif test  "x$TOOLCHAIN_TYPE" = xclang; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   324
    # clang --version output typically looks like
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   325
    #    Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   326
    #    clang version 3.3 (tags/RELEASE_33/final)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   327
    # or
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   328
    #    Debian clang version 3.2-7ubuntu1 (tags/RELEASE_32/final) (based on LLVM 3.2)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   329
    #    Target: x86_64-pc-linux-gnu
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   330
    #    Thread model: posix
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   331
    COMPILER_VERSION_OUTPUT=`$COMPILER --version 2>&1`
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   332
    # Check that this is likely to be clang
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   333
    $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "clang" > /dev/null
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   334
    if test $? -ne 0; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   335
      AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required $TOOLCHAIN_TYPE compiler.])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   336
      AC_MSG_NOTICE([The result from running with --version was: "$COMPILER_VERSION_OUTPUT"])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   337
      AC_MSG_ERROR([A $TOOLCHAIN_TYPE compiler is required. Try setting --with-tools-dir.])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   338
    fi
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   339
    # Collapse compiler output into a single line
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   340
    COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT`
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   341
    COMPILER_VERSION_NUMBER=`$ECHO $COMPILER_VERSION_OUTPUT | \
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   342
        $SED -e 's/^.*clang version \(@<:@1-9@:>@@<:@0-9.@:>@*\).*$/\1/'`
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   343
  else
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   344
      AC_MSG_ERROR([Unknown toolchain type $TOOLCHAIN_TYPE.])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   345
  fi
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   346
  # This sets CC_VERSION_NUMBER or CXX_VERSION_NUMBER. (This comment is a grep marker)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   347
  $1_VERSION_NUMBER="$COMPILER_VERSION_NUMBER"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   348
  # This sets CC_VERSION_STRING or CXX_VERSION_STRING. (This comment is a grep marker)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   349
  $1_VERSION_STRING="$COMPILER_VERSION_STRING"
17664
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
   350
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   351
  AC_MSG_NOTICE([Using $TOOLCHAIN_TYPE $COMPILER_NAME compiler version $COMPILER_VERSION_NUMBER @<:@$COMPILER_VERSION_STRING@:>@])
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
   352
])
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
   353
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   354
# Try to locate the given C or C++ compiler in the path, or otherwise.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   355
#
14111
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   356
# $1 = compiler to test (CC or CXX)
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   357
# $2 = human readable name of compiler (C or C++)
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   358
# $3 = list of compiler names to search for
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   359
AC_DEFUN([TOOLCHAIN_FIND_COMPILER],
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
   360
[
14111
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   361
  COMPILER_NAME=$2
22458
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   362
  SEARCH_LIST="$3"
14111
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   363
22458
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   364
  if test "x[$]$1" != x; then
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   365
    # User has supplied compiler name already, always let that override.
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   366
    AC_MSG_NOTICE([Will use user supplied compiler $1=[$]$1])
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   367
    if test "x`basename [$]$1`" = "x[$]$1"; then
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   368
      # A command without a complete path is provided, search $PATH.
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   369
22458
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   370
      AC_PATH_PROGS(POTENTIAL_$1, [$]$1)
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   371
      if test "x$POTENTIAL_$1" != x; then
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   372
        $1=$POTENTIAL_$1
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   373
      else
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   374
        AC_MSG_ERROR([User supplied compiler $1=[$]$1 could not be found])
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   375
      fi
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   376
    else
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   377
      # Otherwise it might already be a complete path
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   378
      if test ! -x "[$]$1"; then
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   379
        AC_MSG_ERROR([User supplied compiler $1=[$]$1 does not exist])
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   380
      fi
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   381
    fi
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   382
  else
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   383
    # No user supplied value. Locate compiler ourselves.
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   384
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   385
    # If we are cross compiling, assume cross compilation tools follows the
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   386
    # cross compilation standard where they are prefixed with the autoconf
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   387
    # standard name for the target. For example the binary
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   388
    # i686-sun-solaris2.10-gcc will cross compile for i686-sun-solaris2.10.
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   389
    # If we are not cross compiling, then the default compiler name will be
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   390
    # used.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   391
22458
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   392
    $1=
23428
3c8a05bf4656 8038340: Cleanup and fix sysroot and devkit handling on Linux and Solaris
erikj
parents: 23161
diff changeset
   393
    # If TOOLCHAIN_PATH is set, check for all compiler names in there first
22458
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   394
    # before checking the rest of the PATH.
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   395
    # FIXME: Now that we prefix the TOOLS_DIR to the PATH in the PRE_DETECTION
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   396
    # step, this should not be necessary.
23428
3c8a05bf4656 8038340: Cleanup and fix sysroot and devkit handling on Linux and Solaris
erikj
parents: 23161
diff changeset
   397
    if test -n "$TOOLCHAIN_PATH"; then
22458
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   398
      PATH_save="$PATH"
23428
3c8a05bf4656 8038340: Cleanup and fix sysroot and devkit handling on Linux and Solaris
erikj
parents: 23161
diff changeset
   399
      PATH="$TOOLCHAIN_PATH"
3c8a05bf4656 8038340: Cleanup and fix sysroot and devkit handling on Linux and Solaris
erikj
parents: 23161
diff changeset
   400
      AC_PATH_PROGS(TOOLCHAIN_PATH_$1, $SEARCH_LIST)
3c8a05bf4656 8038340: Cleanup and fix sysroot and devkit handling on Linux and Solaris
erikj
parents: 23161
diff changeset
   401
      $1=$TOOLCHAIN_PATH_$1
22458
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   402
      PATH="$PATH_save"
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   403
    fi
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   404
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   405
    # AC_PATH_PROGS can't be run multiple times with the same variable,
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   406
    # so create a new name for this run.
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   407
    if test "x[$]$1" = x; then
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   408
      AC_PATH_PROGS(POTENTIAL_$1, $SEARCH_LIST)
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   409
      $1=$POTENTIAL_$1
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   410
    fi
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   411
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   412
    if test "x[$]$1" = x; then
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   413
      HELP_MSG_MISSING_DEPENDENCY([devkit])
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   414
      AC_MSG_ERROR([Could not find a $COMPILER_NAME compiler. $HELP_MSG])
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   415
    fi
14614
3bb0a6b81bb9 8003945: build-infra: problems finding compiler when using --with-dev-kit
erikj
parents: 14467
diff changeset
   416
  fi
3bb0a6b81bb9 8003945: build-infra: problems finding compiler when using --with-dev-kit
erikj
parents: 14467
diff changeset
   417
22458
6a74da13c52f 8022411: Allow overriding of CXX and CC with absolute path
ihse
parents: 22179
diff changeset
   418
  # Now we have a compiler binary in $1. Make sure it's okay.
14111
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   419
  BASIC_FIXUP_EXECUTABLE($1)
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   420
  TEST_COMPILER="[$]$1"
22466
25aaf85d1ada 8024265: Enable new build on AIX
simonis
parents: 22465
diff changeset
   421
  # Don't remove symbolic links on AIX because 'xlc_r' and 'xlC_r' may all be links
25aaf85d1ada 8024265: Enable new build on AIX
simonis
parents: 22465
diff changeset
   422
  # to 'xlc' but it is crucial that we invoke the compiler with the right name!
25aaf85d1ada 8024265: Enable new build on AIX
simonis
parents: 22465
diff changeset
   423
  if test "x$OPENJDK_BUILD_OS" != xaix; then
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   424
    # FIXME: This test should not be needed anymore; we don't do that for any platform.
22466
25aaf85d1ada 8024265: Enable new build on AIX
simonis
parents: 22465
diff changeset
   425
    AC_MSG_CHECKING([resolved symbolic links for $1])
25aaf85d1ada 8024265: Enable new build on AIX
simonis
parents: 22465
diff changeset
   426
    BASIC_REMOVE_SYMBOLIC_LINKS(TEST_COMPILER)
25aaf85d1ada 8024265: Enable new build on AIX
simonis
parents: 22465
diff changeset
   427
    AC_MSG_RESULT([$TEST_COMPILER])
25aaf85d1ada 8024265: Enable new build on AIX
simonis
parents: 22465
diff changeset
   428
  fi
14111
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   429
  AC_MSG_CHECKING([if $1 is disguised ccache])
17664
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
   430
14111
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   431
  COMPILER_BASENAME=`$BASENAME "$TEST_COMPILER"`
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   432
  if test "x$COMPILER_BASENAME" = "xccache"; then
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   433
    AC_MSG_RESULT([yes, trying to find proper $COMPILER_NAME compiler])
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   434
    # We /usr/lib/ccache in the path, so cc is a symlink to /usr/bin/ccache.
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   435
    # We want to control ccache invocation ourselves, so ignore this cc and try
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   436
    # searching again.
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   437
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   438
    # Remove the path to the fake ccache cc from the PATH
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   439
    RETRY_COMPILER_SAVED_PATH="$PATH"
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   440
    COMPILER_DIRNAME=`$DIRNAME [$]$1`
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   441
    PATH="`$ECHO $PATH | $SED -e "s,$COMPILER_DIRNAME,,g" -e "s,::,:,g" -e "s,^:,,g"`"
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   442
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   443
    # Try again looking for our compiler
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   444
    AC_CHECK_TOOLS(PROPER_COMPILER_$1, $3)
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   445
    BASIC_FIXUP_EXECUTABLE(PROPER_COMPILER_$1)
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   446
    PATH="$RETRY_COMPILER_SAVED_PATH"
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   447
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   448
    AC_MSG_CHECKING([for resolved symbolic links for $1])
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   449
    BASIC_REMOVE_SYMBOLIC_LINKS(PROPER_COMPILER_$1)
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   450
    AC_MSG_RESULT([$PROPER_COMPILER_$1])
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   451
    $1="$PROPER_COMPILER_$1"
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   452
  else
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   453
    AC_MSG_RESULT([no, keeping $1])
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   454
  fi
22179
59d2bd4620b0 8031668: TOOLCHAIN_FIND_COMPILER unexpectedly resolves symbolic links
mduigou
parents: 22035
diff changeset
   455
14111
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   456
  TOOLCHAIN_CHECK_COMPILER_VERSION([$1], [$COMPILER_NAME])
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   457
])
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   458
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   459
# Detect the core components of the toolchain, i.e. the compilers (CC and CXX),
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   460
# preprocessor (CPP and CXXCPP), the linker (LD), the assembler (AS) and the
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   461
# archiver (AR). Verify that the compilers are correct according to the
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   462
# toolchain type.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   463
AC_DEFUN_ONCE([TOOLCHAIN_DETECT_TOOLCHAIN_CORE],
14111
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   464
[
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   465
  #
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   466
  # Setup the compilers (CC and CXX)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   467
  #
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   468
  TOOLCHAIN_FIND_COMPILER([CC], [C], $TOOLCHAIN_CC_BINARY)
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   469
  # Now that we have resolved CC ourself, let autoconf have its go at it
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   470
  AC_PROG_CC([$CC])
14111
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   471
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   472
  TOOLCHAIN_FIND_COMPILER([CXX], [C++], $TOOLCHAIN_CXX_BINARY)
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   473
  # Now that we have resolved CXX ourself, let autoconf have its go at it
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   474
  AC_PROG_CXX([$CXX])
14111
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   475
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   476
  #
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   477
  # Setup the preprocessor (CPP and CXXCPP)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   478
  #
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   479
  AC_PROG_CPP
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   480
  BASIC_FIXUP_EXECUTABLE(CPP)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   481
  AC_PROG_CXXCPP
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   482
  BASIC_FIXUP_EXECUTABLE(CXXCPP)
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
   483
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   484
  #
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   485
  # Setup the linker (LD)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   486
  #
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   487
  if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   488
    # In the Microsoft toolchain we have a separate LD command "link".
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   489
    # Make sure we reject /usr/bin/link (as determined in CYGWIN_LINK), which is
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   490
    # a cygwin program for something completely different.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   491
    AC_CHECK_PROG([LD], [link],[link],,, [$CYGWIN_LINK])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   492
    BASIC_FIXUP_EXECUTABLE(LD)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   493
    # Verify that we indeed succeeded with this trick.
13697
5262b00bc10c 7197849: Update new build-infra makefiles
ohair
parents: 13133
diff changeset
   494
    AC_MSG_CHECKING([if the found link.exe is actually the Visual Studio linker])
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   495
    "$LD" --version > /dev/null
13697
5262b00bc10c 7197849: Update new build-infra makefiles
ohair
parents: 13133
diff changeset
   496
    if test $? -eq 0 ; then
5262b00bc10c 7197849: Update new build-infra makefiles
ohair
parents: 13133
diff changeset
   497
      AC_MSG_RESULT([no])
5262b00bc10c 7197849: Update new build-infra makefiles
ohair
parents: 13133
diff changeset
   498
      AC_MSG_ERROR([This is the Cygwin link tool. Please check your PATH and rerun configure.])
5262b00bc10c 7197849: Update new build-infra makefiles
ohair
parents: 13133
diff changeset
   499
    else
5262b00bc10c 7197849: Update new build-infra makefiles
ohair
parents: 13133
diff changeset
   500
      AC_MSG_RESULT([yes])
5262b00bc10c 7197849: Update new build-infra makefiles
ohair
parents: 13133
diff changeset
   501
    fi
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   502
    LDCXX="$LD"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   503
  else
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   504
    # All other toolchains use the compiler to link.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   505
    LD="$CC"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   506
    LDCXX="$CXX"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   507
  fi
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   508
  AC_SUBST(LD)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   509
  # FIXME: it should be CXXLD, according to standard (cf CXXCPP)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   510
  AC_SUBST(LDCXX)
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
   511
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   512
  #
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   513
  # Setup the assembler (AS)
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   514
  #
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   515
  if test "x$OPENJDK_TARGET_OS" = xsolaris; then
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   516
    # FIXME: should this really be solaris, or solstudio?
22475
777928354ad9 8031759: Improved tool overriding in configure
ihse
parents: 22473
diff changeset
   517
    BASIC_PATH_PROGS(AS, as)
14111
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   518
    BASIC_FIXUP_EXECUTABLE(AS)
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   519
  else
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   520
    # FIXME: is this correct for microsoft?
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
   521
    AS="$CC -c"
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   522
  fi
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   523
  AC_SUBST(AS)
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
   524
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   525
  #
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   526
  # Setup the archiver (AR)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   527
  #
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   528
  if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   529
    # The corresponding ar tool is lib.exe (used to create static libraries)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   530
    AC_CHECK_PROG([AR], [lib],[lib],,,)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   531
  else
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   532
    BASIC_CHECK_TOOLS(AR, ar)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   533
  fi
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   534
  BASIC_FIXUP_EXECUTABLE(AR)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   535
])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   536
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   537
# Setup additional tools that is considered a part of the toolchain, but not the
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   538
# core part. Many of these are highly platform-specific and do not exist,
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   539
# and/or are not needed on all platforms.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   540
AC_DEFUN_ONCE([TOOLCHAIN_DETECT_TOOLCHAIN_EXTRA],
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   541
[
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   542
  if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   543
    BASIC_PATH_PROGS(LIPO, lipo)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   544
    BASIC_FIXUP_EXECUTABLE(LIPO)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   545
  fi
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   546
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   547
  if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   548
    AC_CHECK_PROG([MT], [mt], [mt],,, [/usr/bin/mt])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   549
    BASIC_FIXUP_EXECUTABLE(MT)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   550
    # Setup the resource compiler (RC)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   551
    AC_CHECK_PROG([RC], [rc], [rc],,, [/usr/bin/rc])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   552
    BASIC_FIXUP_EXECUTABLE(RC)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   553
    AC_CHECK_PROG([DUMPBIN], [dumpbin], [dumpbin],,,)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   554
    BASIC_FIXUP_EXECUTABLE(DUMPBIN)
26400
4d6c6f2df610 8057538: Build the freetype library during configure on Windows
simonis
parents: 25034
diff changeset
   555
    # We need to check for 'msbuild.exe' because at the place where we expect to
4d6c6f2df610 8057538: Build the freetype library during configure on Windows
simonis
parents: 25034
diff changeset
   556
    # find 'msbuild.exe' there's also a directory called 'msbuild' and configure
4d6c6f2df610 8057538: Build the freetype library during configure on Windows
simonis
parents: 25034
diff changeset
   557
    # won't find the 'msbuild.exe' executable in that case (and the
4d6c6f2df610 8057538: Build the freetype library during configure on Windows
simonis
parents: 25034
diff changeset
   558
    # 'ac_executable_extensions' is unusable due to performance reasons).
4d6c6f2df610 8057538: Build the freetype library during configure on Windows
simonis
parents: 25034
diff changeset
   559
    # Notice that we intentionally don't fix up the path to MSBUILD because we
4d6c6f2df610 8057538: Build the freetype library during configure on Windows
simonis
parents: 25034
diff changeset
   560
    # will call it in a DOS shell during freetype detection on Windows (see
4d6c6f2df610 8057538: Build the freetype library during configure on Windows
simonis
parents: 25034
diff changeset
   561
    # 'LIB_SETUP_FREETYPE' in "libraries.m4"
4d6c6f2df610 8057538: Build the freetype library during configure on Windows
simonis
parents: 25034
diff changeset
   562
    AC_CHECK_PROG([MSBUILD], [msbuild.exe], [msbuild.exe],,,)
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   563
  fi
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   564
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   565
  if test "x$OPENJDK_TARGET_OS" = xsolaris; then
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   566
    BASIC_PATH_PROGS(STRIP, strip)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   567
    BASIC_FIXUP_EXECUTABLE(STRIP)
22475
777928354ad9 8031759: Improved tool overriding in configure
ihse
parents: 22473
diff changeset
   568
    BASIC_PATH_PROGS(NM, nm)
14111
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   569
    BASIC_FIXUP_EXECUTABLE(NM)
22475
777928354ad9 8031759: Improved tool overriding in configure
ihse
parents: 22473
diff changeset
   570
    BASIC_PATH_PROGS(GNM, gnm)
16582
61f0b8f48036 8006288: build-infra: Use solaris nm and not gnm on solaris
erikj
parents: 15912
diff changeset
   571
    BASIC_FIXUP_EXECUTABLE(GNM)
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   572
  elif test "x$OPENJDK_TARGET_OS" != xwindows; then
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   573
    # FIXME: we should unify this with the solaris case above.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   574
    BASIC_CHECK_TOOLS(STRIP, strip)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   575
    BASIC_FIXUP_EXECUTABLE(STRIP)
22475
777928354ad9 8031759: Improved tool overriding in configure
ihse
parents: 22473
diff changeset
   576
    BASIC_CHECK_TOOLS(NM, nm)
14111
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   577
    BASIC_FIXUP_EXECUTABLE(NM)
16582
61f0b8f48036 8006288: build-infra: Use solaris nm and not gnm on solaris
erikj
parents: 15912
diff changeset
   578
    GNM="$NM"
61f0b8f48036 8006288: build-infra: Use solaris nm and not gnm on solaris
erikj
parents: 15912
diff changeset
   579
    AC_SUBST(GNM)
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   580
  fi
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
   581
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   582
  # objcopy is used for moving debug symbols to separate files when
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   583
  # full debug symbols are enabled.
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   584
  if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux; then
22475
777928354ad9 8031759: Improved tool overriding in configure
ihse
parents: 22473
diff changeset
   585
    BASIC_CHECK_TOOLS(OBJCOPY, [gobjcopy objcopy])
14464
b82a851468d0 8003300: build-infra: fails on solaris when objcopy is not found
tbell
parents: 14112
diff changeset
   586
    # Only call fixup if objcopy was found.
b82a851468d0 8003300: build-infra: fails on solaris when objcopy is not found
tbell
parents: 14112
diff changeset
   587
    if test -n "$OBJCOPY"; then
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   588
      BASIC_FIXUP_EXECUTABLE(OBJCOPY)
14464
b82a851468d0 8003300: build-infra: fails on solaris when objcopy is not found
tbell
parents: 14112
diff changeset
   589
    fi
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   590
  fi
14111
2a82ecb35fc7 8000992: Update new build-infra makefiles
ohair
parents: 13697
diff changeset
   591
22475
777928354ad9 8031759: Improved tool overriding in configure
ihse
parents: 22473
diff changeset
   592
  BASIC_CHECK_TOOLS(OBJDUMP, [gobjdump objdump])
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   593
  if test "x$OBJDUMP" != x; then
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   594
    # Only used for compare.sh; we can live without it. BASIC_FIXUP_EXECUTABLE
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   595
    # bails if argument is missing.
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   596
    BASIC_FIXUP_EXECUTABLE(OBJDUMP)
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   597
  fi
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   598
])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   599
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   600
# Setup the build tools (i.e, the compiler and linker used to build programs
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   601
# that should be run on the build platform, not the target platform, as a build
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   602
# helper). Since the non-cross-compile case uses the normal, target compilers
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   603
# for this, we can only do this after these have been setup.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   604
AC_DEFUN_ONCE([TOOLCHAIN_SETUP_BUILD_COMPILERS],
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   605
[
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   606
  if test "x$COMPILE_TYPE" = "xcross"; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   607
    # Now we need to find a C/C++ compiler that can build executables for the
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   608
    # build platform. We can't use the AC_PROG_CC macro, since it can only be
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   609
    # used once. Also, we need to do this without adding a tools dir to the
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   610
    # path, otherwise we might pick up cross-compilers which don't use standard
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   611
    # naming.
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   612
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   613
    # FIXME: we should list the discovered compilers as an exclude pattern!
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   614
    # If we do that, we can do this detection before POST_DETECTION, and still
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   615
    # find the build compilers in the tools dir, if needed.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   616
    BASIC_PATH_PROGS(BUILD_CC, [cl cc gcc])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   617
    BASIC_FIXUP_EXECUTABLE(BUILD_CC)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   618
    BASIC_PATH_PROGS(BUILD_CXX, [cl CC g++])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   619
    BASIC_FIXUP_EXECUTABLE(BUILD_CXX)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   620
    BASIC_PATH_PROGS(BUILD_LD, ld)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   621
    BASIC_FIXUP_EXECUTABLE(BUILD_LD)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   622
  else
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   623
    # If we are not cross compiling, use the normal target compilers for
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   624
    # building the build platform executables.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   625
    BUILD_CC="$CC"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   626
    BUILD_CXX="$CXX"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   627
    BUILD_LD="$LD"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   628
  fi
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
   629
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   630
  AC_SUBST(BUILD_CC)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   631
  AC_SUBST(BUILD_CXX)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   632
  AC_SUBST(BUILD_LD)
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
   633
])
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
   634
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   635
# Setup legacy variables that are still needed as alternative ways to refer to
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   636
# parts of the toolchain.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   637
AC_DEFUN_ONCE([TOOLCHAIN_SETUP_LEGACY],
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
   638
[
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   639
  if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   640
    # For hotspot, we need these in Windows mixed path,
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   641
    # so rewrite them all. Need added .exe suffix.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   642
    HOTSPOT_CXX="$CXX.exe"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   643
    HOTSPOT_LD="$LD.exe"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   644
    HOTSPOT_MT="$MT.exe"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   645
    HOTSPOT_RC="$RC.exe"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   646
    BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(HOTSPOT_CXX)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   647
    BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(HOTSPOT_LD)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   648
    BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(HOTSPOT_MT)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   649
    BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(HOTSPOT_RC)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   650
    AC_SUBST(HOTSPOT_MT)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   651
    AC_SUBST(HOTSPOT_RC)
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   652
  else
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   653
    HOTSPOT_CXX="$CXX"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   654
    HOTSPOT_LD="$LD"
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   655
  fi
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   656
  AC_SUBST(HOTSPOT_CXX)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   657
  AC_SUBST(HOTSPOT_LD)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   658
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   659
  if test  "x$TOOLCHAIN_TYPE" = xclang; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   660
    USE_CLANG=true
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   661
  fi
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   662
  AC_SUBST(USE_CLANG)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   663
])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   664
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   665
# Do some additional checks on the detected tools.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   666
AC_DEFUN_ONCE([TOOLCHAIN_MISC_CHECKS],
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   667
[
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   668
  # The package path is used only on macosx?
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   669
  # FIXME: clean this up, and/or move it elsewhere.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   670
  PACKAGE_PATH=/opt/local
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   671
  AC_SUBST(PACKAGE_PATH)
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   672
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   673
  # Check for extra potential brokenness.
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   674
  if test  "x$TOOLCHAIN_TYPE" = xmicrosoft; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   675
    # On Windows, double-check that we got the right compiler.
22724
072f729936a9 8035725: Must keep microsoft VS_PATH on PATH after toolchain detection
ihse
parents: 22721
diff changeset
   676
    CC_VERSION_OUTPUT=`$CC 2>&1 | $HEAD -n 1 | $TR -d '\r'`
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   677
    COMPILER_CPU_TEST=`$ECHO $CC_VERSION_OUTPUT | $SED -n "s/^.* \(.*\)$/\1/p"`
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   678
    if test "x$OPENJDK_TARGET_CPU" = "xx86"; then
28901
5acc0ec03d06 8042707: Source changes needed to build JDK 9 with Visual Studio 2013 (VS2013)
erikj
parents: 27594
diff changeset
   679
      if test "x$COMPILER_CPU_TEST" != "x80x86" -a "x$COMPILER_CPU_TEST" != "xx86"; then
5acc0ec03d06 8042707: Source changes needed to build JDK 9 with Visual Studio 2013 (VS2013)
erikj
parents: 27594
diff changeset
   680
        AC_MSG_ERROR([Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for "$COMPILER_CPU_TEST"; expected "80x86" or "x86".])
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   681
      fi
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   682
    elif test "x$OPENJDK_TARGET_CPU" = "xx86_64"; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   683
      if test "x$COMPILER_CPU_TEST" != "xx64"; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   684
        AC_MSG_ERROR([Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for "$COMPILER_CPU_TEST"; expected "x64".])
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   685
      fi
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
   686
    fi
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   687
  fi
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
   688
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   689
  if test "x$TOOLCHAIN_TYPE" = xgcc; then
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   690
    # If this is a --hash-style=gnu system, use --hash-style=both, why?
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   691
    HAS_GNU_HASH=`$CC -dumpspecs 2>/dev/null | $GREP 'hash-style=gnu'`
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   692
    # This is later checked when setting flags.
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   693
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   694
    # "-Og" suppported for GCC 4.8 and later
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   695
    CFLAG_OPTIMIZE_DEBUG_FLAG="-Og"
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   696
    FLAGS_COMPILER_CHECK_ARGUMENTS([$CFLAG_OPTIMIZE_DEBUG_FLAG],
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   697
      [HAS_CFLAG_OPTIMIZE_DEBUG=true],
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   698
      [HAS_CFLAG_OPTIMIZE_DEBUG=false])
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   699
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   700
    # "-z relro" supported in GNU binutils 2.17 and later
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   701
    LINKER_RELRO_FLAG="-Xlinker -z -Xlinker relro"
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   702
    FLAGS_LINKER_CHECK_ARGUMENTS([$LINKER_RELRO_FLAG],
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   703
      [HAS_LINKER_RELRO=true],
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   704
      [HAS_LINKER_RELRO=false])
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   705
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   706
    # "-z now" supported in GNU binutils 2.11 and later
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   707
    LINKER_NOW_FLAG="-Xlinker -z -Xlinker now"
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   708
    FLAGS_LINKER_CHECK_ARGUMENTS([$LINKER_NOW_FLAG],
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   709
      [HAS_LINKER_NOW=true],
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   710
      [HAS_LINKER_NOW=false])
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   711
  fi
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
   712
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   713
  # Check for broken SuSE 'ld' for which 'Only anonymous version tag is allowed
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   714
  # in executable.'
22460
0273c023680c 8017568: PPC64: Generic build preparations needed to enable new build on Linux/PPC64
simonis
parents: 18020
diff changeset
   715
  USING_BROKEN_SUSE_LD=no
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   716
  if test "x$OPENJDK_TARGET_OS" = xlinux && test "x$TOOLCHAIN_TYPE" = xgcc; then
22460
0273c023680c 8017568: PPC64: Generic build preparations needed to enable new build on Linux/PPC64
simonis
parents: 18020
diff changeset
   717
    AC_MSG_CHECKING([for broken SuSE 'ld' which only understands anonymous version tags in executables])
24911
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   718
    $ECHO "SUNWprivate_1.1 { local: *; };" > version-script.map
a039e17f8896 8032045: Enable compiler and linker safety switches for debug builds
mduigou
parents: 23429
diff changeset
   719
    $ECHO "int main() { }" > main.c
22460
0273c023680c 8017568: PPC64: Generic build preparations needed to enable new build on Linux/PPC64
simonis
parents: 18020
diff changeset
   720
    if $CXX -Xlinker -version-script=version-script.map main.c 2>&AS_MESSAGE_LOG_FD >&AS_MESSAGE_LOG_FD; then
0273c023680c 8017568: PPC64: Generic build preparations needed to enable new build on Linux/PPC64
simonis
parents: 18020
diff changeset
   721
      AC_MSG_RESULT(no)
0273c023680c 8017568: PPC64: Generic build preparations needed to enable new build on Linux/PPC64
simonis
parents: 18020
diff changeset
   722
      USING_BROKEN_SUSE_LD=no
0273c023680c 8017568: PPC64: Generic build preparations needed to enable new build on Linux/PPC64
simonis
parents: 18020
diff changeset
   723
    else
0273c023680c 8017568: PPC64: Generic build preparations needed to enable new build on Linux/PPC64
simonis
parents: 18020
diff changeset
   724
      AC_MSG_RESULT(yes)
0273c023680c 8017568: PPC64: Generic build preparations needed to enable new build on Linux/PPC64
simonis
parents: 18020
diff changeset
   725
      USING_BROKEN_SUSE_LD=yes
0273c023680c 8017568: PPC64: Generic build preparations needed to enable new build on Linux/PPC64
simonis
parents: 18020
diff changeset
   726
    fi
22713
8c959ab35832 8034098: Configure leaves 'a.out' in root dir.
erikj
parents: 22475
diff changeset
   727
    rm -rf version-script.map main.c a.out
22460
0273c023680c 8017568: PPC64: Generic build preparations needed to enable new build on Linux/PPC64
simonis
parents: 18020
diff changeset
   728
  fi
0273c023680c 8017568: PPC64: Generic build preparations needed to enable new build on Linux/PPC64
simonis
parents: 18020
diff changeset
   729
  AC_SUBST(USING_BROKEN_SUSE_LD)
16987
19305cbf4362 8013786: JDK-8013480 broke configure on solaris
erikj
parents: 16582
diff changeset
   730
])
17593
de6741d8a142 8007129: build-infra Add configure --with-jtreg option for location of JTREG
erikj
parents: 16988
diff changeset
   731
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22715
diff changeset
   732
# Setup the JTReg Regression Test Harness.
17664
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
   733
AC_DEFUN_ONCE([TOOLCHAIN_SETUP_JTREG],
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
   734
[
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
   735
  AC_ARG_WITH(jtreg, [AS_HELP_STRING([--with-jtreg],
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   736
      [Regression Test Harness @<:@probed@:>@])],
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   737
      [],
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20362
diff changeset
   738
      [with_jtreg=no])
17664
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
   739
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
   740
  if test "x$with_jtreg" = xno; then
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
   741
    # jtreg disabled
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
   742
    AC_MSG_CHECKING([for jtreg])
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
   743
    AC_MSG_RESULT(no)
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
   744
  else
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
   745
    if test "x$with_jtreg" != xyes; then
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
   746
      # with path specified.
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
   747
      JT_HOME="$with_jtreg"
17593
de6741d8a142 8007129: build-infra Add configure --with-jtreg option for location of JTREG
erikj
parents: 16988
diff changeset
   748
    fi
17664
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
   749
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
   750
    if test "x$JT_HOME" != x; then
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
   751
      AC_MSG_CHECKING([for jtreg])
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
   752
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
   753
      # use JT_HOME enviroment var.
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
   754
      BASIC_FIXUP_PATH([JT_HOME])
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
   755
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
   756
      # jtreg win32 script works for everybody
29450
193e2288524d 8075495: Update jtreg bin location in configure
erikj
parents: 29173
diff changeset
   757
      JTREGEXE="$JT_HOME/bin/jtreg"
17664
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
   758
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
   759
      if test ! -f "$JTREGEXE"; then
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
   760
        AC_MSG_ERROR([JTReg executable does not exist: $JTREGEXE])
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
   761
      fi
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
   762
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
   763
      AC_MSG_RESULT($JTREGEXE)
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
   764
    else
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
   765
      # try to find jtreg on path
22475
777928354ad9 8031759: Improved tool overriding in configure
ihse
parents: 22473
diff changeset
   766
      BASIC_REQUIRE_PROGS(JTREGEXE, jtreg)
17664
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
   767
      JT_HOME="`$DIRNAME $JTREGEXE`"
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
   768
    fi
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
   769
  fi
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
   770
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
   771
  AC_SUBST(JT_HOME)
2cb42641740b 8015510: (s) Improve JTReg location detection and provide location to test/Makefile
mduigou
parents: 17593
diff changeset
   772
  AC_SUBST(JTREGEXE)
17593
de6741d8a142 8007129: build-infra Add configure --with-jtreg option for location of JTREG
erikj
parents: 16988
diff changeset
   773
])