On Fri, 2023-07-07 at 22:22 +0530, Christian Hujer wrote: > It appears that GNU make follows the symbolic link in case the > current directory is a symbolic link.
In addition to Kaz's reply, be careful with terms. There's no such thing as "directory [that] is a symbolic link". Using a phrase like that will only confuse you. A directory is a directory. A symbolic link is just a pointer in the filesystem (really a text string with a different path in it that the kernel knows how to handle). As Kaz says, once you set your working directory to a given location, there's no way to know how you got there. Maybe you got there through the real path, or maybe you got there through any number of alternative pathways constructed by any number of symbolic links. Your _SHELL_ may know how you got there, because your shell is handling your "cd" operations and so it can keep track of this. That's the PWD env var that Kaz discusses. But other programs can't know this. If you write a little C program you can see this: #include <stdio.h> #include <unistd.h> int main() { char buf[4096]; getcwd(buf, sizeof(buf)); printf("cwd: %s\n", buf); return 0; } then compile and run it after changing directories in various ways.