From: Simon Josefsson Date: Mon, 18 May 2009 13:13:50 +0000 (+0200) Subject: Don't build with warnings all the time. Use a WERROR_CFLAGS. X-Git-Tag: gnutls_2_7_11~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=166b66760c8cab9e697279a0a25f9bbd457f1692;p=thirdparty%2Fgnutls.git Don't build with warnings all the time. Use a WERROR_CFLAGS. --- diff --git a/NEWS b/NEWS index 26df441dad..8f55f341db 100644 --- a/NEWS +++ b/NEWS @@ -17,6 +17,9 @@ Reported by Andreas Metzler in Reported by "Tom G. Christensen" in +** Building with many warning flags now requires --enable-gcc-warnings. +This avoids crying wolf for normal compiles. + ** API and ABI modifications: No changes since last version. diff --git a/cfg.mk b/cfg.mk index 1ceb691dbd..db54e7b947 100644 --- a/cfg.mk +++ b/cfg.mk @@ -18,9 +18,9 @@ # along with this file; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -WFLAGS ?= WARN_CFLAGS=-Werror +WFLAGS ?= --enable-gcc-warnings ADDFLAGS ?= -CFGFLAGS ?= --enable-gtk-doc $(ADDFLAGS) +CFGFLAGS ?= --enable-gtk-doc $(ADDFLAGS) $(WFLAGS) INDENT_SOURCES = `find . -name \*.c|grep -v -e ^./lgl -e ^./gl -e ^./src/cfg -e -gaa.c -e asn1_tab.c` @@ -52,7 +52,7 @@ update-po: refresh-po git commit -m "Sync with TP." $(PODIR)/LINGUAS $(PODIR)/*.po.in bootstrap: autoreconf - $(WFLAGS) ./configure $(CFGFLAGS) + ./configure $(CFGFLAGS) glimport: gnulib-tool --m4-base gl/m4 --import diff --git a/configure.ac b/configure.ac index 4bfe58a7dd..365173361e 100644 --- a/configure.ac +++ b/configure.ac @@ -183,8 +183,20 @@ AC_PROG_LIBTOOL gl_INIT -# Add many warnings, except some... -if test "$GCC" = "yes"; then +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]) + nw="$nw -Wsystem-headers" # Don't let system headers trigger warnings nw="$nw -Wc++-compat" # We don't care about C++ compilers nw="$nw -Wundef" # Warns on '#if GNULIB_FOO' etc in gnulib @@ -205,11 +217,13 @@ if test "$GCC" = "yes"; then nw="$nw -Wformat-nonliteral" # Incompatible with gettext _() nw="$nw -Wunsafe-loop-optimizations" nw="$nw -Wstrict-overflow" + gl_MANYWARN_ALL_GCC([ws]) gl_MANYWARN_COMPLEMENT(ws, [$ws], [$nw]) for w in $ws; do gl_WARN_ADD([$w]) done + gl_WARN_ADD([-Wno-missing-field-initializers]) # We need this one gl_WARN_ADD([-Wno-sign-compare]) # Too many warnings for now gl_WARN_ADD([-Wno-pointer-sign]) # Too many warnings for now @@ -220,6 +234,7 @@ if test "$GCC" = "yes"; then fi # Export things for */configure.ac. +export WERROR_CFLAGS export WARN_CFLAGS export use_cxx @@ -269,7 +284,7 @@ AC_MSG_NOTICE([summary of build options: Host type: ${host} Install prefix: ${prefix} Compiler: ${CC} - Warning flags: ${WARN_CFLAGS} + Warning flags: errors: ${WERROR_CFLAGS} warnings: ${WARN_CFLAGS} Library types: Shared=${enable_shared}, Static=${enable_static} Valgrind: ${VALGRIND} Guile wrappers: $opt_guile_bindings diff --git a/doc/examples/Makefile.am b/doc/examples/Makefile.am index 9cab8d4742..f5bc40a9a0 100644 --- a/doc/examples/Makefile.am +++ b/doc/examples/Makefile.am @@ -19,7 +19,7 @@ # along with this file; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -AM_CFLAGS = $(WARN_CFLAGS) +AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS) AM_CPPFLAGS = \ -I$(top_srcdir)/lib/includes -I$(top_builddir)/lib/includes \ -I$(top_srcdir)/libextra/includes \ diff --git a/lib/Makefile.am b/lib/Makefile.am index 0d923d7ae3..7180b3cd50 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -29,7 +29,7 @@ endif localedir = $(datadir)/locale -AM_CFLAGS = $(WARN_CFLAGS) +AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS) AM_CPPFLAGS = \ -DLOCALEDIR=\"$(localedir)\" \ -I$(srcdir)/gl \ diff --git a/lib/configure.ac b/lib/configure.ac index a8616f86a1..f77d10cc4f 100644 --- a/lib/configure.ac +++ b/lib/configure.ac @@ -88,6 +88,7 @@ AC_SUBST(LIBGNUTLS_CFLAGS) # Finish things from ../configure.ac. AC_SUBST([WARN_CFLAGS]) +AC_SUBST([WERROR_CFLAGS]) AC_PROG_CXX AM_CONDITIONAL(ENABLE_CXX, test "$use_cxx" != "no") diff --git a/lib/openpgp/Makefile.am b/lib/openpgp/Makefile.am index 1cdfb1bf10..b1f3e4efd2 100644 --- a/lib/openpgp/Makefile.am +++ b/lib/openpgp/Makefile.am @@ -20,7 +20,7 @@ # Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA -AM_CFLAGS = $(WARN_CFLAGS) +AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS) AM_CPPFLAGS = \ -I$(srcdir)/../gl \ -I$(builddir)/../gl \ diff --git a/lib/x509/Makefile.am b/lib/x509/Makefile.am index 3f145aae90..bffaedd640 100644 --- a/lib/x509/Makefile.am +++ b/lib/x509/Makefile.am @@ -18,7 +18,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, # USA -AM_CFLAGS = $(WARN_CFLAGS) +AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS) AM_CPPFLAGS = \ -I$(srcdir)/../gl \ -I$(builddir)/../gl \ diff --git a/libextra/Makefile.am b/libextra/Makefile.am index 07227673b3..5899e80b4f 100644 --- a/libextra/Makefile.am +++ b/libextra/Makefile.am @@ -22,7 +22,7 @@ ACLOCAL_AMFLAGS = -I m4 -I gl/m4 -I ../lib/m4 -AM_CFLAGS = $(WARN_CFLAGS) +AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS) AM_CPPFLAGS = \ -I$(srcdir)/../lib/gl \ -I$(builddir)/../lib/gl \ diff --git a/libextra/configure.ac b/libextra/configure.ac index 61b6523a3d..6d7d1630bf 100644 --- a/libextra/configure.ac +++ b/libextra/configure.ac @@ -47,6 +47,7 @@ AC_SUBST(LIBGNUTLS_EXTRA_CFLAGS) # Finish things from ../configure.ac. AC_SUBST([WARN_CFLAGS]) +AC_SUBST([WERROR_CFLAGS]) AC_CONFIG_FILES([ Makefile diff --git a/src/Makefile.am b/src/Makefile.am index c792f3b0c7..92f59a23ea 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -21,7 +21,7 @@ EXTRA_DIST = README README.srptool SUBDIRS = cfg -AM_CFLAGS = $(WARN_CFLAGS) +AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS) AM_CPPFLAGS = \ -I$(srcdir)/../gl \ -I$(builddir)/../gl \ diff --git a/tests/Makefile.am b/tests/Makefile.am index d787a108cd..0b09cc80de 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -28,7 +28,7 @@ endif EXTRA_DIST = libgcrypt.supp hostname-check.README -AM_CFLAGS = $(WARN_CFLAGS) +AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS) AM_CPPFLAGS = \ -I$(top_srcdir)/gl \ -I$(top_builddir)/gl \