]> git.ipfire.org Git - thirdparty/rsync.git/commitdiff
Always run `mkgitver` prior to a build
authorWayne Davison <wayne@opencoder.net>
Fri, 1 Oct 2021 21:13:00 +0000 (14:13 -0700)
committerWayne Davison <wayne@opencoder.net>
Fri, 1 Oct 2021 21:17:53 +0000 (14:17 -0700)
Some hosts were not running `mkgitver` when they should, so tweak the
script to only update the timestamp when the file's data changes and
then always run the script when performing a build.

Makefile.in
mkgitver

index 0b5973b1e64d6d696367c4e948a6de581e7b954b..c4c00e9649953ccfd3a0370c655c09c5fb4d48be 100644 (file)
@@ -131,12 +131,12 @@ rounding.h: rounding.c rsync.h proto.h
        fi
        @rm -f rounding.out
 
-# While $(wildcard ...) is a GNU make idiom, at least other makes should just turn it into an
-# empty string (we need something that will vanish if we're not building a git checkout).
-# If you want an updated git version w/o GNU make, remove git-version.h after a pull.
-git-version.h: mkgitver $(wildcard $(srcdir)/.git/logs/HEAD)
+git-version.h: ALWAYS_RUN
        $(srcdir)/mkgitver
 
+.PHONY: ALWAYS_RUN
+ALWAYS_RUN:
+
 simd-checksum-x86_64.o: simd-checksum-x86_64.cpp
        @$(srcdir)/cmd-or-msg disable-simd $(CXX) -I. $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $(srcdir)/simd-checksum-x86_64.cpp
 
index 8e76774cce065fc116d5c3327a9543e47f726c4e..49aa150bee666701e2dbcc53a1766414fa1da85d 100755 (executable)
--- a/mkgitver
+++ b/mkgitver
@@ -3,12 +3,18 @@
 srcdir=`dirname $0`
 gitver=`git describe --abbrev=8 2>/dev/null`
 
+if [ ! -f git-version.h ]; then
+    touch git-version.h
+fi
+
 case "$gitver" in
     *.*)
-       echo "#define RSYNC_GITVER \"$gitver\"" >git-version.h
-       ;;
-    *)
-       # We either create an empty file or update the time on what the user gave us.
-       touch git-version.h
+       echo "#define RSYNC_GITVER \"$gitver\"" >git-version.h.new
+       if ! diff git-version.h.new git-version.h >/dev/null; then
+           echo "Updating git-version.h"
+           mv git-version.h.new git-version.h
+       else
+           rm git-version.h.new
+       fi
        ;;
 esac