Update master
[bitcoinplatinum.git] / share / genbuild.sh
blobd959877dc85a391a640b8eb2912156c3aad812d1
1 #!/bin/sh
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
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
18 # get a string like "v0.6.0-66-g59887e8-dirty"
19 DESC="$(git describe --dirty 2>/dev/null)"
21 # get a string like "2012-04-10 16:27:19 +0200"
22 TIME="$(git log -n 1 --format="%ci")"
25 if [ -n "$DESC" ]; then
26 NEWINFO="#define BUILD_DESC \"$DESC\""
27 else
28 NEWINFO="// No build information available"
31 # only update build.h if necessary
32 if [ "$INFO" != "$NEWINFO" ]; then
33 echo "$NEWINFO" >"$FILE"
34 echo "#define BUILD_DATE \"$TIME\"" >>"$FILE"