Complete.Org: Mailing Lists: Archives: freeciv-dev: May 2004:
[Freeciv-Dev] Re: (PR#8650) (PR: #4712)
Home

[Freeciv-Dev] Re: (PR#8650) (PR: #4712)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] Re: (PR#8650) (PR: #4712)
From: "Marko Lindqvist" <marko.lindqvist@xxxxxxxxxxx>
Date: Sun, 2 May 2004 15:28:20 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=8650 >

Jason Short wrote:

> it will be useful.  At a minimum you may want to archive the patch (this
> ticket is as good a place as any).

  Ok, I _hacked_ it into shape where it at least compiles and should 
even work. This is "proof of concept" quality. Contains two new files: 
version.in and m4/version.m4.


  - Caz


diff -Nurd -X freeciv/diff_ignore freeciv/Makefile.am freeciv/Makefile.am
--- freeciv/Makefile.am 2004-04-27 07:10:23.000000000 +0300
+++ freeciv/Makefile.am 2004-05-03 01:11:07.906250000 +0300
@@ -71,6 +71,7 @@
                m4/sdl-client.m4                \
                m4/sdl.m4                       \
                m4/sound.m4                     \
+               m4/version.m4                   \
                m4/vsnprintf.m4                 \
                m4/win32-client.m4              \
                m4/x.213                        \
@@ -80,3 +81,5 @@
                vms/imlib_config.h_vms          \
                vms/readme.vms                  \
                vms/vms_build.com
+
+noinst_HEADERS= version.in
diff -Nurd -X freeciv/diff_ignore freeciv/common/Makefile.am 
freeciv/common/Makefile.am
--- freeciv/common/Makefile.am  2004-02-13 09:57:58.000000000 +0200
+++ freeciv/common/Makefile.am  2004-05-03 01:10:38.906250000 +0300
@@ -4,7 +4,7 @@
 
 noinst_LIBRARIES = libcivcommon.a
 
-INCLUDES = -I../intl -I$(srcdir)/aicore
+INCLUDES = -I../intl -I$(srcdir)/aicore -I$(top_srcdir)
 
 ## Above, note -I../intl instead of -I$(top_srdir/intl) is deliberate.
 
diff -Nurd -X freeciv/diff_ignore freeciv/common/version.c 
freeciv/common/version.c
--- freeciv/common/version.c    2002-11-14 11:15:03.000000000 +0200
+++ freeciv/common/version.c    2004-05-03 01:10:39.015625000 +0300
@@ -22,6 +22,17 @@
 #include "version.h"
 
 
+#define FREECIV_MAJOR_VERSION(x) const int fciv_major_version = (x);
+#define FREECIV_MINOR_VERSION(x) const int fciv_minor_version = (x);
+#define FREECIV_PATCH_VERSION(x) const int fciv_patch_version = (x);
+#define FREECIV_VERSION_LABEL(x) const char fciv_version_label[] = x;
+#define FREECIV_DEVEL_VERSION(x) const bool fciv_devel_version = (x);
+#define FREECIV_BETA_VERSION(x) const bool fciv_beta_version = (x);
+#define FREECIV_NEXT_STABLE(x) const char fciv_next_stable[] = x;
+#define FREECIV_RELEASE_MONTH(x) const int fciv_rel_month = (x);
+
+#include "version.in"
+
 /**********************************************************************
   ...
 ***********************************************************************/
@@ -43,6 +54,18 @@
 /**********************************************************************
   ...
 ***********************************************************************/
+const char *version_string()
+{
+  static char buf[50];
+
+  sprintf(buf, "%d.%d.%d%s", MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION, 
VERSION_LABEL);
+
+  return buf;
+}
+
+/**********************************************************************
+  ...
+***********************************************************************/
 const char *word_version(void)
 {
 #if IS_BETA_VERSION
diff -Nurd -X freeciv/diff_ignore freeciv/common/version.h 
freeciv/common/version.h
--- freeciv/common/version.h    2003-07-28 23:16:18.000000000 +0300
+++ freeciv/common/version.h    2004-05-03 01:16:25.078125000 +0300
@@ -19,48 +19,66 @@
 #endif
 #endif
 
+extern const int fciv_major_version;
+extern const int fciv_minor_version;
+extern const int fciv_patch_version;
+extern const char fciv_version_label[];
+extern const bool fciv_devel_version;
+extern const bool fciv_beta_version;
+extern const char fciv_next_stable[];
+extern const int fciv_rel_month;
+
 /* The following is for the benefit (?) of non-configure make methods. */
 /* !! These must be the same as their counterparts in configure.in. !! */
 #ifndef MAJOR_VERSION
-#define MAJOR_VERSION          1
+#define MAJOR_VERSION fciv_major_version
 #endif
 #ifndef MINOR_VERSION
-#define MINOR_VERSION          14
+#define MINOR_VERSION fciv_minor_version
 #endif
 #ifndef PATCH_VERSION
-#define PATCH_VERSION          99
+#define PATCH_VERSION fciv_patch_version
 #endif
 #ifndef VERSION_LABEL
-#define VERSION_LABEL          "-devel"
+#define VERSION_LABEL fciv_version_label
 #endif
 #ifndef IS_DEVEL_VERSION
-#define IS_DEVEL_VERSION       1
+#define IS_DEVEL_VERSION fciv_devel_version
 #endif
 #ifndef IS_BETA_VERSION
-#define IS_BETA_VERSION                0
+#define IS_BETA_VERSION fciv_beta_version
 #endif
 
 /* This is only used if IS_BETA_VERSION is true. */
 #ifndef NEXT_STABLE_VERSION
-#define NEXT_STABLE_VERSION    "1.13.0"
+#define NEXT_STABLE_VERSION fciv_next_stable
 #endif
+
 /* This is only used in version.c, and only if IS_BETA_VERSION is true.
    The month[] array is defined in version.c (index: 1==Jan, 2==Feb, ...). */
 #ifndef NEXT_RELEASE_MONTH
-#define NEXT_RELEASE_MONTH     (month[6])
+#define NEXT_RELEASE_MONTH (month[fciv_rel_month])
 #endif
 
+#define FREECIV_VERSION_COMMENT(x)
+
+
 #ifndef VERSION_STRING
+#ifdef HAVE_CONFIG_H
 #define VER_STRINGIFY1(x) #x
 #define VER_STRINGIFY(x) VER_STRINGIFY1(x)
 #define VERSION_STRING VER_STRINGIFY(MAJOR_VERSION) "." \
                        VER_STRINGIFY(MINOR_VERSION) "." \
                        VER_STRINGIFY(PATCH_VERSION) VERSION_LABEL
+#else
+#define VERSION_STRING version_string()
+#endif
 #endif
 
 /* version informational strings */
 const char *freeciv_name_version(void);
 const char *word_version(void);
+const char *version_string();
 
 /* If returns NULL, not a beta version. */
 const char *beta_message(void);
diff -Nurd -X freeciv/diff_ignore freeciv/configure.ac freeciv/configure.ac
--- freeciv/configure.ac        2004-04-29 08:37:14.000000000 +0300
+++ freeciv/configure.ac        2004-05-03 01:10:39.078125000 +0300
@@ -14,13 +14,7 @@
 
 dnl client/server should always have the same major and minor versions
 dnl different patch versions are compatible
-dnl These values must match in configure.*, common/version.h, and data/Freeciv.
-MAJOR_VERSION=1
-MINOR_VERSION=14
-PATCH_VERSION=99
-VERSION_LABEL="-devel"
-IS_DEVEL_VERSION=1
-IS_BETA_VERSION=0
+m4_include(version.in)
 
 VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}${VERSION_LABEL}
 
@@ -672,6 +666,8 @@
   CFLAGS="$EXTRA_GCC_DEBUG_CFLAGS $CFLAGS"
 fi
 
+AC_SUBST([CONFIGURE_DEPENDENCIES], ['$(top_srcdir)/version.in'])
+
 AC_CONFIG_FILES([Makefile
           data/Makefile 
          data/misc/Makefile 
diff -Nurd -X freeciv/diff_ignore freeciv/configure.in freeciv/configure.in
--- freeciv/configure.in        2004-04-29 08:37:14.000000000 +0300
+++ freeciv/configure.in        2004-05-03 01:10:39.078125000 +0300
@@ -13,13 +13,7 @@
 
 dnl client/server should always have the same major and minor versions
 dnl different patch versions are compatible
-dnl These values must match in configure.*, common/version.h, and data/Freeciv.
-MAJOR_VERSION=1
-MINOR_VERSION=14
-PATCH_VERSION=99
-VERSION_LABEL="-devel"
-IS_DEVEL_VERSION=1
-IS_BETA_VERSION=0
+m4_include(version.in)
 
 VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}${VERSION_LABEL}
 
@@ -658,6 +652,8 @@
   CFLAGS="$EXTRA_GCC_DEBUG_CFLAGS $CFLAGS"
 fi
 
+AC_SUBST([CONFIGURE_DEPENDENCIES], ['$(top_srcdir)/version.in'])
+
 AC_OUTPUT(Makefile
           data/Makefile 
          data/misc/Makefile 
diff -Nurd -X freeciv/diff_ignore freeciv/m4/version.m4 freeciv/m4/version.m4
--- freeciv/m4/version.m4       1970-01-01 02:00:00.000000000 +0200
+++ freeciv/m4/version.m4       2004-05-03 01:11:07.859375000 +0300
@@ -0,0 +1,19 @@
+#
+# These macros are used in version.in and they just set
+# version information to form understandable for configure.ac and
+# configure.in. Other systems define these macros differently
+# before reading version.in and thus get version information
+# in different form.
+# 
+
+AC_DEFUN([FREECIV_VERSION_COMMENT])
+
+AC_DEFUN([FREECIV_MAJOR_VERSION], [MAJOR_VERSION="$1"])
+AC_DEFUN([FREECIV_MINOR_VERSION], [MINOR_VERSION="$1"])
+AC_DEFUN([FREECIV_PATCH_VERSION], [PATCH_VERSION="$1"])
+AC_DEFUN([FREECIV_VERSION_LABEL], [VERSION_LABEL="$1"])
+AC_DEFUN([FREECIV_DEVEL_VERSION], [IS_DEVEL_VERSION="$1"])
+AC_DEFUN([FREECIV_BETA_VERSION], [IS_BETA_VERSION="$1"])
+
+AC_DEFUN([FREECIV_NEXT_STABLE])
+AC_DEFUN([FREECIV_RELEASE_MONTH])
diff -Nurd -X freeciv/diff_ignore freeciv/server/meta.c freeciv/server/meta.c
--- freeciv/server/meta.c       2004-01-25 15:55:14.000000000 +0200
+++ freeciv/server/meta.c       2004-05-03 01:11:13.734375000 +0300
@@ -265,7 +265,8 @@
   desc[0]='\0';
   
   cat_snprintf(desc, sizeof(desc), "Freeciv\n");
-  cat_snprintf(desc, sizeof(desc), VERSION_STRING"\n");
+  cat_snprintf(desc, sizeof(desc), VERSION_STRING);
+  cat_snprintf(desc, sizeof(desc), "\n");
   /* note: the following strings are not translated here;
      we mark them so they may be translated when received by a client */
   switch(server_state) {
diff -Nurd -X freeciv/diff_ignore freeciv/server/sernet.c 
freeciv/server/sernet.c
--- freeciv/server/sernet.c     2004-03-17 02:22:44.000000000 +0200
+++ freeciv/server/sernet.c     2004-05-03 01:11:13.750000000 +0300
@@ -71,6 +71,7 @@
 #include "shared.h"
 #include "support.h"
 #include "timing.h"
+#include "version.h"
 
 #include "connecthand.h"
 #include "console.h"
diff -Nurd -X freeciv/diff_ignore freeciv/version.in freeciv/version.in
--- freeciv/version.in  1970-01-01 02:00:00.000000000 +0200
+++ freeciv/version.in  2004-05-03 01:11:14.140625000 +0300
@@ -0,0 +1,21 @@
+FREECIV_VERSION_COMMENT("  Copyright (C) 2004 Freeciv team               ")
+
+FREECIV_VERSION_COMMENT("  Programming language independent version      ")
+FREECIV_VERSION_COMMENT("  definition for freeciv. Macros used here      ")
+FREECIV_VERSION_COMMENT("  are defined differently depending on          ")
+FREECIV_VERSION_COMMENT("  language used. Don't add comments             ")
+FREECIV_VERSION_COMMENT("  specific to some language into this file.     ")
+
+FREECIV_VERSION_COMMENT("  For now version information in data/Freeciv   ")
+FREECIV_VERSION_COMMENT("  must be updated manually when ever this file  ")
+FREECIV_VERSION_COMMENT("  changes.                                      ")
+
+FREECIV_MAJOR_VERSION(1)
+FREECIV_MINOR_VERSION(14)
+FREECIV_PATCH_VERSION(99)
+FREECIV_VERSION_LABEL("-devel")
+FREECIV_DEVEL_VERSION(1)
+FREECIV_BETA_VERSION(0)
+
+FREECIV_NEXT_STABLE("1.13.0")
+FREECIV_RELEASE_MONTH(6)

[Prev in Thread] Current Thread [Next in Thread]