1 /**********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12 ***********************************************************************/
15 #include <fc_config.h>
29 #include "fc_svnrev_gen.h"
33 #include "fc_gitrev_gen.h"
36 /**********************************************************************
37 Return string containing both name of Freeciv and version.
38 ***********************************************************************/
39 const char *freeciv_name_version(void)
41 static char msgbuf
[256];
44 fc_snprintf(msgbuf
, sizeof (msgbuf
), _("Freeciv version %s %s"),
45 VERSION_STRING
, _("(beta version)"));
46 #elif defined(SVNREV) && !defined(FC_SVNREV_OFF)
47 fc_snprintf(msgbuf
, sizeof (msgbuf
), _("Freeciv version %s (%s)"),
48 VERSION_STRING
, fc_svn_revision());
49 #elif defined(GITREV) && !defined(FC_GITREV_OFF)
50 fc_snprintf(msgbuf
, sizeof (msgbuf
), _("Freeciv version %s (%s)"),
51 VERSION_STRING
, fc_git_revision());
53 fc_snprintf(msgbuf
, sizeof (msgbuf
), _("Freeciv version %s"),
60 /**********************************************************************
61 Return string describing version type.
62 ***********************************************************************/
63 const char *word_version(void)
66 return _("betatest version ");
72 /**********************************************************************
73 Returns string with svn revision information if it is possible to
74 determine. Can return also some fallback string or even NULL.
75 ***********************************************************************/
76 const char *fc_svn_revision(void)
78 #if defined(SVNREV) && !defined(FC_SVNREV_OFF)
80 bool translate
= FC_SVNREV1
[0] != '\0';
82 fc_snprintf(buf
, sizeof(buf
), "%s%s",
83 translate
? _(FC_SVNREV1
) : FC_SVNREV1
, FC_SVNREV2
);
85 return buf
; /* Either revision, or modified revision */
86 #else /* FC_SVNREV_OFF */
88 #endif /* FC_SVNREV_OFF */
91 /**********************************************************************
92 Returns string with git revision information if it is possible to
93 determine. Can return also some fallback string or even NULL.
94 ***********************************************************************/
95 const char *fc_git_revision(void)
97 #if defined(GITREV) && !defined(FC_GITREV_OFF)
99 bool translate
= FC_GITREV1
[0] != '\0';
101 fc_snprintf(buf
, sizeof(buf
), "%s%s",
102 translate
? _(FC_GITREV1
) : FC_GITREV1
, FC_GITREV2
);
104 return buf
; /* Either revision, or modified revision */
105 #else /* FC_GITREV_OFF */
107 #endif /* FC_GITREV_OFF */
110 /**********************************************************************
111 Returns version string that can be used to compare two freeciv builds.
112 This does not handle git revisions, as there's no way to compare
113 which of the two commits is "higher".
114 ***********************************************************************/
115 const char *fc_comparable_version(void)
118 /* Sane revision number in FC_SVNREV2 */
119 return VERSION_STRING
"-" FC_SVNREV2
;
120 #else /* FC_SVNREV_ON */
121 return VERSION_STRING
;
125 /**********************************************************************
126 Return the BETA message.
127 If returns NULL, not a beta version.
128 ***********************************************************************/
129 const char *beta_message(void)
132 static char msgbuf
[128];
133 static const char *month
[] =
150 if (FREECIV_RELEASE_MONTH
> 0) {
151 fc_snprintf(msgbuf
, sizeof(msgbuf
),
152 /* TRANS: No full stop after the URL, could cause confusion. */
153 _("THIS IS A BETA VERSION\n"
154 "Freeciv %s will be released in %s, at %s"),
155 NEXT_STABLE_VERSION
, _(NEXT_RELEASE_MONTH
), WIKI_URL
);
157 fc_snprintf(msgbuf
, sizeof(msgbuf
),
158 _("THIS IS A BETA VERSION\n"
159 "Freeciv %s will be released at %s"),
160 NEXT_STABLE_VERSION
, WIKI_URL
);
163 #else /* IS_BETA_VERSION */
165 #endif /* IS_BETA_VERSION */
168 /***************************************************************************
169 Return the Freeciv motto.
170 (The motto is common code:
171 only one instance of the string in the source;
172 only one time gettext needs to translate it. --jjm)
173 ***************************************************************************/
174 const char *freeciv_motto(void)
176 return _("'Cause civilization should be free!");
179 /***************************************************************************
180 Return version string in a format suitable to be written to created
181 datafiles as human readable information.
182 ***************************************************************************/
183 const char *freeciv_datafile_version(void)
185 static char buf
[500] = { '\0' };
187 if (buf
[0] == '\0') {
190 ver_rev
= fc_svn_revision();
191 if (ver_rev
== NULL
) {
192 ver_rev
= fc_git_revision();
194 if (ver_rev
!= NULL
) {
195 fc_snprintf(buf
, sizeof(buf
), "%s (%s)", VERSION_STRING
, ver_rev
);
197 fc_snprintf(buf
, sizeof(buf
), "%s", VERSION_STRING
);