[Top][All Lists]

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

AM_*FLAGS and autoconf

From: Norman Gray
Subject: AM_*FLAGS and autoconf
Date: Tue, 15 Feb 2005 22:50:58 +0000


How ought autoconf macros to pass flags, such as CFLAGS, to automake-generated makefiles? The automake FAQ answer < Ordering> doesn't answer all my questions about this.

In my situation, I want to add -I and -L and other options, determined at configure time, to all of the Fortran, C and C++ compile and link commands in a large set of related components. The logic in question is in project-specific autoconf macros incorporated into a large number of scripts.

Setting CFLAGS in ./configure is out, since this is reserved for the user (in this context, the person running ./configure;make), in the sense that they have to be free to type 'make CFLAGS=xxx' without breaking whatever flags the configure script needs to pass to the makefile.

Setting AM_CFLAGS is also out. The automake documentation talks of this being reserved for the author of, and doesn't mention autoconf at all. The FAQ says `You should not add options to these variables from inside configure either', and makes a number of other wise suggestions which I've recently painfully discovered for myself.

The FAQ's suggests defining differently-named variables and substituting them into the But this isn't really a solution, as it would require me to add


at the top of 300+ files, which is exactly the sort of meaningless boilerplate automake is supposed to save us from. I want to insulate the authors as much as possible from the configuration magic, so that they can write files which look as simple as possible, without using FAQ-recommended tricks.

I've also had success with modifying automake so that &read_main_am_file calls &define_configure_variable on all AC_SUBSTed AM_* variables, with the result that AM_CFLAGS+=blah will work. This appears to match the intent of the preceding call to &define_standard_variables, so this didn't feel outrageous. That works, and is currently my least unfavourite option, but seems more drastic than I'd expect to be necessary. This violates the proscription on setting these variables within configure, though it appears to me to make that proscription less necessary.

It looks like I'm in a similar situation to the author of <>, though the thread following that veered in another direction. The thread including <> seems relevant, but turns into a discussion of what AM_* pattern aclocal should veto.

About the only things left are modifying $FC, $CC and various *LD variables (feels hacky and fragile), and generating rules with extra $(MY_CFLAGS) variables, or the boilerplate mentioned above (ditto).

I seem to have argued myself into an impasse, and therefore convinced myself that I must be missing something obvious. Can anyone give any advice?

Best wishes,


Norman Gray  :  Physics & Astronomy, Glasgow University, UK  :

reply via email to

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