On Wed, Mar 3, 2010 at 3:59 PM, Eric Blake <eblake@xxxxxxxxxx> wrote: >> 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]) (ohh and this piece of M4-language-magic you call `very easy'... will I ever be able to understand a bit of it uhh-ohh...) > # ------------------------------------------------ > # Adds parameter to WARN_CFLAGS if the compiler supports it. For example, > # gl_WARN_ADD([-Wparentheses]). > AC_DEFUN([gl_WARN_ADD], (If I understand correctly, this macro checks if the compiler still runs when the flag is given.) > 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], ahh, you already wrote but I just notice now, it is gcc-option. So instead of --enable-errors we could use --enable-gcc-errors and --enable-cl-errors. > 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) ahh ok this way. Before I change my 352 Makefile.am's: - Can this do harm (e.g. in makefiles for packages without C sources or so)? - Can I simply append `AM_CFLAGS += $(WERROR_CFLAGS)' to each Makefile.am and be done? - should I better use something like `-include warnings.mak' or alike to be more flexible in case I'll need it later? - Alternatively, by accident, ts there some way to tell configure something like: right just before writing config.status, set `CFLAGS=$CFLAGS\ $WERROR_CFLAGS' or so? As Peter suggests? - Instead of changing 352 Makefile.am's, should I change 42 configure.{in,ac} to have a line like CFLAGS=$CFLAGS\ $WERROR_CFLAGS right before AC_OUTPUT? Wouldn't this work, too? But as far as I know the order of macros/statements in configure.in does not mean that the actions are really executed in the order they appear... Would this be an automatic way of what Peter suggests? > > 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. ohh I though configure should configure the compiler flags? We do not want that developers have to know about compiler flags (i.e. they should not need to run make CFLAGS=longListOfStrangeThings), especially when they cross-compile just to check for warnings with compilers for platforms they don't use. oki, Steffen _______________________________________________ Autoconf mailing list Autoconf@xxxxxxx http://lists.gnu.org/mailman/listinfo/autoconf