Replaced typo that caused unnecessary regeneration of fc_gitrev_gen.h
[freeciv.git] / bootstrap / generate_gitrev.sh
blobc9bc071e3235e52449d1941d53bb39303bc22cd4
1 #!/bin/sh
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
9 # $2 - top builddir
12 # Absolete paths
13 SRCROOT="$(cd "$1" ; pwd)"
14 INPUTDIR="$(cd "$1/bootstrap" ; pwd)"
15 OUTPUTDIR="$(cd "$2/common" ; pwd)"
17 REVSTATE="OFF"
18 REV1=""
19 REV2="dist"
21 (cd "$INPUTDIR"
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
30 REVSTATE=ON
31 REV2="$REVTMP"
32 else
33 REVSTATE=MOD
34 REV1="modified "
35 REV2="$REVTMP"
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"
43 then
44 mv "$OUTPUTDIR/fc_gitrev_gen.h.tmp" "$OUTPUTDIR/fc_gitrev_gen.h"
46 rm -f "$OUTPUTDIR/fc_gitrev_gen.h.tmp"
47 ) > /dev/null