1*a9fa9459Szrj // version.c -- print gold version information
2*a9fa9459Szrj
3*a9fa9459Szrj // Copyright (C) 2006-2016 Free Software Foundation, Inc.
4*a9fa9459Szrj // Written by Ian Lance Taylor <iant@google.com>.
5*a9fa9459Szrj
6*a9fa9459Szrj // This file is part of gold.
7*a9fa9459Szrj
8*a9fa9459Szrj // This program is free software; you can redistribute it and/or modify
9*a9fa9459Szrj // it under the terms of the GNU General Public License as published by
10*a9fa9459Szrj // the Free Software Foundation; either version 3 of the License, or
11*a9fa9459Szrj // (at your option) any later version.
12*a9fa9459Szrj
13*a9fa9459Szrj // This program is distributed in the hope that it will be useful,
14*a9fa9459Szrj // but WITHOUT ANY WARRANTY; without even the implied warranty of
15*a9fa9459Szrj // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16*a9fa9459Szrj // GNU General Public License for more details.
17*a9fa9459Szrj
18*a9fa9459Szrj // You should have received a copy of the GNU General Public License
19*a9fa9459Szrj // along with this program; if not, write to the Free Software
20*a9fa9459Szrj // Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21*a9fa9459Szrj // MA 02110-1301, USA.
22*a9fa9459Szrj
23*a9fa9459Szrj #include "gold.h"
24*a9fa9459Szrj
25*a9fa9459Szrj #include <string>
26*a9fa9459Szrj #include <cstdio>
27*a9fa9459Szrj
28*a9fa9459Szrj #include "../bfd/bfdver.h"
29*a9fa9459Szrj
30*a9fa9459Szrj namespace gold
31*a9fa9459Szrj {
32*a9fa9459Szrj
33*a9fa9459Szrj // The version of gold.
34*a9fa9459Szrj
35*a9fa9459Szrj // FIXME: This should eventually be PACKAGE_VERSION, and get the
36*a9fa9459Szrj // version number from configure.ac. But it's easier to just change
37*a9fa9459Szrj // this file for now.
38*a9fa9459Szrj
39*a9fa9459Szrj static const char* version_string = "1.12";
40*a9fa9459Szrj
41*a9fa9459Szrj // Report version information.
42*a9fa9459Szrj
43*a9fa9459Szrj void
print_version(bool print_short)44*a9fa9459Szrj print_version(bool print_short)
45*a9fa9459Szrj {
46*a9fa9459Szrj // The --version output is intended to follow the GNU coding
47*a9fa9459Szrj // standards. We want to print something like:
48*a9fa9459Szrj // GNU gold (GNU binutils 2.19) 1.4
49*a9fa9459Szrj // BFD_VERSION_STRING looks like "(GNU Binutils) 2.19". We take off
50*a9fa9459Szrj // those parentheses.
51*a9fa9459Szrj std::string bfd_version(BFD_VERSION_STRING);
52*a9fa9459Szrj if (bfd_version[0] == '(')
53*a9fa9459Szrj {
54*a9fa9459Szrj bfd_version.erase(0, 1);
55*a9fa9459Szrj size_t pos = bfd_version.find(')');
56*a9fa9459Szrj if (pos != std::string::npos)
57*a9fa9459Szrj bfd_version.erase(pos, 1);
58*a9fa9459Szrj }
59*a9fa9459Szrj
60*a9fa9459Szrj printf("GNU gold (%s) %s\n", bfd_version.c_str(), version_string);
61*a9fa9459Szrj
62*a9fa9459Szrj if (!print_short)
63*a9fa9459Szrj {
64*a9fa9459Szrj // This output is intended to follow the GNU standards.
65*a9fa9459Szrj printf(_("Copyright (C) 2016 Free Software Foundation, Inc.\n"));
66*a9fa9459Szrj printf(_("\
67*a9fa9459Szrj This program is free software; you may redistribute it under the terms of\n\
68*a9fa9459Szrj the GNU General Public License version 3 or (at your option) a later version.\n\
69*a9fa9459Szrj This program has absolutely no warranty.\n"));
70*a9fa9459Szrj }
71*a9fa9459Szrj }
72*a9fa9459Szrj
73*a9fa9459Szrj // Return the version string.
74*a9fa9459Szrj
75*a9fa9459Szrj const char*
get_version_string()76*a9fa9459Szrj get_version_string()
77*a9fa9459Szrj {
78*a9fa9459Szrj return version_string;
79*a9fa9459Szrj }
80*a9fa9459Szrj
81*a9fa9459Szrj } // End namespace gold.
82