Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2003:
[Freeciv-Dev] (PR#2479) Change version string of development versions
Home

[Freeciv-Dev] (PR#2479) Change version string of development versions

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: rf13@xxxxxxxxxxxxxxxxx
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#2479) Change version string of development versions
From: "Jason Short via RT" <rt@xxxxxxxxxxxxxx>
Date: Tue, 28 Jan 2003 23:42:54 -0800
Reply-to: rt@xxxxxxxxxxxxxx

[rfalke - Tue Dec  3 08:01:57 2002]:

> Development version should use a string of the format "CVS <date>"
> where <date> is in ISO date like 2002-12-03 instead of the current
> "1.14.1-devel". The date should be the build date.

The core problem is that since the version string goes into config.h,
this requires total recompilation every time you rerun configure (or
autogen.sh, or cvs up, or however it ends up being done).

One idea is to change the version strings

MAJOR_VERSION=`date +%Y`
MINOR_VERSION=`date +%m`
PATCH_VERSION=`date +%d`
VERSION_LABEL="-CVS"

to configure.ac and configure.ac.  This results in version strings like
"2003.01.29-CVS", which is rather nice.  But in config.h there is also
'#define MAJOR_VERSION 2003', which is a bit off.  And you have to
recompile every day (on days when you rerun configure).  And anyone who
doesn't have the 'date' program installed is in trouble.  Note this also
gives the build (err, configure) time rather than the checkout/update
time (which may not be constant in any case) - but since the main goal
is to have better version strings on the daily snapshots, this should be
fine.

There's also the problem of version.h; this should generally be rebuild
automatically as well (from a version.h.in) to include the correct
values.  Of course, this also means lots of recompilation (unless the
values are put into version.c as function calls, AND taken out of
configure.ac...which is a lot of work).

Note that this method will not work on the daily snapshots: the
timestamp given will be that on which the snapshot is compiled (err,
configured), not that on which it was generated.


The idea of using CVS tags has been suggested.  But there is no tag that
will suffice in this case.


So it seems best that the timestamp should be generated when autogen.sh
is run.  Then the values would be taken out of config.h and version.h,
and they would all go into version.c.in from which version.c would be
generated...so that not much recompilation is, in general, needed.

After a good long look at autoconf, I don't believe it can do this.  It
is only a macro expansion mechanism, so actually running the 'date'
program is beyond it.  And I see no means of 'automatically' retrieving
the date.

Automake seems like it would be helpful, but again I have no idea how to
do it.


We could put the tests directly into autogen.sh.  For instance in that
script we have:

echo "+ building timestamps ..."
(date +%Y > major_version && \
 date +%m > minor_version && \
 date +%d > patch_version) || {
  echo
  echo "date failed"
  exit 1
}

and then configure.ac contains:

MAJOR_VERSION=`cat major_version || echo 1`
MINOR_VERSION=`cat minor_version || echo 14`
PATCH_VERSION=`cat patch_version || echo 99`
VERSION_LABEL="-CVS"

this is helpful in the majority of cases, but still doesn't do anything
about version.h.


It would be possible to use autoconf to generate an autogen.sh that did
all the work, i.e., to create an autogen.ac which is used to create
autogen.sh.   autogen could then do the substitution (on
configure.in.in, configure.ac.in, and version.c.in, I think) when it
ran.  But this would be crazyness...


The original autogen.sh method could be used by doing an
AC_SUBST(@MAJOR_VERSION@) instead of AC_DEFINE_UNQUOTED(MAJOR_VERSION)
to get the values into version.h directly.  They could then be moved to
version.c as needed to avoid unnecessary recompilation.  See attached
patch (you will need to copy common/version.h to common/version.h.in). 
This seems like the best idea so far.  But it may end up requiring
additional compilation, in which case the substitutions should all go
into version.c.in to avoid it.

jason

Index: .cvsignore
===================================================================
RCS file: /home/freeciv/CVS/freeciv/.cvsignore,v
retrieving revision 1.7
diff -u -r1.7 .cvsignore
--- .cvsignore  2002/05/22 21:16:05     1.7
+++ .cvsignore  2003/01/29 07:40:36
@@ -1,3 +1,6 @@
+major_version
+minor_version
+patch_version
 acinclude.m4
 aclocal.m4
 autom4te.cache
Index: acconfig.old
===================================================================
RCS file: /home/freeciv/CVS/freeciv/acconfig.old,v
retrieving revision 1.4
diff -u -r1.4 acconfig.old
--- acconfig.old        2003/01/13 21:24:05     1.4
+++ acconfig.old        2003/01/29 07:40:36
@@ -19,13 +19,6 @@
  *    specific parts of configure.)
  */
 
-#undef MAJOR_VERSION
-#undef MINOR_VERSION
-#undef PATCH_VERSION
-#undef VERSION_LABEL
-#undef IS_DEVEL_VERSION
-#undef IS_BETA_VERSION
-#undef VERSION_STRING
 #undef DEBUG
 #undef NDEBUG
 #undef HAVE_LIBICE
Index: autogen.sh
===================================================================
RCS file: /home/freeciv/CVS/freeciv/autogen.sh,v
retrieving revision 1.10
diff -u -r1.10 autogen.sh
--- autogen.sh  2002/10/31 11:19:45     1.10
+++ autogen.sh  2003/01/29 07:40:36
@@ -193,6 +193,14 @@
   echo "automake failed"
   exit 1
 }
+echo "+ building timestamps ..."
+(date +%Y > major_version && \
+ date +%m > minor_version && \
+ date +%d > patch_version) || {
+  echo
+  echo "date failed"
+  exit 1
+}
 
 # now remove the cache, because it can be considered dangerous in this case
 echo "+ removing config.cache ... "
Index: configure.ac
===================================================================
RCS file: /home/freeciv/CVS/freeciv/configure.ac,v
retrieving revision 1.35
diff -u -r1.35 configure.ac
--- configure.ac        2003/01/16 22:14:13     1.35
+++ configure.ac        2003/01/29 07:40:37
@@ -14,10 +14,10 @@
 
 dnl client/server should always have the same major and minor versions
 dnl different patch versions are compatible
-MAJOR_VERSION=1
-MINOR_VERSION=14
-PATCH_VERSION=1
-VERSION_LABEL="-devel"
+MAJOR_VERSION=`cat major_version || echo 1`
+MINOR_VERSION=`cat minor_version || echo 14`
+PATCH_VERSION=`cat patch_version || echo 99`
+VERSION_LABEL="-CVS"
 IS_DEVEL_VERSION=1
 IS_BETA_VERSION=0
 
@@ -29,13 +29,13 @@
 dnl  AC_DEFINE_UNQUOTED(VERSION, $VERSION, [Version number])
 dnl  AC_SUBST(VERSION)
 
-AC_DEFINE_UNQUOTED(MAJOR_VERSION, $MAJOR_VERSION, [Major version])
-AC_DEFINE_UNQUOTED(MINOR_VERSION, $MINOR_VERSION, [Minor version])
-AC_DEFINE_UNQUOTED(PATCH_VERSION, $PATCH_VERSION, [Patch version])
-AC_DEFINE_UNQUOTED(VERSION_LABEL, "${VERSION_LABEL}", [Version label])
-AC_DEFINE_UNQUOTED(VERSION_STRING, 
"${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}${VERSION_LABEL}", [Version 
string])
-AC_DEFINE_UNQUOTED(IS_DEVEL_VERSION, $IS_DEVEL_VERSION, [Is this a devel 
version])
-AC_DEFINE_UNQUOTED(IS_BETA_VERSION, $IS_BETA_VERSION, [Is this a beta 
veersion])
+AC_SUBST(MAJOR_VERSION)
+AC_SUBST(MINOR_VERSION)
+AC_SUBST(PATCH_VERSION)
+AC_SUBST(VERSION_LABEL)
+AC_SUBST(VERSION_STRING)
+AC_SUBST(IS_DEVEL_VERSION)
+AC_SUBST(IS_BETA_VERSION)
 
 dnl Initialize automake stuff
 AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
@@ -682,6 +682,7 @@
          data/nation/Makefile 
          data/history/Makefile 
          common/Makefile 
+         common/version.h
          common/aicore/Makefile 
          ai/Makefile 
          client/Makefile 
Index: configure.in
===================================================================
RCS file: /home/freeciv/CVS/freeciv/configure.in,v
retrieving revision 1.213
diff -u -r1.213 configure.in
--- configure.in        2003/01/16 22:14:13     1.213
+++ configure.in        2003/01/29 07:40:37
@@ -13,10 +13,10 @@
 
 dnl client/server should always have the same major and minor versions
 dnl different patch versions are compatible
-MAJOR_VERSION=1
-MINOR_VERSION=14
-PATCH_VERSION=1
-VERSION_LABEL="-devel"
+MAJOR_VERSION=`cat major_version || echo 1`
+MINOR_VERSION=`cat minor_version || echo 14`
+PATCH_VERSION=`cat patch_version || echo 99`
+VERSION_LABEL="-CVS"
 IS_DEVEL_VERSION=1
 IS_BETA_VERSION=0
 
@@ -28,13 +28,13 @@
 dnl  AC_DEFINE_UNQUOTED(VERSION, $VERSION)
 dnl  AC_SUBST(VERSION)
 
-AC_DEFINE_UNQUOTED(MAJOR_VERSION, $MAJOR_VERSION)
-AC_DEFINE_UNQUOTED(MINOR_VERSION, $MINOR_VERSION)
-AC_DEFINE_UNQUOTED(PATCH_VERSION, $PATCH_VERSION)
-AC_DEFINE_UNQUOTED(VERSION_LABEL, "${VERSION_LABEL}")
-AC_DEFINE_UNQUOTED(VERSION_STRING, 
"${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}${VERSION_LABEL}")
-AC_DEFINE_UNQUOTED(IS_DEVEL_VERSION, $IS_DEVEL_VERSION)
-AC_DEFINE_UNQUOTED(IS_BETA_VERSION, $IS_BETA_VERSION)
+AC_SUBST(MAJOR_VERSION)
+AC_SUBST(MINOR_VERSION)
+AC_SUBST(PATCH_VERSION)
+AC_SUBST(VERSION_LABEL)
+AC_SUBST(VERSION_STRING)
+AC_SUBST(IS_DEVEL_VERSION)
+AC_SUBST(IS_BETA_VERSION)
 
 dnl Initialize automake stuff
 AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
@@ -677,7 +677,8 @@
          data/scenario/Makefile 
          data/nation/Makefile 
          data/history/Makefile 
-         common/Makefile 
+         common/Makefile
+         common/version.h 
           common/aicore/Makefile
          ai/Makefile 
          client/Makefile 
Index: common/.cvsignore
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/.cvsignore,v
retrieving revision 1.3
diff -u -r1.3 .cvsignore
--- common/.cvsignore   2002/04/13 13:59:27     1.3
+++ common/.cvsignore   2003/01/29 07:40:37
@@ -1,3 +1,4 @@
+version.h
 Makefile
 Makefile.in
 .deps
Index: common/version.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/version.h,v
retrieving revision 1.51
diff -u -r1.51 version.h
--- common/version.h    2002/10/11 23:37:00     1.51
+++ common/version.h    2003/01/29 07:40:38
@@ -19,27 +19,20 @@
 #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          1
-#endif
-#ifndef MINOR_VERSION
-#define MINOR_VERSION          14
-#endif
-#ifndef PATCH_VERSION
-#define PATCH_VERSION          1
-#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
-#endif
+/* These values are defined here because not all systems use config.h. */
+
+#define MAJOR_VERSION @MAJOR_VERSION@
 
+#define MINOR_VERSION @MINOR_VERSION@
+
+#define PATCH_VERSION @PATCH_VERSION@
+
+#define VERSION_LABEL "@VERSION_LABEL@"
+
+#define IS_DEVEL_VERSION @IS_DEVEL_VERSION@
+
+#define IS_BETA_VERSION        @IS_BETA_VERSION@
+
 /* This is only used if IS_BETA_VERSION is true. */
 #ifndef NEXT_STABLE_VERSION
 #define NEXT_STABLE_VERSION    "1.13.0"
@@ -50,13 +43,7 @@
 #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
-#endif
+#define VERSION_STRING "@VERSION@"
 
 /* version informational strings */
 const char *freeciv_name_version(void);

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