summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile9
-rw-r--r--ot_stats.c6
2 files changed, 10 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index 587af67..a665890 100644
--- a/Makefile
+++ b/Makefile
@@ -40,12 +40,15 @@ FEATURES+=-DWANT_FULLSCRAPE
40#FEATURES+=-D_DEBUG_RANDOMTORRENTS 40#FEATURES+=-D_DEBUG_RANDOMTORRENTS
41 41
42VERSION=1.0.0 42VERSION=1.0.0
43+GIT_VERSION=`sh -c 'test -r .tarball-version && read v < .tarball-version && echo "$$v" || { command -v git >/dev/null && test -d .git && git describe --tags --match "v*" --always --dirty 2>/dev/null; }'` 43TARBALL_VERSION=test -r .tarball-version && read v < .tarball-version && echo "$$v"
44HAVE_GIT=command -v git >/dev/null && test -d .git
45GIT_VERSION=`sh -c '$(TARBALL_VERSION) || { $(HAVE_GIT) && git describe --tags --match "v*" --always --dirty 2>/dev/null; }'`
46OT_TAG=`sh -c '$(TARBALL_VERSION) || { $(HAVE_GIT) && git describe --tags --match "v*" --exact-match 2>/dev/null; }'`
44 47
45OPTS_debug=-D_DEBUG -g -ggdb # -pg -fprofile-arcs -ftest-coverage 48OPTS_debug=-D_DEBUG -g -ggdb # -pg -fprofile-arcs -ftest-coverage
46OPTS_production=-O3 49OPTS_production=-O3
47 50
48CFLAGS+=-DOT_VERSION=\"$(VERSION)\" -DGIT_VERSION=\"$(GIT_VERSION)\" -Wall -pipe -pthread -Wextra -Wwrite-strings #-ansi -pedantic 51CFLAGS+=-DOT_VERSION=\"$(VERSION)\" -DGIT_VERSION=\"$(GIT_VERSION)\" -DOT_TAG=\"$(OT_TAG)\" -Wall -pipe -pthread -Wextra -Wwrite-strings #-ansi -pedantic
49LDFLAGS+=-pthread 52LDFLAGS+=-pthread
50 53
51# Record feature flags as a dep to allow rebuild when they change 54# Record feature flags as a dep to allow rebuild when they change
@@ -173,6 +176,8 @@ install:
173DISTNAME=opentracker-$(VERSION) 176DISTNAME=opentracker-$(VERSION)
174 177
175dist: 178dist:
179 @test "`git describe --tags --match 'v*' --exact-match 2>/dev/null`" = "v$(VERSION)" || \
180 { echo "HEAD must carry the tag v$(VERSION). Tag the release, or correct VERSION."; exit 1; }
176 rm -rf $(DISTNAME) $(DISTNAME).tar.gz 181 rm -rf $(DISTNAME) $(DISTNAME).tar.gz
177 git archive --format=tar --prefix=$(DISTNAME)/ HEAD | tar -xf - 182 git archive --format=tar --prefix=$(DISTNAME)/ HEAD | tar -xf -
178 git describe --tags --match "v*" --always > $(DISTNAME)/.tarball-version 183 git describe --tags --match "v*" --always > $(DISTNAME)/.tarball-version
diff --git a/ot_stats.c b/ot_stats.c
index 5edbe0a..59a9f04 100644
--- a/ot_stats.c
+++ b/ot_stats.c
@@ -635,11 +635,11 @@ void stats_return_tracker_features(char **reply, const char *reply_end) {
635 635
636void stats_return_tracker_version(char **reply, const char *reply_end) { 636void stats_return_tracker_version(char **reply, const char *reply_end) {
637 fmt_append(reply, reply_end, "opentracker %s", OT_VERSION); 637 fmt_append(reply, reply_end, "opentracker %s", OT_VERSION);
638 /* Empty when the build had no git to ask, which is what a release tarball 638 if (*GIT_VERSION && strcmp(GIT_VERSION, OT_TAG))
639 looks like */
640 if (*GIT_VERSION)
641 fmt_append(reply, reply_end, " (%s)", GIT_VERSION); 639 fmt_append(reply, reply_end, " (%s)", GIT_VERSION);
642 fmt_append(reply, reply_end, "\n"); 640 fmt_append(reply, reply_end, "\n");
641 if (*OT_TAG)
642 fmt_append(reply, reply_end, "https://erdgeist.org/gitweb/opentracker/tag/?h=%s\n", OT_TAG);
643} 643}
644 644
645void return_stats_for_tracker(char **reply, const char *reply_end, int mode, int format) { 645void return_stats_for_tracker(char **reply, const char *reply_end, int mode, int format) {