Update m4
[awesomized/libmemcached] / m4 / ax_compiler_version.m4
1 # ===========================================================================
2 # https://github.com/BrianAker/ddm4/
3 # ===========================================================================
4 #
5 # SYNOPSIS
6 #
7 # AX_C_COMPILER_VERSION()
8 # AX_CXX_COMPILER_VERSION()
9 #
10 # DESCRIPTION
11 #
12 # Capture version of C/C++ compiler
13 #
14 # LICENSE
15 #
16 # Copyright (C) 2012 Brian Aker
17 # All rights reserved.
18 #
19 # Redistribution and use in source and binary forms, with or without
20 # modification, are permitted provided that the following conditions are
21 # met:
22 #
23 # * Redistributions of source code must retain the above copyright
24 # notice, this list of conditions and the following disclaimer.
25 #
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
29 # distribution.
30 #
31 # * The names of its contributors may not be used to endorse or
32 # promote products derived from this software without specific prior
33 # written permission.
34 #
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.
46
47 #serial 4
48
49 AC_DEFUN([AX_C_COMPILER_VERSION],
50 [AC_REQUIRE([AX_COMPILER_VENDOR])
51 AC_MSG_CHECKING([C Compiler version])
52
53 ax_c_compiler_version_vendor="$ax_c_compiler_vendor"
54
55 AC_CHECK_DECL([__GNUC_PATCHLEVEL__],
56 [GNUCC=yes
57 ax_c_compiler_version_gcc="`$CC --dumpversion`"],
58 [GNUCC=no])
59 AC_MSG_CHECKING([GNUCC])
60 AC_MSG_RESULT([$GNUCC])
61
62 AC_CHECK_DECL([__SUNPRO_C],[SUNCC=yes],[SUNCC=no])
63 AC_MSG_CHECKING([SUNCC])
64 AC_MSG_RESULT([$SUNCC])
65
66 AC_CHECK_DECL([__ICC],[INTELCC=yes],[INTELCC=no])
67 AC_MSG_CHECKING([INTELCC])
68 AC_MSG_RESULT([$INTELCC])
69
70 AC_CHECK_DECL([__clang__],[CLANG=yes],[CLANG=no])
71 AC_MSG_CHECKING([CLANG])
72 AC_MSG_RESULT([$CLANG])
73
74 AC_CHECK_DECL([__MINGW32__],
75 [MINGW=yes
76 ax_c_compiler_version_vendor=mingw],
77 [MINGW=no])
78 AC_MSG_CHECKING([MINGW])
79 AC_MSG_RESULT([$MINGW])
80
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])
88
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"])
92
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!
97 #endif
98 ]])],
99 [ac_c_gcc_recent=yes],
100 [ac_c_gcc_recent=no])])
101 ])
102
103 AC_DEFUN([AX_CXX_COMPILER_VERSION],
104 [AC_REQUIRE([AX_C_COMPILER_VERSION])
105 AC_MSG_CHECKING([C++ Compiler version])
106
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])
114
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"])
118 ])