bug-make
[Top][All Lists]
Advanced

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

Re: Idea: Add .COMMANDCHANGE and .CACHE


From: David A. Wheeler
Subject: Re: Idea: Add .COMMANDCHANGE and .CACHE
Date: Mon, 10 Jun 2019 21:14:49 -0400 (EDT)

On Mon, 10 Jun 2019 15:40:53 -0800, Britton Kerin <address@hidden> wrote:
> No, just the rules that :Makefile, which you can easily tune if it matters.
> Heck, you can include some_fragment.mk that has the recipes that
> are a concern and depend on that if you really need that granularity,
> and then the dependency that you want is explicit.

Using a lot of some_fragment.mk files gets you *closer*, but it's not
the same thing.  My proposed .COMMANDCHANGE depends on
the *expanded* set of commands, not the original commands.
That way, if you change a value (say CCFLAGS) the set of commands
is considered *different* and will be re-run.

For example:

In file x.c.mk:
x.o: x.c
<TAB>$(CC) $(CCFLAGS) -o x.o x.c

In file Makefile:
include x.c.mk

main: x.o x.c.mk
...


Let's say I run this with:
  make CCFLAGS="-O1" main
and in run #2 say:
  make CCFLAGS="-O3" main

In run #2 the file x.c.mk has not changed,
and x.o is still after x.c.
Therefore, x.o will not be regenerated.

If we add:
.COMMANDCHANGE:

then a change to CCFLAGS *will* cause re-execution
of the rule that generates x.o.

--- David A. Wheeler



reply via email to

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