<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.000000000 +0300
+++ freeciv/bootstrap/fc_svnrev_gen.h.in	2007-09-04 04:02:05.000000000 +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.000000000 +0300
+++ freeciv/bootstrap/generate_svnrev.sh	2007-09-04 04:02:20.000000000 +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.000000000 +0300
+++ freeciv/common/Makefile.am	2007-09-04 03:37:03.000000000 +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.000000000 +0300
+++ freeciv/common/version.c	2007-09-04 04:12:10.000000000 +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.000000000 +0300
+++ freeciv/common/version.h	2007-09-04 04:05:54.000000000 +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.000000000 +0300
+++ freeciv/configure.ac	2007-09-04 03:38:07.000000000 +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 directories
                           (ok to disable unless you will 'make install')],
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to