]> granicus.if.org Git - recode/commitdiff
Use gnulib's manywarnings module
authorReuben Thomas <rrt@sc3d.org>
Sat, 13 Jan 2018 22:41:57 +0000 (22:41 +0000)
committerReuben Thomas <rrt@sc3d.org>
Mon, 15 Jan 2018 14:35:36 +0000 (14:35 +0000)
bootstrap.conf
configure.ac
src/Makefile.am

index a67fc32842b4d3494168e19908169a49e438bb2f..86f4ed587cee9d34ac4a2e26e24aa52cd8e4234d 100644 (file)
@@ -1,4 +1,4 @@
-# bootstrap.conf (Recode) version 2017-12-09
+# bootstrap.conf (Recode) version 2018-01-13
 
 # This file is part of Recode.
 #
@@ -50,6 +50,7 @@ gnulib_modules='
         gettext-h
         hash
         localcharset
+        manywarnings
         pathmax
         pipe-posix
         quotearg
index abc053f35c4674812c71ac4f25848c41168ed492..29665db9f0dd42b16ac81a9d22c0d679f80ded50 100644 (file)
@@ -20,6 +20,51 @@ AC_SUBST([objdir])
 LT_SYS_MODULE_EXT
 AC_SUBST([shlibext], [$libltdl_cv_shlibext])
 
+dnl Extra warnings with GCC and compatible compilers
+AC_ARG_ENABLE([gcc-warnings],
+  [AS_HELP_STRING([--disable-gcc-warnings],
+                  [turn off lots of GCC warnings])],
+  [case $enableval in
+     yes|no) ;;
+     *)      AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
+   esac
+   gl_gcc_warnings=$enableval],
+  [gl_gcc_warnings=yes]
+)
+if test "$gl_gcc_warnings" = yes; then
+  dnl Set up the list of undesired warnings.
+  nw=
+  nw="$nw -Wsystem-headers"   # Don’t let system headers trigger warnings
+  nw="$nw -Wundef"            # All compiler preprocessors support #if UNDEF
+  nw="$nw -Wtraditional"      # All compilers nowadays support ANSI C
+  nw="$nw -Wdeclaration-after-statement" # We require C99.
+  nw="$nw -Wstrict-overflow"  # Use a lower level (see below).
+  nw="$nw -Wconversion"       # These warnings usually don’t point to mistakes.
+  nw="$nw -Wsign-conversion"  # Likewise.
+
+  gl_MANYWARN_ALL_GCC([warnings])
+
+  dnl Enable all GCC warnings not in this list.
+  gl_MANYWARN_COMPLEMENT([warnings], [$warnings], [$nw])
+  for w in $warnings; do
+    gl_WARN_ADD([$w])
+  done
+
+  dnl Add an extra warning
+  gl_WARN_ADD([-Wstrict-overflow=1])
+  dnl Add some more safety measures
+  gl_WARN_ADD([-D_FORTIFY_SOURCE=2])
+  dnl Remove a warning being promoted to error: we trigger this and can't turn it off with pragmas.
+  gl_WARN_ADD([-Wno-error=format-security])
+
+  # When compiling with GCC, prefer -isystem to -I when including system
+  # include files, to avoid generating useless diagnostics for the files.
+  ISYSTEM='-isystem '
+else
+  ISYSTEM='-I'
+fi
+AC_SUBST([ISYSTEM])
+
 AC_CONFIG_HEADERS([config.h])
 AC_HEADER_STDC
 AM_ICONV
index fec887ce468d34dafb422c9f43ce497a3592fc8d..f563edb39b1d85fef3221a90a9855f693686c9ac 100644 (file)
@@ -68,7 +68,7 @@ MNEMONICS_DS = $(KELD)/iso10646.def $(KELD)/other.def $(KELD)/control.def
 RFC1345_TXT = $(KELD)/rfc1345.txt
 NOMS_CARACS = $(ALAIN)/NomsSeulsfinal.lst
 
-AM_CPPFLAGS = -I.. -I$(srcdir) -I$(top_srcdir)/lib
+AM_CPPFLAGS = -I.. -I$(srcdir) $(ISYSTEM)$(top_builddir)/lib $(ISYSTEM)$(top_srcdir)/lib $(WARN_CFLAGS)
 DEFS = -DLIBDIR=\"$(libdir)\" @DEFS@
 
 ETAGS_ARGS = $(L_STEPS)