Formerly remake.c.~47~

This commit is contained in:
Roland McGrath 1993-02-08 22:56:09 +00:00
parent 078cc29e60
commit ded09420ad

View file

@ -840,7 +840,7 @@ f_mtime (file, search)
register struct file *file; register struct file *file;
int search; int search;
{ {
register time_t mtime; time_t mtime;
/* File's mtime is not known; must get it from the system. */ /* File's mtime is not known; must get it from the system. */
@ -912,11 +912,15 @@ f_mtime (file, search)
{ {
/* If name_mtime failed, search VPATH. */ /* If name_mtime failed, search VPATH. */
char *name = file->name; char *name = file->name;
if (vpath_search (&name) if (vpath_search (&name, &mtime)
/* Last resort, is it a library (-lxxx)? */ /* Last resort, is it a library (-lxxx)? */
|| (name[0] == '-' && name[1] == 'l' || (name[0] == '-' && name[1] == 'l'
&& library_search (&name))) && library_search (&name, &mtime)))
{ {
if (mtime != 0)
/* vpath_search and library_search store zero in MTIME
if they didn't need to do a stat call for their work. */
file->last_mtime = mtime;
rename_file (file, name); rename_file (file, name);
check_renamed (file); check_renamed (file);
return file_mtime (file); return file_mtime (file);
@ -955,8 +959,9 @@ name_mtime (name)
directories. */ directories. */
static int static int
library_search (lib) library_search (lib, mtime_ptr)
char **lib; char **lib;
time_t *mtime_ptr;
{ {
static char *dirs[] = static char *dirs[] =
{ {
@ -967,6 +972,7 @@ library_search (lib)
}; };
char *libname = &(*lib)[2]; /* Name without the `-l'. */ char *libname = &(*lib)[2]; /* Name without the `-l'. */
time_t mtime;
/* Buffer to construct possible names in. */ /* Buffer to construct possible names in. */
char *buf = xmalloc (sizeof (LIBDIR) + 8 + strlen (libname) + 4 + 2 + 1); char *buf = xmalloc (sizeof (LIBDIR) + 8 + strlen (libname) + 4 + 2 + 1);
@ -975,16 +981,19 @@ library_search (lib)
/* Look first for `libNAME.a' in the current directory. */ /* Look first for `libNAME.a' in the current directory. */
sprintf (buf, "lib%s.a", libname); sprintf (buf, "lib%s.a", libname);
if (name_mtime (buf) != (time_t) -1) mtime = name_mtime (buf);
if (mtime != (time_t) -1)
{ {
*lib = buf; *lib = buf;
if (mtime_ptr != 0)
*mtime_ptr = mtime;
return 1; return 1;
} }
/* Now try VPATH search on that. */ /* Now try VPATH search on that. */
file = buf; file = buf;
if (vpath_search (&file)) if (vpath_search (&file, mtime_ptr))
{ {
free (buf); free (buf);
*lib = file; *lib = file;
@ -996,9 +1005,12 @@ library_search (lib)
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);
if (name_mtime (buf) != (time_t) -1) mtime = name_mtime (buf);
if (mtime != (time_t) -1)
{ {
*lib = buf; *lib = buf;
if (mtime_ptr != 0)
*mtime_ptr = mtime;
return 1; return 1;
} }
} }