Formerly remake.c.~34~

This commit is contained in:
Roland McGrath 1992-08-27 23:29:25 +00:00
parent a301f9327a
commit 5aa595c99b

View file

@ -37,7 +37,8 @@ static unsigned int files_remade = 0;
static int update_file (), update_file_1 (), check_dep (), touch_file (); static int update_file (), update_file_1 (), check_dep (), touch_file ();
static void remake_file (); static void remake_file ();
static time_t name_mtime (), library_file_mtime (); static time_t name_mtime ();
static int library_search ();
extern time_t f_mtime (); extern time_t f_mtime ();
/* Remake all the goals in the `struct dep' chain GOALS. Return -1 if nothing /* Remake all the goals in the `struct dep' chain GOALS. Return -1 if nothing
@ -858,26 +859,24 @@ 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)
/* Last resort, is it a library (-lxxx)? */
|| (name[0] == '-' && name[1] == 'l'
&& library_search (&name)))
{ {
rename_file (file, name); rename_file (file, name);
check_renamed (file); check_renamed (file);
return file_mtime (file); return file_mtime (file);
} }
else
/* Last resort, is it a library (-lxxx)? */
if (name[0] == '-' && name[1] == 'l')
mtime = library_file_mtime (&name[2]);
} }
} }
/* Store the mtime into all the entries for this file. */ /* Store the mtime into all the entries for this file. */
do
while (file != 0)
{ {
file->last_mtime = mtime; file->last_mtime = mtime;
file = file->prev; file = file->prev;
} } while (file != 0);
return mtime; return mtime;
} }
@ -898,40 +897,45 @@ name_mtime (name)
} }
/* Return the mtime of a library file specified as -lLIBNAME, /* Search for a library file specified as -lLIBNAME, searching for a
searching for a suitable library file in the system library directories suitable library file in the system library directories and the VPATH
and the VPATH directories. */ directories. */
static time_t static int
library_file_mtime (lib) library_search (lib)
char *lib; char **lib;
{ {
time_t mtime; static char *dirs[] =
char *name; {
"/usr/lib",
"/lib",
LIBDIR, /* Defined by configuration. */
0
};
name = concat ("/usr/lib/lib", lib, ".a"); char *libname = &(*lib)[2];
mtime = name_mtime (name); char *buf = xmalloc (sizeof (LIBDIR) + 8 + strlen (libname) + 4 + 2 + 1);
if (mtime == (time_t) -1) char **dp;
mtime = name_mtime (name + 4);
if (mtime == (time_t) -1) for (dp = dirs; *dp != 0; ++dp)
{ {
char *local = concat ("/usr/local/lib/lib", lib, ".a"); sprintf (buf, "%s/lib%s.a", *dp, libname);
mtime = name_mtime (local); if (name_mtime (buf) != (time_t) -1)
free (local);
}
if (mtime == (time_t) -1)
mtime = name_mtime (name + 9);
if (mtime == (time_t) -1)
{ {
char *newname = name + 9; *lib = buf;
if (vpath_search (&newname)) return 1;
{
mtime = name_mtime (newname);
free (newname);
} }
} }
free (name); sprintf (buf, "lib%s.a", libname);
libname = buf;
if (vpath_search (&libname))
{
free (buf);
*lib = libname;
return 1;
}
return mtime; free (buf);
return 0;
} }