Fix uninitialized atomic variables
[bitcoinplatinum.git] / share / genbuild.sh
blob32ef2a5755aa4e93d3da541f78f576a846b53db0
1 #!/bin/sh
2 # Copyright (c) 2012-2016 The Bitcoin Core developers
3 # Distributed under the MIT software license, see the accompanying
4 # file COPYING or http://www.opensource.org/licenses/mit-license.php.
6 if [ $# -gt 1 ]; then
7 cd "$2"
8 fi
9 if [ $# -gt 0 ]; then
10 FILE="$1"
11 shift
12 if [ -f "$FILE" ]; then
13 INFO="$(head -n 1 "$FILE")"
15 else
16 echo "Usage: $0 <filename> <srcroot>"
17 exit 1
20 git_check_in_repo() {
21 ! { git status --porcelain -uall --ignored "$@" 2>/dev/null || echo '??'; } | grep -q '?'
24 DESC=""
25 SUFFIX=""
26 if [ "${BITCOIN_GENBUILD_NO_GIT}" != "1" -a -e "$(which git 2>/dev/null)" -a "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ] && git_check_in_repo share/genbuild.sh; then
27 # clean 'dirty' status of touched files that haven't been modified
28 git diff >/dev/null 2>/dev/null
30 # if latest commit is tagged and not dirty, then override using the tag name
31 RAWDESC=$(git describe --abbrev=0 2>/dev/null)
32 if [ "$(git rev-parse HEAD)" = "$(git rev-list -1 $RAWDESC 2>/dev/null)" ]; then
33 git diff-index --quiet HEAD -- && DESC=$RAWDESC
36 # otherwise generate suffix from git, i.e. string like "59887e8-dirty"
37 SUFFIX=$(git rev-parse --short HEAD)
38 git diff-index --quiet HEAD -- || SUFFIX="$SUFFIX-dirty"
41 if [ -n "$DESC" ]; then
42 NEWINFO="#define BUILD_DESC \"$DESC\""
43 elif [ -n "$SUFFIX" ]; then
44 NEWINFO="#define BUILD_SUFFIX $SUFFIX"
45 else
46 NEWINFO="// No build information available"
49 # only update build.h if necessary
50 if [ "$INFO" != "$NEWINFO" ]; then
51 echo "$NEWINFO" >"$FILE"