From 74eea59208bc84482638e2f9a0f14eca6158a5fe Mon Sep 17 00:00:00 2001 From: Vegard Nossum Date: Thu, 11 Jun 2009 10:24:12 +0200 Subject: [PATCH] build: figure out git revision and include as part of version string Signed-off-by: Vegard Nossum --- Makefile | 4 +++- include/asmotor.h | 2 +- scripts/localversion.sh | 21 +++++++++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 scripts/localversion.sh diff --git a/Makefile b/Makefile index 7df830b2..031730ed 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,6 @@ -cflags = -Wall -Iinclude -Iinclude/asm/gameboy -g +localversion = $(shell bash scripts/localversion.sh) + +cflags = -Wall -Iinclude -Iinclude/asm/gameboy -DLOCALVERSION=\"$(localversion)\" -g all: diff --git a/include/asmotor.h b/include/asmotor.h index 2a0a5e20..72a9f024 100644 --- a/include/asmotor.h +++ b/include/asmotor.h @@ -11,7 +11,7 @@ #define ASMOTOR -#define ASMOTOR_VERSION "1.10" +#define ASMOTOR_VERSION "1.10-linux" LOCALVERSION #define ASM_VERSION "1.08c" #define LINK_VERSION "1.06c" diff --git a/scripts/localversion.sh b/scripts/localversion.sh new file mode 100644 index 00000000..576305ea --- /dev/null +++ b/scripts/localversion.sh @@ -0,0 +1,21 @@ +#! /bin/bash + +# +# Use git to figure out which version we are using. +# +# Adapted from a script written by Rene Scharfe , +# found in the Linux Kernel. +# + +set -u + +if head=`git rev-parse --verify --short HEAD 2>/dev/null`; then + printf '%s%s' -g $head + + git update-index --refresh --unmerged > /dev/null + if git diff-index --name-only HEAD | read dummy; then + printf '%s' -dirty + fi + + exit +fi