btrfs-progs/m4/btrfs_detect_cstd.m4
Jeff Mahoney eb7b42003a 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>
2018-06-07 16:37:35 +02:00

21 lines
731 B
Plaintext

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.
AC_DEFUN([BTRFS_DETECT_CSTD],
[
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])
])
AC_SUBST([BTRFS_CSTD_FLAGS])
]) dnl BTRFS_DETECT_CSTD