automake
[Top][All Lists]
Advanced

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

Re: AM_CFLAGS not included in translation unit compilation


From: Ralf Wildenhues
Subject: Re: AM_CFLAGS not included in translation unit compilation
Date: Mon, 12 Dec 2005 15:48:25 +0100
User-agent: Mutt/1.5.11

Hi Mike,

* Mike Mattie wrote on Sat, Dec 10, 2005 at 07:24:35PM CET:
> On 12/8/05, Ralf Wildenhues <address@hidden> wrote:
> > * Mike Mattie wrote on Fri, Dec 09, 2005 at 12:59:33AM CET:
> > >
> > > In a recent project I noticed that the individual compilation units do
> > > not include AM_CFLAGS in the invocation of the compiler, however
> > > when the program is constructed in the linking phase the AM_CFLAGS
> > > variable is used. Is there a rational for this ? I would like
> > > to place debugging (-g) in AM_CFLAGS and instead I am placing it in 
> > > prog_CFLAGS.
> >
> > Does reading this chapter of the documentation answer your question?
> > http://sources.redhat.com/automake/automake.html#Flag-Variables-Ordering
> 
> actually it makes me think even more that my automake (1.9.6) has a
> regression against the behavior of previous releases and the
> documentation.

Depends.  I would call it a bugfix rather than a regression.
But let's be precise here.  Here's a cooked-down version of your issue:

touch foo.c bar.c
cat >configure.ac <<EOF
AC_INIT
AM_INIT_AUTOMAKE([foo], [0.1])
AC_PROG_CC
AM_PROG_CC_C_O
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
EOF
cat >Makefile.am <<EOF
AM_CFLAGS = -amcflags
bin_PROGRAMS = foo bar
foo_CFLAGS = -foocflags
EOF
aclocal
automake -a --foreign
autoconf
grep -C2 CFLAGS Makefile.in

For different Automake versions, the following happens:
1.4:  no use of foo_CFLAGS at all.

1.5:  foo_CFLAGS are used for compiling foo.c, but not for linking
      AM_CFLAGS used for compiling bar.c, and for linking both.

Ditto for everything up to 1.9.6 (I believe).

1.9a: AM_CFLAGS used for compiling and linking bar,
      foo_CFLAGS used for compiling and linking foo.

Never are foo_CFLAGS and AM_CFLAGS used *both* on the same command line.
This corresponds to the fact that with many compilers, compilation flags
are not easily overridable, and the primary intended use of foo_CFLAGS
was to give the developer a way to override AM_CFLAGS (I think).

> AM_CFLAGS is clearly missing. however AM_CFLAGS is referanced when
> server.o is linked from sever-server.o

I don't think server.o would ever be used to create sever-server.o.
Automake never issues incremental linking rules itself.  Maybe you
meant 
  server is linked from sever-server.o
?

> I think this is clearly wrong. I have a older autotools project from
> 2003 where I clearly relied on compiler flags for translation units
> being referenced from AM_CFLAGS across the entire
> project.

Well, I don't see any automake version where it would have worked this
way, in that AM_CFLAGS would have been used during compilation.  Except
for when foo_CFLAGS wasn't supported at all.

> If I wished to include flags at the link phase only I would choose
> _LDFLAGS after reading the documentation.

Yes.  AM_CFLAGS and AM_LDFLAGS clearly do have different use though.

> I think the above demonstrates that it is not a ordering issue, rather
> that a variable that should be included in a compilation is missing
> altogether.

Do you still think this?

> What I need to know is will the upstream maintainers call this one as a bug ?

Can't answer that, but I still don't see the way it regresses.  Sorry.

Cheers,
Ralf




reply via email to

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