diff --git a/Makefile b/Makefile index 4001b9b01..728ea333e 100644 --- a/Makefile +++ b/Makefile @@ -385,8 +385,9 @@ gen_version.h: FORCE @if cmp $@.new $@ >/dev/null 2>&2; then rm -f $@.new; else mv $@.new $@; echo Version updated; fi # We force make to relink this every time, to detect version changes. +# Do it atomically, otherwise parallel builds can get upset! tools/headerversions: FORCE tools/headerversions.o $(CCAN_OBJS) - @$(LINK.o) tools/headerversions.o $(CCAN_OBJS) $(LOADLIBES) $(LDLIBS) -o $@ + @trap "rm -f $@.tmp.$$$$" EXIT; $(LINK.o) tools/headerversions.o $(CCAN_OBJS) $(LOADLIBES) $(LDLIBS) -o $@.tmp.$$$$ && mv $@.tmp.$$$$ $@ # That forces this rule to be run every time, too. gen_header_versions.h: tools/headerversions