path: root/m4/btrfs_detect_cstd.m4
diff options
authorJeff Mahoney <>2018-04-30 10:37:08 -0400
committerDavid Sterba <>2018-06-07 16:37:35 +0200
commiteb7b42003a7d3a1d4c0253c6d5a248c9078c6d19 (patch)
treef09fbe12c1bac6772668daa4fabc6f48e56bc835 /m4/btrfs_detect_cstd.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 <> Signed-off-by: David Sterba <>
Diffstat (limited to 'm4/btrfs_detect_cstd.m4')
1 files changed, 20 insertions, 0 deletions
diff --git a/m4/btrfs_detect_cstd.m4 b/m4/btrfs_detect_cstd.m4
new file mode 100644
index 00000000..f0c45d97
--- /dev/null
+++ b/m4/btrfs_detect_cstd.m4
@@ -0,0 +1,20 @@
+dnl We prefer -std=gnu90 but gcc versions prior to 4.5.0 don't support
+dnl it. AX_CHECK_COMPILE_FLAG is the right way to determine whether a
+dnl particular version of gcc supports a flag, but it requires autoconf
+dnl 2.64. Since (for now) we still want to support older releases
+dnl that ship with autoconf 2.63, we the also-deprecated AX_GCC_VERSION
+dnl macro there.
+ m4_version_prereq([2.64], [
+ AX_CHECK_COMPILE_FLAG([-std=gnu90],
+ [BTRFS_CSTD_FLAGS=-std=gnu90],
+ [BTRFS_CSTD_FLAGS=-std=gnu89])
+ ], [
+ AX_GCC_VERSION([4], [5], [0],
+ [BTRFS_CSTD_FLAGS=-std=gnu90],
+ [BTRFS_CSTD_FLAGS=-std=gnu89])
+ ])