automake
[Top][All Lists]
Advanced

[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


Greetings,

How ought autoconf macros to pass flags, such as CFLAGS, to automake-generated makefiles? The automake FAQ answer <http://sources.redhat.com/automake/automake.html#Flag-Variables- 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 configure.ac 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 Makefile.am, 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 Makefile.am. But this isn't really a solution, as it would require me to add

    AM_CFLAGS = $(MY_MAGIC_CFLAGS)
    AM_FCFLAGS = $(MY_MAGIC_FCFLAGS)
    ...

at the top of 300+ Makefile.am files, which is exactly the sort of meaningless boilerplate automake is supposed to save us from. I want to insulate the Makefile.am authors as much as possible from the configuration magic, so that they can write Makefile.am 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 <http://lists.gnu.org/archive/html/autoconf/2002-09/msg00228.html>, though the thread following that veered in another direction. The thread including <http://lists.gnu.org/archive/html/automake/2001-02/msg00275.html> 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 Makefile.in 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


--
----------------------------------------------------------------------
Norman Gray  :  Physics & Astronomy, Glasgow University, UK
http://www.astro.gla.ac.uk/users/norman/  :  www.starlink.ac.uk





reply via email to

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