version.cc 2.3 KB

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