]> git.sur5r.net Git - i3/i3/blobdiff - common.mk
explicitly set filenames to $(basename __FILE__)
[i3/i3] / common.mk
index f202166df5b1f20b576a23fcbc3fd8ce1577ab12..0d2ad51e5b5f613e70f2ab35249c0c9685770cc4 100644 (file)
--- a/common.mk
+++ b/common.mk
@@ -15,14 +15,20 @@ ifndef SYSCONFDIR
   endif
 endif
 
-I3_VERSION := '$(shell [ -f $(TOPDIR)/VERSION ] && cat $(TOPDIR)/VERSION)'
+# 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/::)\")'
-else
-VERSION := ${I3_VERSION}
 endif
 
+MAJOR_VERSION := $(shell echo ${VERSION} | cut -d '.' -f 1)
+MINOR_VERSION := $(shell echo ${VERSION} | cut -d '.' -f 2)
+PATCH_VERSION := $(shell echo ${VERSION} | cut -d '.' -f 3)
+ifeq (${PATCH_VERSION},)
+PATCH_VERSION := 0
+endif
 
 ## Generic flags
 
@@ -46,6 +52,9 @@ I3_CFLAGS += -Wunused-value
 I3_CFLAGS += -Iinclude
 
 I3_CPPFLAGS  = -DI3_VERSION=\"${I3_VERSION}\"
+I3_CPPFLAGS += -DMAJOR_VERSION=${MAJOR_VERSION}
+I3_CPPFLAGS += -DMINOR_VERSION=${MINOR_VERSION}
+I3_CPPFLAGS += -DPATCH_VERSION=${PATCH_VERSION}
 I3_CPPFLAGS += -DSYSCONFDIR=\"${SYSCONFDIR}\"