diff --git a/M4/clang.m4 b/M4/clang.m4 new file mode 100644 index 00000000..2d6499e9 --- /dev/null +++ b/M4/clang.m4 @@ -0,0 +1,31 @@ +dnl @synopsis MN_C_COMPILER_IS_CLANG +dnl +dnl Find out if a compiler claiming to be gcc really is gcc (fuck you clang). +dnl @version 1.0 Oct 31 2013 +dnl @author Erik de Castro Lopo +dnl +dnl Permission to use, copy, modify, distribute, and sell this file for any +dnl purpose is hereby granted without fee, provided that the above copyright +dnl and this permission notice appear in all copies. No representations are +dnl made about the suitability of this software for any purpose. It is +dnl provided "as is" without express or implied warranty. +dnl + + +AC_DEFUN([MN_C_COMPILER_IS_CLANG], +[AC_CACHE_CHECK(whether we are using the CLANG C compiler, + mn_cv_c_compiler_clang, + [ AC_LANG_ASSERT(C) + AC_TRY_LINK([ + #include + ], + [ + #ifndef __clang__ + This is not clang! + #endif + ], + AC_MSG_RESULT([yes]), + AC_MSG_RESULT([no]) + ]) + ) +]) diff --git a/M4/really_gcc.m4 b/M4/really_gcc.m4 new file mode 100644 index 00000000..67aed780 --- /dev/null +++ b/M4/really_gcc.m4 @@ -0,0 +1,33 @@ +dnl @synopsis MN_GCC_REALLY_IS_GCC +dnl +dnl Find out if a compiler claiming to be gcc really is gcc (fuck you clang). +dnl @version 1.0 Oct 31 2013 +dnl @author Erik de Castro Lopo +dnl +dnl Permission to use, copy, modify, distribute, and sell this file for any +dnl purpose is hereby granted without fee, provided that the above copyright +dnl and this permission notice appear in all copies. No representations are +dnl made about the suitability of this software for any purpose. It is +dnl provided "as is" without express or implied warranty. +dnl + +# If the configure script has already detected GNU GCC, then make sure it +# isn't CLANG masquerading as GCC. + +AC_DEFUN([MN_GCC_REALLY_IS_GCC], +[ AC_LANG_ASSERT(C) + if test "x$ac_cv_c_compiler_gnu" = "xyes" ; then + AC_TRY_LINK([ + #include + ], + [ + #ifdef __clang__ + This is clang! + #endif + ], + ac_cv_c_compiler_gnu=yes, + ac_cv_c_compiler_gnu=no + ) + fi + +]) diff --git a/configure.ac b/configure.ac index 7f6481a4..510ebf2e 100644 --- a/configure.ac +++ b/configure.ac @@ -24,6 +24,10 @@ AC_PROG_CC_STDC AC_USE_SYSTEM_EXTENSIONS AM_PROG_CC_C_O AC_PROG_CXX + +MN_C_COMPILER_IS_CLANG +MN_GCC_REALLY_IS_GCC + AC_PROG_SED # Do not check for F77. @@ -661,10 +665,11 @@ if test -z "$PKG_CONFIG" ; then echo fi +echo " Tools :" +echo +echo " Compiler is GCC : ..................... ${ac_cv_c_compiler_gnu}" + if test x$ac_cv_c_compiler_gnu = xyes ; then - echo " Tools :" - echo - echo " Compiler is GCC : ..................... ${ac_cv_c_compiler_gnu}" echo " GCC version : ......................... ${GCC_VERSION}" if test $GCC_MAJOR_VERSION -lt 3 ; then echo "\n"