aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--macros/compiler-flags.m441
1 files changed, 41 insertions, 0 deletions
diff --git a/macros/compiler-flags.m4 b/macros/compiler-flags.m4
index 1a5cd8c6b2..51ff70fc05 100644
--- a/macros/compiler-flags.m4
+++ b/macros/compiler-flags.m4
@@ -45,3 +45,44 @@ AC_DEFUN([GNOME_COMPILE_WARNINGS],[
AC_MSG_RESULT($complCFLAGS)
CFLAGS="$CFLAGS $warnCFLAGS $complCFLAGS"
])
+
+dnl For C++, do basically the same thing.
+
+AC_DEFUN([GNOME_CXX_WARNINGS],[
+ AC_ARG_ENABLE(cxx-warnings,
+ [ --enable-cxx-warnings=[no/minimum/yes] Turn on compiler warnings.],,enable_cxx_warnings=minimum)
+
+ AC_MSG_CHECKING(what warning flags to pass to the C++ compiler)
+ warnCXXFLAGS=
+ if test "x$enable_cxx_warnings" != "xno"; then
+ if test "x$GCC" = "xyes"; then
+ case " $CXXFLAGS " in
+ *[\ \ ]-Wall[\ \ ]*) ;;
+ *) warnCXXFLAGS="-Wall -Wno-unused" ;;
+ esac
+
+ ## -W is not all that useful. And it cannot be controlled
+ ## with individual -Wno-xxx flags, unlike -Wall
+ if test "x$enable_cxx_warnings" = "xyes"; then
+ warnCXXFLAGS="$warnCXXFLAGS -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith"
+ fi
+ fi
+ fi
+ AC_MSG_RESULT($warnCXXFLAGS)
+
+ AC_MSG_CHECKING(what language compliance flags to pass to the C compiler)
+ complCFLAGS=
+ if test "x$GCC" = "xyes"; then
+ case " $CXXFLAGS " in
+ *[\ \ ]-ansi[\ \ ]*) ;;
+ *) complCXXFLAGS="$complCXXFLAGS -ansi" ;;
+ esac
+
+ case " $CXXFLAGS " in
+ *[\ \ ]-pedantic[\ \ ]*) ;;
+ *) complCXXFLAGS="$complCXXFLAGS -pedantic" ;;
+ esac
+ fi
+ AC_MSG_RESULT($complCXXFLAGS)
+ CXXFLAGS="$CXXFLAGS $warnCXXFLAGS $complCXXFLAGS"
+])