Skip to contentSkip to conversation

nfs-utils: Test if extra compiler warnings are available

PATCH In review Justin Mitchell 2 participants 2 messages Mar 7, 2018 – Mar 10, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nfs-utils: Test if extra compiler warnings are available

Some of the latest compiler warnings flags are not available on older compilers so this adds macros to test they are supported

---
 configure.ac | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)
configure.ac +17 -4
index f4eba1f..e0c9039 100644
@@ -550,7 +550,6 @@ my_am_cflags="\
  -Werror=strict-prototypes \
  -Werror=missing-prototypes \
  -Werror=missing-declarations \
- -Werror=format-overflow=2 \
  -Werror=format=2 \
  -Werror=undef \
  -Werror=missing-include-dirs \
@@ -560,15 +559,29 @@ my_am_cflags="\
  -Werror=return-type \
  -Werror=switch \
  -Werror=overflow \
- -Werror=int-conversion \
  -Werror=parentheses \
- -Werror=incompatible-pointer-types \
- -Werror=misleading-indentation \
  -Werror=aggregate-return \
  -Werror=unused-result \
  -fno-strict-aliasing \
 "
 
+AC_DEFUN([CHECK_CCSUPPORT], [
+  my_save_cflags="$CFLAGS"
+  CFLAGS=$1
+  AC_MSG_CHECKING([whether CC supports $1])
+  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
+    [AC_MSG_RESULT([yes])]
+    [$2+=$1],
+    [AC_MSG_RESULT([no])]
+  )
+  CFLAGS="$my_save_cflags"
+])
+
+CHECK_CCSUPPORT([-Werror=format-overflow=2], [my_am_cflags])
+CHECK_CCSUPPORT([-Werror=int-conversion], [my_am_cflags])
+CHECK_CCSUPPORT([-Werror=incompatible-pointer-types], [my_am_cflags])
+CHECK_CCSUPPORT([-Werror=misleading-indentation], [my_am_cflags])
+
 AC_SUBST([AM_CFLAGS], ["$my_am_cflags"])
 
 # Make sure that $ACLOCAL_FLAGS are used during a rebuild
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 4 lines · Justin Mitchell

Some of the latest compiler warnings flags are not available on older compilers so this adds macros to test they are supported

Committed... after a few changes...

steved.

Quoted 50 lines
---
 configure.ac | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)
configure.ac +17 -4
index f4eba1f..e0c9039 100644
@@ -550,7 +550,6 @@ my_am_cflags="\
  -Werror=strict-prototypes \
  -Werror=missing-prototypes \
  -Werror=missing-declarations \
- -Werror=format-overflow=2 \
  -Werror=format=2 \
  -Werror=undef \
  -Werror=missing-include-dirs \
@@ -560,15 +559,29 @@ my_am_cflags="\
  -Werror=return-type \
  -Werror=switch \
  -Werror=overflow \
- -Werror=int-conversion \
  -Werror=parentheses \
- -Werror=incompatible-pointer-types \
- -Werror=misleading-indentation \
  -Werror=aggregate-return \
  -Werror=unused-result \
  -fno-strict-aliasing \
 "
 
+AC_DEFUN([CHECK_CCSUPPORT], [
+  my_save_cflags="$CFLAGS"
+  CFLAGS=$1
+  AC_MSG_CHECKING([whether CC supports $1])
+  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
+    [AC_MSG_RESULT([yes])]
+    [$2+=$1],
+    [AC_MSG_RESULT([no])]
+  )
+  CFLAGS="$my_save_cflags"
+])
+
+CHECK_CCSUPPORT([-Werror=format-overflow=2], [my_am_cflags])
+CHECK_CCSUPPORT([-Werror=int-conversion], [my_am_cflags])
+CHECK_CCSUPPORT([-Werror=incompatible-pointer-types], [my_am_cflags])
+CHECK_CCSUPPORT([-Werror=misleading-indentation], [my_am_cflags])
+
 AC_SUBST([AM_CFLAGS], ["$my_am_cflags"])
 
 # Make sure that $ACLOCAL_FLAGS are used during a rebuild