From f74327e7c6497b1818bc6cacdd12d5a6ae2145fb Mon Sep 17 00:00:00 2001 From: Johannes Lange Date: Sun, 3 Apr 2016 14:38:08 +0200 Subject: [PATCH] use git version information if possible, otherwise use information from (I3_)VERSION files (for tarballs) --- common.mk | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/common.mk b/common.mk index 4fe8f2b0..1e738b04 100644 --- a/common.mk +++ b/common.mk @@ -18,12 +18,14 @@ ifndef SYSCONFDIR endif endif -# In dist tarballs, the version is stored in the I3_VERSION and VERSION files. -I3_VERSION := '$(shell [ -f $(TOPDIR)/I3_VERSION ] && cat $(TOPDIR)/I3_VERSION)' -VERSION := '$(shell [ -f $(TOPDIR)/VERSION ] && cat $(TOPDIR)/VERSION)' -ifeq ('',$(I3_VERSION)) -VERSION := $(shell git describe --tags --abbrev=0) -I3_VERSION := '$(shell git describe --tags --always) ($(shell git log --pretty=format:%cd --date=short -n1), branch \"$(shell git describe --tags --always --all | sed s:heads/::)\")' +# In dist and snapshot tarballs, use the I3_VERSION and VERSION files. Otherwise use git information. +ifeq ($(wildcard .git),) + # not in git repository + VERSION := '$(shell [ -f $(TOPDIR)/VERSION ] && cat $(TOPDIR)/VERSION)' + I3_VERSION := '$(shell [ -f $(TOPDIR)/I3_VERSION ] && cat $(TOPDIR)/I3_VERSION)' +else + VERSION := $(shell git describe --tags --abbrev=0) + I3_VERSION := '$(shell git describe --tags --always) ($(shell git log --pretty=format:%cd --date=short -n1), branch \"$(shell git describe --tags --always --all | sed s:heads/::)\")' endif MAJOR_VERSION := $(shell echo ${VERSION} | cut -d '.' -f 1) -- 2.39.5