Thread (2 messages) flat view 2 messages, 2 authors, 2016-06-15

Re: [PATCH] Don't write directly to a make target ($@).

From: Timo Hirvonen <hidden>
Date: 2016-06-15 22:42:27

Junio C Hamano [off-list ref] wrote:
Jim Meyering [off-list ref] writes:
quoted
Otherwise, if make is suspended, or killed with prejudice, or if the
system crashes, you could be left with an up-to-date, yet corrupt,
generated file.
Thanks.  Maybe you would want a "make clean" target for them too
if you do this.  I often use $@+ instead of t$@ so that I can
say "rm -f *+" there.
quoted
@@ -496,37 +496,43 @@ builtin-help.o: common-cmds.h
 	rm -f $@ && ln git$X $@
 
 common-cmds.h: Documentation/git-*.txt
-	./generate-cmdlist.sh > $@
+	./generate-cmdlist.sh > t$@
+	mv t$@ $@
 
IOW, like this:

common-cmds.h: Documentation/git-*.txt
	rm -f $@+ $@
        ./generate-cmdlist.sh > $@+
        mv $@+ $@

clean::
	rm -f *+
Or just use one tmp file, i.e. ".tmp" instead of t$@.

-- 
http://onion.dynserv.net/~timo/
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help