This is the mail archive of the automake@gnu.org mailing list for the automake project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: adding specific C flags for a SINGLE source file


>>> "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




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]