Bug or Feature? make follows symbolic link for current directory

Christian Hujer <[email protected]>
Newsgroups gmane.comp.gnu.make.general
Message-ID <CAFh9tEcgSh+kNWDwXmWN4qsM0Xzh1fFBdysLzJn2+pO-AP0hpw@mail.gmail.com>
Hello folks,

Is this a bug or a feature?

mkdir foo
ln -s foo bar
cd bar
echo -e 'all:\n\tpwd' >Makefile
make

I would have expected the output to be …/bar but it actually is …/foo.
It appears that GNU make follows the symbolic link in case the current
directory is a symbolic link.
I could not find this behavior in the documentation, and find it a bit
unexpected.

I thought that using $(lastword $(subst /, ,$(abspath .))) I would get
bar and $(lastword $(subst /, ,$(realpath .))) I would get foo.
But because make has already followed the symlink for the current
directory, both return foo.

Is this behavior documented?
And does this behavior make sense?

Tested versions of GNU make: 4.3 (Ubuntu) and 4.4.1.

Best regards,
Christian Hujer
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.