Tue, 06 May 2014 12:24:46 +0200
Backport makefile fix to not regenerate revision on each make
| Makefile.am | file | annotate | diff | comparison | revisions |
--- a/Makefile.am Tue May 06 11:00:48 2014 +0200 +++ b/Makefile.am Tue May 06 12:24:46 2014 +0200 @@ -84,23 +84,29 @@ GNT_DIR=finch endif -# This is phony, so that we always try to rebuild it. If it succeeds -# in calculating changes, it produces its target; otherwise, its -# target does not exist. -.PHONY: package_revision_raw.txt +# We always try to rebuild all objects that depends on this dummy target. +.FORCE: + # if both attempts fail, then we need to remove the empty file that > # creates, and also make sure that the shell command exits # successfully; the rm -f ensures both -package_revision_raw.txt: +package_revision_raw.txt: .FORCE $(AM_V_GEN)REAL_BLDDIR=$$PWD/$(top_builddir); \ - (hg --cwd $(srcdir) id -i --debug) 2>/dev/null >$@ \ - || rm -f $@ + (hg --cwd $(srcdir) id -i --debug) 2>/dev/null >$@.new \ + || rm -f $@.new + $(AM_V_at)if test -f $@.new; then \ + if ! diff $@ $@.new > /dev/null; then \ + mv $@.new $@; \ + else \ + rm $@.new; \ + fi \ + fi package_revision.h: package_revision_raw.txt $(AM_V_GEN)if test -f $<; then \ - echo "#define REVISION \"`cat $<`\"" > $@; \ + echo "#define REVISION \"`cat $<`\"" > $@; \ fi $(AM_V_at)if test ! -f $@ -a -f $(srcdir)/$@; then \ - cp $(srcdir)/$@ $@; \ + cp $(srcdir)/$@ $@; \ fi $(AM_V_at)test -f $@ || echo "#define REVISION \"unknown\"" > $@