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
=`cat "$src/gitcommit"`
20 test -z "$version" -a -e "$src/version" && version
=`cat "$src/version"`
21 test -z "$commit" && commit
=unknown
22 test -z "$version" && version
=unknown
23 cat > "$output-new" <<EOF
25 const char *const recorderCommit = "$commit";
26 const char *const recorderDate = "$date";
27 const char *const recorderVersion = "$version";
30 if test -e "$output" && diff -q "$output" "$output-new" > /dev
/null
2>&1; then
33 mv -f "$output-new" "$output"