utils/makerpm: Fix building of RPMs
[skype-call-recorder.git] / makeversion
blob6679a3d1b3f0fc63e5e148e780ef4353966e5f0b
1 #!/bin/sh
3 # this script creates version.cpp containing version and other compile-time
4 # information. it expects to get the source directory as only argument.
6 output=version.cpp
8 src=$1
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
24 #include "common.h"
25 const char *const recorderCommit = "$commit";
26 const char *const recorderDate = "$date";
27 const char *const recorderVersion = "$version";
28 EOF
30 if test -e "$output" && diff -q "$output" "$output-new" > /dev/null 2>&1; then
31 rm "$output-new"
32 else
33 mv -f "$output-new" "$output"