summaryrefslogtreecommitdiff
path: root/Mk/release.mk
diff options
context:
space:
mode:
Diffstat (limited to 'Mk/release.mk')
-rw-r--r--Mk/release.mk27
1 files changed, 27 insertions, 0 deletions
diff --git a/Mk/release.mk b/Mk/release.mk
new file mode 100644
index 0000000..63429ad
--- /dev/null
+++ b/Mk/release.mk
@@ -0,0 +1,27 @@
1# .tarball-version is what dist wrote into the tarball
2# In a checkout it is absent and git answers instead. A release is always
3# tagged, so in a tarball both of these are that tag, and the gitweb link
4# is to it. Between releases there is no tag and the version is the commit.
5VERSION=1.0.0
6
7TARBALL_VERSION=test -r .tarball-version && read v < .tarball-version && echo "$$v"
8HAVE_GIT=command -v git >/dev/null && test -d .git
9GIT_VERSION=`sh -c '$(TARBALL_VERSION) || { $(HAVE_GIT) && git describe --tags --match "v*" --always --dirty 2>/dev/null; }'`
10OT_TAG=`sh -c '$(TARBALL_VERSION) || { $(HAVE_GIT) && git describe --tags --match "v*" --exact-match 2>/dev/null; }'`
11
12CFLAGS+=-DOT_VERSION=\"$(VERSION)\" -DGIT_VERSION=\"$(GIT_VERSION)\" -DOT_TAG=\"$(OT_TAG)\"
13
14# Roll a release: tag it v$(VERSION), then make dist. The tarball is HEAD by
15# construction, so the working tree it was rolled from does not enter into it.
16DISTNAME=opentracker-$(VERSION)
17
18dist:
19 @test "`git describe --tags --match 'v*' --exact-match 2>/dev/null`" = "v$(VERSION)" || \
20 { echo "HEAD must carry the tag v$(VERSION). Tag the release, or correct VERSION."; exit 1; }
21 rm -rf $(DISTNAME) $(DISTNAME).tar.gz
22 git archive --format=tar --prefix=$(DISTNAME)/ HEAD | tar -xf -
23 git describe --tags --match "v*" --always > $(DISTNAME)/.tarball-version
24 tar -czf $(DISTNAME).tar.gz $(DISTNAME)
25 rm -rf $(DISTNAME)
26
27.PHONY: dist