summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorPalmer Dabbelt <palmer@sifive.com>2019-08-17 17:11:09 +0300
committerAnup Patel <anup@brainfault.org>2019-08-19 08:28:21 +0300
commita2a7763ac7651e64c3928ba0a13be9317bd48c4d (patch)
tree81c722621d23220ab136cc56b56258178f0f9975 /Makefile
parent75229705a0bf804099fbf32b61d7f6ba459226ec (diff)
downloadopensbi-a2a7763ac7651e64c3928ba0a13be9317bd48c4d.tar.xz
Include `git describe` in OpenSBI
OpenSBI includes a version, but that is only updated when tagged. For users that are using the git releases we instead end up with an ambiguous version number, which makes it hard to figure out what everyone is using. This patch checks for a git directory and prints out the result of `git describe`, which is a mix of pretty and unambiguous. Signed-off-by: Palmer Dabbelt <palmer@sifive.com> Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile4
1 files changed, 4 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 78c28c0..9784598 100644
--- a/Makefile
+++ b/Makefile
@@ -65,6 +65,7 @@ export firmware_dir=$(CURDIR)/firmware
# Find library version
OPENSBI_VERSION_MAJOR=`grep "define OPENSBI_VERSION_MAJOR" $(include_dir)/sbi/sbi_version.h | sed 's/.*MAJOR.*\([0-9][0-9]*\)/\1/'`
OPENSBI_VERSION_MINOR=`grep "define OPENSBI_VERSION_MINOR" $(include_dir)/sbi/sbi_version.h | sed 's/.*MINOR.*\([0-9][0-9]*\)/\1/'`
+OPENSBI_VERSION_GIT=$(shell if [ -d $(src_dir)/.git ]; then git describe; fi)
# Setup compilation commands
ifdef CROSS_COMPILE
@@ -151,6 +152,9 @@ endif
# Setup compilation commands flags
GENFLAGS = -I$(platform_src_dir)/include
GENFLAGS += -I$(include_dir)
+ifneq ($(OPENSBI_VERSION_GIT),)
+GENFLAGS += -DOPENSBI_VERSION_GIT="\"$(OPENSBI_VERSION_GIT)\""
+endif
GENFLAGS += $(libsbiutils-genflags-y)
GENFLAGS += $(platform-genflags-y)
GENFLAGS += $(firmware-genflags-y)