I want to add some warning flags from configure, including -Werror. Using CFLAGS doesn't seem to be a good idea (some autoconf tests stops working), so how about something like this module?
It allows me to add to configure.ac this: gl_WARN_ADD([-Wall]) gl_WARN_ADD([-Wpointer-arith]) gl_WARN_ADD([-Wstrict-prototypes]) gl_WARN_ADD([-Wno-pointer-sign]) gl_WARN_ADD([-Werror]) Or similar. One todo-item would be: Define one AC_SUBST variable per warning flag, so that I can customize exactly which variables to use inside Makefile.am. This can be added later if a patch materializes, and if this really is a good idea. /Simon >From 88dac5949945b72bba1508f6569f5e5deb6222f1 Mon Sep 17 00:00:00 2001 From: Simon Josefsson <[EMAIL PROTECTED]> Date: Mon, 10 Nov 2008 19:04:07 +0100 Subject: [PATCH] Add warnings module. --- ChangeLog | 6 ++++++ MODULES.html.sh | 1 + m4/warnings.m4 | 32 ++++++++++++++++++++++++++++++++ modules/warnings | 16 ++++++++++++++++ 4 files changed, 55 insertions(+), 0 deletions(-) create mode 100644 m4/warnings.m4 create mode 100644 modules/warnings diff --git a/ChangeLog b/ChangeLog index a81aa77..54fe08e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-11-10 Simon Josefsson <[EMAIL PROTECTED]> + + * modules/warnings: New module. + * m4/warnings.m4: New file. + * MODULES.html.sh: Mention warnings module. + 2008-11-10 Eric Blake <[EMAIL PROTECTED]> fdl.texi: revert accidental change to license diff --git a/MODULES.html.sh b/MODULES.html.sh index 5198f0d..d3e5c13 100755 --- a/MODULES.html.sh +++ b/MODULES.html.sh @@ -2972,6 +2972,7 @@ func_all_modules () func_module relocatable-prog func_module relocatable-prog-wrapper func_module relocatable-script + func_module warnings func_end_table element="Support for building documentation" diff --git a/m4/warnings.m4 b/m4/warnings.m4 new file mode 100644 index 0000000..c1ec209 --- /dev/null +++ b/m4/warnings.m4 @@ -0,0 +1,32 @@ +# warnings.m4 serial 1 +dnl Copyright (C) 2008 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Simon Josefsson + +# gl_WARN_INIT +# Initializes WARN_CFLAGS variable. +AC_DEFUN([gl_WARN_INIT], +[ + AC_ARG_VAR(WARN_CFLAGS, [C compiler warning flags]) +]) + +# gl_WARN_ADD([parameter]) adds parameter to WARN_CFLAGS if compiler +# supports it. For example, use gl_WARN_ADD([-Werror]). +AC_DEFUN([gl_WARN_ADD], +[ + AC_MSG_CHECKING([whether compiler handles $1]) + + save_CFLAGS="$CFLAGS" + CFLAGS="${CFLAGS} $1" + AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]), foo=yes, foo=no) + CFLAGS="$save_CFLAGS" + + AC_MSG_RESULT($foo) + + if test "$foo" = "yes"; then + WARN_CFLAGS="$WARN_CFLAGS $1" + fi +]) diff --git a/modules/warnings b/modules/warnings new file mode 100644 index 0000000..c893900 --- /dev/null +++ b/modules/warnings @@ -0,0 +1,16 @@ +Description: +Helper M4 functions for safely adding compiler warning parameters. + +Files: +m4/warnings.m4 + +Depends-on: + +configure.ac: +gl_WARN_INIT + +License: +LGPLv2+ + +Maintainer: +all -- 1.5.6.5