if (library)
if (!add_version_magic && library)
main (argc, argv)     int argc;     char **argv;{  register int i = 0;  register char *p;  int verbose = 0;  Option opt;  int skip;  char *arg;  /* This will be NULL if we encounter a situation where we should not     link in libf2c.  */  char *library = "-lf2c";  /* 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, the user wants version info, so 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;  /* The name of the compiler we will want to run---by default, it     will be the definition of `GCC_NAME', e.g., `gcc'.  */  char *gcc = GCC_NAME;  /* 0 => -xnone in effect on input/output     1 => -xfoo in effect on input/output     2 => -xnone in effect on input, -xf77 on output     3 => -xnone in effect on input, -xf77-cpp-input on output.  */  int saw_speclang = 0;  /* 0 => initial/reset state     1 => last arg was -l<library>     2 => last two args were -l<library> -lm.  */  int saw_library = 0;  /* Initialize for append_arg().  */  xargc = argc;  newargv = xargv = argv;  newargc = 0;  append_arg (argv[0]);  p = argv[0] + strlen (argv[0]);  while (p != argv[0] && p[-1] != '/')    --p;  programname = p;  if (argc == 1)    fatal ("No input files specified.\n");#ifndef __MSDOS__  /* We do a little magic to find out where the main gcc executable     is.  If they ran us as /usr/local/bin/g77, then we will look     for /usr/local/bin/gcc; similarly, if they just ran us as `g77',     we'll just look for `gcc'.  */  if (p != argv[0])    {      *--p = '\0';      gcc = (char *) malloc ((strlen (argv[0]) + 1 + strlen (GCC_NAME) + 1)			     * sizeof (char));      sprintf (gcc, "%s/%s", argv[0], GCC_NAME);    }#endif  /* First pass through arglist.     If -nostdlib or a "turn-off-linking" option is anywhere in the     command line, don't do any library-option processing (except     relating to -x).  Also, if -v is specified, but no other options     that do anything special (allowing -V version, etc.), remember     to add special stuff to make gcc command actually invoke all     the different phases of the compilation process so all the version     numbers can be seen.     Also, here is where all problems with missing arguments to 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     program is concerned.  */  for (i = 1; i < argc; ++i)    {      if (argv[i][0] != '-')	{	  add_version_magic = 0;	  continue;	}      lookup_option (&opt, &skip, NULL, argv[i]);      switch (opt)	{	case OPTION_nostdlib:	case OPTION_c:	case OPTION_S:	case OPTION_E:	case OPTION_M:	case OPTION_MM:	  /* These options disable linking entirely or linking of the	     standard libraries.  */	  library = NULL;	  add_version_magic = 0;	  break;	case OPTION_v:	  verbose = 1;	  printf ("g77 version %s\n", ffezzz_version_string);	  break;	case OPTION_b:	case OPTION_B:	case OPTION_driver:	case OPTION_i:	case OPTION_V:	  /* These options are useful in conjunction with -v to get	     appropriate version info.  */	  break;	case OPTION_version:	  printf ("\GNU Fortran %s\n\Copyright (C) 1996 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\\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\", ffezzz_version_string);	  exit (0);	  break;	case OPTION_help:	  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\--driver=COMMAND       specify preprocessor/compiler/linker driver\n\                         to use instead of the default `gcc'.\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 on these commands.\n\\n\Report bugs to fortran@gnu.ai.mit.edu.\n");	  exit (0);	  break;	default:	  add_version_magic = 0;	  break;	}      /* This is the one place we check for missing arguments in the	 program.  */      if (i + skip < argc)	i += skip;      else	fatal ("argument to `%s' missing\n", argv[i]);    }  /* If only -v and related options (like -V), don't link the standard     libraries.  */  if (add_version_magic)    library = NULL;  /* Second pass through arglist, transforming arguments as appropriate.  */  for (i = 1; i < argc; ++i)    {      if (argv[i][0] == '\0')	append_arg (argv[i]);	/* Interesting.  Just append as is. */      else if ((argv[i][0] == '-') && (argv[i][1] != 'l'))	{	  /* Not a filename or library. */	  if (saw_library == 1)	/* -l<library>. */	    append_arg ("-lm");	  saw_library = 0;	  lookup_option (&opt, &skip, &arg, argv[i]);	  if (argv[i][1] == '\0')	    append_arg (argv[i]);	/* "-" == Standard input. */	  else if (opt == OPTION_x)	    {	      /* Track input language. */	      char *lang;	      append_arg (argv[i]);	      if (arg == NULL)		lang = argv[i+1];	      else		lang = arg;	      saw_speclang = (strcmp (lang, "none") != 0);	    }	  else if (opt == OPTION_driver)	    {	      if (arg == NULL)		gcc = argv[i+1];	      else		gcc = arg;	      i += skip;	      continue;		/* Don't append args to new list. */	    }	  append_arg (argv[i]);	  for (; skip != 0; --skip)	    append_arg (argv[++i]);	}      else	{			/* A filename/library, not an option. */	  int len;	  int want_speclang;	  /* Here, always append the arg _after_ other stuff, possibly.  */	  if (saw_speclang == 1)	    saw_library = 0;	/* -xfoo currently active. */	  /* Put -xf77 and -xnone around list of filenames ending in	     .F or .f, but don't include other filenames or libraries	     in that list.  */	  else if ((argv[i][0] != '-')	/* Not a library. */		   && (len = strlen (argv[i])) > 2		   && ((argv[i][len - 1] == 'F')		       || (argv[i][len - 1] == 'f'))		   && argv[i][len - 2] == '.')	    {			/* filename.f or filename.F. */	      if (saw_library == 1)	/* -l<library>. */		append_arg ("-lm");	      saw_library = 0;	      want_speclang = (argv[i][len - 1] == 'F') + 2;	      if (saw_speclang != want_speclang)		{		  if (want_speclang == 2)		    append_arg ("-xf77");		  else		    append_arg ("-xf77-cpp-input");		  saw_speclang = want_speclang;		}	    }	  else	    {			/* -lfoo or "alien" filename. */	      if (saw_speclang)		append_arg ("-xnone");	      saw_speclang = 0;	      if (strcmp (argv[i], "-lm") == 0		  || strcmp (argv[i], "-lmath") == 0)		{		  if (saw_library == 1)		    saw_library = 2;	/* -l<library> -lm. */		  else if (library)		    {		      append_arg (library);		      saw_library = 2;	/* -l<library> -lm. */		    }		}	      else if ((library != NULL)		       && (strcmp (argv[i], library) == 0))		saw_library = 1;	/* -l<library>. */	      else		{		/* "Alien" library or filename. */		  if (saw_library == 1)		    append_arg ("-lm");		  saw_library = 0;		}	    }	  append_arg (argv[i]);	}    }  /* Add -lf2c -lm as necessary.  */  if (library)    {				/* Doing a link and no -nostdlib. */      if (saw_speclang)	append_arg ("-xnone");      switch (saw_library)	{	case 0:	  append_arg (library);	case 1:	  append_arg ("-lm");	default:	  break;	}    }  else if (verbose && add_version_magic)    {      choose_temp_base ();      append_arg ("-fnull-version");      append_arg ("-o");      append_arg (temp_filename);      append_arg ("-xf77-cpp-input");      append_arg ("/dev/null");      append_arg ("-xnone");      if (library)	{	  append_arg (library);	  append_arg ("-lm");	}    }  append_arg (NULL);  --newargc;			/* Don't count null arg at end. */  newargv[0] = gcc;		/* This is safe even if newargv == xargv. */  if (verbose)    {#if 0      if (newargv == xargv)	fprintf (stderr, "[Original:]");#endif      for (i = 0; i < newargc; i++)	fprintf (stderr, " %s", newargv[i]);      fprintf (stderr, "\n");    }#if !defined(OS2) && !defined (_WIN32)#ifdef __MSDOS__  run_dos (gcc, newargv);#else /* !__MSDOS__ */  if (execvp (gcc, newargv) < 0)    pfatal_with_name (gcc);#endif /* __MSDOS__ */#else /* OS2 or _WIN32 */  if (spawnvp (1, gcc, newargv) < 0)    pfatal_with_name (gcc);#endif  return 0;}