Stop sharing requirement_unit_state_ereq().
[freeciv.git] / common / version.c
blob15840d73e896dfa33238714f996c5074e8b813ac
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)
6 any later version.
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 ***********************************************************************/
14 #ifdef HAVE_CONFIG_H
15 #include <fc_config.h>
16 #endif
18 /* utility */
19 #include "fcintl.h"
20 #include "shared.h"
21 #include "support.h"
23 /* common */
24 #include "fc_types.h"
26 #include "version.h"
28 #ifdef SVNREV
29 #include "fc_svnrev_gen.h"
30 #endif /* SVNREV */
32 #ifdef GITREV
33 #include "fc_gitrev_gen.h"
34 #endif /* GITREV */
36 /**********************************************************************
37 Return string containing both name of Freeciv and version.
38 ***********************************************************************/
39 const char *freeciv_name_version(void)
41 static char msgbuf[256];
43 #if IS_BETA_VERSION
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());
52 #else
53 fc_snprintf(msgbuf, sizeof (msgbuf), _("Freeciv version %s"),
54 VERSION_STRING);
55 #endif
57 return msgbuf;
60 /**********************************************************************
61 Return string describing version type.
62 ***********************************************************************/
63 const char *word_version(void)
65 #if IS_BETA_VERSION
66 return _("betatest version ");
67 #else
68 return _("version ");
69 #endif
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)
79 static char buf[100];
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 */
87 return NULL;
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)
98 static char buf[100];
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 */
106 return NULL;
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)
117 #ifdef FC_SVNREV_ON
118 /* Sane revision number in FC_SVNREV2 */
119 return VERSION_STRING "-" FC_SVNREV2;
120 #else /* FC_SVNREV_ON */
121 return VERSION_STRING;
122 #endif
125 /**********************************************************************
126 Return the BETA message.
127 If returns NULL, not a beta version.
128 ***********************************************************************/
129 const char *beta_message(void)
131 #if IS_BETA_VERSION
132 static char msgbuf[500];
133 static const char *month[] =
135 NULL,
136 N_("January"),
137 N_("February"),
138 N_("March"),
139 N_("April"),
140 N_("May"),
141 N_("June"),
142 N_("July"),
143 N_("August"),
144 N_("September"),
145 N_("October"),
146 N_("November"),
147 N_("December")
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);
156 } else {
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);
162 return msgbuf;
163 #else /* IS_BETA_VERSION */
164 return NULL;
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') {
188 const char *ver_rev;
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);
196 } else {
197 fc_snprintf(buf, sizeof(buf), "%s", VERSION_STRING);
201 return buf;