aboutsummaryrefslogtreecommitdiffstats
path: root/generate_version_h.sh
diff options
context:
space:
mode:
Diffstat (limited to 'generate_version_h.sh')
-rwxr-xr-xgenerate_version_h.sh23
1 files changed, 19 insertions, 4 deletions
diff --git a/generate_version_h.sh b/generate_version_h.sh
index 4ea23c0..a9b39e4 100755
--- a/generate_version_h.sh
+++ b/generate_version_h.sh
@@ -1,8 +1,23 @@
-#!/bin/sh
+#!/bin/bash
-VERSION=`git describe --abbrev=0`
-HASH=`git show --format="%h" --no-patch master`
-BRANCH=`git rev-parse --abbrev-ref HEAD`
+if [ -d ".git" ]
+then
+# If we have a git directory use that as an information source
+ VERSION=`git describe --abbrev=0`
+ HASH=`git show --format="%h" --no-patch master`
+ BRANCH=`git rev-parse --abbrev-ref HEAD`
+elif [ "$#" = "3" ]
+then
+# If we have 3 commandline arguments use them
+ VERSION="$1"
+ HASH="$2"
+ BRANCH="$3"
+else
+# We don't know our version
+ VERSION="Unknown"
+ HASH="none"
+ BRANCH="Unknown"
+fi
echo "#ifndef HAVE_VERSION_H"
echo "#define HAVE_VERSION_H"