Update CMakeLists.txt - play with openssl
[novacoin.git] / share / genbuild.sh
1 #!/bin/bash
2
3 realpath() {
4     [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
5 }
6
7 PREVDIR=$(pwd)
8 SCRIPT=$(realpath $0)
9 SCRIPTPATH=`dirname $SCRIPT`
10
11 if [ $# -gt 0 ]; then
12     FILE="$1"
13     shift
14     if [ -f "$FILE" ]; then
15         INFO="$(head -n 1 "$FILE")"
16     fi
17 else
18     echo "Usage: $0 <filename>"
19     exit 1
20 fi
21
22 cd $SCRIPTPATH
23
24 if [ -e "$(which git)" ]; then
25     # clean 'dirty' status of touched files that haven't been modified
26     git diff >/dev/null 2>/dev/null 
27
28     # get a string like "v0.6.0-66-g59887e8"
29     DESC="$(git describe 2>/dev/null)"
30
31     # get a string like "2012-04-10 16:27:19 +0200"
32     TIME="$(git log -n 1 --format="%ci")"
33 fi
34
35 if [ -n "$DESC" ]; then
36     NEWINFO="#define BUILD_DESC \"$DESC\""
37 else
38     NEWINFO="// No build information available"
39 fi
40
41 # only update build.h if necessary
42 if [ "$INFO" != "$NEWINFO" ]; then
43     echo "$NEWINFO" >"$FILE"
44     echo "#define BUILD_DATE \"$TIME\"" >>"$FILE"
45 fi
46
47 cd $PREVDIR