diff --git a/Makefile.buildtests b/Makefile.buildtests
index 20dba3f5c682007aae69fc8a8d5e7d6b034d1ed3..bcac8c93ed63337760da6a2cc46f3e000bbaee69 100644
--- a/Makefile.buildtests
+++ b/Makefile.buildtests
@@ -55,6 +55,7 @@ buildtest:
 			RIOTCPU=$${RIOTCPU} \
 			BINDIRBASE=$${BINDIRBASE} \
 			RIOTNOLINK=$${RIOTNOLINK} \
+			RIOT_VERSION=$${RIOT_VERSION} \
 			$(MAKE) -j$(NPROC) 2>&1 >/dev/null) ; \
 		if [ "$${?}" = "0" ]; then \
 			$${ECHO} "$${GREEN}success$${RESET}"; \
diff --git a/Makefile.include b/Makefile.include
index d4f4c7aa80682da5d96e36ca1fccbf216d3a1ab0..ccab20d05bb12023e7edd9446e074bcab75ab046 100644
--- a/Makefile.include
+++ b/Makefile.include
@@ -64,16 +64,18 @@ endif
 include $(RIOTBASE)/Makefile.cflags
 
 # make the RIOT version available to the program
-GIT_STRING := $(shell git describe --always --abbrev=4 --dirty=-`hostname`)
-ifneq (,$(GIT_STRING))
-  GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
-  ifeq ($(strip $(GIT_BRANCH)),master)
-    RIOT_VERSION := $(GIT_STRING)
+ifeq ($(origin RIOT_VERSION), undefined)
+  GIT_STRING := $(shell git describe --always --abbrev=4 --dirty=-`hostname`)
+  ifneq (,$(GIT_STRING))
+    GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
+    ifeq ($(strip $(GIT_BRANCH)),master)
+      RIOT_VERSION := $(GIT_STRING)
+    else
+      RIOT_VERSION := $(GIT_STRING)-$(GIT_BRANCH)
+    endif
   else
-    RIOT_VERSION := $(GIT_STRING)-$(GIT_BRANCH)
+    RIOT_VERSION := UNKNOWN
   endif
-else
-  RIOT_VERSION := UNKNOWN
 endif
 export CFLAGS += -DRIOT_VERSION='"$(RIOT_VERSION)"'