From 21b8b7cb3cdc89fbaa5431012b5a5c822e16e7af Mon Sep 17 00:00:00 2001 From: Juli Mallett Date: Tue, 21 May 2002 20:24:46 +0000 Subject: [PATCH] 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 . 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 --- usr.bin/make/main.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c index 58b4e5060f25..0c8a2f5053d1 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)