automake
[Top][All Lists]
Advanced

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

Re: adding specific C flags for a SINGLE source file


From: Alexandre Duret-Lutz
Subject: Re: adding specific C flags for a SINGLE source file
Date: Fri, 10 Dec 2004 21:35:11 +0100
User-agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux)

>>> "Bruce" == Bruce Allen <address@hidden> 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





reply via email to

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