Formerly remake.c.~39~

This commit is contained in:
Roland McGrath 1992-12-09 20:34:36 +00:00
parent 0a7da8a929
commit 1faf31158c

View file

@ -786,10 +786,12 @@ remake_file (file)
} }
/* Return the mtime of a file, given a `struct file'. /* Return the mtime of a file, given a `struct file'.
Caches the time in the struct file to avoid excess stat calls. If the file Caches the time in the struct file to avoid excess stat calls.
is not found, and SEARCH is nonzero, VPATH searching and replacement is
done. If that fails, a library (-lLIBNAME) is tried but the library's If the file is not found, and SEARCH is nonzero, VPATH searching and
actual name (/lib/libLIBNAME.a, etc.) is not substituted into FILE. */ replacement is done. If that fails, a library (-lLIBNAME) is tried and
the library's actual name (/lib/libLIBNAME.a, etc.) is substituted into
FILE. */
time_t time_t
f_mtime (file, search) f_mtime (file, search)
@ -916,8 +918,8 @@ library_search (lib)
{ {
static char *dirs[] = static char *dirs[] =
{ {
"/usr/lib",
"/lib", "/lib",
"/usr/lib",
LIBDIR, /* Defined by configuration. */ LIBDIR, /* Defined by configuration. */
0 0
}; };
@ -926,6 +928,28 @@ library_search (lib)
char *buf = xmalloc (sizeof (LIBDIR) + 8 + strlen (libname) + 4 + 2 + 1); char *buf = xmalloc (sizeof (LIBDIR) + 8 + strlen (libname) + 4 + 2 + 1);
char **dp; char **dp;
sprintf (buf, "lib%s.a", libname);
/* Look first for `libNAME.a' in the current directory. */
if (name_mtime (libname) != (time_t) -1)
{
*lib = buf;
return 1;
}
/* Now try VPATH search on that. */
libname = buf;
if (vpath_search (&libname))
{
free (buf);
*lib = libname;
return 1;
}
/* Now try the standard set of directories. */
for (dp = dirs; *dp != 0; ++dp) for (dp = dirs; *dp != 0; ++dp)
{ {
sprintf (buf, "%s/lib%s.a", *dp, libname); sprintf (buf, "%s/lib%s.a", *dp, libname);
@ -936,15 +960,6 @@ library_search (lib)
} }
} }
sprintf (buf, "lib%s.a", libname);
libname = buf;
if (vpath_search (&libname))
{
free (buf);
*lib = libname;
return 1;
}
free (buf); free (buf);
return 0; return 0;
} }