3 # this script creates version.cpp containing version and other compile-time
4 # information. it expects to get the source directory as only argument.
9 test "$src" = '' && src
=.
11 date=`date --utc +%Y-%m-%d`
12 if test -e "$src/.git"; then
13 commit
=`( cd "$src"; git rev-parse HEAD 2> /dev/null; )`
14 version
=`( cd "$src"; git describe --tags HEAD 2> /dev/null; ) || echo "$commit"`
15 if test "$commit" != ''; then
16 ( cd "$src"; git
diff --quiet HEAD
; ) ||
{ commit
="$commit (dirty)"; version
="$version (dirty)"; }
19 test -z "$commit" -a -e "$src/gitcommit" && commit
=`< "$src/gitcommit"`
20 test -z "$version" -a -e "$src/version" && version
=`< "$src/version"`
21 test -z "$commit" && commit
=unknown
22 test -z "$version" && version
=unknown
23 cat > "$output-new" <<EOF
25 const char *recorderCommit = "$commit";
26 const char *recorderDate = "$date";
27 const char *recorderVersion = "$version";
30 if test -e "$output" && diff -q "$output" "$output-new" > /dev
/null
2>&1; then
33 mv "$output-new" "$output"