4 [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
9 SCRIPTPATH=`dirname $SCRIPT`
14 if [ -f "$FILE" ]; then
15 INFO="$(head -n 1 "$FILE")"
18 echo "Usage: $0 <filename>"
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
28 # get a string like "v0.6.0-66-g59887e8"
29 DESC="$(git describe 2>/dev/null)"
31 # get a string like "2012-04-10 16:27:19 +0200"
32 TIME="$(git log -n 1 --format="%ci")"
35 if [ -n "$DESC" ]; then
36 NEWINFO="#define BUILD_DESC \"$DESC\""
38 NEWINFO="// No build information available"
41 # only update build.h if necessary
42 if [ "$INFO" != "$NEWINFO" ]; then
43 echo "$NEWINFO" >"$FILE"
44 echo "#define BUILD_DATE \"$TIME\"" >>"$FILE"