From 22a2a43021e8e82226d4b33189e77673b7326c95 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Wed, 12 Nov 2008 11:11:54 +0100 Subject: build: add configure-time --enable-gcc-warnings option; avoid warnings * bootstrap.conf (gnulib_modules): Add "warnings" module. * configure.ac: Add --enable-gcc-warnings, derived from code in bison. * src/Makefile.am (AM_CFLAGS): Set to $(WARN_CFLAGS) # $(WERROR_CFLAGS) * lib/Makefile.am (AM_CFLAGS): Change spelling to $(WARN_CFLAGS) Don't use $(WERROR_CFLAGS), yet. * src/system.h (usage): Declare. * src/base64.c (usage): Declare to be global, for consistency. * src/timeout.c (usage): Likewise. * src/truncate.c (usage): Likewise. * src/getlimits.c (usage): Likewise. * src/pinky.c (ttyname): Declare with prototype, rather than an empty argument list. * src/who.c (ttyname): Likewise. * src/su.c (crypt, getusershell, setusershell, endusershell): Likewise. --- configure.ac | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index 549c7ee2c..f165893a0 100644 --- a/configure.ac +++ b/configure.ac @@ -44,6 +44,39 @@ gl_EARLY gl_INIT coreutils_MACROS +AC_ARG_ENABLE([gcc-warnings], + [AS_HELP_STRING([--enable-gcc-warnings], + [turn on lots of GCC warnings (not recommended)])], + [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]) + gl_WARN_ADD([-Wall]) + gl_WARN_ADD([-Wextra]) + gl_WARN_ADD([-Wshadow]) + gl_WARN_ADD([-Wno-sign-compare]) + gl_WARN_ADD([-Wformat]) + gl_WARN_ADD([-Wformat-security]) + gl_WARN_ADD([-Wcast-align]) + gl_WARN_ADD([-Wpointer-arith]) + gl_WARN_ADD([-Wwrite-strings]) + gl_WARN_ADD([-Wbad-function-cast]) + gl_WARN_ADD([-Wmissing-declarations]) + gl_WARN_ADD([-Wmissing-prototypes]) + gl_WARN_ADD([-Wstrict-prototypes]) + 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]) +fi + AC_FUNC_FORK optional_bin_progs= -- cgit v1.2.3-54-g00ecf