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)