Only update the version file on make dist
authorIustin Pop <iustin@google.com>
Mon, 12 Oct 2009 12:20:36 +0000 (14:20 +0200)
committerIustin Pop <iustin@google.com>
Mon, 12 Oct 2009 12:30:43 +0000 (14:30 +0200)
Since on regular compiles the version information is not critical, it's
better to only update it on make dist; furthermore, there it is indeed
needed to regenerate it automatically, without requiring the use of make
maintainerclean beforehand.

This patch simply adds a new phony target that forces regeneration as a
prerequisite for the dist rule.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

Makefile

index 6015109..047089a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -46,13 +46,13 @@ clean:
        cd Ganeti && rm -f *.o *.prof *.ps *.stat *.aux *.hi
        cd Ganeti/HTools && rm -f *.o *.prof *.ps *.stat *.aux *.hi
 
-.PHONY: version
+regen-version:
+       rm -f version
+       $(MAKE) version
+
 version:
-       set -e; \
        if test -d .git; then \
-         git describe > $@.tmp; \
-         cmp -s $@ $@.tmp || mv $@.tmp $@; \
-         rm -f $@.tmp; \
+         git describe > $@; \
        elif test ! -f $@ ; then \
          echo "Cannot auto-generate $@ file"; exit 1; \
        fi
@@ -60,7 +60,7 @@ version:
 Ganeti/HTools/Version.hs: Ganeti/HTools/Version.hs.in version
        sed -e "s/%ver%/$$(cat version)/" < $< > $@
 
-dist: Ganeti/HTools/Version.hs version doc
+dist: regen-version Ganeti/HTools/Version.hs doc
        VN=$$(cat version|sed 's/^v//') ; \
        PFX="ganeti-htools-$$VN" ; \
        ANAME="$$PFX.tar" ; \
@@ -84,4 +84,4 @@ endif
 tags:
        find -name '*.hs' | xargs hasktags -e
 
-.PHONY : all doc maintainer-clean clean dist check tags
+.PHONY : all doc maintainer-clean clean dist check tags regen-version