Commit b8468bc7 by Nick Clifton Committed by Nick Clifton

Add --help option.

From-SVN: r21109
parent c6b0465b
Mon Jul 13 17:18:47 1998 Nick Clifton <nickc@cygnus.com>
* cccp.c (main): Add support for parsing --help.
(display_help): New function: display command line switches.
* cpplib.c (cpp_handle_option): Add support for parsing --help.
(display_help): New function: display command line switches.
* gcc.c (main): Add support for parsing --help, and passing it on
to the sub-processes invoked by gcc.
(display_help): New function: display comman line switches.
* tm.texi (TARGET_SWITCHES and TARGET_OPTIONS): Document
'description' field added to structure.
* toplev.c: Add support for parsing --help.
Add documentation strings to command line option tables.
(display_help): New function: display comman line switches.
Mon Jul 13 16:15:10 1998 John Carr <jfc@mit.edu>
* sparc.c, sparc.h, sparc.md: New trampoline code.
......
......@@ -1047,6 +1047,7 @@ GENERIC_PTR xmalloc PROTO((size_t));
static GENERIC_PTR xrealloc PROTO((GENERIC_PTR, size_t));
static GENERIC_PTR xcalloc PROTO((size_t, size_t));
static char *savestring PROTO((char *));
static void print_help PROTO((void));
/* Read LEN bytes at PTR from descriptor DESC, for file FILENAME,
retrying if necessary. If MAX_READ_LEN is defined, read at most
......@@ -1146,6 +1147,73 @@ eprint_string (string, length)
}
static void
print_help ()
{
printf ("Usage: %s [switches] input output\n", progname);
printf ("Switches:\n");
printf (" -include <file> Include the contents of <file> before other files\n");
printf (" -imacros <file> Accept definition of marcos in <file>\n");
printf (" -iprefix <path> Specify <path> as a prefix for next two options\n");
printf (" -iwithprefix <dir> Add <dir> to the end of the system include paths\n");
printf (" -iwithprefixbefore <dir> Add <dir> to the end of the main include paths\n");
printf (" -isystem <dir> Add <dir> to the start of the system include paths\n");
printf (" -idirafter <dir> Add <dir> to the end of the system include paths\n");
printf (" -I <dir> Add <dir> to the end of the main include paths\n");
printf (" -nostdinc Do not search the system include directories\n");
printf (" -nostdinc++ Do not search the system include directories for C++\n");
printf (" -o <file> Put output into <file>\n");
printf (" -pedantic Issue all warnings demanded by strict ANSI C\n");
printf (" -traditional Follow K&R pre-processor behaviour\n");
printf (" -trigraphs Support ANSI C trigraphs\n");
printf (" -lang-c Assume that the input sources are in C\n");
printf (" -lang-c89 Assume that the input sources are in C89\n");
printf (" -lang-c++ Assume that the input sources are in C++\n");
printf (" -lang-objc Assume that the input sources are in ObjectiveC\n");
printf (" -lang-objc++ Assume that the input sources are in ObjectiveC++\n");
printf (" -lang-asm Assume that the input sources are in assembler\n");
printf (" -lang-chill Assume that the input sources are in Chill\n");
printf (" -+ Allow parsing of C++ style features\n");
printf (" -w Inhibit warning messages\n");
printf (" -Wtrigraphs Warn if trigraphs are encountered\n");
printf (" -Wno-trigraphs Do not warn about trigraphs\n");
printf (" -Wcomment{s} Warn if one comment starts inside another\n");
printf (" -Wno-comment{s} Do not warn about comments\n");
printf (" -Wtraditional Warn if a macro argument is/would be turned into\n");
printf (" a string if -tradtional is specified\n");
printf (" -Wno-traditional Do not warn about stringification\n");
printf (" -Wundef Warn if an undefined macro is used by #if\n");
printf (" -Wno-undef Do not warn about testing udefined macros\n");
printf (" -Wimport Warn about the use of the #import directive\n");
printf (" -Wno-import Do not warn about the use of #import\n");
printf (" -Werror Treat all warnings as errors\n");
printf (" -Wno-error Do not treat warnings as errors\n");
printf (" -Wall Enable all preprocessor warnings\n");
printf (" -M Generate make dependencies\n");
printf (" -MM As -M, but ignore system header files\n");
printf (" -MD As -M, but put output in a .d file\n");
printf (" -MMD As -MD, but ignore system header files\n");
printf (" -MG Treat missing header file as generated files\n");
printf (" -g Include #define and #undef directives in the output\n");
printf (" -D<macro> Define a <macro> with string '1' as its value\n");
printf (" -D<macro>=<val> Define a <macro> with <val> as its value\n");
printf (" -A<question> (<answer>) Assert the <answer> to <question>\n");
printf (" -U<macro> Undefine <macro> \n");
printf (" -u or -undef Do not predefine any macros\n");
printf (" -v Display the version number\n");
printf (" -H Print the name of header files as they are used\n");
printf (" -C Do not discard comments\n");
printf (" -dM Display a list of macro definitions active at end\n");
printf (" -dD Preserve macro definitions in output\n");
printf (" -dN As -dD except that only the names are preserved\n");
printf (" -dI Include #include directives in the output\n");
printf (" -ifoutput Describe skipped code blocks in output \n");
printf (" -P Do not generate #line directives\n");
printf (" -$ Do not include '$' in identifiers\n");
printf (" -remap Remap file names when including files.\n");
printf (" -h or --help Display this information\n");
}
int
main (argc, argv)
int argc;
......@@ -1245,7 +1313,10 @@ main (argc, argv)
for (i = 1; i < argc; i++) {
if (argv[i][0] != '-') {
if (out_fname != NULL)
fatal ("Usage: %s [switches] input output", argv[0]);
{
print_help ();
fatal ("Too many arguments");
}
else if (in_fname != NULL)
out_fname = argv[i];
else
......@@ -1525,6 +1596,13 @@ main (argc, argv)
debug_output = 1;
break;
case '-':
if (strcmp (argv[i], "--help") != 0)
return i;
print_help ();
exit (0);
break;
case 'v':
fprintf (stderr, "GNU CPP version %s", version_string);
#ifdef TARGET_VERSION
......
......@@ -251,7 +251,8 @@ static char *savestring PROTO ((char *));
static void conditional_skip PROTO ((cpp_reader *, int,
enum node_type, U_CHAR *));
static void skip_if_group PROTO ((cpp_reader *, int));
static int parse_name PARAMS ((cpp_reader *, int));
static int parse_name PARAMS ((cpp_reader *, int));
static void print_help PROTO ((void));
/* Last arg to output_line_command. */
enum file_change_code {same_file, enter_file, leave_file};
......@@ -6235,6 +6236,79 @@ push_pending (pfile, cmd, arg)
CPP_OPTIONS (pfile)->pending = pend;
}
static void
print_help ()
{
printf ("Usage: %s [switches] input output\n", progname);
printf ("Switches:\n");
/* start-sanitize-obscured-headers */
printf (" -fgenobscured=<args> Generate obscured versions of header files used\n");
printf (" -fuseobscured=<args> Search for obscured versions of header files\n");
/* end-sanitize-obscured-headers */
printf (" -include <file> Include the contents of <file> before other files\n");
printf (" -imacros <file> Accept definition of marcos in <file>\n");
printf (" -iprefix <path> Specify <path> as a prefix for next two options\n");
printf (" -iwithprefix <dir> Add <dir> to the end of the system include paths\n");
printf (" -iwithprefixbefore <dir> Add <dir> to the end of the main include paths\n");
printf (" -isystem <dir> Add <dir> to the start of the system include paths\n");
printf (" -idirafter <dir> Add <dir> to the end of the system include paths\n");
printf (" -I <dir> Add <dir> to the end of the main include paths\n");
printf (" -nostdinc Do not search the system include directories\n");
printf (" -nostdinc++ Do not search the system include directories for C++\n");
printf (" -o <file> Put output into <file>\n");
printf (" -pedantic Issue all warnings demanded by strict ANSI C\n");
printf (" -traditional Follow K&R pre-processor behaviour\n");
printf (" -trigraphs Support ANSI C trigraphs\n");
printf (" -lang-c Assume that the input sources are in C\n");
printf (" -lang-c89 Assume that the input sources are in C89\n");
printf (" -lang-c++ Assume that the input sources are in C++\n");
printf (" -lang-objc Assume that the input sources are in ObjectiveC\n");
printf (" -lang-objc++ Assume that the input sources are in ObjectiveC++\n");
printf (" -lang-asm Assume that the input sources are in assembler\n");
printf (" -lang-chill Assume that the input sources are in Chill\n");
printf (" -+ Allow parsing of C++ style features\n");
printf (" -w Inhibit warning messages\n");
printf (" -Wtrigraphs Warn if trigraphs are encountered\n");
printf (" -Wno-trigraphs Do not warn about trigraphs\n");
printf (" -Wcomment{s} Warn if one comment starts inside another\n");
printf (" -Wno-comment{s} Do not warn about comments\n");
printf (" -Wtraditional Warn if a macro argument is/would be turned into\n");
printf (" a string if -tradtional is specified\n");
printf (" -Wno-traditional Do not warn about stringification\n");
printf (" -Wundef Warn if an undefined macro is used by #if\n");
printf (" -Wno-undef Do not warn about testing udefined macros\n");
printf (" -Wimport Warn about the use of the #import directive\n");
printf (" -Wno-import Do not warn about the use of #import\n");
printf (" -Werror Treat all warnings as errors\n");
printf (" -Wno-error Do not treat warnings as errors\n");
printf (" -Wall Enable all preprocessor warnings\n");
printf (" -M Generate make dependencies\n");
printf (" -MM As -M, but ignore system header files\n");
printf (" -MD As -M, but put output in a .d file\n");
printf (" -MMD As -MD, but ignore system header files\n");
printf (" -MG Treat missing header file as generated files\n");
printf (" -g Include #define and #undef directives in the output\n");
printf (" -D<macro> Define a <macro> with string '1' as its value\n");
printf (" -D<macro>=<val> Define a <macro> with <val> as its value\n");
printf (" -A<question> (<answer>) Assert the <answer> to <question>\n");
printf (" -U<macro> Undefine <macro> \n");
printf (" -u or -undef Do not predefine any macros\n");
printf (" -v Display the version number\n");
printf (" -H Print the name of header files as they are used\n");
printf (" -C Do not discard comments\n");
printf (" -dM Display a list of macro definitions active at end\n");
printf (" -dD Preserve macro definitions in output\n");
printf (" -dN As -dD except that only the names are preserved\n");
printf (" -dI Include #include directives in the output\n");
printf (" -ifoutput Describe skipped code blocks in output \n");
printf (" -P Do not generate #line directives\n");
printf (" -$ Do not include '$' in identifiers\n");
printf (" -remap Remap file names when including files.\n");
printf (" -h or --help Display this information\n");
}
/* Handle one command-line option in (argc, argv).
Can be called multiple times, to handle multiple sets of options.
Returns number of strings consumed. */
......@@ -6249,8 +6323,8 @@ cpp_handle_option (pfile, argc, argv)
if (argv[i][0] != '-') {
if (opts->out_fname != NULL)
{
cpp_fatal (pfile, "Usage: %s [switches] input output", argv[0]);
return argc;
print_help ();
cpp_fatal (pfile, "Too many arguments");
}
else if (opts->in_fname != NULL)
opts->out_fname = argv[i];
......@@ -6576,6 +6650,12 @@ cpp_handle_option (pfile, argc, argv)
opts->debug_output = 1;
break;
case '-':
if (strcmp (argv[i], "--help") != 0)
return i;
print_help ();
break;
case 'v':
fprintf (stderr, "GNU CPP version %s", version_string);
#ifdef TARGET_VERSION
......
......@@ -546,10 +546,13 @@ bits in @code{target_flags}. Its definition is an initializer
with a subgrouping for each command option.
Each subgrouping contains a string constant, that defines the option
name, and a number, which contains the bits to set in
@code{target_flags}. A negative number says to clear bits instead;
the negative of the number is which bits to clear. The actual option
name is made by appending @samp{-m} to the specified name.
name, a number, which contains the bits to set in
@code{target_flags}, and a second string which is the description
displayed by --help. If the number is negative then the bits specified
by the number are cleared instead of being set. If the description
string is present but empty, then no help information will be displayed
for that option, but it will not count as an undocumented option. The
actual option name is made by appending @samp{-m} to the specified name.
One of the subgroupings should have a null string. The number in
this grouping is the default value for @code{target_flags}. Any
......@@ -560,9 +563,9 @@ with opposite meanings, and picks the latter as the default:
@smallexample
#define TARGET_SWITCHES \
@{ @{ "68020", 1@}, \
@{ "68000", -1@}, \
@{ "", 1@}@}
@{ @{ "68020", 1, "" @}, \
@{ "68000", -1, "Compile for the 68000" @}, \
@{ "", 1, "" @}@}
@end smallexample
@findex TARGET_OPTIONS
......@@ -572,10 +575,10 @@ options that have values. Its definition is an initializer with a
subgrouping for each command option.
Each subgrouping contains a string constant, that defines the fixed part
of the option name, and the address of a variable. The variable, type
@code{char *}, is set to the variable part of the given option if the fixed
part matches. The actual option name is made by appending @samp{-m} to the
specified name.
of the option name, the address of a variable, and a description string.
The variable, type @code{char *}, is set to the variable part of the
given option if the fixed part matches. The actual option name is made
by appending @samp{-m} to the specified name.
Here is an example which defines @samp{-mshort-data-@var{number}}. If the
given option is @samp{-mshort-data-512}, the variable @code{m88k_short_data}
......@@ -584,7 +587,7 @@ will be set to the string @code{"512"}.
@smallexample
extern char *m88k_short_data;
#define TARGET_OPTIONS \
@{ @{ "short-data-", &m88k_short_data @} @}
@{ @{ "short-data-", &m88k_short_data, "Specify the size of the short data section" @} @}
@end smallexample
@findex TARGET_VERSION
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment