summaryrefslogtreecommitdiff
path: root/m4/ax_gcc_version.m4
diff options
context:
space:
mode:
authorJeff Mahoney <jeffm@suse.com>2018-04-30 10:37:08 -0400
committerDavid Sterba <dsterba@suse.com>2018-06-07 16:37:35 +0200
commiteb7b42003a7d3a1d4c0253c6d5a248c9078c6d19 (patch)
treef09fbe12c1bac6772668daa4fabc6f48e56bc835 /m4/ax_gcc_version.m4
parent1c73f56f5a41f44a6196d06675cfb0fcdd2bbd9d (diff)
btrfs-progs: build: detect whether -std=gnu90 is supported
GCC releases prior to 4.5.0 don't support -std=gnu90 so btrfs-progs won't build at all on older distros. We can detect whether the compiler supports -std=gnu90 and fall back to -std=gnu89 if it doesn't. AX_CHECK_COMPILE_FLAG is the right way to do this, but it depends on autoconf 2.64. AX_GCC_VERSION has been deprecated, so we'll use that only for earlier autoconf versions so we can drop it when we drop support for older autoconf releases. Signed-off-by: Jeff Mahoney <jeffm@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'm4/ax_gcc_version.m4')
-rw-r--r--m4/ax_gcc_version.m437
1 files changed, 37 insertions, 0 deletions
diff --git a/m4/ax_gcc_version.m4 b/m4/ax_gcc_version.m4
new file mode 100644
index 00000000..63914d55
--- /dev/null
+++ b/m4/ax_gcc_version.m4
@@ -0,0 +1,37 @@
+dnl @synopsis AX_GCC_VERSION(MAJOR, MINOR, PATCHLEVEL, [ACTION-SUCCESS], [ACTION-FAILURE])
+dnl @summary check wither gcc is at least version MAJOR.MINOR.PATCHLEVEL
+dnl @category InstalledPackages
+dnl
+dnl Check whether we are using gcc and, if so, whether its version
+dnl is at least MAJOR.MINOR.PATCHLEVEL
+dnl
+dnl ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
+dnl success/failure.
+dnl
+dnl @version 2005-05-30
+dnl @license GPLWithACException
+dnl @author Steven G. Johnson <stevenj@alum.mit.edu> and Matteo Frigo.
+AC_DEFUN([AX_GCC_VERSION],
+[
+AC_REQUIRE([AC_PROG_CC])
+AC_CACHE_CHECK(whether we are using gcc $1.$2.$3 or later, ax_cv_gcc_$1_$2_$3,
+[
+ax_cv_gcc_$1_$2_$3=no
+if test "$GCC" = "yes"; then
+dnl The semicolon after "yes" below is to pacify NeXT's syntax-checking cpp.
+AC_EGREP_CPP(yes, [
+#ifdef __GNUC__
+# if (__GNUC__ > $1) || (__GNUC__ == $1 && __GNUC_MINOR__ > $2) \
+ || (__GNUC__ == $1 && __GNUC_MINOR__ == $2 && __GNUC_PATCHLEVEL__ >= $3)
+ yes;
+# endif
+#endif
+], [ax_cv_gcc_$1_$2_$3=yes])
+fi
+])
+if test "$ax_cv_gcc_$1_$2_$3" = yes; then
+ m4_default([$4], :)
+else
+ m4_default([$5], :)
+fi
+])