aboutsummaryrefslogtreecommitdiffstats
path: root/generate_version_h.sh
blob: a9b39e49199072b63cacb373ff4f4289299e7370 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash

if [ -d ".git" ]
then
# If we have a git directory use that as an information source
 VERSION=`git describe --abbrev=0`
 HASH=`git show --format="%h" --no-patch master`
 BRANCH=`git rev-parse --abbrev-ref HEAD`
elif [ "$#" = "3" ]
then
# If we have 3 commandline arguments use them
 VERSION="$1"
 HASH="$2"
 BRANCH="$3"
else
# We don't know our version
 VERSION="Unknown"
 HASH="none"
 BRANCH="Unknown"
fi

echo "#ifndef HAVE_VERSION_H"
echo "#define HAVE_VERSION_H"
echo ""
echo "#define VERSION \"$VERSION\""
echo "#define HASH \"$HASH\""
echo "#define BRANCH \"$BRANCH\""
echo "#define VERSION_FULL VERSION\"-\"HASH\" (\"BRANCH\")\""
echo "char* version();"
echo ""
echo "#endif"