Re: [Freeciv-Dev] (PR#4712) Version strings for svn versions

2007-09-03 Thread Marko Lindqvist

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

On 14/08/07, Marko Lindqvist  wrote:

  Plan is to commit this and then to test that it works. Then we can
 start using it.

 This should be final patch for this ticket. svn revision number is
appended to version string, but only if configured with new option
--enable-svnrev. Default is off for now.


 - 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	2007-09-02 15:58:48.0 +0300
+++ freeciv/bootstrap/fc_svnrev_gen.h.in	2007-09-04 04:02:05.0 +0300
@@ -18,9 +18,11 @@
 #ifndef FC__FC_SVNREV_H
 #define FC__FC_SVNREV_H
 
-/* Either FC_SVNREV_OFF or FC_SVNREV_ON macro defined.
+/* One of the macros FC_SVNREV_OFF, FC_SVNREV_ON or FC_SVNREV_MOD defined.
  * If FC_SVNREV_ON is defined, FC_SVNREV contains valid svn revision number
  * string (currently starting with 'r')
+ * If FC_SVNREV_MOD is defined, this seems to be modified svn checkout.
+ * In that case FC_SVNREV contains revision number and word modified.
  * 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
diff -Nurd -X.diff_ignore freeciv/bootstrap/generate_svnrev.sh freeciv/bootstrap/generate_svnrev.sh
--- freeciv/bootstrap/generate_svnrev.sh	2007-09-02 15:58:48.0 +0300
+++ freeciv/bootstrap/generate_svnrev.sh	2007-09-04 04:02:20.0 +0300
@@ -28,6 +28,7 @@
REVSTATE=ON
REV=$REVTMP
  else
+   REVSTATE=MOD
REV=modified $REVTMP
  fi
fi
diff -Nurd -X.diff_ignore freeciv/common/Makefile.am freeciv/common/Makefile.am
--- freeciv/common/Makefile.am	2007-09-04 03:08:01.0 +0300
+++ freeciv/common/Makefile.am	2007-09-04 03:37:03.0 +0300
@@ -96,6 +96,14 @@
 	cd $(srcdir)  ./generate_packets.py
 	touch packets_generate
 
+if SVNREV
+# fc_svnrev_gen.h must be generated before it can be included.
+# Automatic dependencies are only generated during first
+# build. We need dependency for that first build.
+version.o : fc_svnrev_gen.h
+
+endif
+
 .PHONY : fc_svnrev_gen.h
 fc_svnrev_gen.h :
 	$(top_srcdir)/bootstrap/generate_svnrev.sh $(top_srcdir) $(top_builddir)
diff -Nurd -X.diff_ignore freeciv/common/version.c freeciv/common/version.c
--- freeciv/common/version.c	2007-08-04 18:38:32.0 +0300
+++ freeciv/common/version.c	2007-09-04 04:12:10.0 +0300
@@ -22,6 +22,10 @@
 
 #include version.h
 
+#ifdef SVNREV
+#include fc_svnrev_gen.h
+#endif /* SVNREV */
+
 
 /**
   ...
@@ -33,6 +37,9 @@
 #if IS_BETA_VERSION
   my_snprintf(msgbuf, sizeof (msgbuf), _(Freeciv version %s %s),
   VERSION_STRING, _((beta version)));
+#elif defined(SVNREV)  !defined(FC_SVNREV_OFF)
+  my_snprintf(msgbuf, sizeof (msgbuf), _(Freeciv version %s (%s)),
+  VERSION_STRING, fc_svn_revision());
 #else
   my_snprintf(msgbuf, sizeof (msgbuf), _(Freeciv version %s),
   VERSION_STRING);
@@ -54,6 +61,19 @@
 }
 
 /**
+  Returns string with svn revision information if it is possible to
+  determine. Can return also some fallback string or even NULL.
+***/
+const char *fc_svn_revision(void)
+{
+#if defined(SVNREV)  !defined(FC_SVNREV_OFF)
+  return FC_SVNREV; /* Either revision, or modified revision */
+#else  /* FC_SVNREV_OFF */
+  return NULL;
+#endif /* FC_SVNREV_OFF */
+}
+
+/**
   Return the BETA message.
   If returns NULL, not a beta version.
 ***/
diff -Nurd -X.diff_ignore freeciv/common/version.h freeciv/common/version.h
--- freeciv/common/version.h	2007-08-04 18:38:32.0 +0300
+++ freeciv/common/version.h	2007-09-04 04:05:54.0 +0300
@@ -28,6 +28,7 @@
 /* version informational strings */
 const char *freeciv_name_version(void);
 const char *word_version(void);
+const char *fc_svn_revision(void);
 
 const char *freeciv_motto(void);
 
diff -Nurd -X.diff_ignore freeciv/configure.ac freeciv/configure.ac
--- freeciv/configure.ac	2007-08-26 22:07:41.0 +0300
+++ freeciv/configure.ac	2007-09-04 03:38:07.0 +0300
@@ -118,6 +118,18 @@
 WITH_XAW3D=1
 )
 
+AC_ARG_ENABLE([svnrev],
+[  --enable-svnrev get svn revision to version information],
+[case ${enableval} in
+  yes) svnrev=true  ;;
+  no)  svnrev=false ;;
+  *)   AC_MSG_ERROR([bad value ${enableval} for --enable-svnrev]) ;;
+esac], [svnrev=false])
+AM_CONDITIONAL([SVNREV], [test x$svnrev = xtrue])
+if test x$svnrev = xtrue ; then
+  AC_DEFINE([SVNREV], [1], [Get svn revision information to version number])
+fi
+
 AC_ARG_ENABLE(make_data,
 [  --disable-make-data do not recurse make into data 

Re: [Freeciv-Dev] (PR#4712) Version strings for svn versions

2007-08-30 Thread Marko Lindqvist

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.0 +0200
+++ freeciv/bootstrap/fc_svnrev_gen.h.in	2007-08-30 14:38:47.0 +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.0 +0200
+++ freeciv/bootstrap/generate_svnrev.sh	2007-08-30 15:04:34.0 +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.0 +0300
+++ freeciv/common/Makefile.am	2007-08-30 14:55:42.0 +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


[Freeciv-Dev] (PR#4712) Version strings for svn versions

2007-08-14 Thread Marko Lindqvist

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

 Since this ticket has last been touched, we have moved from
self-hosted CVS to gna svn.

 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.


 - 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.0 +0200
+++ freeciv/bootstrap/fc_svnrev_gen.h.in	2007-08-14 20:35:28.0 +0300
@@ -0,0 +1,28 @@
+/**
+ 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, FC_SVNREV contains some fallback string */
+#define FC_SVNREV_SVNREVSTATE
+#define FC_SVNREV SVNREV
+
+#endif /* FC__FC_SVNREV_H */
diff -Nurd -X.diff_ignore freeciv/common/Makefile.am freeciv/common/Makefile.am
--- freeciv/common/Makefile.am	2007-08-04 18:38:32.0 +0300
+++ freeciv/common/Makefile.am	2007-08-14 20:39:54.0 +0300
@@ -91,6 +91,31 @@
 	cd $(srcdir)  ./generate_packets.py
 	touch packets_generate
 
+.PHONY: fc_svnrev_gen.h
+fc_svnrev_gen.h :
+	(REV= ; REVSTATE=OFF ; \
+ if which svn  which tail  \
+   test -d $(top_srcdir)/.svn ; then \
+   if test x$$(cd $(top_srcdir) ; svn diff | tail -n 1) = x ; then \
+MAXREV=0 ; \
+REV=$$(cd $(top_srcdir) ; svn ls -v | (while read REVNUM REST ; do if test $$REVNUM -gt $$MAXREV ; then MAXREV=$$REVNUM ; fi ; done ; echo r$$MAXREV )) ; \
+fi ; \
+echo REV: $$REV; \
+if test x$$REV = x ; then \
+  REV=svn ; \
+else \
+  REVSTATE=ON ; \
+fi ; \
+else \
+  REV=dist ; \
+fi ; \
+cat $(top_srcdir)/bootstrap/fc_svnrev_gen.h.in | sed -e s,SVNREV,$$REV, -e s,SVNREVSTATE,$$REVSTATE,  fc_svnrev_gen.h.tmp ; \
+	if ! test -f fc_svnrev_gen.h || ! cmp fc_svnrev_gen.h fc_svnrev_gen.h.tmp ; then \
+  mv fc_svnrev_gen.h.tmp fc_svnrev_gen.h ; \
+else \
+  rm fc_svnrev_gen.h.tmp ; \
+fi)  /dev/null
+
 #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