From 0585a54b4a126cdd35df9e4a9a234cce94a17ff6 Mon Sep 17 00:00:00 2001 From: "Gary V. Vaughan" Date: Wed, 18 Sep 2013 15:12:19 +0700 Subject: gnulib: use manywarnings module. * ltdl/m4/gnulib-cache.m4: Import manywarnings. Regenerate. * configure.ac: Support --enable-gcc-warnings configure option. * Makeflie.am (AM_CFLAGS): Honor --enable-gcc-warnings setting. Signed-off-by: Gary V. Vaughan --- Makefile.am | 1 + configure.ac | 46 ++++++++++++++++++++++++++++++++++++++++++++++ ltdl/m4/gnulib-cache.m4 | 1 + 3 files changed, 48 insertions(+) diff --git a/Makefile.am b/Makefile.am index 5047773f..0f680873 100644 --- a/Makefile.am +++ b/Makefile.am @@ -40,6 +40,7 @@ changelog_old = $(srcdir)/ChangeLog.old # Revisit this if libtool on cygwin improves. # See http://lists.gnu.org/archive/html/libtool-patches/2007-02/msg00062.html AM_CPPFLAGS = +AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS) AM_LDFLAGS = -export-dynamic -export-symbols-regex ".*" EXTRA_DIST = BUILT_SOURCES = diff --git a/configure.ac b/configure.ac index f1bdbb7e..62e5459b 100644 --- a/configure.ac +++ b/configure.ac @@ -99,6 +99,52 @@ if test "x$with_included_ltdl" != "xyes"; then CFLAGS="$save_CFLAGS" fi +AC_ARG_ENABLE([gcc-warnings], + [AS_HELP_STRING([--enable-gcc-warnings], + [turn on lots of GCC warnings (for developers)])], + [case $enableval in + yes|no) ;; + *) AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;; + esac + gl_gcc_warnings=$enableval], + [gl_gcc_warnings=no] +) + +if test "$gl_gcc_warnings" = yes; then + gl_WARN_ADD([-Werror], [WERROR_CFLAGS]) + AC_SUBST([WERROR_CFLAGS]) + + nw= + nw="$nw -Waggregate-return" # C90 is anachronistic + nw="$nw -Wlong-long" # C90 is anachronistic + nw="$nw -Wundef" # Warns on '#if GNULIB_FOO' etc in gnulib + nw="$nw -Wtraditional" # Warns on #elif which we use often + nw="$nw -Wsystem-headers" # Don't let system headers trigger warnings + nw="$nw -Wpadded" # Our structs are not packed + nw="$nw -Wredundant-decls" # Gnulib has multiple decls + nw="$nw -Wformat-nonliteral" # Needed in builtin.c + nw="$nw -Wunreachable-code" # Needed in output.c + nw="$nw -Wconversion" # Too many warnings for now + nw="$nw -Wsign-conversion" # Too many warnings for now + nw="$nw -Wtraditional-conversion" # Too many warnings for now + nw="$nw -Wcast-qual" # Too many warnings for now + nw="$nw -Wswitch-enum" # Too many warnings for now + # This, $nw, is the list of warnings we disable. + + gl_MANYWARN_ALL_GCC([ws]) + gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw]) + for w in $ws; do + gl_WARN_ADD([$w]) + done + + gl_WARN_ADD([-fdiagnostics-show-option]) + gl_WARN_ADD([-funit-at-a-time]) + + AC_SUBST([WARN_CFLAGS]) + + AC_DEFINE([_FORTIFY_SOURCE], [2], + [enable compile-time and run-time bounds-checking, and some warnings]) +fi # Use gcc's -pipe option if available: for faster compilation. case "$CFLAGS" in diff --git a/ltdl/m4/gnulib-cache.m4 b/ltdl/m4/gnulib-cache.m4 index bf877a55..c65023f6 100644 --- a/ltdl/m4/gnulib-cache.m4 +++ b/ltdl/m4/gnulib-cache.m4 @@ -66,6 +66,7 @@ gl_MODULES([ intprops inttypes maintainer-makefile + manywarnings memchr2 memcmp2 memmem -- cgit v1.2.1