📄 g77spec.c
字号:
int n_infiles = 0; int n_outfiles = 0;#if 0 fprintf (stderr, "Incoming:"); for (i = 0; i < argc; i++) fprintf (stderr, " %s", argv[i]); fprintf (stderr, "\n");#endif g77_xargc = argc; g77_xargv = argv; g77_newargc = 0; g77_newargv = argv; g77_fn = fn; /* 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] == '+') && (argv[i][1] == 'e')) { add_version_magic = 0; continue; } if ((argv[i][0] != '-') || (argv[i][1] == '\0')) { ++n_infiles; 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_syntax_only: case OPTION_E: case OPTION_M: case OPTION_MM: /* 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; case OPTION_b: case OPTION_B: case OPTION_L: 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) 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\\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); exit (0); break; case OPTION_help: /* Let gcc.c handle this, as the egcs version 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\%s.\n", GCCBUGURL); exit (0); break;#endif case OPTION_driver: (*fn) ("--driver no longer supported", argv[i]); 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 (*fn) ("argument to `%s' missing", argv[i]); } if ((n_outfiles != 0) && (n_infiles == 0)) (*fn) ("No input files; unwilling to write output files"); /* Second pass through arglist, transforming arguments as appropriate. */ append_arg (argv[0]); /* Start with command name, of course. */ for (i = 1; i < argc; ++i) { if (argv[i][0] == '\0') { append_arg (argv[i]); /* Interesting. Just append as is. */ continue; } if ((argv[i][0] == '-') && (argv[i][1] != 'l')) { /* Not a filename or library. */ if (saw_library == 1 && need_math) /* -l<library>. */ append_arg (MATH_LIBRARY); saw_library = 0; lookup_option (&opt, &skip, &arg, argv[i]); if (argv[i][1] == '\0') { append_arg (argv[i]); /* "-" == Standard input. */ continue; } if (opt == OPTION_x) { /* Track input language. */ char *lang; if (arg == NULL) lang = argv[i+1]; else lang = arg; saw_speclang = (strcmp (lang, "none") != 0); } append_arg (argv[i]); for (; skip != 0; --skip) append_arg (argv[++i]); continue; } /* A filename/library, not an option. */ if (saw_speclang) saw_library = 0; /* -xfoo currently active. */ else { /* -lfoo or filename. */ if (strcmp (argv[i], MATH_LIBRARY) == 0#ifdef ALT_LIBM || strcmp (argv[i], ALT_LIBM) == 0#endif ) { if (saw_library == 1) saw_library = 2; /* -l<library> -lm. */ else append_arg (FORTRAN_LIBRARY); } else if (strcmp (argv[i], FORTRAN_LIBRARY) == 0) saw_library = 1; /* -l<library>. */ else { /* Other library, or filename. */ if (saw_library == 1 && need_math) append_arg (MATH_LIBRARY); saw_library = 0; } } append_arg (argv[i]); } /* Append `-lg2c -lm' as necessary. */ if (! add_version_magic && library) { /* Doing a link and no -nostdlib. */ if (saw_speclang) append_arg ("-xnone"); switch (saw_library) { case 0: append_arg (library); case 1: if (need_math) append_arg (MATH_LIBRARY); default: break; } } else if (add_version_magic && verbose) { append_arg ("-c"); append_arg ("-xf77-version"); append_arg ("/dev/null"); append_arg ("-xnone"); } if (verbose && g77_newargv != g77_xargv) { fprintf (stderr, "Driving:"); for (i = 0; i < g77_newargc; i++) fprintf (stderr, " %s", g77_newargv[i]); fprintf (stderr, "\n"); } *in_argc = g77_newargc; *in_argv = g77_newargv;}/* Called before linking. Returns 0 on success and -1 on failure. */int lang_specific_pre_link () /* Not used for F77. */{ return 0;}/* Number of extra output files that lang_specific_pre_link may generate. */int lang_specific_extra_outfiles = 0; /* Not used for F77. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -