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 32 33 34 35 36 37
|
#!/bin/sh
if [ ! -z "$1" ]; then
dir="$1"
else
dir=.
fi
cat >> version.h.new <<_EOM_
/* Generated file that contains the version identifier from
the "git describe" command.
DO NOT EDIT. Check Makefile and mkversion.sh in src.
*/
_EOM_
gitversion=''
if v=$(git -C $dir describe --match 'V*' 2>/dev/null); then
if [ ! -z $v ]; then
gitversion=$(echo $v | sed 's/^V//')
if [ $(git -C $dir diff | wc -c) != 0 ]; then
gitversion="$gitversion-DIRTY";
fi
echo "#define GIT_VERSION "'"'$gitversion'"' >> version.h.new
fi
fi
if [ ! -r version.h ]; then
mv version.h.new version.h
elif cmp version.h version.h.new >/dev/null; then
# echo "No GIT version change"
rm version.h.new
else
echo "Updated GIT version"
mv version.h.new version.h
fi
|