]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
sim: common: add a version output helper w/copyright+license info
authorMike Frysinger <vapier@gentoo.org>
Sun, 3 Jan 2021 07:52:11 +0000 (02:52 -0500)
committerMike Frysinger <vapier@gentoo.org>
Mon, 4 Jan 2021 22:41:23 +0000 (17:41 -0500)
This mirrors the existing sim_print_help function, and the behavior
of all other GNU tools with their --version.

sim/common/ChangeLog
sim/common/sim-options.c
sim/common/sim-options.h

index e815aeafd6502cf1847143aaa360b7a43168aebe..0b1c666c53986d4fedcb3d2024ff7d2e9a1a5e90 100644 (file)
@@ -1,3 +1,9 @@
+2021-01-04  Mike Frysinger  <vapier@gentoo.org>
+
+       * sim-options.c (standard_option_handler): Call sim_print_version.
+       (sim_print_version): New function.
+       * sim-options.h (sim_print_version): New prototype.
+
 2021-01-04  Mike Frysinger  <vapier@gentoo.org>
 
        * sim-config.c (print_sim_config): Rename to ...
index 3064dfcb88e62461687815f0d6405e9742d49d66..1d8abdaa05bf6d77274b9f39dc9a52da7854565c 100644 (file)
@@ -388,7 +388,7 @@ standard_option_handler (SIM_DESC sd, sim_cpu *cpu, int opt,
       break;
 
     case OPTION_VERSION:
-      sim_io_printf (sd, "GNU simulator %s%s\n", PKGVERSION, version);
+      sim_print_version (sd, is_command);
       if (STATE_OPEN_KIND (sd) == SIM_OPEN_STANDALONE)
        exit (0);
       break;
@@ -817,6 +817,26 @@ sim_print_help (SIM_DESC sd, int is_command)
     }
 }
 
+/* Print version information.  */
+
+void
+sim_print_version (SIM_DESC sd, int is_command)
+{
+  sim_io_printf (sd, "GNU simulator %s%s\n", PKGVERSION, version);
+
+  sim_io_printf (sd, "Copyright (C) 2021 Free Software Foundation, Inc.\n");
+
+  /* Following the copyright is a brief statement that the program is
+     free software, that users are free to copy and change it on
+     certain conditions, that it is covered by the GNU GPL, and that
+     there is no warranty.  */
+
+  sim_io_printf (sd, "\
+License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>\
+\nThis is free software: you are free to change and redistribute it.\n\
+There is NO WARRANTY, to the extent permitted by law.\n");
+}
+
 /* Utility of sim_args_command to find the closest match for a command.
    Commands that have "-" in them can be specified as separate words.
    e.g. sim memory-region 0x800000,0x4000
index 0f3f3c011e778ca7d44bccc3ccdfdc5afee76d84..84eb3d8336cf8ac8934e6cf0f37a002819e34485 100644 (file)
@@ -141,6 +141,10 @@ SIM_RC sim_parse_args (SIM_DESC sd, char * const *argv);
    this function is called from the command line interpreter. */
 void sim_print_help (SIM_DESC sd, int is_command);
 
+/* Print version information for the program.  IS_COMMAND is non-zero when
+   this function is called from the command line interpreter. */
+void sim_print_version (SIM_DESC sd, int is_command);
+
 /* Try to parse the command as if it is an option, Only fail when
    totally unsuccessful */
 SIM_RC sim_args_command (SIM_DESC sd, const char *cmd);