| 1 |
# =========================================================================== |
| 2 |
# https://github.com/BrianAker/ddm4/ |
| 3 |
# =========================================================================== |
| 4 |
# |
| 5 |
# SYNOPSIS |
| 6 |
# |
| 7 |
# AX_COMPILER_VERSION() |
| 8 |
# |
| 9 |
# DESCRIPTION |
| 10 |
# |
| 11 |
# Capture version of C/C++ compiler |
| 12 |
# |
| 13 |
# LICENSE |
| 14 |
# |
| 15 |
# Copyright (C) 2012 Brian Aker |
| 16 |
# All rights reserved. |
| 17 |
# |
| 18 |
# Redistribution and use in source and binary forms, with or without |
| 19 |
# modification, are permitted provided that the following conditions are |
| 20 |
# met: |
| 21 |
# |
| 22 |
# * Redistributions of source code must retain the above copyright |
| 23 |
# notice, this list of conditions and the following disclaimer. |
| 24 |
# |
| 25 |
# * Redistributions in binary form must reproduce the above |
| 26 |
# copyright notice, this list of conditions and the following disclaimer |
| 27 |
# in the documentation and/or other materials provided with the |
| 28 |
# distribution. |
| 29 |
# |
| 30 |
# * The names of its contributors may not be used to endorse or |
| 31 |
# promote products derived from this software without specific prior |
| 32 |
# written permission. |
| 33 |
# |
| 34 |
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 35 |
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 36 |
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 37 |
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 38 |
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 39 |
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 40 |
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 41 |
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 42 |
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 43 |
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 44 |
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 45 |
|
| 46 |
#serial 6 |
| 47 |
AC_DEFUN([_C_COMPILER_VERSION], |
| 48 |
[AC_MSG_CHECKING([C Compiler version]) |
| 49 |
|
| 50 |
AS_CASE(["$ax_cv_c_compiler_vendor"], |
| 51 |
[sun],[ax_c_compiler_version=`$CC -V 2>&1 | sed 1q`], |
| 52 |
[intel],[ax_c_compiler_version=`$CC --version 2>&1 | sed 1q`], |
| 53 |
[clang],[ax_c_compiler_version=`$CC --version 2>&1 | sed 1q`], |
| 54 |
[gnu],[ax_c_compiler_version=`$CC --version | sed 1q`], |
| 55 |
[mingw],[ax_c_compiler_version=`$CC --version | sed 1q`], |
| 56 |
[ax_c_compiler_version="unknown: $ax_cv_c_compiler_vendor"]) |
| 57 |
|
| 58 |
AC_MSG_RESULT(["$ax_c_compiler_version"]) |
| 59 |
AC_SUBST([CC_VERSION_VENDOR],["$ax_cv_c_compiler_vendor"]) |
| 60 |
AC_SUBST([CC_VERSION],["$ax_c_compiler_version"]) |
| 61 |
]) |
| 62 |
|
| 63 |
AC_DEFUN([_CXX_COMPILER_VERSION], |
| 64 |
[AC_MSG_CHECKING([C++ Compiler version]) |
| 65 |
|
| 66 |
AS_CASE(["$ax_cv_c_compiler_vendor"], |
| 67 |
[sun],[ax_cxx_compiler_version=`$CXX -V 2>&1 | sed 1q`], |
| 68 |
[intel],[ax_cxx_compiler_version=`$CXX --version 2>&1 | sed 1q`], |
| 69 |
[clang],[ax_cxx_compiler_version=`$CXX --version 2>&1 | sed 1q`], |
| 70 |
[gnu],[ax_cxx_compiler_version=`$CXX --version | sed 1q`], |
| 71 |
[mingw],[ax_cxx_compiler_version=`$CXX --version | sed 1q`], |
| 72 |
[ax_cxx_compiler_version="unknown: $ax_cv_c_compiler_vendor"]) |
| 73 |
|
| 74 |
AC_MSG_RESULT(["$ax_cxx_compiler_version"]) |
| 75 |
AC_SUBST([CXX_VERSION_VENDOR],["$ax_cv_c_compiler_vendor"]) |
| 76 |
AC_SUBST([CXX_VERSION],["$ax_cxx_compiler_version"]) |
| 77 |
]) |
| 78 |
|
| 79 |
AC_DEFUN([AX_COMPILER_VERSION], |
| 80 |
[AC_REQUIRE([AX_COMPILER_VENDOR]) |
| 81 |
|
| 82 |
AC_MSG_CHECKING([MINGW]) |
| 83 |
AC_CHECK_DECL([__MINGW64__], |
| 84 |
[MINGW=yes |
| 85 |
ax_c_compiler_version_vendor=mingw], |
| 86 |
[MINGW=no]) |
| 87 |
AC_MSG_RESULT([$MINGW]) |
| 88 |
|
| 89 |
AC_REQUIRE([_C_COMPILER_VERSION]) |
| 90 |
AC_REQUIRE([_CXX_COMPILER_VERSION]) |
| 91 |
AS_IF([test "x$GCC" = xyes], |
| 92 |
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ |
| 93 |
#if !defined(__GNUC__) || (__GNUC__ < 4) || ((__GNUC__ >= 4) && (__GNUC_MINOR__ < 7)) |
| 94 |
# error GCC is Too Old! |
| 95 |
#endif |
| 96 |
]])], |
| 97 |
[ac_c_gcc_recent=yes], |
| 98 |
[ac_c_gcc_recent=no]) |
| 99 |
]) |
| 100 |
]) |