static int print_multi_directory;
+/* Flag saying to print the relative path we'd use to
+ find OS libraries given the current compiler flags. */
+
+static int print_multi_os_directory;
+
/* Flag saying to print the list of subdirectories and
compiler flags used to select them in a standard form. */
static char *build_search_list PARAMS ((struct path_prefix *, const char *, int));
static void putenv_from_prefixes PARAMS ((struct path_prefix *, const char *));
static int access_check PARAMS ((const char *, int));
-static char *find_a_file PARAMS ((struct path_prefix *, const char *, int));
+static char *find_a_file PARAMS ((struct path_prefix *, const char *,
+ int, int));
static void add_prefix PARAMS ((struct path_prefix *, const char *,
- const char *, int, int, int *));
+ const char *, int, int, int *, int));
static void translate_options PARAMS ((int *, const char *const **));
static char *skip_whitespace PARAMS ((char *));
static void delete_if_ordinary PARAMS ((const char *));
{"--print-missing-file-dependencies", "-MG", 0},
{"--print-multi-lib", "-print-multi-lib", 0},
{"--print-multi-directory", "-print-multi-directory", 0},
+ {"--print-multi-os-directory", "-print-multi-os-directory", 0},
{"--print-prog-name", "-print-prog-name=", "aj"},
{"--profile", "-p", 0},
{"--profile-blocks", "-a", 0},
int require_machine_suffix; /* Don't use without machine_suffix. */
/* 2 means try both machine_suffix and just_machine_suffix. */
int *used_flag_ptr; /* 1 if a file was found with this prefix. */
- int priority; /* Sort key - priority within list */
+ int priority; /* Sort key - priority within list. */
+ int os_multilib; /* 1 if OS multilib scheme should be used,
+ 0 for GCC multilib scheme. */
};
struct path_prefix
set_multilib_dir based on the compilation options. */
static const char *multilib_dir;
+
+/* Subdirectory to use for locating libraries in OS conventions. Set by
+ set_multilib_dir based on the compilation options. */
+
+static const char *multilib_os_dir;
\f
/* Structure to keep track of the specs that have been defined so far.
These are accessed using %(specname) or %[specname] in a compiler
INIT_STATIC_SPEC ("multilib_extra", &multilib_extra),
INIT_STATIC_SPEC ("multilib_matches", &multilib_matches),
INIT_STATIC_SPEC ("multilib_exclusions", &multilib_exclusions),
+ INIT_STATIC_SPEC ("multilib_options", &multilib_options),
INIT_STATIC_SPEC ("linker", &linker_name_spec),
INIT_STATIC_SPEC ("link_libgcc", &link_libgcc_spec),
INIT_STATIC_SPEC ("md_exec_prefix", &md_exec_prefix),
(long) (p1 - buffer + 1));
p[-2] = '\0';
- new_filename = find_a_file (&startfile_prefixes, p1, R_OK);
+ new_filename = find_a_file (&startfile_prefixes, p1, R_OK, 0);
read_specs (new_filename ? new_filename : p1, FALSE);
continue;
}
(long) (p1 - buffer + 1));
p[-2] = '\0';
- new_filename = find_a_file (&startfile_prefixes, p1, R_OK);
+ new_filename = find_a_file (&startfile_prefixes, p1, R_OK, 0);
if (new_filename)
read_specs (new_filename, FALSE);
else if (verbose_flag)
Return 0 if not found, otherwise return its name, allocated with malloc. */
static char *
-find_a_file (pprefix, name, mode)
+find_a_file (pprefix, name, mode, multilib)
struct path_prefix *pprefix;
const char *name;
- int mode;
+ int mode, multilib;
{
char *temp;
const char *const file_suffix =
((mode & X_OK) != 0 ? HOST_EXECUTABLE_SUFFIX : "");
struct prefix_list *pl;
int len = pprefix->max_len + strlen (name) + strlen (file_suffix) + 1;
+ const char *multilib_name, *multilib_os_name;
#ifdef DEFAULT_ASSEMBLER
if (! strcmp (name, "as") && access (DEFAULT_ASSEMBLER, mode) == 0)
if (machine_suffix)
len += strlen (machine_suffix);
+ multilib_name = name;
+ multilib_os_name = name;
+ if (multilib && multilib_os_dir)
+ {
+ int len1 = multilib_dir ? strlen (multilib_dir) + 1 : 0;
+ int len2 = strlen (multilib_os_dir) + 1;
+
+ len += len1 > len2 ? len1 : len2;
+ if (multilib_dir)
+ multilib_name = ACONCAT ((multilib_dir, dir_separator_str, name,
+ NULL));
+ if (strcmp (multilib_os_dir, ".") != 0)
+ multilib_os_name = ACONCAT ((multilib_os_dir, dir_separator_str, name,
+ NULL));
+ }
+
temp = xmalloc (len);
/* Determine the filename to execute (special case for absolute paths). */
else
for (pl = pprefix->plist; pl; pl = pl->next)
{
+ const char *this_name
+ = pl->os_multilib ? multilib_os_name : multilib_name;
+
if (machine_suffix)
{
/* Some systems have a suffix for executable files.
{
strcpy (temp, pl->prefix);
strcat (temp, machine_suffix);
- strcat (temp, name);
+ strcat (temp, multilib_name);
strcat (temp, file_suffix);
if (access_check (temp, mode) == 0)
{
}
}
- /* Now try just the name. */
+ /* Now try just the multilib_name. */
strcpy (temp, pl->prefix);
strcat (temp, machine_suffix);
- strcat (temp, name);
+ strcat (temp, multilib_name);
if (access_check (temp, mode) == 0)
{
if (pl->used_flag_ptr != 0)
{
strcpy (temp, pl->prefix);
strcat (temp, just_machine_suffix);
- strcat (temp, name);
+ strcat (temp, multilib_name);
strcat (temp, file_suffix);
if (access_check (temp, mode) == 0)
{
strcpy (temp, pl->prefix);
strcat (temp, just_machine_suffix);
- strcat (temp, name);
+ strcat (temp, multilib_name);
if (access_check (temp, mode) == 0)
{
if (pl->used_flag_ptr != 0)
if (file_suffix[0] != 0)
{
strcpy (temp, pl->prefix);
- strcat (temp, name);
+ strcat (temp, this_name);
strcat (temp, file_suffix);
if (access_check (temp, mode) == 0)
{
}
strcpy (temp, pl->prefix);
- strcat (temp, name);
+ strcat (temp, this_name);
if (access_check (temp, mode) == 0)
{
if (pl->used_flag_ptr != 0)
2 means try both machine_suffix and just_machine_suffix. */
static void
-add_prefix (pprefix, prefix, component, priority, require_machine_suffix, warn)
+add_prefix (pprefix, prefix, component, priority, require_machine_suffix,
+ warn, os_multilib)
struct path_prefix *pprefix;
const char *prefix;
const char *component;
/* enum prefix_priority */ int priority;
int require_machine_suffix;
int *warn;
+ int os_multilib;
{
struct prefix_list *pl, **prev;
int len;
pl->require_machine_suffix = require_machine_suffix;
pl->used_flag_ptr = warn;
pl->priority = priority;
+ pl->os_multilib = os_multilib;
if (warn)
*warn = 0;
commands[0].prog = argbuf[0]; /* first command. */
commands[0].argv = &argbuf[0];
- string = find_a_file (&exec_prefixes, commands[0].prog, X_OK);
+ string = find_a_file (&exec_prefixes, commands[0].prog, X_OK, 0);
if (string)
commands[0].argv[0] = string;
argbuf[i] = 0; /* termination of command args. */
commands[n_commands].prog = argbuf[i + 1];
commands[n_commands].argv = &argbuf[i + 1];
- string = find_a_file (&exec_prefixes, commands[n_commands].prog, X_OK);
+ string = find_a_file (&exec_prefixes, commands[n_commands].prog,
+ X_OK, 0);
if (string)
commands[n_commands].argv[0] = string;
n_commands++;
fputs (_("\
-print-multi-lib Display the mapping between command line options and\n\
multiple library search directories\n"), stdout);
+ fputs (_(" -print-multi-os-directory Display the relative path to OS libraries\n"), stdout);
fputs (_(" -Wa,<options> Pass comma-separated <options> on to the assembler\n"), stdout);
fputs (_(" -Wp,<options> Pass comma-separated <options> on to the preprocessor\n"), stdout);
fputs (_(" -Wl,<options> Pass comma-separated <options> on to the linker\n"), stdout);
set_std_prefix (gcc_exec_prefix, len);
add_prefix (&exec_prefixes, gcc_exec_prefix, "GCC",
- PREFIX_PRIORITY_LAST, 0, NULL);
+ PREFIX_PRIORITY_LAST, 0, NULL, 0);
add_prefix (&startfile_prefixes, gcc_exec_prefix, "GCC",
- PREFIX_PRIORITY_LAST, 0, NULL);
+ PREFIX_PRIORITY_LAST, 0, NULL, 0);
}
/* COMPILER_PATH and LIBRARY_PATH have values
else
nstore[endp - startp] = 0;
add_prefix (&exec_prefixes, nstore, 0,
- PREFIX_PRIORITY_LAST, 0, NULL);
+ PREFIX_PRIORITY_LAST, 0, NULL, 0);
add_prefix (&include_prefixes,
concat (nstore, "include", NULL),
- 0, PREFIX_PRIORITY_LAST, 0, NULL);
+ 0, PREFIX_PRIORITY_LAST, 0, NULL, 0);
if (*endp == 0)
break;
endp = startp = endp + 1;
else
nstore[endp - startp] = 0;
add_prefix (&startfile_prefixes, nstore, NULL,
- PREFIX_PRIORITY_LAST, 0, NULL);
+ PREFIX_PRIORITY_LAST, 0, NULL, 1);
if (*endp == 0)
break;
endp = startp = endp + 1;
else
nstore[endp - startp] = 0;
add_prefix (&startfile_prefixes, nstore, NULL,
- PREFIX_PRIORITY_LAST, 0, NULL);
+ PREFIX_PRIORITY_LAST, 0, NULL, 1);
if (*endp == 0)
break;
endp = startp = endp + 1;
print_multi_lib = 1;
else if (! strcmp (argv[i], "-print-multi-directory"))
print_multi_directory = 1;
+ else if (! strcmp (argv[i], "-print-multi-os-directory"))
+ print_multi_os_directory = 1;
else if (! strncmp (argv[i], "-Wa,", 4))
{
int prev, j;
{
if (len == 7)
add_prefix (&include_prefixes, "include", NULL,
- PREFIX_PRIORITY_B_OPT, 0, NULL);
+ PREFIX_PRIORITY_B_OPT, 0, NULL, 0);
else
{
char * string = xmalloc (len + 1);
strncpy (string, value, len - 7);
strcpy (string + len - 7, "include");
add_prefix (&include_prefixes, string, NULL,
- PREFIX_PRIORITY_B_OPT, 0, NULL);
+ PREFIX_PRIORITY_B_OPT, 0, NULL, 0);
}
}
add_prefix (&exec_prefixes, value, NULL,
- PREFIX_PRIORITY_B_OPT, 0, &warn_B);
+ PREFIX_PRIORITY_B_OPT, 0, &warn_B, 0);
add_prefix (&startfile_prefixes, value, NULL,
- PREFIX_PRIORITY_B_OPT, 0, &warn_B);
+ PREFIX_PRIORITY_B_OPT, 0, &warn_B, 0);
add_prefix (&include_prefixes, concat (value, "include", NULL),
- NULL, PREFIX_PRIORITY_B_OPT, 0, NULL);
+ NULL, PREFIX_PRIORITY_B_OPT, 0, NULL, 0);
n_switches++;
}
break;
as well as trying the machine and the version. */
#ifndef OS2
add_prefix (&exec_prefixes, standard_exec_prefix, "GCC",
- PREFIX_PRIORITY_LAST, 1, warn_std_ptr);
+ PREFIX_PRIORITY_LAST, 1, warn_std_ptr, 0);
add_prefix (&exec_prefixes, standard_exec_prefix, "BINUTILS",
- PREFIX_PRIORITY_LAST, 2, warn_std_ptr);
+ PREFIX_PRIORITY_LAST, 2, warn_std_ptr, 0);
add_prefix (&exec_prefixes, standard_exec_prefix_1, "BINUTILS",
- PREFIX_PRIORITY_LAST, 2, warn_std_ptr);
+ PREFIX_PRIORITY_LAST, 2, warn_std_ptr, 0);
#endif
add_prefix (&startfile_prefixes, standard_exec_prefix, "BINUTILS",
- PREFIX_PRIORITY_LAST, 1, warn_std_ptr);
+ PREFIX_PRIORITY_LAST, 1, warn_std_ptr, 0);
add_prefix (&startfile_prefixes, standard_exec_prefix_1, "BINUTILS",
- PREFIX_PRIORITY_LAST, 1, warn_std_ptr);
+ PREFIX_PRIORITY_LAST, 1, warn_std_ptr, 0);
tooldir_prefix = concat (tooldir_base_prefix, spec_machine,
dir_separator_str, NULL);
add_prefix (&exec_prefixes,
concat (gcc_exec_tooldir_prefix, "bin",
dir_separator_str, NULL),
- NULL, PREFIX_PRIORITY_LAST, 0, NULL);
+ NULL, PREFIX_PRIORITY_LAST, 0, NULL, 0);
add_prefix (&startfile_prefixes,
concat (gcc_exec_tooldir_prefix, "lib",
dir_separator_str, NULL),
- NULL, PREFIX_PRIORITY_LAST, 0, NULL);
+ NULL, PREFIX_PRIORITY_LAST, 0, NULL, 1);
}
tooldir_prefix = concat (standard_exec_prefix, spec_machine,
add_prefix (&exec_prefixes,
concat (tooldir_prefix, "bin", dir_separator_str, NULL),
- "BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL);
+ "BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL, 0);
add_prefix (&startfile_prefixes,
concat (tooldir_prefix, "lib", dir_separator_str, NULL),
- "BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL);
+ "BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL, 1);
/* More prefixes are enabled in main, after we read the specs file
and determine whether this is cross-compilation or not. */
;
else if (! strcmp (argv[i], "-print-multi-directory"))
;
+ else if (! strcmp (argv[i], "-print-multi-os-directory"))
+ ;
else if (! strcmp (argv[i], "-ftarget-help"))
;
else if (! strcmp (argv[i], "-fhelp"))
continue;
#endif
/* Try subdirectory if there is one. */
- if (multilib_dir != NULL)
+ if (multilib_dir != NULL
+ || (pl->os_multilib && multilib_os_dir != NULL))
{
- if (machine_suffix)
+ const char *multi_dir;
+
+ multi_dir = pl->os_multilib ? multilib_os_dir
+ : multilib_dir;
+ if (machine_suffix && multilib_dir)
{
if (strlen (pl->prefix) + strlen (machine_suffix)
>= bufsize)
}
if (!pl->require_machine_suffix)
{
- if (is_directory (pl->prefix, multilib_dir, 1))
+ if (is_directory (pl->prefix, multi_dir, 1))
{
do_spec_1 ("-L", 0, NULL);
#ifdef SPACE_AFTER_L_OPTION
do_spec_1 (" ", 0, NULL);
#endif
do_spec_1 (pl->prefix, 1, NULL);
- do_spec_1 (multilib_dir, 1, NULL);
+ do_spec_1 (multi_dir, 1, NULL);
/* Make this a separate argument. */
do_spec_1 (" ", 0, NULL);
}
char *newname;
/* Try multilib_dir if it is defined. */
- if (multilib_dir != NULL)
+ if (multilib_os_dir != NULL)
{
- const char *const try = ACONCAT ((multilib_dir, dir_separator_str, name, NULL));
-
- newname = find_a_file (&startfile_prefixes, try, R_OK);
+ newname = find_a_file (&startfile_prefixes, name, R_OK, 1);
/* If we don't find it in the multi library dir, then fall
through and look for it in the normal places. */
return newname;
}
- newname = find_a_file (&startfile_prefixes, name, R_OK);
+ newname = find_a_file (&startfile_prefixes, name, R_OK, 0);
return newname ? newname : name;
}
spec_version, dir_separator_str, NULL);
just_machine_suffix = concat (spec_machine, dir_separator_str, NULL);
- specs_file = find_a_file (&startfile_prefixes, "specs", R_OK);
+ specs_file = find_a_file (&startfile_prefixes, "specs", R_OK, 0);
/* Read the specs file unless it is a default one. */
if (specs_file != 0 && strcmp (specs_file, "specs"))
read_specs (specs_file, TRUE);
if (*md_exec_prefix)
{
add_prefix (&exec_prefixes, md_exec_prefix, "GCC",
- PREFIX_PRIORITY_LAST, 0, NULL);
+ PREFIX_PRIORITY_LAST, 0, NULL, 0);
add_prefix (&startfile_prefixes, md_exec_prefix, "GCC",
- PREFIX_PRIORITY_LAST, 0, NULL);
+ PREFIX_PRIORITY_LAST, 0, NULL, 0);
}
if (*md_startfile_prefix)
add_prefix (&startfile_prefixes, md_startfile_prefix, "GCC",
- PREFIX_PRIORITY_LAST, 0, NULL);
+ PREFIX_PRIORITY_LAST, 0, NULL, 1);
if (*md_startfile_prefix_1)
add_prefix (&startfile_prefixes, md_startfile_prefix_1, "GCC",
- PREFIX_PRIORITY_LAST, 0, NULL);
+ PREFIX_PRIORITY_LAST, 0, NULL, 1);
/* If standard_startfile_prefix is relative, base it on
standard_exec_prefix. This lets us move the installed tree
standard_startfile_prefix on that as well. */
if (IS_ABSOLUTE_PATHNAME (standard_startfile_prefix))
add_prefix (&startfile_prefixes, standard_startfile_prefix, "BINUTILS",
- PREFIX_PRIORITY_LAST, 0, NULL);
+ PREFIX_PRIORITY_LAST, 0, NULL, 1);
else
{
if (gcc_exec_prefix)
add_prefix (&startfile_prefixes,
concat (gcc_exec_prefix, machine_suffix,
standard_startfile_prefix, NULL),
- NULL, PREFIX_PRIORITY_LAST, 0, NULL);
+ NULL, PREFIX_PRIORITY_LAST, 0, NULL, 1);
add_prefix (&startfile_prefixes,
concat (standard_exec_prefix,
machine_suffix,
standard_startfile_prefix, NULL),
- NULL, PREFIX_PRIORITY_LAST, 0, NULL);
+ NULL, PREFIX_PRIORITY_LAST, 0, NULL, 1);
}
add_prefix (&startfile_prefixes, standard_startfile_prefix_1,
- "BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL);
+ "BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL, 1);
add_prefix (&startfile_prefixes, standard_startfile_prefix_2,
- "BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL);
+ "BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL, 1);
#if 0 /* Can cause surprises, and one can use -B./ instead. */
add_prefix (&startfile_prefixes, "./", NULL,
- PREFIX_PRIORITY_LAST, 1, NULL);
+ PREFIX_PRIORITY_LAST, 1, NULL, 0);
#endif
}
else
add_prefix (&startfile_prefixes,
concat (gcc_exec_prefix, machine_suffix,
standard_startfile_prefix, NULL),
- "BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL);
+ "BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL, 1);
}
if (*startfile_prefix_spec != 0
int ndx;
for (ndx = 0; ndx < argbuf_index; ndx++)
add_prefix (&startfile_prefixes, argbuf[ndx], "BINUTILS",
- PREFIX_PRIORITY_LAST, 0, NULL);
+ PREFIX_PRIORITY_LAST, 0, NULL, 1);
}
/* Process any user specified specs in the order given on the command
line. */
for (uptr = user_specs_head; uptr; uptr = uptr->next)
{
- char *filename = find_a_file (&startfile_prefixes, uptr->filename, R_OK);
+ char *filename = find_a_file (&startfile_prefixes, uptr->filename,
+ R_OK, 0);
read_specs (filename ? filename : uptr->filename, FALSE);
}
if (print_prog_name)
{
- char *newname = find_a_file (&exec_prefixes, print_prog_name, X_OK);
+ char *newname = find_a_file (&exec_prefixes, print_prog_name, X_OK, 0);
printf ("%s\n", (newname ? newname : print_prog_name));
return (0);
}
return (0);
}
+ if (print_multi_os_directory)
+ {
+ if (multilib_os_dir == NULL)
+ printf (".\n");
+ else
+ printf ("%s\n", multilib_os_dir);
+ return (0);
+ }
+
if (target_help_flag)
{
/* Print if any target specific options. */
/* We'll use ld if we can't find collect2. */
if (! strcmp (linker_name_spec, "collect2"))
{
- char *s = find_a_file (&exec_prefixes, "collect2", X_OK);
+ char *s = find_a_file (&exec_prefixes, "collect2", X_OK, 0);
if (s == NULL)
linker_name_spec = "ld";
}
goto next_member;
}
\f
+struct mdswitchstr
+{
+ const char *str;
+ int len;
+};
+
+static struct mdswitchstr *mdswitches;
+static int n_mdswitches;
+
/* Check whether a particular argument was used. The first time we
canonicalize the switches to keep only the ones we care about. */
xmalloc from calling fatal, and prevents us from re-executing this
block of code. */
mswitches
- = (struct mswitchstr *) xmalloc ((sizeof (struct mswitchstr))
- * (n_switches ? n_switches : 1));
+ = (struct mswitchstr *)
+ xmalloc (sizeof (struct mswitchstr)
+ * (n_mdswitches + (n_switches ? n_switches : 1)));
for (i = 0; i < n_switches; i++)
{
int xlen = strlen (switches[i].part1);
break;
}
}
+
+ /* Add MULTILIB_DEFAULTS switches too, as long as they were not present
+ on the command line nor any options mutually incompatible with
+ them. */
+ for (i = 0; i < n_mdswitches; i++)
+ {
+ const char *r;
+
+ for (q = multilib_options; *q != '\0'; q++)
+ {
+ while (*q == ' ')
+ q++;
+
+ r = q;
+ while (strncmp (q, mdswitches[i].str, mdswitches[i].len) != 0
+ || strchr (" /", q[mdswitches[i].len]) == NULL)
+ {
+ while (*q != ' ' && *q != '/' && *q != '\0')
+ q++;
+ if (*q != '/')
+ break;
+ q++;
+ }
+
+ if (*q != ' ' && *q != '\0')
+ {
+ while (*r != ' ' && *r != '\0')
+ {
+ q = r;
+ while (*q != ' ' && *q != '/' && *q != '\0')
+ q++;
+
+ if (used_arg (r, q - r))
+ break;
+
+ if (*q != '/')
+ {
+ mswitches[n_mswitches].str = mdswitches[i].str;
+ mswitches[n_mswitches].len = mdswitches[i].len;
+ mswitches[n_mswitches].replace = (char *) 0;
+ mswitches[n_mswitches].rep_len = 0;
+ n_mswitches++;
+ break;
+ }
+
+ r = q + 1;
+ }
+ break;
+ }
+ }
+ }
}
for (i = 0; i < n_mswitches; i++)
const char *p;
int len;
{
- const char *start, *end;
-
- for (start = multilib_defaults; *start != '\0'; start = end + 1)
- {
- while (*start == ' ' || *start == '\t')
- start++;
-
- if (*start == '\0')
- break;
-
- for (end = start + 1; *end != ' ' && *end != '\t' && *end != '\0'; end++)
- ;
-
- if ((end - start) == len && strncmp (p, start, len) == 0)
- return 1;
+ int i;
- if (*end == '\0')
- break;
- }
+ for (i = 0; i < n_mdswitches; i++)
+ if (len == mdswitches[i].len && ! strncmp (p, mdswitches[i].str, len))
+ return 1;
return 0;
}
const char *p;
unsigned int this_path_len;
const char *this_path, *this_arg;
+ const char *start, *end;
int not_arg;
- int ok;
+ int ok, ndfltok, first;
+
+ n_mdswitches = 0;
+ start = multilib_defaults;
+ while (*start == ' ' || *start == '\t')
+ start++;
+ while (*start != '\0')
+ {
+ n_mdswitches++;
+ while (*start != ' ' && *start != '\t' && *start != '\0')
+ start++;
+ while (*start == ' ' || *start == '\t')
+ start++;
+ }
+
+ if (n_mdswitches)
+ {
+ int i = 0;
+
+ mdswitches
+ = (struct mdswitchstr *) xmalloc (sizeof (struct mdswitchstr)
+ * n_mdswitches);
+ for (start = multilib_defaults; *start != '\0'; start = end + 1)
+ {
+ while (*start == ' ' || *start == '\t')
+ start++;
+
+ if (*start == '\0')
+ break;
+
+ for (end = start + 1;
+ *end != ' ' && *end != '\t' && *end != '\0'; end++)
+ ;
+
+ obstack_grow (&multilib_obstack, start, end - start);
+ obstack_1grow (&multilib_obstack, 0);
+ mdswitches[i].str = obstack_finish (&multilib_obstack);
+ mdswitches[i++].len = end - start;
+
+ if (*end == '\0')
+ break;
+ }
+ }
p = multilib_exclusions;
while (*p != '\0')
++p;
}
+ first = 1;
p = multilib_select;
while (*p != '\0')
{
/* Check the arguments. */
ok = 1;
+ ndfltok = 1;
++p;
while (*p != ';')
{
there is a more specific library which uses this
argument. If this argument is a default, we need not
consider that more specific library. */
- if (! default_arg (this_arg, p - this_arg))
- {
- ok = used_arg (this_arg, p - this_arg);
- if (not_arg)
- ok = ! ok;
- }
+ ok = used_arg (this_arg, p - this_arg);
+ if (not_arg)
+ ok = ! ok;
+
+ if (! ok)
+ ndfltok = 0;
+
+ if (default_arg (this_arg, p - this_arg))
+ ok = 1;
if (*p == ' ')
++p;
}
- if (ok)
+ if (ok && first)
{
if (this_path_len != 1
|| this_path[0] != '.')
{
char *new_multilib_dir = xmalloc (this_path_len + 1);
+ char *q;
+
strncpy (new_multilib_dir, this_path, this_path_len);
new_multilib_dir[this_path_len] = '\0';
+ q = strchr (new_multilib_dir, ':');
+ if (q != NULL)
+ *q = '\0';
multilib_dir = new_multilib_dir;
}
- break;
+ first = 0;
+ }
+
+ if (ndfltok)
+ {
+ const char *q = this_path, *end = this_path + this_path_len;
+
+ while (q < end && *q != ':')
+ q++;
+ if (*q == ':')
+ {
+ char *new_multilib_os_dir = xmalloc (end - q);
+ strncpy (new_multilib_os_dir, q + 1, end - q - 1);
+ new_multilib_os_dir[end - q] = '\0';
+ multilib_os_dir = new_multilib_os_dir;
+ break;
+ }
}
++p;
}
+
+ if (multilib_dir == NULL && multilib_os_dir != NULL
+ && strcmp (multilib_os_dir, ".") == 0)
+ {
+ free ((char *) multilib_os_dir);
+ multilib_os_dir = NULL;
+ }
+ else if (multilib_dir != NULL && multilib_os_dir == NULL)
+ multilib_os_dir = multilib_dir;
}
/* Print out the multiple library subdirectory selection
{
const char *p1;
- for (p1 = last_path; p1 < p; p1++)
+ for (p1 = last_path; p1 < p && *p1 != ':'; p1++)
putchar (*p1);
putchar (';');
}