Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2005:
[Freeciv-Dev] (PR#14351) [Patch] Read version info from version.in
Home

[Freeciv-Dev] (PR#14351) [Patch] Read version info from version.in

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#14351) [Patch] Read version info from version.in
From: "Marko Lindqvist" <marko.lindqvist@xxxxxxxxxxx>
Date: Sun, 16 Oct 2005 06:20:35 -0700
Reply-to: bugs@xxxxxxxxxxx

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


  With attached patch C -code reads version information directly from 
version.in when there is no config.h present. No need to manually update 
version.h every time version changes.
  However, it seems that nobody is building freeciv without config.h.
sernet.c has been missing version.h include for years and nobody has 
complained.


  - ML


diff -Nurd -X.diff_ignore freeciv/common/Makefile.am freeciv/common/Makefile.am
--- freeciv/common/Makefile.am  2005-10-16 13:16:38.015625000 +0300
+++ freeciv/common/Makefile.am  2005-10-16 13:40:26.562500000 +0300
@@ -4,7 +4,7 @@
 
 noinst_LIBRARIES = libcivcommon.a
 
-AM_CPPFLAGS = -I../intl -I$(top_srcdir)/utility -I$(srcdir)/aicore
+AM_CPPFLAGS = -I../intl -I$(top_srcdir)/utility -I$(srcdir)/aicore 
-I$(top_srcdir)
 
 ## Above, note -I../intl instead of -I$(top_srcdir/intl) is deliberate.
 
diff -Nurd -X.diff_ignore freeciv/common/version.c freeciv/common/version.c
--- freeciv/common/version.c    2005-10-16 13:16:40.515625000 +0300
+++ freeciv/common/version.c    2005-10-16 15:47:28.000000000 +0300
@@ -16,11 +16,37 @@
 #endif
 
 #include "fcintl.h"
+#include "fc_types.h"
 #include "shared.h"
 #include "support.h"
 
 #include "version.h"
 
+#define FREECIV_VERSION_COMMENT(comment)
+#define FREECIV_VERSION_INFO(major, minor, patch, label) \
+  const int fc_major_version = major;                    \
+  const int fc_minor_version = minor;                    \
+  const int fc_patch_version = patch;                    \
+  const char *fc_version_label = label;
+#define FREECIV_DEVEL_VERSION(devel)                     \
+  const int is_devel_version = devel;
+#define FREECIV_BETA_VERSION(beta)                       \
+  const int is_beta_version = beta;
+
+#include "version.in"
+
+/**********************************************************************
+  ...
+***********************************************************************/
+const char *freeciv_version_string(void)
+{
+  static char version_string[50];
+
+  my_snprintf(version_string, sizeof(version_string), "%d.%d.%d%s",
+              MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION, VERSION_LABEL);
+
+  return version_string;
+}
 
 /**********************************************************************
   ...
@@ -29,13 +55,13 @@
 {
   static char msgbuf[128];
 
-#if IS_BETA_VERSION
-  my_snprintf(msgbuf, sizeof (msgbuf), _("Freeciv version %s %s"),
-              VERSION_STRING, _("(beta version)"));
-#else
-  my_snprintf(msgbuf, sizeof (msgbuf), _("Freeciv version %s"),
-              VERSION_STRING);
-#endif
+  if (is_beta_version) {
+    my_snprintf(msgbuf, sizeof (msgbuf), _("Freeciv version %s %s"),
+                VERSION_STRING, _("(beta version)"));
+  } else {
+    my_snprintf(msgbuf, sizeof (msgbuf), _("Freeciv version %s"),
+                VERSION_STRING);
+  }
 
   return msgbuf;
 }
@@ -45,11 +71,11 @@
 ***********************************************************************/
 const char *word_version(void)
 {
-#if IS_BETA_VERSION
-  return _("betatest version ");
-#else
-  return _("version ");
-#endif
+  if (is_beta_version) {
+    return _("betatest version ");
+  } else {
+    return _("version ");
+  }
 }
 
 /**********************************************************************
@@ -58,37 +84,37 @@
 ***********************************************************************/
 const char *beta_message(void)
 {
-#if IS_BETA_VERSION
-  static char msgbuf[128];
-  static const char *month[] =
-  {
-    NULL,
-    N_("January"),
-    N_("February"),
-    N_("March"),
-    N_("April"),
-    N_("May"),
-    N_("June"),
-    N_("July"),
-    N_("August"),
-    N_("September"),
-    N_("October"),
-    N_("November"),
-    N_("December")
-  };
-  my_snprintf (msgbuf, sizeof (msgbuf),
-              _("THIS IS A BETA VERSION\n"
-                "Freeciv %s will be released in\n"
-                "%s, at %s"), /* No full stop here since it would be
-                                 immediately following a URL, which
-                                 would only cause confusion. */
-              NEXT_STABLE_VERSION,
-              _(NEXT_RELEASE_MONTH),
-              WEBSITE_URL);
-  return msgbuf;
-#else
-  return NULL;
-#endif
+  if (is_beta_version) {
+    static char msgbuf[128];
+    static const char *month[] =
+    {
+      NULL,
+      N_("January"),
+      N_("February"),
+      N_("March"),
+      N_("April"),
+      N_("May"),
+      N_("June"),
+      N_("July"),
+      N_("August"),
+      N_("September"),
+      N_("October"),
+      N_("November"),
+      N_("December")
+    };
+    my_snprintf (msgbuf, sizeof (msgbuf),
+                 _("THIS IS A BETA VERSION\n"
+                   "Freeciv %s will be released in\n"
+                   "%s, at %s"), /* No full stop here since it would be
+                                    immediately following a URL, which
+                                    would only cause confusion. */
+                 NEXT_STABLE_VERSION,
+                 _(NEXT_RELEASE_MONTH),
+                 WEBSITE_URL);
+    return msgbuf;
+  } else {
+    return NULL;
+  }
 }
 
 /***************************************************************************
diff -Nurd -X.diff_ignore freeciv/common/version.h freeciv/common/version.h
--- freeciv/common/version.h    2005-10-16 13:16:40.546875000 +0300
+++ freeciv/common/version.h    2005-10-16 15:47:30.125000000 +0300
@@ -19,46 +19,42 @@
 #endif
 #endif
 
-/* 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          2
+extern const int fc_major_version;
+#define MAJOR_VERSION fc_major_version
 #endif
+
 #ifndef MINOR_VERSION
-#define MINOR_VERSION          0
+extern const int fc_minor_version;
+#define MINOR_VERSION fc_minor_version
 #endif
+
 #ifndef PATCH_VERSION
-#define PATCH_VERSION          99
+extern const int fc_patch_version;
+#define PATCH_VERSION fc_patch_version
 #endif
+
 #ifndef VERSION_LABEL
-#define VERSION_LABEL          "-devel"
-#endif
-#ifndef IS_DEVEL_VERSION
-#define IS_DEVEL_VERSION       1
-#endif
-#ifndef IS_BETA_VERSION
-#define IS_BETA_VERSION                0
+extern const char *fc_version_label;
+#define VERSION_LABEL fc_version_label
 #endif
 
-/* This is only used if IS_BETA_VERSION is true. */
+/* This is only used if is_beta_version is true. */
 #ifndef NEXT_STABLE_VERSION
 #define NEXT_STABLE_VERSION    "1.13.0"
 #endif
-/* This is only used in version.c, and only if IS_BETA_VERSION is true.
+/* 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])
 #endif
 
 #ifndef VERSION_STRING
-#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
+#define VERSION_STRING freeciv_version_string()
 #endif
 
 /* version informational strings */
+const char *freeciv_version_string(void);
 const char *freeciv_name_version(void);
 const char *word_version(void);
 
diff -Nurd -X.diff_ignore freeciv/server/sernet.c freeciv/server/sernet.c
--- freeciv/server/sernet.c     2005-10-16 13:21:01.718750000 +0300
+++ freeciv/server/sernet.c     2005-10-16 15:48:51.968750000 +0300
@@ -73,6 +73,7 @@
 #include "shared.h"
 #include "support.h"
 #include "timing.h"
+#include "version.h"
 
 #include "connecthand.h"
 #include "console.h"

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#14351) [Patch] Read version info from version.in, Marko Lindqvist <=