This is the mail archive of the
automake@gnu.org
mailing list for the automake project.
Re: adding specific C flags for a SINGLE source file
- From: Alexandre Duret-Lutz <adl at src dot lip6 dot fr>
- To: Bruce Allen <ballen at gravity dot phys dot uwm dot edu>
- Cc: automake at gnu dot org
- Date: Fri, 10 Dec 2004 21:35:11 +0100
- Subject: Re: adding specific C flags for a SINGLE source file
- References: <Pine.GSO.4.21.0412091815350.25521-100000@dirac.phys.uwm.edu>
>>> "Bruce" == Bruce Allen <ballen@gravity.phys.uwm.edu> writes:
[...]
Bruce> In other words:
Bruce> libboincbenchmark_a_CXXFLAGS=-O3
Bruce> CXXFLAGS=-g -O2
Bruce> and I end up with
Bruce> -O3 -g -O2.
Bruce> Any idea how to get around this?
I have never been in this situation, so perhaps the idea below
has flaws that I can't see. Basically my impression is that in
this case, `-g -O2' is not some option that the user selected.
So it makes sense to override them locally. However if the user
really had set CFLAGS, you should not override this setting: the
user should always have the last say.
Given this, I think I'd replace AC_PROG_CC by
user_CFLAGS=$CFLAGS
AC_PROG_CC
if test "x$user_CFLAGS" = x; then
# If the user didn't specify CFLAGS, then CFLAGS contains
# a subset of -g -O2 selected by AC_PROG_CC. This is not
# a user setting, and we want to be able to override this
# locally in our rules, so put these flags in a separate
# variable and empty CFLAGS.
AC_SUBST([DEFAULTFLAGS], [$CFLAGS])
CFLAGS=
fi
and in Makefile.am use
foo_CFLAGS = $(DEFAULTFLAGS)
and
libfoo_a_CFLAGS = $(DEFAULTFLAGS) $(O3)
as appropriate.
($(O3) being the Makefile variable that contains -O3 if the compiler
support it).
Does that sound sensible?
--
Alexandre Duret-Lutz