diff options
author | Richard Kenner <kenner@vlsi1.ultra.nyu.edu> | 2000-09-20 20:06:55 +0000 |
---|---|---|
committer | Richard Kenner <kenner@gcc.gnu.org> | 2000-09-20 16:06:55 -0400 |
commit | dc36ec2cadc111bf6edfe5a96a009df76bd88889 (patch) | |
tree | daffb6dff669c55643880060479f59d766bbffb2 /gcc/gcc.c | |
parent | 5fa7c8cec4c4d452a4283b9a52b9de9b2e5211b7 (diff) | |
download | gcc-dc36ec2cadc111bf6edfe5a96a009df76bd88889.zip gcc-dc36ec2cadc111bf6edfe5a96a009df76bd88889.tar.gz gcc-dc36ec2cadc111bf6edfe5a96a009df76bd88889.tar.bz2 |
gcc.c (modify_target): New variable and struct.
* gcc.c (modify_target): New variable and struct.
(process_command): Handle MODIFY_TARGET_NAME.
* tm.texi (MODIFY_TARGET_NAME): Add documentation for new macro.
* config/pa/pa.h (MODIFY_TARGET_NAME): New macro.
From-SVN: r36555
Diffstat (limited to 'gcc/gcc.c')
-rw-r--r-- | gcc/gcc.c | 71 |
1 files changed, 71 insertions, 0 deletions
@@ -164,6 +164,21 @@ static const char *cross_compile = "1"; static const char *cross_compile = "0"; #endif +#ifdef MODIFY_TARGET_NAME + +/* Information on how to alter the target name based on a command-line + switch. The only case we support now is simply appending or deleting a + string to or from the end of the first part of the configuration name. */ + +struct modify_target +{ + const char *sw; + enum add_del {ADD, DELETE} add_del; + const char *str; +} +modify_target[] = MODIFY_TARGET_NAME; +#endif + /* The number of errors that have occurred; the link phase will not be run if this is non-zero. */ static int error_count = 0; @@ -2832,6 +2847,7 @@ process_command (argc, argv) const char *const *argv; { register int i; + unsigned int j; const char *temp; char *temp1; const char *spec_lang = 0; @@ -2839,6 +2855,9 @@ process_command (argc, argv) int have_c = 0; int have_o = 0; int lang_n_infiles = 0; +#ifdef MODIFY_TARGET_NAME + int is_modify_target_name; +#endif GET_ENV_PATH_LIST (gcc_exec_prefix, "GCC_EXEC_PREFIX"); @@ -3005,6 +3024,7 @@ process_command (argc, argv) /* Scan argv twice. Here, the first time, just count how many switches there will be in their vector, and how many input files in theirs. + Also parse any switches that determine the configuration name, such as -b. Here we also parse the switches that cc itself uses (e.g. -v). */ for (i = 1; i < argc; i++) @@ -3316,6 +3336,46 @@ process_command (argc, argv) default: normal_switch: + +#ifdef MODIFY_TARGET_NAME + is_modify_target_name = 0; + + for (j = 0; + j < sizeof modify_target / sizeof modify_target[0]; j++) + if (! strcmp (argv[i], modify_target[j].sw)) + { + char *new_name + = (char *) xmalloc (strlen (modify_target[j].str) + + strlen (spec_machine)); + const char *p, *r; + char *q; + int made_addition = 0; + + is_modify_target_name = 1; + for (p = spec_machine, q = new_name; *p != 0; ) + { + if (modify_target[j].add_del == DELETE + && (! strncmp (q, modify_target[j].str, + strlen (modify_target[j].str)))) + p += strlen (modify_target[j].str); + else if (modify_target[j].add_del == ADD + && ! made_addition && *p == '-') + { + for (r = modify_target[j].str; *r != 0; ) + *q++ = *r++; + made_addition = 1; + } + + *q++ = *p++; + } + + spec_machine = new_name; + } + + if (is_modify_target_name) + break; +#endif + n_switches++; if (SWITCH_TAKES_ARG (c) > (p[1] != 0)) @@ -3413,6 +3473,17 @@ process_command (argc, argv) for (i = 1; i < argc; i++) { /* Just skip the switches that were handled by the preceding loop. */ +#ifdef MODIFY_TARGET_NAME + is_modify_target_name = 0; + + for (j = 0; j < sizeof modify_target / sizeof modify_target[0]; j++) + if (! strcmp (argv[i], modify_target[j].sw)) + is_modify_target_name = 1; + + if (is_modify_target_name) + ; + else +#endif if (! strncmp (argv[i], "-Wa,", 4)) ; else if (! strncmp (argv[i], "-Wp,", 4)) |