summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorErik de Castro Lopo <erikd@mega-nerd.com>2013-11-22 18:13:36 +1100
committerErik de Castro Lopo <erikd@mega-nerd.com>2013-11-22 18:13:40 +1100
commita6a4b6f2052829c205319ecb0f5df553baedc9a4 (patch)
tree2f97b1c5f9b2bcc72e7eb1187fbda801eef8d93a /m4
parent8e2eea6322348de674ebb4d3a2295131c92b0c49 (diff)
downloadflac-a6a4b6f2052829c205319ecb0f5df553baedc9a4.tar.gz
Detect Clang masquerading as GCC.
Autoconf detects the Clang compiler as GNU GCC (clang sets defines like __GNUC__ etc) but Clang is *not* completely compatible. If we detect Clang we set ac_vc_c_compiler_gnu to 'no'.
Diffstat (limited to 'm4')
-rw-r--r--m4/clang.m431
-rw-r--r--m4/really_gcc.m432
2 files changed, 63 insertions, 0 deletions
diff --git a/m4/clang.m4 b/m4/clang.m4
new file mode 100644
index 00000000..036f0e68
--- /dev/null
+++ b/m4/clang.m4
@@ -0,0 +1,31 @@
+dnl @synopsis XIPH_C_COMPILER_IS_CLANG
+dnl
+dnl Find out if a compiler claiming to be gcc really is gcc (clang lies).
+dnl @version 1.0 Oct 31 2013
+dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+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([XIPH_C_COMPILER_IS_CLANG],
+[AC_CACHE_CHECK(whether we are using the CLANG C compiler,
+ xiph_cv_c_compiler_clang,
+ [ AC_LANG_ASSERT(C)
+ AC_TRY_LINK([
+ #include <stdio.h>
+ ],
+ [
+ #ifndef __clang__
+ This is not clang!
+ #endif
+ ],
+ xiph_cv_c_compiler_clang=yes,
+ xiph_cv_c_compiler_clang=no
+ ])
+ )]
+)
diff --git a/m4/really_gcc.m4 b/m4/really_gcc.m4
new file mode 100644
index 00000000..cba53ab3
--- /dev/null
+++ b/m4/really_gcc.m4
@@ -0,0 +1,32 @@
+dnl @synopsis XIPH_GCC_REALLY_IS_GCC
+dnl
+dnl Find out if a compiler claiming to be gcc really is gcc (clang lies).
+dnl @version 1.0 Oct 31 2013
+dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+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([XIPH_GCC_REALLY_IS_GCC],
+[ AC_LANG_ASSERT(C)
+ if test "x$ac_cv_c_compiler_gnu" = "xyes" ; then
+ AC_TRY_LINK([
+ #include <stdio.h>
+ ],
+ [
+ #ifdef __clang__
+ This is clang!
+ #endif
+ ],
+ ac_cv_c_compiler_gnu=yes,
+ ac_cv_c_compiler_gnu=no
+ )
+ fi
+])