From 4de144ff7048b1f7e85425de515e510eaf600ea8 Mon Sep 17 00:00:00 2001
From: Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
Date: Mon, 6 Mar 2017 13:03:32 -0400
Subject: [PATCH] add build variant to version string

---
 Makefile               | 25 +++++++++++++++----------
 config.h               |  2 +-
 tools/rebind_device.sh |  0
 3 files changed, 16 insertions(+), 11 deletions(-)
 mode change 100644 => 100755 tools/rebind_device.sh

diff --git a/Makefile b/Makefile
index 06497e394..b49d149d2 100644
--- a/Makefile
+++ b/Makefile
@@ -33,15 +33,6 @@ CFLAGS  += -Wall -Werror -fdiagnostics-color=auto
 CFLAGS  += -D_POSIX_C_SOURCE=200809L -D_GNU_SOURCE=1 -DV=$(V)
 LDFLAGS += -L$(BUILDDIR)
 
-ifdef CI
-	CFLAGS += -D_GIT_REV='"${CI_BUILD_REF:0:7}~ci"'
-else
-	GIT = $(shell type -p git)
-	ifneq ($(GIT),)
-		CFLAGS += -D_GIT_REV='"$(shell git rev-parse --short HEAD)"'
-	endif
-endif
-
 # We must compile without optimizations for gcov!
 ifdef DEBUG
 	CFLAGS += -O0 -g
@@ -71,10 +62,24 @@ endif
 
 SPACE :=
 SPACE +=
-BUILDDIR := $(BUILDDIR)/$(subst $(SPACE),-,$(strip $(VARIANTS)))
+VARIANT = $(subst $(SPACE),-,$(strip $(VARIANTS)))
 
+BUILDDIR := $(BUILDDIR)/$(VARIANT)
 SRCDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
 
+# Add git revision and build variant defines
+ifdef CI
+	CFLAGS += -D_GIT_REV='"${CI_BUILD_REF:0:7}"'
+	CFLAGS += -D_VARIANT='"-ci-$(VARIANT)"'
+else
+	GIT = $(shell type -p git)
+	GIT_REV = $(shell git rev-parse --short HEAD)
+	ifneq ($(GIT),)
+		CFLAGS += -D_GIT_REV='"$(GIT_REV)"'
+	endif
+	CFLAGS += -D_VARIANT='"-$(VARIANT)"'
+endif
+
 # pkg-config dependencies
 PKGS = libconfig
 
diff --git a/config.h b/config.h
index 5809cb9cc..e394fff1c 100644
--- a/config.h
+++ b/config.h
@@ -15,7 +15,7 @@
 #endif
 
 /** The version number of VILLASnode */
-#define VERSION			"v0.6-" _GIT_REV
+#define VERSION			"v0.7-" _GIT_REV _VARIANT
 
 /** Default number of values in a sample */
 #define DEFAULT_VALUES		64
diff --git a/tools/rebind_device.sh b/tools/rebind_device.sh
old mode 100644
new mode 100755