[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: AC_CHECK_FUNCS and gcc with -Werror
From: |
Eric Blake |
Subject: |
Re: AC_CHECK_FUNCS and gcc with -Werror |
Date: |
Wed, 03 Mar 2010 07:59:08 -0700 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666 |
According to Steffen Dettmer on 3/3/2010 7:27 AM:
> I'm sorry, I didn't express well what we want. We do not
> need/want -Werror inside configure. Just inside make.
>
> I'm afraid again I just fail to see the obvious and it is very
> easy to do?
Yes. Here's how m4 does it. It uses the gl_WARN_ADD macro from the
gnulib module manywarnings; but if you choose not to use gnulib, it is a
simple enough macro that you can probably just inline it directly into
configure.ac:
# gl_WARN_ADD(PARAMETER, [VARIABLE = WARN_CFLAGS])
# ------------------------------------------------
# Adds parameter to WARN_CFLAGS if the compiler supports it. For example,
# gl_WARN_ADD([-Wparentheses]).
AC_DEFUN([gl_WARN_ADD],
[AS_VAR_PUSHDEF([gl_Warn], [gl_cv_warn_$1])dnl
AC_CACHE_CHECK([whether compiler handles $1], [gl_Warn], [
save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="${CPPFLAGS} $1"
AC_PREPROC_IFELSE([AC_LANG_PROGRAM([])],
[AS_VAR_SET([gl_Warn], [yes])],
[AS_VAR_SET([gl_Warn], [no])])
CPPFLAGS="$save_CPPFLAGS"
])
AS_VAR_PUSHDEF([gl_Flags], m4_if([$2], [], [[WARN_CFLAGS]], [[$2]]))dnl
AS_VAR_IF([gl_Warn], [yes], [gl_AS_VAR_APPEND([gl_Flags], [" $1"])])
AS_VAR_POPDEF([gl_Flags])dnl
AS_VAR_POPDEF([gl_Warn])dnl
m4_ifval([$2], [AS_LITERAL_IF([$2], [AC_SUBST([$2])], [])])dnl
])
Then in configure.ac, you give the user the option to request extra
compiler flags, and create an AC_SUBST variable containing the result of
the supported flags:
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])
# ... more here, for selecting particular -W warnings
fi
Finally, in Makefile.am, you use those flags. That way, CFLAGS was
unchanged during configure (except temporarily, during gl_WARN_ADD, when
sniffing whether the flag works), but make gets the benefit of the flag:
AM_CFLAGS = $(WERROR_CFLAGS)
> We now have in configure.in (or actually an included .m4 file)
> `CFLAGS="$CFLAGS -Werror";'
That's where you are going wrong. The recommended approach is to modify
CFLAGS in the Makefile, using an AC_SUBST, rather than hard-coding the
modification into configure.
--
Eric Blake address@hidden +1-801-349-2682
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- Re: AC_CHECK_FUNCS and gcc with -Werror, (continued)
- Re: AC_CHECK_FUNCS and gcc with -Werror, Steffen Dettmer, 2010/03/03
- Re: AC_CHECK_FUNCS and gcc with -Werror, Peter Breitenlohner, 2010/03/03
- Re: AC_CHECK_FUNCS and gcc with -Werror, Russ Allbery, 2010/03/03
- Re: AC_CHECK_FUNCS and gcc with -Werror, Steffen Dettmer, 2010/03/03
- Re: AC_CHECK_FUNCS and gcc with -Werror, Russ Allbery, 2010/03/03
- Re: AC_CHECK_FUNCS and gcc with -Werror, Steffen Dettmer, 2010/03/04
- Re: AC_CHECK_FUNCS and gcc with -Werror, Russ Allbery, 2010/03/04
- Re: AC_CHECK_FUNCS and gcc with -Werror, NightStrike, 2010/03/05
- Re: AC_CHECK_FUNCS and gcc with -Werror, Steffen Dettmer, 2010/03/03
- Re: AC_CHECK_FUNCS and gcc with -Werror, Ralf Corsepius, 2010/03/03
- Re: AC_CHECK_FUNCS and gcc with -Werror,
Eric Blake <=
- Re: AC_CHECK_FUNCS and gcc with -Werror, Steffen Dettmer, 2010/03/03
- Re: AC_CHECK_FUNCS and gcc with -Werror, Eric Blake, 2010/03/03
- Re: AC_CHECK_FUNCS and gcc with -Werror, Eric Blake, 2010/03/03
- Re: AC_CHECK_FUNCS and gcc with -Werror, Steffen Dettmer, 2010/03/04
- Re: AC_CHECK_FUNCS and gcc with -Werror, Ralf Wildenhues, 2010/03/06
- Re: AC_CHECK_FUNCS and gcc with -Werror, Steffen Dettmer, 2010/03/04
Re: AC_CHECK_FUNCS and gcc with -Werror, Steffen Dettmer, 2010/03/03