2 # Not a shell script, but something intended to be sourced from shell scripts
4 # Check that (1) we have git (2) this is a git tree.
5 if ( which git >/dev/null 2>/dev/null && git describe >/dev/null 2>/dev/null )
14 if [ -f version.lisp-expr -a ! git_available_p ]
16 # Relase tarball, leave version.lisp-expr alone.
18 elif [ ! git_available_p ]
20 echo "Can't run 'git describe' and version.lisp-expr is missing." >&2
21 echo "To fix this, either install git or create a fake version.lisp-expr file." >&2
22 echo "You can create a fake version.lisp-expr file like this:" >&2
23 echo " \$ echo '\"1.0.99.999\"' > version.lisp-expr" >&2
27 version_head=`git rev-parse HEAD`
28 if [ -z "$SBCL_BUILDING_RELEASE_FROM" ]
30 version_root="origin/master"
32 version_root="$SBCL_BUILDING_RELEASE_FROM"
34 version_base=`git rev-parse "$version_root"`
35 version_tag=`git describe --tags --match="sbcl*" --abbrev=0 $version_base`
36 version_release=`echo $version_tag | sed -e 's/sbcl[_-]//' | sed -e 's/_/\./g'`
37 # Using wc -l instead of --count argument to rev-list because
38 # pre-1.7.2 Gits are still common out in the wilderness.
39 version_n_root=`git rev-list $version_base --not $version_tag | wc -l`
40 version_n_branch=`git rev-list HEAD --not $version_base | wc -l`
41 if [ -z "$NO_GIT_HASH_IN_VERSION" ]
43 version_hash="-`git rev-parse --short $version_head`"
47 if git diff HEAD --no-ext-diff --quiet --exit-code
51 version_dirty="-dirty"
53 # Now that we have all the pieces, put them together.
54 cat >version.lisp-expr <<EOF
55 ;;; This file is auto-generated using generate-version.sh. Every time
56 ;;; you re-run make.sh, this file will be overwritten if you are
57 ;;; working from a Git checkout.
59 if [ "$version_base" = "$version_head" ]
61 if [ "0" = "$version_n_root" ]
64 $version_release $version_dirty >>version.lisp-expr
66 printf "\"%s.%s%s%s\"\n" \
67 $version_release $version_n_root \
68 $version_hash $version_dirty >>version.lisp-expr
71 echo "base=$version_base"
72 echo "head=$version_head"
73 version_branchname=`git describe --contains --all HEAD`
74 printf "\"%s.%s.%s.%s%s%s\"\n" \
75 $version_release $version_n_root \
76 $version_branchname $version_n_branch \
77 $version_hash $version_dirty >>version.lisp-expr