From 3f3114921d643d347c8c9ad1e85de07d101c3e9f Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Mon, 2 Nov 2026 17:02:39 +0100 Subject: Split the Makefile into Mk fragments and fix the default target --- Mk/release.mk | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Mk/release.mk (limited to 'Mk/release.mk') 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 @@ +# .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; }'` + +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 -- cgit v1.3