lmi
[Top][All Lists]
Advanced

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

Re: [lmi] [lmi-commits] master e4abb6e1 14/17: Don't specify nonempty $C


From: Greg Chicares
Subject: Re: [lmi] [lmi-commits] master e4abb6e1 14/17: Don't specify nonempty $CFLAGS or $CXXFLAGS
Date: Wed, 6 Jul 2022 01:48:39 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0

On 7/5/22 11:46, Vadim Zeitlin wrote:
> On Tue, 5 Jul 2022 10:11:27 +0000 Greg Chicares <gchicares@sbcglobal.net> 
> wrote:
> 
> GC> Let's try a concrete example, taking care to follow this advice:
> 
>  Sorry, I'm not sure I follow: what does this example test/prove exactly?

I'm glad to learn that it shows I had misunderstood your intention.

> GC> https://www.gnu.org/software/make/manual/make.html#Overriding
> GC> | The makefile probably specifies the usual value for CFLAGS, like this:
> GC> | CFLAGS=-g
> GC> 
> GC> This makefile's author successfully forces "-fno-omit-frame-pointer",
> GC> but less successfully hopes also to specify a default flag '-g' that
> GC> is intended to persist when the user overrides $CFLAGS using "+=".
> 
>  But it doesn't use += for CFLAGS?

I thought you meant that the makefile user should use "+=", but
instead you mean that the makefile author should use "+="
(whereas the GNU make manual prescribes a simple "=" here).

>  The idea would rather be to write "CFLAGS += -g" in the makefile itself,
> wouldn't it?

I'm not convinced, but let's try:

/opt/lmi/src/lmi[0]$cat eraseme.make                                            
 
CFLAGS += -g

test_flags:
        @echo "CFLAGS is $(CFLAGS)"
/opt/lmi/src/lmi[0]$make -f eraseme.make test_flags                             
     
CFLAGS is -g
/opt/lmi/src/lmi[0]$make CFLAGS="-O3" -f eraseme.make test_flags 
CFLAGS is -O3

If I override CFLAGS on the command line, then "CFLAGS += -g"
in the makefile has no effect.

I don't see any benefit to specifying CFLAGS in the makefile.
I think the best technique is to define ALL_CFLAGS in terms
of CFLAGS, thus:
  ALL_CFLAGS = overridable_flags $(CFLAGS) non_overridable_flags


reply via email to

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