3 # Freeciv - Copyright (C) 2007 - The Freeciv Project
5 # This script generates fc_gitrev_gen.h from fc_gitrev_gen.h.tmpl.
6 # See fc_gitrev_gen.h.tmpl for details.
8 # Parameters - $1 - top srcdir
13 SRCROOT
="$(cd "$1" ; pwd)"
14 INPUTDIR
="$(cd "$1/bootstrap
" ; pwd)"
15 OUTPUTDIR
="$(cd "$2/common
" ; pwd)"
22 # Check that all commands required by this script are available
23 # If not, we will not claim to know which git revision this is
24 # (REVSTATE will be OFF)
25 if which git
&& which tail && which wc ; then
26 REVTMP
="$(git rev-parse HEAD 2>/dev/null)"
27 if test "x$REVTMP" != "x" ; then
28 # This is git repository. Check for local modifications
29 if test $
(cd "$SRCROOT" ; git
diff |
wc -l) -eq 0 ; then
40 sed -e "s,<GITREV1>,$REV1," -e "s,<GITREV2>,$REV2," -e "s,<GITREVSTATE>,$REVSTATE," fc_gitrev_gen.h.tmpl
> "$OUTPUTDIR/fc_gitrev_gen.h.tmp"
41 if ! test -f "$OUTPUTDIR/fc_gitrev_gen.h" ||
42 ! cmp "$OUTPUTDIR/fc_gitrev_gen.h" "$OUTPUTDIR/fc_gitrev_gen.h.tmp"
44 mv "$OUTPUTDIR/fc_gitrev_gen.h.tmp" "$OUTPUTDIR/fc_gitrev_gen.h"
46 rm -f "$OUTPUTDIR/fc_gitrev_gen.h.tmp"