summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2011-03-01 08:26:46 +0100
committerJim Meyering <meyering@redhat.com>2011-03-26 14:20:28 +0100
commit7db26531249dc63cbc83fe98def44beca37545dd (patch)
tree2e1617a643c7ee12e16059bdbb7970680b9f2269
parent2876ed918f00810f399dcb626df61feea389bfac (diff)
downloadpatch-7db26531249dc63cbc83fe98def44beca37545dd.tar.gz
build: accept new configure-time option --enable-gcc-warnings
* configure.ac: Enable many options. * bootstrap.conf (gnulib_modules): Add manywarnings. * src/Makefile.am (AM_CFLAGS): Use $(WARN_CFLAGS) and $(WERROR_CFLAGS).
-rw-r--r--bootstrap.conf1
-rw-r--r--configure.ac91
-rw-r--r--m4/.gitignore2
-rw-r--r--src/Makefile.am2
4 files changed, 96 insertions, 0 deletions
diff --git a/bootstrap.conf b/bootstrap.conf
index b5c029c..759f0d3 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -38,6 +38,7 @@ lchmod
lstat
maintainer-makefile
malloc
+manywarnings
memchr
minmax
mkdir
diff --git a/configure.ac b/configure.ac
index 82e0a52..b3ed541 100644
--- a/configure.ac
+++ b/configure.ac
@@ -46,6 +46,97 @@ AC_SYS_LARGEFILE
AC_HEADER_STDC
gl_INIT
+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=
+ # This, $nw, is the list of warnings we disable.
+ nw="$nw -Wdeclaration-after-statement" # too useful to forbid
+ nw="$nw -Waggregate-return" # anachronistic
+ nw="$nw -Wlong-long" # C90 is anachronistic (lib/gethrxtime.h)
+ nw="$nw -Wc++-compat" # We don't care about C++ compilers
+ nw="$nw -Wundef" # Warns on '#if GNULIB_FOO' etc in gnulib
+ nw="$nw -Wtraditional" # Warns on #elif which we use often
+ nw="$nw -Wcast-qual" # Too many warnings for now
+ nw="$nw -Wconversion" # Too many warnings for now
+ nw="$nw -Wsystem-headers" # Don't let system headers trigger warnings
+ nw="$nw -Wsign-conversion" # Too many warnings for now
+ nw="$nw -Wtraditional-conversion" # Too many warnings for now
+ nw="$nw -Wunreachable-code" # Too many warnings for now
+ nw="$nw -Wpadded" # Our structs are not padded
+ nw="$nw -Wredundant-decls" # openat.h declares e.g., mkdirat
+ nw="$nw -Wlogical-op" # any use of fwrite provokes this
+ nw="$nw -Wformat-nonliteral" # who.c and pinky.c strftime uses
+ nw="$nw -Wvla" # warnings in gettext.h
+ nw="$nw -Wnested-externs" # use of XARGMATCH/verify_function__
+ nw="$nw -Wswitch-enum" # Too many warnings for now
+ nw="$nw -Wswitch-default" # Too many warnings for now
+ nw="$nw -Wstack-protector" # not worth working around
+ # things to fix soon:
+ nw="$nw -Wshadow"
+ nw="$nw -Wmissing-prototypes"
+ nw="$nw -Wmissing-format-attribute"
+ nw="$nw -Wmissing-declarations"
+ nw="$nw -Wstrict-overflow"
+ nw="$nw -Wunsafe-loop-optimizations"
+# nw="$nw -Wfloat-equal" # sort.c, seq.c
+# nw="$nw -Wmissing-format-attribute" # copy.c
+# nw="$nw -Winline" # system.h's readdir_ignoring_dot_and_dotdot
+ # ?? -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-unused-parameter]) # Too many warnings for now
+
+ # In spite of excluding -Wlogical-op above, it is enabled, as of
+ # gcc 4.5.0 20090517, and it provokes warnings in cat.c, dd.c, truncate.c
+ gl_WARN_ADD([-Wno-logical-op])
+
+ gl_WARN_ADD([-fdiagnostics-show-option])
+ gl_WARN_ADD([-funit-at-a-time])
+
+ AC_SUBST([WARN_CFLAGS])
+
+ AC_DEFINE([lint], [1], [Define to 1 if the compiler is checking for lint.])
+ AC_DEFINE([_FORTIFY_SOURCE], [2],
+ [enable compile-time and run-time bounds-checking, and some warnings])
+ AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks])
+
+ # We use a slightly smaller set of warning options for lib/.
+ # Remove the following and save the result in GNULIB_WARN_CFLAGS.
+ nw=
+ nw="$nw -Wuninitialized"
+ nw="$nw -Wunused-macros"
+ nw="$nw -Wmissing-prototypes"
+ nw="$nw -Wold-style-definition"
+ gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
+ AC_SUBST([GNULIB_WARN_CFLAGS])
+
+ # For gnulib-tests, the set is slightly smaller still.
+ nw=
+ nw="$nw -Wstrict-prototypes"
+ gl_MANYWARN_COMPLEMENT([GNULIB_TEST_WARN_CFLAGS],
+ [$GNULIB_WARN_CFLAGS], [$nw])
+ AC_SUBST([GNULIB_TEST_WARN_CFLAGS])
+fi
+
AC_TYPE_MODE_T
AC_TYPE_OFF_T
diff --git a/m4/.gitignore b/m4/.gitignore
index 3171a02..f111425 100644
--- a/m4/.gitignore
+++ b/m4/.gitignore
@@ -53,6 +53,7 @@ lseek.m4
lstat.m4
malloc.m4
malloca.m4
+manywarnings.m4
mbrtowc.m4
mbsinit.m4
mbstate_t.m4
@@ -107,6 +108,7 @@ utimes.m4
vasnprintf.m4
vasprintf.m4
warn-on-use.m4
+warnings.m4
wchar_h.m4
wchar_t.m4
wctype_h.m4
diff --git a/src/Makefile.am b/src/Makefile.am
index c119cfb..fc64a66 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -16,6 +16,8 @@
## Process this file with automake to produce Makefile.in.
+AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS)
+
bin_PROGRAMS = patch
patch_SOURCES = \
bestmatch.h \