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 eblake@xxxxxxxxxx +1-801-349-2682 Libvirt virtualization library http://libvirt.org
Attachment:
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Autoconf mailing list Autoconf@xxxxxxx http://lists.gnu.org/mailman/listinfo/autoconf