OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [gcc/] [fortran/] [gfortranspec.c] - Diff between revs 816 and 826

Only display areas with differences | Details | Blame | View Log

Rev 816 Rev 826
/* Specific flags and argument handling of the Fortran front-end.
/* Specific flags and argument handling of the Fortran front-end.
   Copyright (C) 1997, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
   Copyright (C) 1997, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
   2007, 2008, 2009, 2010
   2007, 2008, 2009, 2010
   Free Software Foundation, Inc.
   Free Software Foundation, Inc.
 
 
This file is part of GCC.
This file is part of GCC.
 
 
GNU CC is free software; you can redistribute it and/or modify
GNU CC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
the Free Software Foundation; either version 3, or (at your option)
any later version.
any later version.
 
 
GNU CC is distributed in the hope that it will be useful,
GNU CC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
GNU General Public License for more details.
 
 
You should have received a copy of the GNU General Public License
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.  */
<http://www.gnu.org/licenses/>.  */
 
 
/* This file is copied more or less verbatim from g77.  */
/* This file is copied more or less verbatim from g77.  */
/* This file contains a filter for the main `gcc' driver, which is
/* This file contains a filter for the main `gcc' driver, which is
   replicated for the `gfortran' driver by adding this filter.  The purpose
   replicated for the `gfortran' driver by adding this filter.  The purpose
   of this filter is to be basically identical to gcc (in that
   of this filter is to be basically identical to gcc (in that
   it faithfully passes all of the original arguments to gcc) but,
   it faithfully passes all of the original arguments to gcc) but,
   unless explicitly overridden by the user in certain ways, ensure
   unless explicitly overridden by the user in certain ways, ensure
   that the needs of the language supported by this wrapper are met.
   that the needs of the language supported by this wrapper are met.
 
 
   For GNU Fortran 95(gfortran), we do the following to the argument list
   For GNU Fortran 95(gfortran), we do the following to the argument list
   before passing it to `gcc':
   before passing it to `gcc':
 
 
   1.  Make sure `-lgfortran -lm' is at the end of the list.
   1.  Make sure `-lgfortran -lm' is at the end of the list.
 
 
   2.  Make sure each time `-lgfortran' or `-lm' is seen, it forms
   2.  Make sure each time `-lgfortran' or `-lm' is seen, it forms
       part of the series `-lgfortran -lm'.
       part of the series `-lgfortran -lm'.
 
 
   #1 and #2 are not done if `-nostdlib' or any option that disables
   #1 and #2 are not done if `-nostdlib' or any option that disables
   the linking phase is present, or if `-xfoo' is in effect.  Note that
   the linking phase is present, or if `-xfoo' is in effect.  Note that
   a lack of source files or -l options disables linking.
   a lack of source files or -l options disables linking.
 
 
   This program was originally made out of gcc/cp/g++spec.c, but the
   This program was originally made out of gcc/cp/g++spec.c, but the
   way it builds the new argument list was rewritten so it is much
   way it builds the new argument list was rewritten so it is much
   easier to maintain, improve the way it decides to add or not add
   easier to maintain, improve the way it decides to add or not add
   extra arguments, etc.  And several improvements were made in the
   extra arguments, etc.  And several improvements were made in the
   handling of arguments, primarily to make it more consistent with
   handling of arguments, primarily to make it more consistent with
   `gcc' itself.  */
   `gcc' itself.  */
 
 
#include "config.h"
#include "config.h"
#include "system.h"
#include "system.h"
#include "gcc.h"
#include "gcc.h"
 
 
#include "coretypes.h"
#include "coretypes.h"
#include "tm.h"
#include "tm.h"
#include "intl.h"
#include "intl.h"
 
 
#ifndef MATH_LIBRARY
#ifndef MATH_LIBRARY
#define MATH_LIBRARY "-lm"
#define MATH_LIBRARY "-lm"
#endif
#endif
 
 
#ifndef FORTRAN_LIBRARY
#ifndef FORTRAN_LIBRARY
#define FORTRAN_LIBRARY "-lgfortran"
#define FORTRAN_LIBRARY "-lgfortran"
#endif
#endif
 
 
#ifdef HAVE_LD_STATIC_DYNAMIC
#ifdef HAVE_LD_STATIC_DYNAMIC
#define ADD_ARG_LIBGFORTRAN(arg) \
#define ADD_ARG_LIBGFORTRAN(arg) \
  { \
  { \
    if (static_lib && !static_linking) \
    if (static_lib && !static_linking) \
      append_arg ("-Wl,-Bstatic"); \
      append_arg ("-Wl,-Bstatic"); \
    append_arg (arg); \
    append_arg (arg); \
    if (static_lib && !static_linking) \
    if (static_lib && !static_linking) \
      append_arg ("-Wl,-Bdynamic"); \
      append_arg ("-Wl,-Bdynamic"); \
  }
  }
#else
#else
#define ADD_ARG_LIBGFORTRAN(arg) append_arg (arg);
#define ADD_ARG_LIBGFORTRAN(arg) append_arg (arg);
#endif
#endif
 
 
 
 
/* Options this driver needs to recognize, not just know how to
/* Options this driver needs to recognize, not just know how to
   skip over.  */
   skip over.  */
typedef enum
typedef enum
{
{
  OPTION_b,                     /* Aka --prefix.  */
  OPTION_b,                     /* Aka --prefix.  */
  OPTION_B,                     /* Aka --target.  */
  OPTION_B,                     /* Aka --target.  */
  OPTION_c,                     /* Aka --compile.  */
  OPTION_c,                     /* Aka --compile.  */
  OPTION_E,                     /* Aka --preprocess.  */
  OPTION_E,                     /* Aka --preprocess.  */
  OPTION_help,                  /* --help.  */
  OPTION_help,                  /* --help.  */
  OPTION_i,                     /* -imacros, -include, -include-*.  */
  OPTION_i,                     /* -imacros, -include, -include-*.  */
  OPTION_l,
  OPTION_l,
  OPTION_L,                     /* Aka --library-directory.  */
  OPTION_L,                     /* Aka --library-directory.  */
  OPTION_nostdlib,              /* Aka --no-standard-libraries, or
  OPTION_nostdlib,              /* Aka --no-standard-libraries, or
                                   -nodefaultlibs.  */
                                   -nodefaultlibs.  */
  OPTION_o,                     /* Aka --output.  */
  OPTION_o,                     /* Aka --output.  */
  OPTION_S,                     /* Aka --assemble.  */
  OPTION_S,                     /* Aka --assemble.  */
  OPTION_static,                /* -static.  */
  OPTION_static,                /* -static.  */
  OPTION_static_libgfortran,    /* -static-libgfortran.  */
  OPTION_static_libgfortran,    /* -static-libgfortran.  */
  OPTION_syntax_only,           /* -fsyntax-only.  */
  OPTION_syntax_only,           /* -fsyntax-only.  */
  OPTION_v,                     /* Aka --verbose.  */
  OPTION_v,                     /* Aka --verbose.  */
  OPTION_version,               /* --version.  */
  OPTION_version,               /* --version.  */
  OPTION_V,                     /* Aka --use-version.  */
  OPTION_V,                     /* Aka --use-version.  */
  OPTION_x,                     /* Aka --language.  */
  OPTION_x,                     /* Aka --language.  */
  OPTION_                       /* Unrecognized or unimportant.  */
  OPTION_                       /* Unrecognized or unimportant.  */
}
}
Option;
Option;
 
 
/* The original argument list and related info is copied here.  */
/* The original argument list and related info is copied here.  */
static int g77_xargc;
static int g77_xargc;
static const char *const *g77_xargv;
static const char *const *g77_xargv;
static void lookup_option (Option *, int *, const char **, const char *);
static void lookup_option (Option *, int *, const char **, const char *);
static void append_arg (const char *);
static void append_arg (const char *);
 
 
/* The new argument list will be built here.  */
/* The new argument list will be built here.  */
static int g77_newargc;
static int g77_newargc;
static const char **g77_newargv;
static const char **g77_newargv;
 
 
/* --- This comes from gcc.c (2.8.1) verbatim: */
/* --- This comes from gcc.c (2.8.1) verbatim: */
 
 
/* This defines which switch letters take arguments.  */
/* This defines which switch letters take arguments.  */
 
 
#ifndef SWITCH_TAKES_ARG
#ifndef SWITCH_TAKES_ARG
#define SWITCH_TAKES_ARG(CHAR) DEFAULT_SWITCH_TAKES_ARG(CHAR)
#define SWITCH_TAKES_ARG(CHAR) DEFAULT_SWITCH_TAKES_ARG(CHAR)
#endif
#endif
 
 
/* This defines which multi-letter switches take arguments.  */
/* This defines which multi-letter switches take arguments.  */
 
 
#ifndef WORD_SWITCH_TAKES_ARG
#ifndef WORD_SWITCH_TAKES_ARG
#define WORD_SWITCH_TAKES_ARG(STR) DEFAULT_WORD_SWITCH_TAKES_ARG (STR)
#define WORD_SWITCH_TAKES_ARG(STR) DEFAULT_WORD_SWITCH_TAKES_ARG (STR)
#endif
#endif
 
 
/* --- End of verbatim.  */
/* --- End of verbatim.  */
 
 
/* Assumes text[0] == '-'.  Returns number of argv items that belong to
/* Assumes text[0] == '-'.  Returns number of argv items that belong to
   (and follow) this one, an option id for options important to the
   (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
   caller, and a pointer to the first char of the arg, if embedded (else
   returns NULL, meaning no arg or it's the next argv).
   returns NULL, meaning no arg or it's the next argv).
 
 
   Note that this also assumes gcc.c's pass converting long options
   Note that this also assumes gcc.c's pass converting long options
   to short ones, where available, has already been run.  */
   to short ones, where available, has already been run.  */
 
 
static void
static void
lookup_option (Option *xopt, int *xskip, const char **xarg, const char *text)
lookup_option (Option *xopt, int *xskip, const char **xarg, const char *text)
{
{
  Option opt = OPTION_;
  Option opt = OPTION_;
  int skip;
  int skip;
  const char *arg = NULL;
  const char *arg = NULL;
 
 
  if ((skip = SWITCH_TAKES_ARG (text[1])))
  if ((skip = SWITCH_TAKES_ARG (text[1])))
    skip -= (text[2] != '\0');  /* See gcc.c.  */
    skip -= (text[2] != '\0');  /* See gcc.c.  */
 
 
  if (text[1] == 'B')
  if (text[1] == 'B')
    opt = OPTION_B, skip = (text[2] == '\0'), arg = text + 2;
    opt = OPTION_B, skip = (text[2] == '\0'), arg = text + 2;
  else if (text[1] == 'b')
  else if (text[1] == 'b')
    opt = OPTION_b, skip = (text[2] == '\0'), arg = text + 2;
    opt = OPTION_b, skip = (text[2] == '\0'), arg = text + 2;
  else if ((text[1] == 'c') && (text[2] == '\0'))
  else if ((text[1] == 'c') && (text[2] == '\0'))
    opt = OPTION_c, skip = 0;
    opt = OPTION_c, skip = 0;
  else if ((text[1] == 'E') && (text[2] == '\0'))
  else if ((text[1] == 'E') && (text[2] == '\0'))
    opt = OPTION_E, skip = 0;
    opt = OPTION_E, skip = 0;
  else if (text[1] == 'i')
  else if (text[1] == 'i')
    opt = OPTION_i, skip = 0;
    opt = OPTION_i, skip = 0;
  else if (text[1] == 'l')
  else if (text[1] == 'l')
    opt = OPTION_l;
    opt = OPTION_l;
  else if (text[1] == 'L')
  else if (text[1] == 'L')
    opt = OPTION_L, arg = text + 2;
    opt = OPTION_L, arg = text + 2;
  else if (text[1] == 'o')
  else if (text[1] == 'o')
    opt = OPTION_o;
    opt = OPTION_o;
  else if ((text[1] == 'S') && (text[2] == '\0'))
  else if ((text[1] == 'S') && (text[2] == '\0'))
    opt = OPTION_S, skip = 0;
    opt = OPTION_S, skip = 0;
  else if (text[1] == 'V')
  else if (text[1] == 'V')
    opt = OPTION_V, skip = (text[2] == '\0');
    opt = OPTION_V, skip = (text[2] == '\0');
  else if ((text[1] == 'v') && (text[2] == '\0'))
  else if ((text[1] == 'v') && (text[2] == '\0'))
    opt = OPTION_v, skip = 0;
    opt = OPTION_v, skip = 0;
  else if (text[1] == 'x')
  else if (text[1] == 'x')
    opt = OPTION_x, arg = text + 2;
    opt = OPTION_x, arg = text + 2;
  else if (text[1] == 'J')
  else if (text[1] == 'J')
    ;
    ;
  else
  else
    {
    {
      if ((skip = WORD_SWITCH_TAKES_ARG (text + 1)) != 0)  /* See gcc.c.  */
      if ((skip = WORD_SWITCH_TAKES_ARG (text + 1)) != 0)  /* See gcc.c.  */
        ;
        ;
      else if (!strcmp (text, "-fhelp"))        /* Really --help!! */
      else if (!strcmp (text, "-fhelp"))        /* Really --help!! */
        opt = OPTION_help;
        opt = OPTION_help;
      else if (!strcmp (text, "-nostdlib")
      else if (!strcmp (text, "-nostdlib")
               || !strcmp (text, "-nodefaultlibs"))
               || !strcmp (text, "-nodefaultlibs"))
        opt = OPTION_nostdlib;
        opt = OPTION_nostdlib;
      else if (!strcmp (text, "-fsyntax-only"))
      else if (!strcmp (text, "-fsyntax-only"))
        opt = OPTION_syntax_only;
        opt = OPTION_syntax_only;
      else if (!strcmp (text, "-static-libgfortran"))
      else if (!strcmp (text, "-static-libgfortran"))
        opt = OPTION_static_libgfortran;
        opt = OPTION_static_libgfortran;
      else if (!strcmp (text, "-fversion"))     /* Really --version!! */
      else if (!strcmp (text, "-fversion"))     /* Really --version!! */
        opt = OPTION_version;
        opt = OPTION_version;
      else if (!strcmp (text, "-Xlinker") || !strcmp (text, "-specs"))
      else if (!strcmp (text, "-Xlinker") || !strcmp (text, "-specs"))
        skip = 1;
        skip = 1;
      else
      else
        skip = 0;
        skip = 0;
    }
    }
 
 
  if (xopt != NULL)
  if (xopt != NULL)
    *xopt = opt;
    *xopt = opt;
  if (xskip != NULL)
  if (xskip != NULL)
    *xskip = skip;
    *xskip = skip;
  if (xarg != NULL)
  if (xarg != NULL)
    {
    {
      if ((arg != NULL) && (arg[0] == '\0'))
      if ((arg != NULL) && (arg[0] == '\0'))
        *xarg = NULL;
        *xarg = NULL;
      else
      else
        *xarg = arg;
        *xarg = arg;
    }
    }
}
}
 
 
/* Append another argument to the list being built.  As long as it is
/* Append another argument to the list being built.  As long as it is
   identical to the corresponding arg in the original list, just increment
   identical to the corresponding arg in the original list, just increment
   the new arg count.  Otherwise allocate a new list, etc.  */
   the new arg count.  Otherwise allocate a new list, etc.  */
 
 
static void
static void
append_arg (const char *arg)
append_arg (const char *arg)
{
{
  static int newargsize;
  static int newargsize;
 
 
#if 0
#if 0
  fprintf (stderr, "`%s'\n", arg);
  fprintf (stderr, "`%s'\n", arg);
#endif
#endif
 
 
  if (g77_newargv == g77_xargv
  if (g77_newargv == g77_xargv
      && g77_newargc < g77_xargc
      && g77_newargc < g77_xargc
      && (arg == g77_xargv[g77_newargc]
      && (arg == g77_xargv[g77_newargc]
          || !strcmp (arg, g77_xargv[g77_newargc])))
          || !strcmp (arg, g77_xargv[g77_newargc])))
    {
    {
      ++g77_newargc;
      ++g77_newargc;
      return;                   /* Nothing new here.  */
      return;                   /* Nothing new here.  */
    }
    }
 
 
  if (g77_newargv == g77_xargv)
  if (g77_newargv == g77_xargv)
    {                           /* Make new arglist.  */
    {                           /* Make new arglist.  */
      int i;
      int i;
 
 
      newargsize = (g77_xargc << 2) + 20;       /* This should handle all.  */
      newargsize = (g77_xargc << 2) + 20;       /* This should handle all.  */
      g77_newargv = (const char **) xmalloc (newargsize * sizeof (char *));
      g77_newargv = (const char **) xmalloc (newargsize * sizeof (char *));
 
 
      /* Copy what has been done so far.  */
      /* Copy what has been done so far.  */
      for (i = 0; i < g77_newargc; ++i)
      for (i = 0; i < g77_newargc; ++i)
        g77_newargv[i] = g77_xargv[i];
        g77_newargv[i] = g77_xargv[i];
    }
    }
 
 
  if (g77_newargc == newargsize)
  if (g77_newargc == newargsize)
    fatal ("overflowed output arg list for '%s'", arg);
    fatal ("overflowed output arg list for '%s'", arg);
 
 
  g77_newargv[g77_newargc++] = arg;
  g77_newargv[g77_newargc++] = arg;
}
}
 
 
void
void
lang_specific_driver (int *in_argc, const char *const **in_argv,
lang_specific_driver (int *in_argc, const char *const **in_argv,
                      int *in_added_libraries ATTRIBUTE_UNUSED)
                      int *in_added_libraries ATTRIBUTE_UNUSED)
{
{
  int argc = *in_argc;
  int argc = *in_argc;
  const char *const *argv = *in_argv;
  const char *const *argv = *in_argv;
  int i;
  int i;
  int verbose = 0;
  int verbose = 0;
  Option opt;
  Option opt;
  int skip;
  int skip;
  const char *arg;
  const char *arg;
 
 
  /* This will be NULL if we encounter a situation where we should not
  /* This will be NULL if we encounter a situation where we should not
     link in libf2c.  */
     link in libf2c.  */
  const char *library = FORTRAN_LIBRARY;
  const char *library = FORTRAN_LIBRARY;
 
 
  /* 0 => -xnone in effect.
  /* 0 => -xnone in effect.
     1 => -xfoo in effect.  */
     1 => -xfoo in effect.  */
  int saw_speclang = 0;
  int saw_speclang = 0;
 
 
  /* 0 => initial/reset state
  /* 0 => initial/reset state
     1 => last arg was -l<library>
     1 => last arg was -l<library>
     2 => last two args were -l<library> -lm.  */
     2 => last two args were -l<library> -lm.  */
  int saw_library = 0;
  int saw_library = 0;
 
 
  /* By default, we throw on the math library if we have one.  */
  /* By default, we throw on the math library if we have one.  */
  int need_math = (MATH_LIBRARY[0] != '\0');
  int need_math = (MATH_LIBRARY[0] != '\0');
 
 
  /* Whether we should link a static libgfortran.  */
  /* Whether we should link a static libgfortran.  */
  int static_lib = 0;
  int static_lib = 0;
 
 
  /* Whether we need to link statically.  */
  /* Whether we need to link statically.  */
  int static_linking = 0;
  int static_linking = 0;
 
 
  /* The number of input and output files in the incoming arg list.  */
  /* The number of input and output files in the incoming arg list.  */
  int n_infiles = 0;
  int n_infiles = 0;
  int n_outfiles = 0;
  int n_outfiles = 0;
 
 
#if 0
#if 0
  fprintf (stderr, "Incoming:");
  fprintf (stderr, "Incoming:");
  for (i = 0; i < argc; i++)
  for (i = 0; i < argc; i++)
    fprintf (stderr, " %s", argv[i]);
    fprintf (stderr, " %s", argv[i]);
  fprintf (stderr, "\n");
  fprintf (stderr, "\n");
#endif
#endif
 
 
  g77_xargc = argc;
  g77_xargc = argc;
  g77_xargv = argv;
  g77_xargv = argv;
  g77_newargc = 0;
  g77_newargc = 0;
  g77_newargv = CONST_CAST2 (const char **, const char *const *, argv);
  g77_newargv = CONST_CAST2 (const char **, const char *const *, argv);
 
 
  /* First pass through arglist.
  /* First pass through arglist.
 
 
     If -nostdlib or a "turn-off-linking" option is anywhere in the
     If -nostdlib or a "turn-off-linking" option is anywhere in the
     command line, don't do any library-option processing (except
     command line, don't do any library-option processing (except
     relating to -x).  Also, if -v is specified, but no other options
     relating to -x).  Also, if -v is specified, but no other options
     that do anything special (allowing -V version, etc.), remember
     that do anything special (allowing -V version, etc.), remember
     to add special stuff to make gcc command actually invoke all
     to add special stuff to make gcc command actually invoke all
     the different phases of the compilation process so all the version
     the different phases of the compilation process so all the version
     numbers can be seen.
     numbers can be seen.
 
 
     Also, here is where all problems with missing arguments to options
     Also, here is where all problems with missing arguments to options
     are caught.  If this loop is exited normally, it means all options
     are caught.  If this loop is exited normally, it means all options
     have the appropriate number of arguments as far as the rest of this
     have the appropriate number of arguments as far as the rest of this
     program is concerned.  */
     program is concerned.  */
 
 
  for (i = 1; i < argc; ++i)
  for (i = 1; i < argc; ++i)
    {
    {
      if ((argv[i][0] == '+') && (argv[i][1] == 'e'))
      if ((argv[i][0] == '+') && (argv[i][1] == 'e'))
        {
        {
          continue;
          continue;
        }
        }
 
 
      if ((argv[i][0] != '-') || (argv[i][1] == '\0'))
      if ((argv[i][0] != '-') || (argv[i][1] == '\0'))
        {
        {
          ++n_infiles;
          ++n_infiles;
          continue;
          continue;
        }
        }
 
 
      lookup_option (&opt, &skip, NULL, argv[i]);
      lookup_option (&opt, &skip, NULL, argv[i]);
 
 
      switch (opt)
      switch (opt)
        {
        {
        case OPTION_nostdlib:
        case OPTION_nostdlib:
        case OPTION_c:
        case OPTION_c:
        case OPTION_S:
        case OPTION_S:
        case OPTION_syntax_only:
        case OPTION_syntax_only:
        case OPTION_E:
        case OPTION_E:
          /* These options disable linking entirely or linking of the
          /* These options disable linking entirely or linking of the
             standard libraries.  */
             standard libraries.  */
          library = 0;
          library = 0;
          break;
          break;
 
 
        case OPTION_static_libgfortran:
        case OPTION_static_libgfortran:
          static_lib = 1;
          static_lib = 1;
          break;
          break;
 
 
        case OPTION_static:
        case OPTION_static:
          static_linking = 1;
          static_linking = 1;
 
 
        case OPTION_l:
        case OPTION_l:
          ++n_infiles;
          ++n_infiles;
          break;
          break;
 
 
        case OPTION_o:
        case OPTION_o:
          ++n_outfiles;
          ++n_outfiles;
          break;
          break;
 
 
        case OPTION_v:
        case OPTION_v:
          verbose = 1;
          verbose = 1;
          break;
          break;
 
 
        case OPTION_b:
        case OPTION_b:
        case OPTION_B:
        case OPTION_B:
        case OPTION_L:
        case OPTION_L:
        case OPTION_i:
        case OPTION_i:
        case OPTION_V:
        case OPTION_V:
          /* These options are useful in conjunction with -v to get
          /* These options are useful in conjunction with -v to get
             appropriate version info.  */
             appropriate version info.  */
          break;
          break;
 
 
        case OPTION_version:
        case OPTION_version:
          printf ("GNU Fortran %s%s\n", pkgversion_string, version_string);
          printf ("GNU Fortran %s%s\n", pkgversion_string, version_string);
          printf ("Copyright %s 2010 Free Software Foundation, Inc.\n\n",
          printf ("Copyright %s 2010 Free Software Foundation, Inc.\n\n",
                  _("(C)"));
                  _("(C)"));
          printf (_("GNU Fortran comes with NO WARRANTY, to the extent permitted by law.\n\
          printf (_("GNU Fortran comes with NO WARRANTY, to the extent permitted by law.\n\
You may redistribute copies of GNU Fortran\n\
You may redistribute copies of GNU Fortran\n\
under the terms of the GNU General Public License.\n\
under the terms of the GNU General Public License.\n\
For more information about these matters, see the file named COPYING\n\n"));
For more information about these matters, see the file named COPYING\n\n"));
          exit (0);
          exit (0);
          break;
          break;
 
 
        case OPTION_help:
        case OPTION_help:
          /* Let gcc.c handle this, as it has a really
          /* Let gcc.c handle this, as it has a really
             cool facility for handling --help and --verbose --help.  */
             cool facility for handling --help and --verbose --help.  */
          return;
          return;
 
 
        default:
        default:
          break;
          break;
        }
        }
 
 
      /* This is the one place we check for missing arguments in the
      /* This is the one place we check for missing arguments in the
         program.  */
         program.  */
 
 
      if (i + skip < argc)
      if (i + skip < argc)
        i += skip;
        i += skip;
      else
      else
        fatal ("argument to '%s' missing", argv[i]);
        fatal ("argument to '%s' missing", argv[i]);
    }
    }
 
 
  if ((n_outfiles != 0) && (n_infiles == 0))
  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 there are no input files, no need for the library.  */
  if (n_infiles == 0)
  if (n_infiles == 0)
    library = 0;
    library = 0;
 
 
  /* Second pass through arglist, transforming arguments as appropriate.  */
  /* Second pass through arglist, transforming arguments as appropriate.  */
 
 
  append_arg (argv[0]);          /* Start with command name, of course.  */
  append_arg (argv[0]);          /* Start with command name, of course.  */
 
 
  for (i = 1; i < argc; ++i)
  for (i = 1; i < argc; ++i)
    {
    {
      if (argv[i][0] == '\0')
      if (argv[i][0] == '\0')
        {
        {
          append_arg (argv[i]); /* Interesting.  Just append as is.  */
          append_arg (argv[i]); /* Interesting.  Just append as is.  */
          continue;
          continue;
        }
        }
 
 
      if ((argv[i][0] == '-') && (argv[i][1] != 'l'))
      if ((argv[i][0] == '-') && (argv[i][1] != 'l'))
        {
        {
          /* Not a filename or library.  */
          /* Not a filename or library.  */
 
 
          if (saw_library == 1 && need_math)    /* -l<library>.  */
          if (saw_library == 1 && need_math)    /* -l<library>.  */
            append_arg (MATH_LIBRARY);
            append_arg (MATH_LIBRARY);
 
 
          saw_library = 0;
          saw_library = 0;
 
 
          lookup_option (&opt, &skip, &arg, argv[i]);
          lookup_option (&opt, &skip, &arg, argv[i]);
 
 
          if (argv[i][1] == '\0')
          if (argv[i][1] == '\0')
            {
            {
              append_arg (argv[i]);     /* "-" == Standard input.  */
              append_arg (argv[i]);     /* "-" == Standard input.  */
              continue;
              continue;
            }
            }
 
 
          if (opt == OPTION_x)
          if (opt == OPTION_x)
            {
            {
              /* Track input language.  */
              /* Track input language.  */
              const char *lang;
              const char *lang;
 
 
              if (arg == NULL)
              if (arg == NULL)
                lang = argv[i + 1];
                lang = argv[i + 1];
              else
              else
                lang = arg;
                lang = arg;
 
 
              saw_speclang = (strcmp (lang, "none") != 0);
              saw_speclang = (strcmp (lang, "none") != 0);
            }
            }
 
 
          append_arg (argv[i]);
          append_arg (argv[i]);
 
 
          for (; skip != 0; --skip)
          for (; skip != 0; --skip)
            append_arg (argv[++i]);
            append_arg (argv[++i]);
 
 
          continue;
          continue;
        }
        }
 
 
      /* A filename/library, not an option.  */
      /* A filename/library, not an option.  */
 
 
      if (saw_speclang)
      if (saw_speclang)
        saw_library = 0; /* -xfoo currently active.  */
        saw_library = 0; /* -xfoo currently active.  */
      else
      else
        {                       /* -lfoo or filename.  */
        {                       /* -lfoo or filename.  */
          if (strcmp (argv[i], MATH_LIBRARY) == 0)
          if (strcmp (argv[i], MATH_LIBRARY) == 0)
            {
            {
              if (saw_library == 1)
              if (saw_library == 1)
                saw_library = 2;        /* -l<library> -lm.  */
                saw_library = 2;        /* -l<library> -lm.  */
              else
              else
                {
                {
                  ADD_ARG_LIBGFORTRAN (FORTRAN_LIBRARY);
                  ADD_ARG_LIBGFORTRAN (FORTRAN_LIBRARY);
                }
                }
            }
            }
          else if (strcmp (argv[i], FORTRAN_LIBRARY) == 0)
          else if (strcmp (argv[i], FORTRAN_LIBRARY) == 0)
            {
            {
              saw_library = 1;  /* -l<library>.  */
              saw_library = 1;  /* -l<library>.  */
              ADD_ARG_LIBGFORTRAN (argv[i]);
              ADD_ARG_LIBGFORTRAN (argv[i]);
              continue;
              continue;
            }
            }
          else
          else
            {                   /* Other library, or filename.  */
            {                   /* Other library, or filename.  */
              if (saw_library == 1 && need_math)
              if (saw_library == 1 && need_math)
                append_arg (MATH_LIBRARY);
                append_arg (MATH_LIBRARY);
              saw_library = 0;
              saw_library = 0;
            }
            }
        }
        }
      append_arg (argv[i]);
      append_arg (argv[i]);
    }
    }
 
 
  /* Append `-lg2c -lm' as necessary.  */
  /* Append `-lg2c -lm' as necessary.  */
 
 
  if (library)
  if (library)
    {                           /* Doing a link and no -nostdlib.  */
    {                           /* Doing a link and no -nostdlib.  */
      if (saw_speclang)
      if (saw_speclang)
        append_arg ("-xnone");
        append_arg ("-xnone");
 
 
      switch (saw_library)
      switch (saw_library)
        {
        {
        case 0:
        case 0:
          ADD_ARG_LIBGFORTRAN (library);
          ADD_ARG_LIBGFORTRAN (library);
          /* Fall through.  */
          /* Fall through.  */
 
 
        case 1:
        case 1:
          if (need_math)
          if (need_math)
            append_arg (MATH_LIBRARY);
            append_arg (MATH_LIBRARY);
        default:
        default:
          break;
          break;
        }
        }
    }
    }
 
 
#ifdef ENABLE_SHARED_LIBGCC
#ifdef ENABLE_SHARED_LIBGCC
  if (library)
  if (library)
    {
    {
      int i;
      int i;
 
 
      for (i = 1; i < g77_newargc; i++)
      for (i = 1; i < g77_newargc; i++)
        if (g77_newargv[i][0] == '-')
        if (g77_newargv[i][0] == '-')
          if (strcmp (g77_newargv[i], "-static-libgcc") == 0
          if (strcmp (g77_newargv[i], "-static-libgcc") == 0
              || strcmp (g77_newargv[i], "-static") == 0)
              || strcmp (g77_newargv[i], "-static") == 0)
            break;
            break;
 
 
      if (i == g77_newargc)
      if (i == g77_newargc)
        append_arg ("-shared-libgcc");
        append_arg ("-shared-libgcc");
    }
    }
 
 
#endif
#endif
 
 
  if (verbose && g77_newargv != g77_xargv)
  if (verbose && g77_newargv != g77_xargv)
    {
    {
      fprintf (stderr, _("Driving:"));
      fprintf (stderr, _("Driving:"));
      for (i = 0; i < g77_newargc; i++)
      for (i = 0; i < g77_newargc; i++)
        fprintf (stderr, " %s", g77_newargv[i]);
        fprintf (stderr, " %s", g77_newargv[i]);
      fprintf (stderr, "\n");
      fprintf (stderr, "\n");
    }
    }
 
 
  *in_argc = g77_newargc;
  *in_argc = g77_newargc;
  *in_argv = g77_newargv;
  *in_argv = g77_newargv;
}
}
 
 
 
 
/* Called before linking.  Returns 0 on success and -1 on failure.  */
/* Called before linking.  Returns 0 on success and -1 on failure.  */
int
int
lang_specific_pre_link (void)   /* Not used for F77.  */
lang_specific_pre_link (void)   /* Not used for F77.  */
{
{
  return 0;
  return 0;
}
}
 
 
/* Number of extra output files that lang_specific_pre_link may generate.  */
/* Number of extra output files that lang_specific_pre_link may generate.  */
int lang_specific_extra_outfiles = 0;    /* Not used for F77.  */
int lang_specific_extra_outfiles = 0;    /* Not used for F77.  */
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.