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`
7 # Check that some of the newer git versions we use are supported.
8 if [ "0" != `git rev-list HEAD --not HEAD --count 2> /dev/null` ]
10 echo "Too old a git installation."
12 echo "Your git doesn't support --count option with git rev-list,"
13 echo "which SBCL build requires. Git 1.7.2 or later should work."
24 if [ -f version.lisp-expr -a ! git_available_p ]
26 # Relase tarball, leave version.lisp-expr alone.
28 elif [ ! git_available_p ]
30 echo "Can't run 'git describe' and version.lisp-expr is missing." >&2
31 echo "To fix this, either install git or create a fake version.lisp-expr file." >&2
32 echo "You can create a fake version.lisp-expr file like this:" >&2
33 echo " \$ echo '\"1.0.99.999\"' > version.lisp-expr" >&2
37 version_head=`git rev-parse HEAD`
38 if [ -z "$SBCL_BUILDING_RELEASE_FROM" ]
40 version_root="origin/master"
42 version_root="$SBCL_BUILDING_RELEASE_FROM"
44 version_base=`git rev-parse "$version_root"`
45 version_tag=`git describe --tags --match="sbcl*" --abbrev=0 $version_base`
46 version_release=`echo $version_tag | sed -e 's/sbcl[_-]//' | sed -e 's/_/\./g'`
47 version_n_root=`git rev-list $version_base --not $version_tag --count`
48 version_n_branch=`git rev-list HEAD --not $version_base --count`
49 if [ -z "$NO_GIT_HASH_IN_VERSION" ]
51 version_hash="-`git rev-parse --short $version_head`"
55 if git diff HEAD --no-ext-diff --quiet --exit-code
59 version_dirty="-dirty"
61 # Now that we have all the pieces, put them together.
62 cat >version.lisp-expr <<EOF
63 ;;; This file is auto-generated using generate-version.sh. Every time
64 ;;; you re-run make.sh, this file will be overwritten if you are
65 ;;; working from a Git checkout.
67 if [ "$version_base" = "$version_head" ]
69 if [ "0" = "$version_n_root" ]
72 $version_release $version_dirty >>version.lisp-expr
74 printf "\"%s.%s%s%s\"\n" \
75 $version_release $version_n_root \
76 $version_hash $version_dirty >>version.lisp-expr
79 echo "base=$version_base"
80 echo "head=$version_head"
81 version_branchname=`git describe --contains --all HEAD`
82 printf "\"%s.%s.%s.%s%s%s\"\n" \
83 $version_release $version_n_root \
84 $version_branchname $version_n_branch \
85 $version_hash $version_dirty >>version.lisp-expr