flash/nor/at91samd: Use 32-bit register writes for ST-Link compat
[fw/openocd] / guess-rev.sh
1 #!/bin/sh
2 #
3 # This scripts adds local version information from the version
4 # control systems git, mercurial (hg) and subversion (svn).
5 #
6 # Copied from Linux 2.6.32 scripts/setlocalversion and modified
7 # slightly to work better for OpenOCD.
8 #
9
10 usage() {
11         echo "Usage: $0 [srctree]" >&2
12         exit 1
13 }
14
15 cd "${1:-.}" || usage
16
17 # Check for git and a git repo.
18 if head=`git rev-parse --verify --short HEAD 2>/dev/null`; then
19
20         # If we are at a tagged commit (like "v2.6.30-rc6"), we ignore it,
21         # because this version is defined in the top level Makefile.
22         if [ -z "`git describe --exact-match 2>/dev/null`" ]; then
23
24                 # If we are past a tagged commit (like "v2.6.30-rc5-302-g72357d5"),
25                 # we pretty print it.
26                 if atag="`git describe 2>/dev/null`"; then
27                         echo "$atag" | awk -F- '{printf("-%05d-%s", $(NF-1),$(NF))}'
28
29                 # If we don't have a tag at all we print -g{commitish}.
30                 else
31                         printf '%s%s' -g $head
32                 fi
33         fi
34
35         # Is this git on svn?
36         if git config --get svn-remote.svn.url >/dev/null; then
37                 printf -- '-svn%s' "`git svn find-rev $head`"
38         fi
39
40         # Update index only on r/w media
41         [ -w . ] && git update-index --refresh --unmerged > /dev/null
42
43         # Check for uncommitted changes
44         if git diff-index --name-only HEAD | grep -v "^scripts/package" \
45             | read dummy; then
46                 printf '%s' -dirty
47         fi
48
49         # All done with git
50         exit
51 fi
52
53 # Check for mercurial and a mercurial repo.
54 if hgid=`hg id 2>/dev/null`; then
55         tag=`printf '%s' "$hgid" | cut -d' ' -f2`
56
57         # Do we have an untagged version?
58         if [ -z "$tag" -o "$tag" = tip ]; then
59                 id=`printf '%s' "$hgid" | sed 's/[+ ].*//'`
60                 printf '%s%s' -hg "$id"
61         fi
62
63         # Are there uncommitted changes?
64         # These are represented by + after the changeset id.
65         case "$hgid" in
66                 *+|*+\ *) printf '%s' -dirty ;;
67         esac
68
69         # All done with mercurial
70         exit
71 fi
72
73 # Check for svn and a svn repo.
74 if rev=`svn info 2>/dev/null | grep '^Last Changed Rev'`; then
75         rev=`echo $rev | awk '{print $NF}'`
76         printf -- '-svn%s' "$rev"
77
78         # All done with svn
79         exit
80 fi
81
82 # There's no reecognized repository; we must be a snapshot.
83 printf -- '-snapshot'