summaryrefslogtreecommitdiff
path: root/remake.c
diff options
context:
space:
mode:
Diffstat (limited to 'remake.c')
-rw-r--r--remake.c41
1 files changed, 28 insertions, 13 deletions
diff --git a/remake.c b/remake.c
index 17a6037..d7716c0 100644
--- a/remake.c
+++ b/remake.c
@@ -786,10 +786,12 @@ remake_file (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
- 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
- actual name (/lib/libLIBNAME.a, etc.) is not substituted into FILE. */
+ Caches the time in the struct file to avoid excess stat calls.
+
+ If the file is not found, and SEARCH is nonzero, VPATH searching and
+ 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
f_mtime (file, search)
@@ -916,8 +918,8 @@ library_search (lib)
{
static char *dirs[] =
{
- "/usr/lib",
"/lib",
+ "/usr/lib",
LIBDIR, /* Defined by configuration. */
0
};
@@ -926,17 +928,18 @@ library_search (lib)
char *buf = xmalloc (sizeof (LIBDIR) + 8 + strlen (libname) + 4 + 2 + 1);
char **dp;
- for (dp = dirs; *dp != 0; ++dp)
+ sprintf (buf, "lib%s.a", libname);
+
+ /* Look first for `libNAME.a' in the current directory. */
+
+ if (name_mtime (libname) != (time_t) -1)
{
- sprintf (buf, "%s/lib%s.a", *dp, libname);
- if (name_mtime (buf) != (time_t) -1)
- {
- *lib = buf;
- return 1;
- }
+ *lib = buf;
+ return 1;
}
- sprintf (buf, "lib%s.a", libname);
+ /* Now try VPATH search on that. */
+
libname = buf;
if (vpath_search (&libname))
{
@@ -945,6 +948,18 @@ library_search (lib)
return 1;
}
+ /* Now try the standard set of directories. */
+
+ for (dp = dirs; *dp != 0; ++dp)
+ {
+ sprintf (buf, "%s/lib%s.a", *dp, libname);
+ if (name_mtime (buf) != (time_t) -1)
+ {
+ *lib = buf;
+ return 1;
+ }
+ }
+
free (buf);
return 0;
}