<URL: http://bugs.freeciv.org/Ticket/Display.html?id=4712 >

On 14/08/2007, Marko Lindqvist <[EMAIL PROTECTED]> wrote:
>
>  Attached patch adds target fc_svnrev_gen.h to common/Makefile. At
> this point this file is not used (included) anywhere, and it is not
> dependency for anything (it will be built only if explicitly
> requested)
>
>  That header contains a couple of macros.
>  - First there is either FC_SVNREV_ON or FC_SVNREV_OFF defined.
> FC_SVNREV_ON will be defined if source directory is unmodified svn
> checkout directory.
>  - FC_SVNREV itself contains release string ("r13171") if FC_SVNREV_ON
> defined, or some fallback string if FC_SVNREV_OFF is defined.
>
>  I have tested this in my system using number of tricks, but in the
> end it cannot be fully tested before it is committed (since changing
> build system locally to support this will mean that local system is
> not unmodified).
>  Plan is to commit this and then to test that it works. Then we can
> start using it.

 Mostly rewritten to make later integration easier


 - ML

diff -Nurd -X.diff_ignore freeciv/bootstrap/fc_svnrev_gen.h.in freeciv/bootstrap/fc_svnrev_gen.h.in
--- freeciv/bootstrap/fc_svnrev_gen.h.in	1970-01-01 02:00:00.000000000 +0200
+++ freeciv/bootstrap/fc_svnrev_gen.h.in	2007-08-30 14:38:47.000000000 +0300
@@ -0,0 +1,29 @@
+/**********************************************************************
+ Freeciv - Copyright (C) 2004 - The Freeciv Project
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+***********************************************************************/
+
+/* common/fc_svnrev_gen.h is automatically generated from
+ * bootstrap/fc_svnrev_gen.h.in. Do not edit fc_svnrev_ge.h, edit
+ * fc_svnrev_gen.h.in */
+
+#ifndef FC__FC_SVNREV_H
+#define FC__FC_SVNREV_H
+
+/* Either FC_SVNREV_OFF or FC_SVNREV_ON macro defined.
+ * If FC_SVNREV_ON is defined, FC_SVNREV contains valid svn revision number
+ * string (currently starting with 'r')
+ * If FC_SVNREV_OFF is defined, you should not use FC_SVNREV even though
+ * it does contain fallback string (currently "dist") */
+#define FC_SVNREV_<SVNREVSTATE>
+#define FC_SVNREV "<SVNREV>"
+
+#endif /* FC__FC_SVNREV_H */
diff -Nurd -X.diff_ignore freeciv/bootstrap/generate_svnrev.sh freeciv/bootstrap/generate_svnrev.sh
--- freeciv/bootstrap/generate_svnrev.sh	1970-01-01 02:00:00.000000000 +0200
+++ freeciv/bootstrap/generate_svnrev.sh	2007-08-30 15:04:34.000000000 +0300
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+# This script generates fc_svnrev_gen.h from fc_svnrev_gen.h.in.
+# See fc_svnrev_gen.h.in for details.
+
+# Parameters - $1 - top srcdir
+#              $2 - top builddir
+#
+
+# Absolete paths
+INPUTDIR=$(cd "$1/bootstrap" ; pwd)
+OUTPUTDIR=$(cd "$2/common" ; pwd)
+
+REVSTATE="OFF"
+REV="dist"
+
+(cd "$INPUTDIR"
+ # Check that all commands required by this script are available
+ # If not, we will not claim to know which svn revision this is
+ # (REVSTATE will be OFF)
+ if which svn && which tail && which wc ; then
+   REVTMP="r$(svn info 2>/dev/null | grep "^Revision: " | sed 's/^Revision: //')"
+   if test "$REVTMP" != "r" ; then
+     # This is svn checkout. Check for local modifications
+     if test $(cd "$1" ; svn diff | wc -l) -eq 0 ; then
+       REVSTATE=ON
+       REV="$REVTMP"
+     else
+       REV="modified $REVTMP"
+     fi
+   fi
+ fi
+
+ sed -e "s,<SVNREV>,$REV," -e "s,<SVNREVSTATE>,$REVSTATE," fc_svnrev_gen.h.in > "$OUTPUTDIR/fc_svnrev_gen.h.tmp"
+ if ! test -f "$OUTPUTDIR/fc_svnrev_gen.h" ||
+    ! cmp "$OUTPUTDIR/fc_svnrev_gen.h" "$OUTPUTDIR/fc_svnrev_gen.h.tmp"
+ then
+   mv "$OUTPUTDIR/fc_svnrev_gen.h.tmp" "$OUTPUTDIR/fc_svnrev_gen.h"
+ fi
+ rm -f "$OUTPUTDIR/fc_svnrev_gen.h.tmp"
+) > /dev/null
diff -Nurd -X.diff_ignore freeciv/common/Makefile.am freeciv/common/Makefile.am
--- freeciv/common/Makefile.am	2007-08-30 14:38:04.000000000 +0300
+++ freeciv/common/Makefile.am	2007-08-30 14:55:42.000000000 +0300
@@ -91,6 +91,9 @@
 	cd $(srcdir) && ./generate_packets.py
 	touch packets_generate
 
+.PHONY : fc_svnrev_gen.h
+fc_svnrev_gen.h :
+	$(top_srcdir)/bootstrap/generate_svnrev.sh $(top_srcdir) $(top_builddir)
+
 #libcivcommon_a_DEPENDENCIES = ../utility/libcivutility.a
 #libcivcommon_a_LIBADD       = ../utility/libcivutility.a
-
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to