summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorjmallett <jmallett@FreeBSD.org>2002-05-21 20:24:46 +0000
committerjmallett <jmallett@FreeBSD.org>2002-05-21 20:24:46 +0000
commit4c8f46cf75901f6eeca741030d0075e8789c0566 (patch)
treeaf86aef02d837e7b0ca45b69c477816ff6dfc399 /usr.bin
parent1a9e2f75a7848f318007acaac78c5571e3e83033 (diff)
downloadFreeBSD-src-4c8f46cf75901f6eeca741030d0075e8789c0566.zip
FreeBSD-src-4c8f46cf75901f6eeca741030d0075e8789c0566.tar.gz
Make ReadMakefile() operate using the realpath(3) name for the file handed to
it, which means that relative paths will be expanded to absolute paths, and filenames without a path will end up with their absolute path included as well. This aids tremendously in debugging a build using our make(1) with multiple Makefile's, such as when there is a syntax error in a file in a sub-directory as per <bsd.subdir.mk>. Normally we'd end up with just "Makefile" known about the Makefile in question, which means that an error would be useless for someone trying to debug their build system, now we end up with a complete real pathname for the Makefile. So mostly this is useful in a debugging context, but possibly others too (I haven't thought of them yet, but they probably are more useful if you make Dir_FindFile use realpath(3), but that's another story). Reviewed by: -current MFC after: 2 weeks
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/make/main.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c
index 58b4e50..0c8a2f5 100644
--- a/usr.bin/make/main.c
+++ b/usr.bin/make/main.c
@@ -919,12 +919,16 @@ ReadMakefile(p, q)
/* if we've chdir'd, rebuild the path name */
if (curdir != objdir && *fname != '/') {
(void)snprintf(path, MAXPATHLEN, "%s/%s", curdir, fname);
- if ((stream = fopen(path, "r")) != NULL) {
+ if (realpath(path, path) != NULL &&
+ (stream = fopen(path, "r")) != NULL) {
fname = path;
goto found;
}
- } else if ((stream = fopen(fname, "r")) != NULL)
- goto found;
+ } else if (realpath(fname, path) != NULL) {
+ fname = path;
+ if ((stream = fopen(fname, "r")) != NULL)
+ goto found;
+ }
/* look in -I and system include directories. */
name = Dir_FindFile(fname, parseIncPath);
if (!name)
OpenPOWER on IntegriCloud