1 # ===========================================================================
2 # https://github.com/BrianAker/ddm4/
3 # ===========================================================================
7 # AX_C_COMPILER_VERSION()
8 # AX_CXX_COMPILER_VERSION()
12 # Capture version of C/C++ compiler
16 # Copyright (C) 2012 Brian Aker
17 # All rights reserved.
19 # Redistribution and use in source and binary forms, with or without
20 # modification, are permitted provided that the following conditions are
23 # * Redistributions of source code must retain the above copyright
24 # notice, this list of conditions and the following disclaimer.
26 # * Redistributions in binary form must reproduce the above
27 # copyright notice, this list of conditions and the following disclaimer
28 # in the documentation and/or other materials provided with the
31 # * The names of its contributors may not be used to endorse or
32 # promote products derived from this software without specific prior
35 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
36 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
37 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
38 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
39 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
41 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
42 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
43 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
44 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
45 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
49 AC_DEFUN([AX_C_COMPILER_VERSION],
50 [AC_REQUIRE([AX_COMPILER_VENDOR])
51 AC_MSG_CHECKING([C Compiler version])
53 ax_c_compiler_version_vendor="$ax_c_compiler_vendor"
55 AC_CHECK_DECL([__GNUC_PATCHLEVEL__],
57 ax_c_compiler_version_gcc="`$CC --dumpversion`"],
59 AC_MSG_CHECKING([GNUCC])
60 AC_MSG_RESULT([$GNUCC])
62 AC_CHECK_DECL([__SUNPRO_C],[SUNCC=yes],[SUNCC=no])
63 AC_MSG_CHECKING([SUNCC])
64 AC_MSG_RESULT([$SUNCC])
66 AC_CHECK_DECL([__ICC],[INTELCC=yes],[INTELCC=no])
67 AC_MSG_CHECKING([INTELCC])
68 AC_MSG_RESULT([$INTELCC])
70 AC_CHECK_DECL([__clang__],[CLANG=yes],[CLANG=no])
71 AC_MSG_CHECKING([CLANG])
72 AC_MSG_RESULT([$CLANG])
74 AC_CHECK_DECL([__MINGW32__],
76 ax_c_compiler_version_vendor=mingw],
78 AC_MSG_CHECKING([MINGW])
79 AC_MSG_RESULT([$MINGW])
81 AS_CASE(["$ax_c_compiler_version_vendor"],
82 [sun],[ax_c_compiler_version="`$CC -V 2>&1 | sed 1q`"],
83 [intel],[ax_c_compiler_version="`$CC --version 2>&1 | sed 1q`"],
84 [clang],[ax_c_compiler_version="`$CC --version 2>&1 | sed 1q`"],
85 [gnu],[ax_c_compiler_version="`$CC --version | sed 1q`"],
86 [mingw],[ax_c_compiler_version="`$CC --version | sed 1q`"],
87 [ax_c_compiler_version=unknown])
89 AC_MSG_RESULT(["$ax_c_compiler_version"])
90 AC_SUBST([CC_VERSION_VENDOR],["$ax_c_compiler_version_vendor"])
91 AC_SUBST([CC_VERSION],["$ax_c_compiler_version"])
93 AS_IF([test "$GCC" = "yes"],
94 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
95 #if !defined(__GNUC__) || (__GNUC__ < 4) || ((__GNUC__ >= 4) && (__GNUC_MINOR__ < 2))
96 # error GCC is Too Old!
99 [ac_c_gcc_recent=yes],
100 [ac_c_gcc_recent=no])])
103 AC_DEFUN([AX_CXX_COMPILER_VERSION],
104 [AC_REQUIRE([AX_C_COMPILER_VERSION])
105 AC_MSG_CHECKING([C++ Compiler version])
107 AS_CASE(["$ax_c_compiler_version_vendor"],
108 [sun],[ax_cxx_compiler_version="`$CC -V 2>&1 | sed 1q`"],
109 [intel],[ax_cxx_compiler_version="`$CC --version 2>&1 | sed 1q`"],
110 [clang],[ax_cxx_compiler_version="`$CC --version 2>&1 | sed 1q`"],
111 [gnu],[ax_cxx_compiler_version="`$CC --version | sed 1q`"],
112 [mingw],[ax_cxx_compiler_version="`$CC --version | sed 1q`"],
113 [ax_cxx_compiler_version=unknown])
115 AC_MSG_RESULT(["$ax_cxx_compiler_version"])
116 AC_SUBST([CXX_VERSION_VENDOR],["$ax_c_compiler_version_vendor"])
117 AC_SUBST([CXX_VERSION],["$ax_cxx_compiler_version"])