Tizen 2.0 Release
[profile/ivi/osmesa.git] / bin / extract_git_sha1
1 #!/bin/sh
2 if [ ! -f src/mesa/main/git_sha1.h ]; then
3         touch src/mesa/main/git_sha1.h
4 fi
5
6 if [ ! -d .git ]; then
7         exit
8 fi
9
10 if which git > /dev/null; then
11     # Extract the 7-digit "short" SHA1 for the current HEAD, convert
12     # it to a string, and wrap it in a #define.  This is used in
13     # src/mesa/main/version.c to put the GIT SHA1 in the GL_VERSION string.
14     git log -n 1 --oneline |\
15         sed 's/^\([^ ]*\) .*/#define MESA_GIT_SHA1 "git-\1"/' \
16         > src/mesa/main/git_sha1.h.tmp
17     if ! cmp -s src/mesa/main/git_sha1.h.tmp src/mesa/main/git_sha1.h; then
18         mv src/mesa/main/git_sha1.h.tmp src/mesa/main/git_sha1.h
19     fi
20 fi