Fix reporting of memory faults on Windows.
[sbcl.git] / generate-version.sh
blobf51b46710c0a877fe79805657084cf7b0707c30e
1 #!/bin/sh
3 git_available_p() {
4 # Check that (1) we have git (2) this is a git tree.
5 if ( command -v git >/dev/null && git describe >/dev/null 2>/dev/null )
6 then
7 echo "ok"
8 else
9 echo ""
13 AVAILABLE=`git_available_p`
14 if [ -f version.lisp-expr -a -z "$AVAILABLE" ]
15 then
16 # Relase tarball, leave version.lisp-expr alone.
17 exit 0
18 elif [ -z "$AVAILABLE" ]
19 then
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
24 exit 1
26 # Build it.
27 version_head=`git rev-parse HEAD`
28 if grep -q "ref: refs/heads/.*" .git/HEAD > /dev/null 2>&1
29 then
30 version_branchname=`cut -d / -f 3- < .git/HEAD`
31 else
32 # Detached head.
33 version_branchname="HEAD"
35 if [ -z "$SBCL_BUILDING_RELEASE_FROM" ]
36 then
37 if [ "`git rev-list HEAD --not origin/master`" = '' ]
38 then
39 # If origin/master contains all the commits on current
40 # branch, use current head as the root instead.
41 version_root="$version_branchname"
42 else
43 version_root="origin/master"
45 else
46 version_root="$SBCL_BUILDING_RELEASE_FROM"
48 version_base=`git rev-parse "$version_root"`
49 version_tag=`git describe --tags --match="sbcl*" --abbrev=0 $version_base`
50 version_release=`echo $version_tag | sed -e 's/sbcl[_-]//' | sed -e 's/_/\./g'`
51 # Using wc -l instead of --count argument to rev-list because
52 # pre-1.7.2 Gits are still common out in the wilderness.
53 version_n_root=`git rev-list $version_base --not $version_tag | wc -l | sed -e 's/[ \t]//g'`
54 version_n_branch=`git rev-list HEAD --not $version_base | wc -l | sed -e 's/[ \t]//g'`
55 if [ -z "$NO_GIT_HASH_IN_VERSION" ]
56 then
57 version_hash="-`git rev-parse --short $version_head`"
58 else
59 version_hash=""
61 if git diff HEAD --no-ext-diff --quiet --exit-code
62 then
63 version_dirty=""
64 else
65 version_dirty="-dirty"
67 # Now that we have all the pieces, put them together.
68 cat >version.lisp-expr <<EOF
69 ;;; This file is auto-generated using generate-version.sh. Every time
70 ;;; you re-run make.sh, this file will be overwritten if you are
71 ;;; working from a Git checkout.
72 EOF
73 if [ "$version_base" = "$version_head" ]
74 then
75 if [ "0" = "$version_n_root" ]
76 then
77 printf "\"%s%s\"\n" \
78 $version_release $version_dirty >>version.lisp-expr
79 else
80 printf "\"%s.%s%s%s\"\n" \
81 $version_release $version_n_root \
82 $version_hash $version_dirty >>version.lisp-expr
84 else
85 echo "base=$version_base"
86 echo "head=$version_head"
87 printf "\"%s.%s.%s.%s%s%s\"\n" \
88 $version_release $version_n_root \
89 $version_branchname $version_n_branch \
90 $version_hash $version_dirty >>version.lisp-expr