summaryrefslogtreecommitdiff
path: root/usr.bin/make
diff options
context:
space:
mode:
authorjmc <jmc@NetBSD.org>2003-12-18 22:36:18 +0000
committerjmc <jmc@NetBSD.org>2003-12-18 22:36:18 +0000
commitbe1cdb8652c7bfd6fed557c96becd2bfba4fc9e5 (patch)
treeaef7da72983866cb81a3b09457a0e1d7b72d2328 /usr.bin/make
parent52f06d7766521d4819901d3ad5f1ed4ef5ce1a9b (diff)
When looking for a makefile and curdir != objdir (i.e. working inside of an
objdir) try opening the file from curdir and if that fails try from objdir. This way .depend files get picked up via their full path names rather than just .depend so vars like PARSEDIR, PARSEFILE are then set correctly. This fixes PR#13289 reporting incorrect pathnames for .depends with errors in them
Diffstat (limited to 'usr.bin/make')
-rw-r--r--usr.bin/make/main.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c
index 8e7c7d74160..fba52960b8e 100644
--- a/usr.bin/make/main.c
+++ b/usr.bin/make/main.c
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.94 2003/12/07 20:30:28 dsl Exp $ */
+/* $NetBSD: main.c,v 1.95 2003/12/18 22:36:18 jmc Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
*/
#ifdef MAKE_BOOTSTRAP
-static char rcsid[] = "$NetBSD: main.c,v 1.94 2003/12/07 20:30:28 dsl Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.95 2003/12/18 22:36:18 jmc Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
@@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\n\
#if 0
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: main.c,v 1.94 2003/12/07 20:30:28 dsl Exp $");
+__RCSID("$NetBSD: main.c,v 1.95 2003/12/18 22:36:18 jmc Exp $");
#endif
#endif /* not lint */
#endif
@@ -1031,6 +1031,16 @@ ReadMakefile(ClientData p, ClientData q)
fname = path;
goto found;
}
+
+ /* If curdir failed, try objdir (ala .depend) */
+ plen = strlen(objdir) + strlen(fname) + 2;
+ if (len < plen)
+ path = erealloc(path, len = 2 * plen);
+ (void)snprintf(path, len, "%s/%s", objdir, fname);
+ if ((stream = fopen(path, "r")) != NULL) {
+ fname = path;
+ goto found;
+ }
} else if ((stream = fopen(fname, "r")) != NULL)
goto found;
/* look in -I and system include directories. */