help-make
[Top][All Lists]
Advanced

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

Re: solved I think: rebuild if any variable changes. Is it right?


From: Paul Smith
Subject: Re: solved I think: rebuild if any variable changes. Is it right?
Date: Mon, 06 Sep 2021 00:55:00 -0400
User-agent: Evolution 3.36.5-0ubuntu1

Just some notes:

On Sun, 2021-06-27 at 14:31 -0800, Britton Kerin wrote:
>     [ -a $(OSMVF) ]                    \

This is not portable.  The POSIX standard defines the -e option for
exists.  The -a option is available in some shells like bash but is not
required.

>     (diff $(OSMVF) $(NSMVF) >$(SVDOF)) \

If you just want to know if two files are the same as you did in your
previous versions, cmp -s is much faster and simpler than diff.

You can do it more quickly even than that, using make's built-in
functions rather than a shell; why not put all the values into a
variable then read in the existing file and test it and write it out if
it's different?

   OSMV := $(file <$(OSMVF))
   NSMV := $(foreach v,...)

   ifneq ($(OSMV),$(NSMV))
   $(file >$(OSMVF),$(NSMV))
   endif

This doesn't create the diff, though you can make it a bit fancier
inside the ifneq to do that.

But since there's only one instance of this per invocation of make
maybe it doesn't matter.


This is a nice trick.  However, I don't think it's ideally what people
want.  Rather than rebuilding every target if any variable value
changes, I think people would ideally prefer that only the targets
which are impacted by that variable change would be rebuilt.

In order to make that work, what you'd need to do is compare the
expanded recipe for a given target against the expanded recipe that was
used the last time the target was built and rebuild the target if they
were different.  That is a much more difficult thing to do however so
this is a nicely achievable step in that direction.




reply via email to

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