summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWayne Davison <wayne@opencoder.net>2020-08-01 00:15:06 -0700
committerWayne Davison <wayne@opencoder.net>2020-08-01 00:15:06 -0700
commitd73c26d2b70ce6430bd8fc5cecdb50489829ef12 (patch)
tree5b7d81b08806bf3929b4b938202b0ee32b4f7927
parente83bbeb6735575e1fd178eeaf620c1ab85bd8f93 (diff)
downloadrsync-d73c26d2b70ce6430bd8fc5cecdb50489829ef12.tar.gz
Put git version in a file for between-release versioning.
-rw-r--r--.gitignore1
-rw-r--r--Makefile.in8
-rwxr-xr-xmkgitver10
-rw-r--r--options.c3
4 files changed, 20 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
index 6fb512ee..47d75e91 100644
--- a/.gitignore
+++ b/.gitignore
@@ -32,6 +32,7 @@ aclocal.m4
/rsync
/stunnel-rsyncd.conf
/shconfig
+/git-version.h
/testdir
/tests-dont-exist
/testtmp
diff --git a/Makefile.in b/Makefile.in
index e1060b77..2c30ee5d 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -99,7 +99,7 @@ rsync$(EXEEXT): $(OBJS)
$(OBJS): $(HEADERS)
$(CHECK_OBJS): $(HEADERS)
tls.o xattrs.o: lib/sysxattrs.h
-options.o: latest-year.h help-rsync.h help-rsyncd.h
+options.o: latest-year.h help-rsync.h help-rsyncd.h git-version.h
exclude.o: default-cvsignore.h
loadparm.o: default-dont-compress.h daemon-parm.h
@@ -132,6 +132,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)
+ $(srcdir)/mkgitver
+
simd-checksum-x86_64.o: simd-checksum-x86_64.cpp
@$(srcdir)/cmdormsg disable-simd $(CXX) -I. $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $(srcdir)/simd-checksum-x86_64.cpp
diff --git a/mkgitver b/mkgitver
new file mode 100755
index 00000000..e8461da2
--- /dev/null
+++ b/mkgitver
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+srcdir=`dirname $0`
+
+if test -d "$srcdir/.git"; then
+ gitver=\"`git describe --tags`\" || exit 1
+else
+ gitver=RSYNC_VERSION
+fi
+echo "#define RSYNC_GITVER $gitver" >git-version.h
diff --git a/options.c b/options.c
index 36e88621..0e9f3db6 100644
--- a/options.c
+++ b/options.c
@@ -23,6 +23,7 @@
#include "itypes.h"
#include "ifuncs.h"
#include "latest-year.h"
+#include "git-version.h"
#include <popt.h>
extern int module_id;
@@ -727,7 +728,7 @@ static void print_rsync_version(enum logcode f)
subprotocol = istring(".PR%d", SUBPROTOCOL_VERSION);
#endif
rprintf(f, "%s version %s protocol version %d%s\n",
- RSYNC_NAME, RSYNC_VERSION, PROTOCOL_VERSION, subprotocol);
+ RSYNC_NAME, RSYNC_GITVER, PROTOCOL_VERSION, subprotocol);
rprintf(f, "Copyright (C) 1996-" LATEST_YEAR " by Andrew Tridgell, Wayne Davison, and others.\n");
rprintf(f, "Web site: https://rsync.samba.org/\n");