Add checkpoint
[novacoin.git] / share / genbuild.sh
1 #!/bin/sh
2
3 if [ $# -gt 0 ]; then
4     FILE="$1"
5     shift
6     if [ -f "$FILE" ]; then
7         INFO="$(head -n 1 "$FILE")"
8     fi
9 else
10     echo "Usage: $0 <filename>"
11     exit 1
12 fi
13
14 if [ -e "$(which git)" ]; then
15     # clean 'dirty' status of touched files that haven't been modified
16     git diff >/dev/null 2>/dev/null 
17
18     # get a string like "v0.6.0-66-g59887e8-dirty"
19     DESC="$(git describe --dirty 2>/dev/null)"
20
21     # get a string like "2012-04-10 16:27:19 +0200"
22     TIME="$(git log -n 1 --format="%ci")"
23 fi
24
25 if [ -n "$DESC" ]; then
26     NEWINFO="#define BUILD_DESC \"$DESC\""
27 else
28     NEWINFO="// No build information available"
29 fi
30
31 # only update build.h if necessary
32 if [ "$INFO" != "$NEWINFO" ]; then
33     echo "$NEWINFO" >"$FILE"
34     echo "#define BUILD_DATE \"$TIME\"" >>"$FILE"
35 fi