Markus Armbruster <arm...@redhat.com> writes:

> Blue Swirl <blauwir...@gmail.com> writes:
>
>> Add logic to detect changes in generated files. If the old
>> and new files are identical, don't touch the generated file.
>> This avoids a lot of churn since many files depend on trace.h.
>>
>> Signed-off-by: Blue Swirl <blauwir...@gmail.com>
>> ---
>>  Makefile |   18 ++++++++++++++++--
>>  1 files changed, 16 insertions(+), 2 deletions(-)
>>
>> diff --git a/Makefile b/Makefile
>> index ff39025..085e8ed 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -107,10 +107,24 @@ ui/vnc.o: QEMU_CFLAGS += $(VNC_TLS_CFLAGS)
>>  bt-host.o: QEMU_CFLAGS += $(BLUEZ_CFLAGS)
>>
>>  trace.h: $(SRC_PATH)/trace-events config-host.mak
>> -    $(call quiet-command,sh $(SRC_PATH)/tracetool --$(TRACE_BACKEND) -h
>> < $< > $@,"  GEN   $@")
>> +    $(call quiet-command,sh $(SRC_PATH)/tracetool --$(TRACE_BACKEND) -h
>> < $< > $...@.tmp,"  GEN   $@")
>> +    @if test -f $@; then \
>> +      if ! cmp -s $@ $...@.tmp; then \
>> +        mv $...@.tmp $@; \
>> +      fi; \
>> +     else \
>> +      mv $...@.tmp $@; \
>> +     fi
>
> Why the conditional?  cmp -s fails fine when argument files don't exist.
>
> Note that common versions of make including GNU Make do not stat a
> rule's target to check whether the rule changed it.  Instead, they
> assume it changed, and remake everything depending on it.

That was from memory.  And my example makefile to illustrate the problem
was flawed.  So your patch might work reliably after all.  The common
make voodoo incantation for this is a stamp file, though, as Paolo
pointed out.

[...]

Reply via email to