Make rule for src/libpspp/version.c atomic
authorJohn Darrington <john@darrington.wattle.id.au>
Thu, 10 Dec 2015 10:51:08 +0000 (11:51 +0100)
committerJohn Darrington <john@darrington.wattle.id.au>
Thu, 10 Dec 2015 10:51:08 +0000 (11:51 +0100)
This rule could have resulted in a half constructed target if it failed
half way through for any reason.  Now it is all or nothing.

src/libpspp/automake.mk

index 55e1a1f6cc7f60474dd75d49402cd95cd931b0b5..7baa24e05782803576311c4092d7e7cc1b2052f3 100644 (file)
@@ -113,21 +113,22 @@ nodist_src_libpspp_liblibpspp_la_SOURCES = src/libpspp/version.c
 
 src/libpspp/version.c: $(top_srcdir)/AUTHORS Makefile
        @$(MKDIR_P) src/libpspp
-       $(AM_V_GEN)echo "/*     -*- mode: c; buffer-read-only: t -*-" > $@
-       $(AM_V_at)echo "   Generated by src/libpspp/automake.mk --- Do not edit.">> $@
-       $(AM_V_at)echo "" >> $@
-       $(AM_V_at)echo "   The following line is for the benefit of the perl module" >>$@
-       $(AM_V_at)echo "\$$VERSION='$(VERSION_FOR_PERL)';" >> $@
-       $(AM_V_at)echo "*/" >> $@
-       $(AM_V_at)echo "#include \"version.h\"" >> $@
-       $(AM_V_at)echo "const char bare_version[] = \"$(VERSION)\";" >> $@
-       $(AM_V_at)echo "const char version[] = \"GNU $(PACKAGE) $(VERSION)\";" >> $@
+       $(AM_V_GEN)echo "/*     -*- mode: c; buffer-read-only: t -*-" > $@,tmp
+       $(AM_V_at)echo "   Generated by src/libpspp/automake.mk --- Do not edit.">> $@,tmp
+       $(AM_V_at)echo "" >> $@,tmp
+       $(AM_V_at)echo "   The following line is for the benefit of the perl module" >>$@,tmp
+       $(AM_V_at)echo "\$$VERSION='$(VERSION_FOR_PERL)';" >> $@,tmp
+       $(AM_V_at)echo "*/" >> $@,tmp
+       $(AM_V_at)echo "#include \"version.h\"" >> $@,tmp
+       $(AM_V_at)echo "const char bare_version[] = \"$(VERSION)\";" >> $@,tmp
+       $(AM_V_at)echo "const char version[] = \"GNU $(PACKAGE) $(VERSION)\";" >> $@,tmp
        $(AM_V_at)echo "const char stat_version[] = \"GNU $(PACKAGE) $(VERSION) \
-$(AM_V_at)(`LC_ALL=C TZ=UTC date`).\";" >> $@
-       $(AM_V_at)echo "const char host_system[] = \"$(host_triplet)\";" >> $@
-       $(AM_V_at)echo "const char build_system[] = \"$(build_triplet)\";" >> $@
-       $(AM_V_at)echo "const char locale_dir[] = \"$(datadir)/locale\";" >> $@
-       $(AM_V_at)echo "const char examples_dir[] = \"$(examplesdir)\";" >> $@
-       $(AM_V_at)echo "const char *const authors[] = {" >> $@
-       $(AM_V_at)sed -e 's/^/  \"/' -e 's/$$/\",/' $(top_srcdir)/AUTHORS >> $@
-       $(AM_V_at)echo "0 };" >> $@
+$(AM_V_at)(`LC_ALL=C TZ=UTC date`).\";" >> $@,tmp
+       $(AM_V_at)echo "const char host_system[] = \"$(host_triplet)\";" >> $@,tmp
+       $(AM_V_at)echo "const char build_system[] = \"$(build_triplet)\";" >> $@,tmp
+       $(AM_V_at)echo "const char locale_dir[] = \"$(datadir)/locale\";" >> $@,tmp
+       $(AM_V_at)echo "const char examples_dir[] = \"$(examplesdir)\";" >> $@,tmp
+       $(AM_V_at)echo "const char *const authors[] = {" >> $@,tmp
+       $(AM_V_at)sed -e 's/^/  \"/' -e 's/$$/\",/' $(top_srcdir)/AUTHORS >> $@,tmp
+       $(AM_V_at)echo "0 };" >> $@,tmp
+       mv $@,tmp $@