rabbitmq-components.mk: Compute default PROJECT_VERSION

If `git-revisions.txt` exists, take the version from this file.
Otherwise, use git-describe(1) to compute a version from the working
copy. If it's not a Git clone, fall back to `0.0.0`.

[#130992027]
This commit is contained in:
Jean-Sébastien Pédron 2016-12-06 13:32:24 +01:00
parent 869f8f9763
commit 3243506499
1 changed files with 16 additions and 0 deletions

View File

@ -5,6 +5,22 @@ ifeq ($(.DEFAULT_GOAL),)
.DEFAULT_GOAL = all
endif
# PROJECT_VERSION defaults to:
# 1. the version stored in `git-revisions.txt`, if it exists;
# 2. a version based on git-describe(1).
ifeq ($(PROJECT_VERSION),)
PROJECT_VERSION := $(shell \
if test -f git-revisions.txt; then \
head -n1 git-revisions.txt | \
awk '{print $$$(words $(PROJECT_DESCRIPTION) version);}'; \
else \
(git describe --dirty --abbrev=7 --tags --always --first-parent \
2>/dev/null || echo rabbitmq_v0_0_0) | \
sed -e 's/rabbitmq_v//' -e 's/_/./g' -e 's/-/+/' -e 's/-/./g'; \
fi)
endif
# --------------------------------------------------------------------
# RabbitMQ components.
# --------------------------------------------------------------------