Subject: Re: [PATCH v2 6/6] Makefile: allow for combining DEVELOPER=1 and CFLAGS="..."

From: Jeff King <[email-masked]>
Date: Fri, 22 Feb 2019 10:29:26 -0500

On Fri, Feb 22, 2019 at 03:41:27PM +0100, Ævar Arnfjörð Bjarmason wrote:

> So let's introduce a "DEVELOPER_CFLAGS" variable in config.mak.dev and
> add it to ALL_CFLAGS. Before this the ALL_CFLAGS variable
> would (basically, there's some nuance we won't go into) be set to:

Yeah, I definitely think this is the right direction, and the patch
looks good to me.

> Examples of things that weren't possible before, but are now:
> 
>     # Use -O0 instead of -O2 for less painful debuggng
>     DEVELOPER=1 CFLAGS="-O0 -g"

Sort an aside, but in my config.mak I have:

  O=0
  CFLAGS = -g -O$(O)

which lets me do "make O=2", which is nice and short. I wonder if other
people would want that, too.

(I default to -O0 because 99% of my compiles are for development and
debugging, so the compile being fast is more important than the build
result being fast; for perf testing or daily use, I use O=2).

> So we could have gotten away with the much smaller change of changing
> "CFLAGS" in config.mak.dev to "DEVELOPER_CFLAGS" and adding that to
> ALL_CFLAGS earlier in the Makefile "before" the config.mak.*
> includes. But I think it's more readable to use variables "after"
> they're included.

I think the reordering does make things more readable overall. And it
may be more sensible if config.mak uses any ":=" assignments.

-Peff