summaryrefslogtreecommitdiff
path: root/Mk/release.mk
blob: 5c4afe997bfb90a356d3e913e4effb7bfe1ae932 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# .tarball-version is what dist wrote into the tarball
# In a checkout it is absent and git answers instead. A release is always
# tagged, so in a tarball both of these are that tag, and the gitweb link
# is to it. Between releases there is no tag and the version is the commit.
VERSION=1.0.0

TARBALL_VERSION=test -r .tarball-version && read v < .tarball-version && echo "$$v"
HAVE_GIT=command -v git >/dev/null && test -d .git
GIT_VERSION=`sh -c '$(TARBALL_VERSION) || { $(HAVE_GIT) && git describe --tags --match "v*" --always --dirty 2>/dev/null; }'`
OT_TAG=`sh -c '$(TARBALL_VERSION) || { $(HAVE_GIT) && git describe --tags --match "v*" --exact-match 2>/dev/null; }'`

OT_CFLAGS+=-DOT_VERSION=\"$(VERSION)\" -DGIT_VERSION=\"$(GIT_VERSION)\" -DOT_TAG=\"$(OT_TAG)\"

# Roll a release: tag it v$(VERSION), then make dist. The tarball is HEAD by
# construction, so the working tree it was rolled from does not enter into it.
DISTNAME=opentracker-$(VERSION)

dist:
	@test "`git describe --tags --match 'v*' --exact-match 2>/dev/null`" = "v$(VERSION)" || \
		{ echo "HEAD must carry the tag v$(VERSION). Tag the release, or correct VERSION."; exit 1; }
	rm -rf $(DISTNAME) $(DISTNAME).tar.gz
	git archive --format=tar --prefix=$(DISTNAME)/ HEAD | tar -xf -
	git describe --tags --match "v*" --always > $(DISTNAME)/.tarball-version
	tar -czf $(DISTNAME).tar.gz $(DISTNAME)
	rm -rf $(DISTNAME)

.PHONY: dist