OSDN Git Service

* include/ext/stl_rope.h (_Rope_RopeRep<>::_M_c_string_lock): Tweak.
[pf3gnuchains/gcc-fork.git] / gcc / f / g77spec.c
index 505bc12..426bb96 100644 (file)
@@ -1,20 +1,21 @@
 /* Specific flags and argument handling of the Fortran front-end.
-   Copyright (C) 1997, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1999, 2000, 2001, 2002, 2003
+   Free Software Foundation, Inc.
 
-This file is part of GNU CC.
+This file is part of GCC.
 
-GNU CC is free software; you can redistribute it and/or modify
+GCC is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2, or (at your option)
 any later version.
 
-GNU CC is distributed in the hope that it will be useful,
+GCC is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING.  If not, write to
+along with GCC; see the file COPYING.  If not, write to
 the Free Software Foundation, 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
@@ -46,13 +47,18 @@ Boston, MA 02111-1307, USA.  */
 
 #include "config.h"
 #include "system.h"
+#include "coretypes.h"
+#include "tm.h"
 #include "gcc.h"
-#include <f/version.h>
 
 #ifndef MATH_LIBRARY
 #define MATH_LIBRARY "-lm"
 #endif
 
+#ifndef FORTRAN_INIT
+#define FORTRAN_INIT "-lfrtbegin"
+#endif
+
 #ifndef FORTRAN_LIBRARY
 #define FORTRAN_LIBRARY "-lg2c"
 #endif
@@ -86,48 +92,23 @@ typedef enum
 
 /* The original argument list and related info is copied here.  */
 static int g77_xargc;
-static const char **g77_xargv;
+static const char *const *g77_xargv;
 static void lookup_option PARAMS ((Option *, int *, const char **,
                                   const char *));
 static void append_arg PARAMS ((const char *));
 
 /* The new argument list will be built here.  */
 static int g77_newargc;
-static char **real_g77_newargv;
 static const char **g77_newargv;
 
-extern char *version_string;
-
-/* --- This comes from gcc.c (2.8.1) verbatim: */
-
-/* This defines which switch letters take arguments.  */
-
-#define DEFAULT_SWITCH_TAKES_ARG(CHAR)      \
-  ((CHAR) == 'D' || (CHAR) == 'U' || (CHAR) == 'o' \
-   || (CHAR) == 'e' || (CHAR) == 'T' || (CHAR) == 'u' \
-   || (CHAR) == 'I' || (CHAR) == 'm' || (CHAR) == 'x' \
-   || (CHAR) == 'L' || (CHAR) == 'A')
-
 #ifndef SWITCH_TAKES_ARG
 #define SWITCH_TAKES_ARG(CHAR) DEFAULT_SWITCH_TAKES_ARG(CHAR)
 #endif
 
-/* This defines which multi-letter switches take arguments.  */
-
-#define DEFAULT_WORD_SWITCH_TAKES_ARG(STR)             \
- (!strcmp (STR, "Tdata") || !strcmp (STR, "Ttext")     \
-  || !strcmp (STR, "Tbss") || !strcmp (STR, "include") \
-  || !strcmp (STR, "imacros") || !strcmp (STR, "aux-info") \
-  || !strcmp (STR, "idirafter") || !strcmp (STR, "iprefix") \
-  || !strcmp (STR, "iwithprefix") || !strcmp (STR, "iwithprefixbefore") \
-  || !strcmp (STR, "isystem") || !strcmp (STR, "specs"))
-
 #ifndef WORD_SWITCH_TAKES_ARG
 #define WORD_SWITCH_TAKES_ARG(STR) DEFAULT_WORD_SWITCH_TAKES_ARG (STR)
 #endif
 
-/* --- End of verbatim.  */
-
 /* Assumes text[0] == '-'.  Returns number of argv items that belong to
    (and follow) this one, an option id for options important to the
    caller, and a pointer to the first char of the arg, if embedded (else
@@ -193,6 +174,8 @@ lookup_option (xopt, xskip, xarg, text)
        opt = OPTION_syntax_only;
       else if (! strcmp (text, "-dumpversion"))
        opt = OPTION_version;
+      else if (! strcmp (text, "-fversion"))  /* Really --version!! */
+       opt = OPTION_version;
       else if (! strcmp (text, "-Xlinker")
               || ! strcmp (text, "-specs"))
        skip = 1;
@@ -242,8 +225,7 @@ append_arg (arg)
       int i;
 
       newargsize = (g77_xargc << 2) + 20;      /* This should handle all. */
-      real_g77_newargv = (char **) xmalloc (newargsize * sizeof (char *));
-      g77_newargv = (const char **) real_g77_newargv;
+      g77_newargv = (const char **) xmalloc (newargsize * sizeof (char *));
 
       /* Copy what has been done so far.  */
       for (i = 0; i < g77_newargc; ++i)
@@ -259,11 +241,11 @@ append_arg (arg)
 void
 lang_specific_driver (in_argc, in_argv, in_added_libraries)
      int *in_argc;
-     char ***in_argv;
+     const char *const **in_argv;
      int *in_added_libraries ATTRIBUTE_UNUSED;
 {
   int argc = *in_argc;
-  const char **argv = (const char **) *in_argv;
+  const char *const *argv = *in_argv;
   int i;
   int verbose = 0;
   Option opt;
@@ -274,13 +256,6 @@ lang_specific_driver (in_argc, in_argv, in_added_libraries)
      link in libf2c.  */
   const char *library = FORTRAN_LIBRARY;
 
-  /* This will become 0 if anything other than -v and kin (like -V)
-     is seen, meaning the user is trying to accomplish something.
-     If it remains nonzero, and the user wants version info, add stuff to
-     the command line to make gcc invoke all the appropriate phases
-     to get all the version info.  */
-  int add_version_magic = 1;
-
   /* 0 => -xnone in effect.
      1 => -xfoo in effect.  */
   int saw_speclang = 0;
@@ -290,6 +265,9 @@ lang_specific_driver (in_argc, in_argv, in_added_libraries)
      2 => last two args were -l<library> -lm.  */
   int saw_library = 0;
 
+  /* 0 => initial/reset state
+     1 => FORTRAN_INIT linked in */
+  int use_init = 0;
   /* By default, we throw on the math library if we have one.  */
   int need_math = (MATH_LIBRARY[0] != '\0');
 
@@ -304,12 +282,10 @@ lang_specific_driver (in_argc, in_argv, in_added_libraries)
   fprintf (stderr, "\n");
 #endif
 
-  real_g77_newargv = *in_argv;
-
   g77_xargc = argc;
   g77_xargv = argv;
   g77_newargc = 0;
-  g77_newargv = argv;
+  g77_newargv = (const char **) argv;
 
   /* First pass through arglist.
 
@@ -330,14 +306,12 @@ lang_specific_driver (in_argc, in_argv, in_added_libraries)
     {
       if ((argv[i][0] == '+') && (argv[i][1] == 'e'))
        {
-         add_version_magic = 0;
          continue;
        }
 
       if ((argv[i][0] != '-') || (argv[i][1] == '\0'))
        {
          ++n_infiles;
-         add_version_magic = 0;
          continue;
        }
 
@@ -355,23 +329,17 @@ lang_specific_driver (in_argc, in_argv, in_added_libraries)
          /* These options disable linking entirely or linking of the
             standard libraries.  */
          library = 0;
-         add_version_magic = 0;
          break;
 
        case OPTION_l:
          ++n_infiles;
-         add_version_magic = 0;
          break;
 
        case OPTION_o:
          ++n_outfiles;
-         add_version_magic = 0;
          break;
 
        case OPTION_v:
-         if (! verbose)
-           fprintf (stderr, "g77 version %s (from FSF-g77 version %s)\n",
-                    version_string, ffe_version_string);
          verbose = 1;
          break;
 
@@ -386,64 +354,28 @@ lang_specific_driver (in_argc, in_argv, in_added_libraries)
 
        case OPTION_version:
          printf ("\
-GNU Fortran %s\n\
-Copyright (C) 1997 Free Software Foundation, Inc.\n\
-For more version information on components of the GNU Fortran\n\
-compilation system, especially useful when reporting bugs,\n\
-type the command `g77 --verbose'.\n\
+GNU Fortran (GCC) %s\n\
+Copyright (C) 2002 Free Software Foundation, Inc.\n\
 \n\
 GNU Fortran comes with NO WARRANTY, to the extent permitted by law.\n\
 You may redistribute copies of GNU Fortran\n\
 under the terms of the GNU General Public License.\n\
 For more information about these matters, see the file named COPYING\n\
 or type the command `info -f g77 Copying'.\n\
-", ffe_version_string);
+", version_string);
          exit (0);
          break;
 
        case OPTION_help:
-         /* Let gcc.c handle this, as the egcs version has a really
+         /* Let gcc.c handle this, as it has a really
             cool facility for handling --help and --verbose --help.  */
          return;
 
-#if 0
-         printf ("\
-Usage: g77 [OPTION]... FORTRAN-SOURCE...\n\
-\n\
-Compile and link Fortran source code to produce an executable program,\n\
-which by default is named `a.out', and can be invoked with the UNIX\n\
-command `./a.out'.\n\
-\n\
-Options:\n\
---debug                include debugging information in executable.\n\
---help                 display this help and exit.\n\
---optimize[=LEVEL]     take extra time and memory to make generated\n\
-                         executable run faster.  LEVEL is 0 for no\n\
-                         optimization, 1 for normal optimization, and\n\
-                         increases through 3 for more optimization.\n\
---output=PROGRAM       name the executable PROGRAM instead of a.out;\n\
-                         invoke with the command `./PROGRAM'.\n\
---version              display version information and exit.\n\
-\n\
-Many other options exist to tailor the compilation process, specify\n\
-the dialect of the Fortran source code, specify details of the\n\
-code-generation methodology, and so on.\n\
-\n\
-For more information on g77 and gcc, type the commands `info -f g77'\n\
-and `info -f gcc' to read the Info documentation.\n\
-\n\
-For bug reporting instructions, please see:\n\
-<URL:http://www.gnu.org/software/gcc/faq.html#bugreport>.\n");
-         exit (0);
-         break;
-#endif
-
        case OPTION_driver:
          fatal ("--driver no longer supported");
          break;
 
        default:
-         add_version_magic = 0;
          break;
        }
 
@@ -457,7 +389,11 @@ For bug reporting instructions, please see:\n\
     }
 
   if ((n_outfiles != 0) && (n_infiles == 0))
-    fatal ("No input files; unwilling to write output files");
+    fatal ("no input files; unwilling to write output files");
+
+  /* If there are no input files, no need for the library.  */
+  if (n_infiles == 0)
+    library = 0;
 
   /* Second pass through arglist, transforming arguments as appropriate.  */
 
@@ -524,7 +460,14 @@ For bug reporting instructions, please see:\n\
              if (saw_library == 1)
                saw_library = 2;        /* -l<library> -lm. */
              else
-               append_arg (FORTRAN_LIBRARY);
+               {
+                 if (0 == use_init)
+                   {
+                     append_arg (FORTRAN_INIT);
+                     use_init = 1;
+                   }
+                 append_arg (FORTRAN_LIBRARY);
+               }
            }
          else if (strcmp (argv[i], FORTRAN_LIBRARY) == 0)
            saw_library = 1;    /* -l<library>. */
@@ -540,7 +483,7 @@ For bug reporting instructions, please see:\n\
 
   /* Append `-lg2c -lm' as necessary.  */
 
-  if (! add_version_magic && library)
+  if (library)
     {                          /* Doing a link and no -nostdlib. */
       if (saw_speclang)
        append_arg ("-xnone");
@@ -548,6 +491,11 @@ For bug reporting instructions, please see:\n\
       switch (saw_library)
        {
        case 0:
+         if (0 == use_init)
+           {
+             append_arg (FORTRAN_INIT);
+             use_init = 1;
+           }
          append_arg (library);
        case 1:
         if (need_math)
@@ -556,13 +504,23 @@ For bug reporting instructions, please see:\n\
          break;
        }
     }
-  else if (add_version_magic && verbose)
+
+#ifdef ENABLE_SHARED_LIBGCC
+  if (library)
     {
-      append_arg ("-c");
-      append_arg ("-xf77-version");
-      append_arg ("/dev/null");
-      append_arg ("-xnone");
+      int i;
+
+      for (i = 1; i < g77_newargc; i++)
+       if (g77_newargv[i][0] == '-')
+         if (strcmp (g77_newargv[i], "-static-libgcc") == 0
+             || strcmp (g77_newargv[i], "-static") == 0)
+           break;
+    
+      if (i == g77_newargc)
+       append_arg ("-shared-libgcc");
     }
+  
+#endif
 
   if (verbose
       && g77_newargv != g77_xargv)
@@ -574,7 +532,7 @@ For bug reporting instructions, please see:\n\
     }
 
   *in_argc = g77_newargc;
-  *in_argv = real_g77_newargv;
+  *in_argv = g77_newargv;
 }
 
 /* Called before linking.  Returns 0 on success and -1 on failure. */
@@ -585,3 +543,9 @@ int lang_specific_pre_link ()  /* Not used for F77. */
 
 /* Number of extra output files that lang_specific_pre_link may generate. */
 int lang_specific_extra_outfiles = 0;  /* Not used for F77. */
+
+/* Table of language-specific spec functions.  */ 
+const struct spec_function lang_specific_spec_functions[] =
+{
+  { 0, 0 }
+};