diff --git a/build-tools/git-version b/build-tools/git-version index b8c6802294..6bc9a50c1b 100755 --- a/build-tools/git-version +++ b/build-tools/git-version @@ -1,20 +1,31 @@ #!/bin/sh -version_file=$1 +srcdir=$1 +fallback=$2 -if [ -f $version_file ] ; then - git_version=`cat $version_file` +if [ "x$fallback" = "x" ]; then + fallback=UNKNOWN +fi + +if [ -f $srcdir/.version ] ; then + git_version=`cat $srcdir/.version` else if which git > /dev/null; then + cd $srcdir git_version=`git describe --abbrev=4 HEAD 2>/dev/null` - - # Is the working tree dirty? - if ! git diff-index --quiet --cached HEAD --ignore-submodules || \ - ! git diff-files --quiet --ignore-submodules ; then - git_version="$git_version-dirty" + if [ $? = 0 ]; then + # Is the working tree dirty? + if git diff-index --quiet --cached HEAD --ignore-submodules && \ + git diff-files --quiet --ignore-submodules ; then + : + else + git_version="$git_version-dirty" + fi + else + git_version=$fallback fi else - git_version=UNKNOWN + git_version=$fallback fi fi diff --git a/configure-libafs.in b/configure-libafs.in index 77fb092a02..a8ba6f2d31 100644 --- a/configure-libafs.in +++ b/configure-libafs.in @@ -1,5 +1,5 @@ AC_PRERQ([2.60]) -AC_INIT([OpenAFS], m4_esyscmd([build-tools/git-version .version])) +AC_INIT([OpenAFS], m4_esyscmd([build-tools/git-version .])) AC_CONFIG_SRCDIR(src/libafs/Makefile.common.in) AM_INIT_AUTOMAKE diff --git a/configure.in b/configure.in index 039d8c7fdd..5ebc1d41aa 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ AC_PREREQ([2.60]) -AC_INIT([OpenAFS], m4_esyscmd([build-tools/git-version .version])) +AC_INIT([OpenAFS], m4_esyscmd([build-tools/git-version .])) AC_CONFIG_SRCDIR([src/config/stds.h]) AM_INIT_AUTOMAKE diff --git a/src/config/Makefile.version-NOCML.in b/src/config/Makefile.version-NOCML.in index e5baf5a036..c5613ffa00 100644 --- a/src/config/Makefile.version-NOCML.in +++ b/src/config/Makefile.version-NOCML.in @@ -10,12 +10,12 @@ PACKAGE=@PACKAGE@ AFS_component_version_number.o: AFS_component_version_number.c AFS_component_version_number.c: @TOP_OBJDIR@/src/config/Makefile.version - VERSION=`@abs_top_srcdir@/build-tools/git-version @abs_top_srcdir@/.version` && \ + VERSION=`@abs_top_srcdir@/build-tools/git-version @abs_top_srcdir@ "@VERSION@"` && \ echo 'char cml_version_number[]="@(#) OpenAFS '$$VERSION' built ' `date +"%Y-%m-%d"` '";' >AFS_component_version_number.c && \ echo 'char* AFSVersion = "${PACKAGE} '$$VERSION'";' >>AFS_component_version_number.c version.xml: - VERSION=`@abs_top_srcdir@/build-tools/git-version @abs_top_srcdir/.version` && \ + VERSION=`@abs_top_srcdir@/build-tools/git-version @abs_top_srcdir@ "@VERSION@"` && \ echo '' >version.xml && \ echo '' >>version.xml && \ echo ''$$VERSION'' >>version.xml && \