4 SCRIPT=$(readlink -f $0)
5 SCRIPTPATH=`dirname $SCRIPT`
10 if [ -f "$FILE" ]; then
11 INFO="$(head -n 1 "$FILE")"
14 echo "Usage: $0 <filename>"
20 if [ -e "$(which git)" ]; then
21 # clean 'dirty' status of touched files that haven't been modified
22 git diff >/dev/null 2>/dev/null
24 # get a string like "v0.6.0-66-g59887e8-dirty"
25 DESC="$(git describe --dirty 2>/dev/null)"
27 # get a string like "2012-04-10 16:27:19 +0200"
28 TIME="$(git log -n 1 --format="%ci")"
31 if [ -n "$DESC" ]; then
32 NEWINFO="#define BUILD_DESC \"$DESC\""
34 NEWINFO="// No build information available"
37 # only update build.h if necessary
38 if [ "$INFO" != "$NEWINFO" ]; then
39 echo "$NEWINFO" >"$FILE"
40 echo "#define BUILD_DATE \"$TIME\"" >>"$FILE"