diff mbox

[PATCHv2,1/4] scripts/git_hash: fix build from tar source

Message ID 1439558708-31151-2-git-send-email-anders.roxell@linaro.org
State Accepted
Commit 06537738ea438c3e339fc269dedb4ed6c5e48f07
Headers show

Commit Message

Anders Roxell Aug. 14, 2015, 1:25 p.m. UTC
Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
---
 .gitignore            |  1 +
 platform/Makefile.inc |  2 +-
 scripts/Makefile.am   |  2 +-
 scripts/git_hash.sh   | 18 ++++++++++++++----
 4 files changed, 17 insertions(+), 6 deletions(-)
diff mbox

Patch

diff --git a/.gitignore b/.gitignore
index f534808..b4c146b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,6 +12,7 @@ 
 .deps/
 .dirstamp
 .libs/
+.scmversion
 CUnit-Memory-Dump.xml
 ID
 Makefile
diff --git a/platform/Makefile.inc b/platform/Makefile.inc
index f64e37c..8e8e97b 100644
--- a/platform/Makefile.inc
+++ b/platform/Makefile.inc
@@ -12,6 +12,6 @@  lib_LTLIBRARIES = $(LIB)/libodp.la
 
 AM_LDFLAGS += -version-number '$(ODP_LIBSO_VERSION)'
 
-GIT_DESC = `$(top_srcdir)/scripts/git_hash.sh`
+GIT_DESC = `$(top_srcdir)/scripts/git_hash.sh $(top_srcdir)`
 AM_CFLAGS += "-DGIT_HASH=$(GIT_DESC)"
 AM_CFLAGS += -DPLATFORM=${with_platform}
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index 617eadc..431e537 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -1 +1 @@ 
-EXTRA_DIST = git_hash.sh odp_version.sh
+EXTRA_DIST = git_hash.sh odp_version.sh ../.scmversion
diff --git a/scripts/git_hash.sh b/scripts/git_hash.sh
index c9f1faf..48ae24e 100755
--- a/scripts/git_hash.sh
+++ b/scripts/git_hash.sh
@@ -1,9 +1,19 @@ 
 #!/bin/bash
 
+if [ -z ${1} ]; then
+	echo "should be called with a path"
+	exit
+fi
+ROOTDIR=${1}
+
 repo=https://git.linaro.org/lng/odp.git
-hash=$(git describe | tr -d "\n")
-if git diff-index --name-only HEAD &>/dev/null ; then
-	dirty=-dirty
+if [ -d ${ROOTDIR}/.git ]; then
+	hash=$(git describe | tr -d "\n")
+	if git diff-index --name-only HEAD &>/dev/null ; then
+		dirty=-dirty
+	fi
+
+	echo -n "'${repo}' (${hash}${dirty})">${ROOTDIR}/.scmversion
 fi
 
-echo -n "'${repo}' (${hash}${dirty})"
+cat ${ROOTDIR}/.scmversion