diff --git a/.gitignore b/.gitignore index d261255c45..9ef0621bbf 100644 --- a/.gitignore +++ b/.gitignore @@ -52,6 +52,7 @@ rs_state.ini /TAGS /NTLang.bat /golast.bat +/.version # Destination build directories /alpha_nbsd* diff --git a/build-tools/git-version b/build-tools/git-version new file mode 100755 index 0000000000..b8c6802294 --- /dev/null +++ b/build-tools/git-version @@ -0,0 +1,21 @@ +#!/bin/sh + +version_file=$1 + +if [ -f $version_file ] ; then + git_version=`cat $version_file` +else + if which git > /dev/null; then + 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" + fi + else + git_version=UNKNOWN + fi +fi + +echo "$git_version" | sed -e 's/openafs-[^-]*-//' -e 's/_/./g' | tr -d '\012' diff --git a/build-tools/libafsdep b/build-tools/libafsdep new file mode 100644 index 0000000000..163773d532 --- /dev/null +++ b/build-tools/libafsdep @@ -0,0 +1 @@ +git-version diff --git a/configure-libafs.in b/configure-libafs.in index c8c476edf5..77fb092a02 100644 --- a/configure-libafs.in +++ b/configure-libafs.in @@ -1,5 +1,5 @@ AC_PRERQ([2.60]) -AC_INIT([OpenAFS], [1.5.74.1]) +AC_INIT([OpenAFS], m4_esyscmd([build-tools/git-version .version])) AC_CONFIG_SRCDIR(src/libafs/Makefile.common.in) AM_INIT_AUTOMAKE diff --git a/configure.in b/configure.in index b6269e0fb3..039d8c7fdd 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ AC_PREREQ([2.60]) -AC_INIT([OpenAFS], [1.5.74.1]) +AC_INIT([OpenAFS], m4_esyscmd([build-tools/git-version .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 0d612ddfa2..e5baf5a036 100644 --- a/src/config/Makefile.version-NOCML.in +++ b/src/config/Makefile.version-NOCML.in @@ -6,18 +6,19 @@ # directory or online at http://www.openafs.org/dl/license10.html PACKAGE=@PACKAGE@ -VERSION=@VERSION@ AFS_component_version_number.o: AFS_component_version_number.c AFS_component_version_number.c: @TOP_OBJDIR@/src/config/Makefile.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=`@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: - echo '' >version.xml - echo '' >>version.xml - echo '${VERSION}' >>version.xml + VERSION=`@abs_top_srcdir@/build-tools/git-version @abs_top_srcdir/.version` && \ + echo '' >version.xml && \ + echo '' >>version.xml && \ + echo ''$$VERSION'' >>version.xml && \ echo '' >>version.xml version.txt: diff --git a/src/config/make_libafs_tree.pl b/src/config/make_libafs_tree.pl index fb8295d755..05e1eb8b10 100755 --- a/src/config/make_libafs_tree.pl +++ b/src/config/make_libafs_tree.pl @@ -76,6 +76,8 @@ finddepth(\&find_libafsdep, $projdir); ©it("$projdir/src/libafs/MakefileProto.$ostype.in", "$treedir/src/libafs/MakefileProto.in"); +$showonly || system("$projdir/build-tools/git-version $projdir/.version > $treedir/.version"); + # We need to regenerate this to support building amd64 kernels from a # libafs_tree built on i386. unlink("$treedir/include/afs/param.h");