autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AC_CHECK_FUNCS and gcc with -Werror


From: Russ Allbery
Subject: Re: AC_CHECK_FUNCS and gcc with -Werror
Date: Wed, 03 Mar 2010 11:41:16 -0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

Peter Breitenlohner <address@hidden> writes:
> On Wed, 3 Mar 2010, Steffen Dettmer wrote:

>> ohh sorry, I expressd myself wrongly. As I already wrote Eric,
>> for us it does not matter how -Werror is switched internally,
>> only that it is set within Makefile.

> (1) one way to do that is to append -Werror to CFLAGS after doing all
> sorts of tests in configure.ac.  The tests always use the current value
> of CFLAGS.

> (2) as noted by others, appending a mandatory(?) flag to CFLAGS is a bad
> idea (and contradicts the GNU coding standards).  CFLAGS is one of the
> variables passed from configure to Makefile that can also be specified
> on the Make command line, i.e., `is reserved for the user'.

What I do for my projects is add a separate warnings target to my Automake
Makefile.am:

# A set of flags for warnings.  Add -O because gcc won't find some warnings
# without optimization turned on, and add -DDEBUG=1 so we'll also compile all
# debugging code and test it.
WARNINGS = -g -O -DDEBUG=1 -Wall -W -Wendif-labels -Wpointer-arith \
        -Wbad-function-cast -Wwrite-strings -Wstrict-prototypes \
        -Wmissing-prototypes -Wnested-externs -Werror

warnings:
        $(MAKE) V=0 CFLAGS='$(WARNINGS)'
        $(MAKE) V=0 CFLAGS='$(WARNINGS)' $(check_PROGRAMS)

The coding style standard then requires that all code compile with make
warnings before being committed, but that way the distributed code to the
end user doesn't enable aggressive warnings and -Werror, since normally
new warnings on the end-user system are better skipped than used to prompt
a build failure.

Overriding CFLAGS as this target does is not good practice for any target
that would be used by the end user, since the user may have set CFLAGS to
something else, but it's fine for targets like this that are generally
only run by developers.

This approach also lets me use gcc-specific warning flags since I know the
developers will be using gcc, as opposed to end users who may be using a
wide variety of other compilers.

-- 
Russ Allbery (address@hidden)             <http://www.eyrie.org/~eagle/>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]