* ldmain.c (set_scripts_dir): Check . and <ld bin dir>/../lib for
ldscripts, as well as <ld bin dir> and SCRIPTDIR.
This commit is contained in:
parent
8549490910
commit
f42084627b
@ -1,5 +1,8 @@
|
|||||||
Mon Jul 12 11:45:48 1993 David J. Mackenzie (djm@thepub.cygnus.com)
|
Mon Jul 12 11:45:48 1993 David J. Mackenzie (djm@thepub.cygnus.com)
|
||||||
|
|
||||||
|
* ldmain.c (set_scripts_dir): Check . and <ld bin dir>/../lib for
|
||||||
|
ldscripts, as well as <ld bin dir> and SCRIPTDIR.
|
||||||
|
|
||||||
* ldlang.c (lang_process): Use sizeof instead of magic constant.
|
* ldlang.c (lang_process): Use sizeof instead of magic constant.
|
||||||
|
|
||||||
* ldmain.c (get_emulation, check_for_scripts_dir,
|
* ldmain.c (get_emulation, check_for_scripts_dir,
|
||||||
|
44
ld/ldmain.c
44
ld/ldmain.c
@ -338,36 +338,52 @@ check_for_scripts_dir (dir)
|
|||||||
sprintf (buf, "%s/ldscripts", dir);
|
sprintf (buf, "%s/ldscripts", dir);
|
||||||
|
|
||||||
res = stat (buf, &s) == 0 && S_ISDIR (s.st_mode);
|
res = stat (buf, &s) == 0 && S_ISDIR (s.st_mode);
|
||||||
|
free (buf);
|
||||||
if (res)
|
if (res)
|
||||||
{
|
ldfile_add_library_path (dir);
|
||||||
buf[dirlen] = '\0';
|
|
||||||
ldfile_add_library_path (buf);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
free (buf);
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set the default directory for finding script files.
|
/* Set the default directory for finding script files.
|
||||||
Libraries will be searched for here too, but that's ok. */
|
Libraries will be searched for here too, but that's ok.
|
||||||
|
We look for the "ldscripts" directory in:
|
||||||
|
|
||||||
|
the curent dir
|
||||||
|
SCRIPTDIR (passed from Makefile)
|
||||||
|
the dir where this program is
|
||||||
|
the dir where this program is/../lib */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_scripts_dir ()
|
set_scripts_dir ()
|
||||||
{
|
{
|
||||||
char *end;
|
char *end, *dir;
|
||||||
|
size_t dirlen;
|
||||||
|
|
||||||
|
if (check_for_scripts_dir ("."))
|
||||||
|
return; /* Newest version, most likely. */
|
||||||
|
|
||||||
if (check_for_scripts_dir (SCRIPTDIR))
|
if (check_for_scripts_dir (SCRIPTDIR))
|
||||||
return; /* Good--we've been installed. */
|
return; /* We've been installed normally. */
|
||||||
|
|
||||||
/* Look for "ldscripts" in the dir where our binary is. */
|
/* Look for "ldscripts" in the dir where our binary is. */
|
||||||
end = strrchr (program_name, '/');
|
end = strrchr (program_name, '/');
|
||||||
if (!end)
|
if (!end)
|
||||||
return; /* Hope for the best. */
|
return;
|
||||||
|
|
||||||
*end = '\0';
|
/* Make a copy of program_name in dir. */
|
||||||
check_for_scripts_dir (program_name);
|
dirlen = end - program_name;
|
||||||
*end = '/';
|
dir = (char *) ldmalloc (dirlen + 8); /* Leave room for later "/../lib". */
|
||||||
|
strncpy (dir, program_name, dirlen);
|
||||||
|
dir[dirlen] = '\0';
|
||||||
|
if (check_for_scripts_dir (dir))
|
||||||
|
return; /* Don't free dir. */
|
||||||
|
|
||||||
|
/* Look for "ldscripts" in <the dir where our binary is>/../lib. */
|
||||||
|
strcpy (dir + dirlen, "/../lib");
|
||||||
|
if (check_for_scripts_dir (dir))
|
||||||
|
return;
|
||||||
|
|
||||||
|
free (dir); /* Well, we tried. */
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user