3 # determine-version -- report a useful version for releases
5 # Copyright 2008, Aron Griffis <agriffis@n01se.net>
6 # Copyright 2008, Oracle
7 # Released under the GNU GPLv2
16 which git &> /dev/null
17 if [ $? == 0 -a -d .git ]; then
18 if head=`git rev-parse --verify HEAD 2>/dev/null`; then
19 if tag=`git describe --tags 2>/dev/null`; then
23 # Are there uncommitted changes?
24 git update-index --refresh --unmerged > /dev/null
25 if git diff-index --name-only HEAD | grep -v "^scripts/package" \
32 if [ "$opt" = "--configure" ]; then
33 # Omit the trailing newline, so that m4_esyscmd can use the result directly.
34 echo "$v" | tr -d '\n'
38 echo "/* NOTE: this file is autogenerated by version.sh, do not edit */" > .build-version.h
39 echo "#ifndef __BUILD_VERSION" >> .build-version.h
40 echo >> .build-version.h
41 echo "#define __BUILD_VERSION" >> .build-version.h
42 echo >> .build-version.h
43 echo "#define BTRFS_LIB_MAJOR $lib_major" >> .build-version.h
44 echo "#define BTRFS_LIB_MINOR $lib_minor" >> .build-version.h
45 echo "#define BTRFS_LIB_PATCHLEVEL $lib_patchlevel" >> .build-version.h
46 echo >> .build-version.h
47 echo "#define BTRFS_LIB_VERSION ( BTRFS_LIB_MAJOR * 10000 + \\" >> .build-version.h
48 echo " BTRFS_LIB_MINOR * 100 + \\" >> .build-version.h
49 echo " BTRFS_LIB_PATCHLEVEL )" >> .build-version.h
50 echo >> .build-version.h
51 echo "#define BTRFS_BUILD_VERSION \"Btrfs $v\"" >> .build-version.h
52 echo "#endif" >> .build-version.h
54 diff -q version.h .build-version.h >& /dev/null
61 mv .build-version.h version.h