+2009-04-16 Rafael Avila de Espindola <espindola@google.com>
+
+ * common.opt (fversion): New.
+ * gcc.c (print_version): New.
+ (process_command): Don't print the version. Just set print_version.
+ (main): Print version. Call subprocesses if print_version and
+ verbose_flag are set.
+ * opts.c (common_handle_option): Handle OPT_fversion.
+
2009-04-16 Richard Guenther <rguenther@suse.de>
Ira Rosen <irar@il.ibm.com>
static int print_help_list;
+/* Flag saying to print the version of gcc and its sub-processes. */
+
+static int print_version;
+
/* Flag saying to print the sysroot suffix used for searching for
headers. */
else if (strcmp (argv[i], "-fversion") == 0)
{
/* translate_options () has turned --version into -fversion. */
- printf (_("%s %s%s\n"), programname, pkgversion_string,
- version_string);
- printf ("Copyright %s 2009 Free Software Foundation, Inc.\n",
- _("(C)"));
- fputs (_("This is free software; see the source for copying conditions. There is NO\n\
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"),
- stdout);
- exit (0);
+ print_version = 1;
+
+ /* We will be passing a dummy file on to the sub-processes. */
+ n_infiles++;
+ n_switches++;
+
+ /* CPP driver cannot obtain switch from cc1_options. */
+ if (is_cpp_driver)
+ add_preprocessor_option ("--version", strlen ("--version"));
+ add_assembler_option ("--version", strlen ("--version"));
+ add_linker_option ("--version", strlen ("--version"));
}
else if (strcmp (argv[i], "-fhelp") == 0)
{
error ("warning: '-x %s' after last input file has no effect", spec_lang);
/* Ensure we only invoke each subprocess once. */
- if (print_subprocess_help || print_help_list)
+ if (print_subprocess_help || print_help_list || print_version)
{
n_infiles = 1;
fflush (stdout);
}
+ if (print_version)
+ {
+ printf (_("%s %s%s\n"), programname, pkgversion_string,
+ version_string);
+ printf ("Copyright %s 2009 Free Software Foundation, Inc.\n",
+ _("(C)"));
+ fputs (_("This is free software; see the source for copying conditions. There is NO\n\
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"),
+ stdout);
+ if (! verbose_flag)
+ return 0;
+
+ /* We do not exit here. We use the same mechanism of --help to print
+ the version of the sub-processes. */
+ fputc ('\n', stdout);
+ fflush (stdout);
+ }
+
if (verbose_flag)
{
int n;