[PATCH] configure.ac: Add a macro to check for supported compiler flags.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ancient versions of gcc, such as the gcc 4.1.2 in RHEL 5.5, don't
support some -W flags that newer versions do.  Fix up configure.ac
and Makefile.am to use them if you have them.

Signed-off-by: Jim Schutt <jaschut@xxxxxxxxxx>
---
 configure.ac    |   21 +++++++++++++++++++++
 src/Makefile.am |    2 +-
 2 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/configure.ac b/configure.ac
index 5642717..dc4d710 100644
--- a/configure.ac
+++ b/configure.ac
@@ -33,6 +33,27 @@ AC_PROG_CXX
 AC_PROG_MAKE_SET
 AC_PROG_LIBTOOL
 
+# Checks for compiler warning types
+
+# AC_CHECK_CC_FLAG(FLAG_TO_TEST, VARIABLE_TO_SET_IF_SUPPORTED)
+# ---------
+AC_DEFUN([AC_CHECK_CC_FLAG],
+[{
+	AC_LANG_PUSH([C])
+	my_cflags_save="$CFLAGS"
+	CFLAGS="$my_cflags_save $1"
+	AC_MSG_CHECKING([whether $CC accepts $1])
+	AC_COMPILE_IFELSE(AC_LANG_PROGRAM(),
+			  [AC_MSG_RESULT([yes]); AC_SUBST([$2], ["$1"])],
+			  [AC_MSG_RESULT([no])]
+			 )
+	CFLAGS="$my_cflags_save"
+	AC_LANG_POP([C])
+}])
+
+AC_CHECK_CC_FLAG([-Wtype-limits], [WARN_TYPE_LIMITS])
+AC_CHECK_CC_FLAG([-Wignored-qualifiers], [WARN_IGNORED_QUALIFIERS])
+
 # Checks for libraries.
 AC_CHECK_LIB([m], [pow], [true], AC_MSG_FAILURE([libm not found]))
 AC_CHECK_LIB([pthread], [pthread_create], [true], AC_MSG_FAILURE([libpthread not found]))
diff --git a/src/Makefile.am b/src/Makefile.am
index 3113111..071360e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -479,7 +479,7 @@ CLEANFILES += \
 ##
 
 AM_COMMON_FLAGS = -Wall -D__CEPH__ -D_FILE_OFFSET_BITS=64 -D_REENTRANT -D_THREAD_SAFE -rdynamic \
--Wtype-limits -Wignored-qualifiers -Winit-self -Wpointer-arith \
+${WARN_TYPE_LIMITS} ${WARN_IGNORED_QUALIFIERS} -Winit-self -Wpointer-arith \
 -fno-strict-aliasing
 
 AM_CFLAGS = $(AM_COMMON_FLAGS)
-- 
1.6.6


--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [CEPH Users]     [Ceph Large]     [Information on CEPH]     [Linux BTRFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux