[x264-devel] configure: don't generate a git version number if .git isn't present

Sean McGovern git at videolan.org
Wed Oct 30 21:18:32 CET 2013


x264 | branch: master | Sean McGovern <gseanmcg at gmail.com> | Wed Sep  4 14:15:00 2013 -0700| [62ca772373a2c3e10b77f96a463f312047a04a4d] | committer: Jason Garrett-Glaser

configure: don't generate a git version number if .git isn't present

> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=62ca772373a2c3e10b77f96a463f312047a04a4d
---

 version.sh |   15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/version.sh b/version.sh
index 5466ef2..2e70464 100755
--- a/version.sh
+++ b/version.sh
@@ -1,5 +1,8 @@
 #!/bin/bash
 [ -n "$1" ] && cd $1
+
+git_version() {
+trap 'rm -f config.git-hash' EXIT
 git rev-list HEAD | sort > config.git-hash
 LOCALVER=`wc -l config.git-hash | awk '{print $1}'`
 if [ $LOCALVER \> 1 ] ; then
@@ -14,11 +17,13 @@ if [ $LOCALVER \> 1 ] ; then
         VER="${VER}M"
     fi
     VER="$VER $(git rev-list HEAD -n 1 | cut -c 1-7)"
-    echo "#define X264_VERSION \" r$VER\""
-else
-    echo "#define X264_VERSION \"\""
-    VER="x"
+    VERSION=" r$VER"
 fi
-rm -f config.git-hash
+}
+
+VER="x"
+VERSION=""
+[ -d .git ] && (type git >/dev/null 2>&1) && git_version
+echo "#define X264_VERSION \"$VERSION\""
 API=`grep '#define X264_BUILD' < x264.h | sed -e 's/.* \([1-9][0-9]*\).*/\1/'`
 echo "#define X264_POINTVER \"0.$API.$VER\""



More information about the x264-devel mailing list