This is the mail archive of the binutils@sourceware.cygnus.com mailing list for the binutils project.


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

Re: RFC src/configure* - "CFLAGS=-g -O" instead of "CFLAGS=... -Wall"


Michael Snyder wrote:
> 
> Geoff Keating wrote:
> >
> > > Date: Wed, 05 Apr 2000 09:53:42 +1000
> > > From: Andrew Cagney <ac131313@cygnus.com>
> > > Organization: Cygnus Solutions
> > > X-Accept-Language: en
> > >
> > > Hello,
> > >
> > > At present the top level configure + Makefile.in force (when GCC) CFLAGS
> > > to:
> > >
> > >       CFLAGS = -g -O -Wall
> > >
> > > I'd like to scale that back to just:
> > >
> > >       CFLAGS = -g -O
> > >
> > > letting each sub directory set their own -W* policy.  The src/gdb and
> > > src/sim directories try to do this now using separate WARN_CFLAGS (only
> > > they get overuled by CFLAGS :-).
> >
> > GCC has
> >
> > CFLAGS = -g @stage1_warn_cflags@
> > WARN_CFLAGS = -W -Wall -Wtraditional
> >
> > where @stage1_warn_cflags@ gets turned into $(WARN_CFLAGS), or not,
> > depending on whether the compiler is GCC.  This also gets overruled
> > from the toplevel CFLAGS, which is probably why the -Wall is there.
> 
> I believe ALL the subdirectory CFLAGS are overruled by the
> toplevel CFLAGS.  If we make this change, then in order to
> get the -Wall behavior, it will be necessary to run make
> from the subdirectory, or pass CFLAGS in to make.

Yes.

And it is about here that what I planned goes horribly wrong.... :-)


Basic problem.  I can't see a way of differentiating between:

	make
and	make WARN_CFLAGS=

This is important as the top-level make shouldn't pass down
``WARN_CFLAGS='' in the first case but should in the second.  The
existing techniques:

	make WARN_CFLAGS="$(WARN_CFLAGS)"
or	make "`echo 'CFLAGS=$(CFLAGS)' | sed -e s/.*=$$/XFOO=/`"

don't cover this.  The first assumes that by default the top level does
define the variable while the second assumes that by default the sub
makefile does not define the variable.


Looking at changes: CFLAGS=-g -O2

For this to work, the sub-makefiles need to define something like
``ALL_CFLAGS'' (GDB and GCC do, BINUTILS doesn't) vis:

	ALL_CFLAGS = $(CFLAGS) $(WARN_CFLAGS)

what does binutils think of this?  A way of optionally passing down
WARN_CFLAGS (as described above) would also be needed.


Lets try: ``'' (CFLAGS not set at top level)

See problem above.



Lets try a delayed evaluation:

	CFLAGS=-g -O2 \$$(WARN_CFLAGS)

and then pass down:

	make "CFLAGS=$(CFLAGS)"

well, pretty close.  Playing around with BSD and GNU make suggests it
probably works.  Just don't know how portable it would be. 

Any make experts?

	Andrew

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