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