[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: |
Vadim Zeitlin |
Subject: |
Re: [lmi] [lmi-commits] master e4abb6e1 14/17: Don't specify nonempty $CFLAGS or $CXXFLAGS |
Date: |
Tue, 5 Jul 2022 13:46:02 +0200 |
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?
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?
GC> $ cat eraseme.make
GC> CFLAGS=-g
GC> ALL_CFLAGS = -std=c99 $(CFLAGS) -fno-omit-frame-pointer
GC>
GC> %.o: %.c
GC> $(CC) $(ALL_CFLAGS) $< -o$@
GC>
GC> test_flags:
GC> @echo "CFLAGS is $(CFLAGS)"
GC> @echo "ALL_CFLAGS is $(ALL_CFLAGS)"
GC>
GC> With no command-line override, '-g' is used, of course:
GC>
GC> $ make -f eraseme.make test_flags
GC> CFLAGS is -g
GC> ALL_CFLAGS is -std=c99 -g -fno-omit-frame-pointer
GC>
GC> With a command-line override, '-g' vanishes:
GC>
GC> $ make CFLAGS+="-O3 -fomit-frame-pointer" -f eraseme.make test_flags
GC> CFLAGS is -O3 -fomit-frame-pointer
GC> ALL_CFLAGS is -std=c99 -O3 -fomit-frame-pointer -fno-omit-frame-pointer
GC>
GC> Writing "=" instead of "+=" produces the same outcome:
GC>
GC> $ make CFLAGS="-O3 -fomit-frame-pointer" -f eraseme.make test_flags
GC> CFLAGS is -O3 -fomit-frame-pointer
GC> ALL_CFLAGS is -std=c99 -O3 -fomit-frame-pointer -fno-omit-frame-pointer
But nobody writes "+=" on the command line, as it's mostly useless because
there is no value to append to. Well, I guess you could do something like
$ CFLAGS=-fxxx make CFLAGS+=-fyyy ...
but, again, this is something I have literally never seen.
The idea would rather be to write "CFLAGS += -g" in the makefile itself,
wouldn't it?
Sorry again if I'm completely missing the point here, as I have a
suspicion I might be...
VZ
pgp3uOkOxOdN8.pgp
Description: PGP signature