X-Git-Url: http://git.sourceforge.jp/view?a=blobdiff_plain;f=gcc%2Ffortran%2Fgfortranspec.c;h=8f860a6b2d72375ce2c13aac4cf0a3fdd486ae8f;hb=60d645bbd2abe708f24bb71018ec35ee25c11976;hp=90db93d2d2fe76bb84d1264ff8f6ae546eca3247;hpb=b14e2757acd28c7edeeaf2bf64d061563ab11606;p=pf3gnuchains%2Fgcc-fork.git
diff --git a/gcc/fortran/gfortranspec.c b/gcc/fortran/gfortranspec.c
index 90db93d2d2f..8f860a6b2d7 100644
--- a/gcc/fortran/gfortranspec.c
+++ b/gcc/fortran/gfortranspec.c
@@ -1,12 +1,13 @@
/* Specific flags and argument handling of the Fortran front-end.
- Copyright (C) 1997, 1999, 2000, 2001, 2002, 2003, 2004 Free Software
- Foundation, Inc.
+ Copyright (C) 1997, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
+ 2007, 2008, 2009, 2010
+ Free Software Foundation, Inc.
This file is part of GCC.
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
-the Free Software Foundation; either version 2, or (at your option)
+the Free Software Foundation; either version 3, or (at your option)
any later version.
GNU CC is distributed in the hope that it will be useful,
@@ -15,9 +16,9 @@ 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
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
+along with GCC; see the file COPYING3. If not see
+. */
+
/* This file is copied more or less verbatim from g77. */
/* This file contains a filter for the main `gcc' driver, which is
replicated for the `gfortran' driver by adding this filter. The purpose
@@ -51,19 +52,30 @@ Boston, MA 02111-1307, USA. */
#include "coretypes.h"
#include "tm.h"
+#include "intl.h"
#ifndef MATH_LIBRARY
#define MATH_LIBRARY "-lm"
#endif
-#ifndef FORTRAN_INIT
-#define FORTRAN_INIT "-lgfortranbegin"
-#endif
-
#ifndef FORTRAN_LIBRARY
#define FORTRAN_LIBRARY "-lgfortran"
#endif
+#ifdef HAVE_LD_STATIC_DYNAMIC
+#define ADD_ARG_LIBGFORTRAN(arg) \
+ { \
+ if (static_lib && !static_linking) \
+ append_arg ("-Wl,-Bstatic"); \
+ append_arg (arg); \
+ if (static_lib && !static_linking) \
+ append_arg ("-Wl,-Bdynamic"); \
+ }
+#else
+#define ADD_ARG_LIBGFORTRAN(arg) append_arg (arg);
+#endif
+
+
/* Options this driver needs to recognize, not just know how to
skip over. */
typedef enum
@@ -80,6 +92,8 @@ typedef enum
-nodefaultlibs. */
OPTION_o, /* Aka --output. */
OPTION_S, /* Aka --assemble. */
+ OPTION_static, /* -static. */
+ OPTION_static_libgfortran, /* -static-libgfortran. */
OPTION_syntax_only, /* -fsyntax-only. */
OPTION_v, /* Aka --verbose. */
OPTION_version, /* --version. */
@@ -99,8 +113,6 @@ static void append_arg (const char *);
static int g77_newargc;
static const char **g77_newargv;
-const struct spec_function lang_specific_spec_functions[] = {{0,0}};
-
/* --- This comes from gcc.c (2.8.1) verbatim: */
/* This defines which switch letters take arguments. */
@@ -159,9 +171,11 @@ lookup_option (Option *xopt, int *xskip, const char **xarg, const char *text)
opt = OPTION_v, skip = 0;
else if (text[1] == 'x')
opt = OPTION_x, arg = text + 2;
+ else if (text[1] == 'J')
+ ;
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!! */
opt = OPTION_help;
@@ -170,8 +184,8 @@ lookup_option (Option *xopt, int *xskip, const char **xarg, const char *text)
opt = OPTION_nostdlib;
else if (!strcmp (text, "-fsyntax-only"))
opt = OPTION_syntax_only;
- else if (!strcmp (text, "-dumpversion"))
- opt = OPTION_version;
+ else if (!strcmp (text, "-static-libgfortran"))
+ opt = OPTION_static_libgfortran;
else if (!strcmp (text, "-fversion")) /* Really --version!! */
opt = OPTION_version;
else if (!strcmp (text, "-Xlinker") || !strcmp (text, "-specs"))
@@ -228,7 +242,7 @@ append_arg (const char *arg)
}
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;
}
@@ -258,13 +272,15 @@ lang_specific_driver (int *in_argc, const char *const **in_argv,
2 => last two args were -l -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');
+ /* Whether we should link a static libgfortran. */
+ int static_lib = 0;
+
+ /* Whether we need to link statically. */
+ int static_linking = 0;
+
/* The number of input and output files in the incoming arg list. */
int n_infiles = 0;
int n_outfiles = 0;
@@ -279,7 +295,7 @@ lang_specific_driver (int *in_argc, const char *const **in_argv,
g77_xargc = argc;
g77_xargv = argv;
g77_newargc = 0;
- g77_newargv = (const char **) argv;
+ g77_newargv = CONST_CAST2 (const char **, const char *const *, argv);
/* First pass through arglist.
@@ -323,6 +339,13 @@ lang_specific_driver (int *in_argc, const char *const **in_argv,
library = 0;
break;
+ case OPTION_static_libgfortran:
+ static_lib = 1;
+ break;
+
+ case OPTION_static:
+ static_linking = 1;
+
case OPTION_l:
++n_infiles;
break;
@@ -345,15 +368,13 @@ lang_specific_driver (int *in_argc, const char *const **in_argv,
break;
case OPTION_version:
- printf ("\
-GNU Fortran 95 (GCC %s)\n\
-Copyright (C) 2004 Free Software Foundation, Inc.\n\
-\n\
-GNU Fortran comes with NO WARRANTY, to the extent permitted by law.\n\
+ printf ("GNU Fortran %s%s\n", pkgversion_string, version_string);
+ printf ("Copyright %s 2010 Free Software Foundation, Inc.\n\n",
+ _("(C)"));
+ printf (_("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\
-", version_string);
+For more information about these matters, see the file named COPYING\n\n"));
exit (0);
break;
@@ -367,12 +388,12 @@ For more information about these matters, see the file named COPYING\n\
}
/* This is the one place we check for missing arguments in the
- program. */
+ program. */
if (i + skip < argc)
i += skip;
else
- fatal ("argument to `%s' missing", argv[i]);
+ fatal ("argument to '%s' missing", argv[i]);
}
if ((n_outfiles != 0) && (n_infiles == 0))
@@ -395,25 +416,34 @@ For more information about these matters, see the file named COPYING\n\
}
if ((argv[i][0] == '-') && (argv[i][1] == 'M'))
- {
- char *p;
-
- if (argv[i][2] == '\0')
- {
- p = xmalloc (strlen (argv[i + 1]) + 2);
- p[0] = '-';
- p[1] = 'J';
- strcpy (&p[2], argv[i + 1]);
- i++;
- }
- else
- {
- p = xmalloc (strlen (argv[i]) + 1);
- strcpy (p, argv[i]);
- }
- append_arg (p);
- continue;
- }
+ {
+ char *p;
+
+ fprintf (stderr, _("Warning: Using -M is deprecated, "
+ "use -J instead\n"));
+ if (argv[i][2] == '\0')
+ {
+ if (i+1 < argc)
+ {
+ p = XNEWVEC (char, strlen (argv[i + 1]) + 3);
+ p[0] = '-';
+ p[1] = 'J';
+ strcpy (&p[2], argv[i + 1]);
+ i++;
+ }
+ else
+ fatal ("argument to '%s' missing", argv[i]);
+ }
+ else
+ {
+ p = XNEWVEC (char, strlen (argv[i]) + 1);
+ p[0] = '-';
+ p[1] = 'J';
+ strcpy (&p[2], argv[i] + 2);
+ }
+ append_arg (p);
+ continue;
+ }
if ((argv[i][0] == '-') && (argv[i][1] != 'l'))
{
@@ -465,16 +495,15 @@ For more information about these matters, see the file named COPYING\n\
saw_library = 2; /* -l -lm. */
else
{
- if (0 == use_init)
- {
- append_arg (FORTRAN_INIT);
- use_init = 1;
- }
- append_arg (FORTRAN_LIBRARY);
+ ADD_ARG_LIBGFORTRAN (FORTRAN_LIBRARY);
}
}
else if (strcmp (argv[i], FORTRAN_LIBRARY) == 0)
- saw_library = 1; /* -l. */
+ {
+ saw_library = 1; /* -l. */
+ ADD_ARG_LIBGFORTRAN (argv[i]);
+ continue;
+ }
else
{ /* Other library, or filename. */
if (saw_library == 1 && need_math)
@@ -495,12 +524,9 @@ For more information about these matters, see the file named COPYING\n\
switch (saw_library)
{
case 0:
- if (0 == use_init)
- {
- append_arg (FORTRAN_INIT);
- use_init = 1;
- }
- append_arg (library);
+ ADD_ARG_LIBGFORTRAN (library);
+ /* Fall through. */
+
case 1:
if (need_math)
append_arg (MATH_LIBRARY);
@@ -528,7 +554,7 @@ For more information about these matters, see the file named COPYING\n\
if (verbose && g77_newargv != g77_xargv)
{
- fprintf (stderr, "Driving:");
+ fprintf (stderr, _("Driving:"));
for (i = 0; i < g77_newargc; i++)
fprintf (stderr, " %s", g77_newargv[i]);
fprintf (stderr, "\n");
@@ -538,6 +564,7 @@ For more information about these matters, see the file named COPYING\n\
*in_argv = g77_newargv;
}
+
/* Called before linking. Returns 0 on success and -1 on failure. */
int
lang_specific_pre_link (void) /* Not used for F77. */