Makefile and symbolic links

hanno picture hanno · Aug 11, 2011 · Viewed 16.8k times · Source

I'm experiencing a strange problem with a makefile. I simply want to set a symbolic link in the makefile but get an error message on one machine (Linux 2.6.18-238.12.1.el5)

make: execvp: ln: Too many levels of symbolic links

It works perfectly fine on my MacBook. It also works fine if I execute the same command in the shell. What could go wrong? Are there any environment variables important for ln?

Answer

Nemo picture Nemo · Aug 11, 2011

The execvp in the error message is the key, I think. I believe it is saying there are too many levels of symbolic links while trying to locate the ln command itself.

Example:

all:
    ln -nsf /tmp/foo /tmp/foo
    /tmp/foo/ln x y

Running "make" with this Makefile errors out with:

make: execvp: /tmp/foo/ln: Too many levels of symbolic links

So, how is your Makefile invoking ln, exactly? What is in your PATH etc.?

[update]

I bet the Makefile is messing up your PATH. Here is a Makefile that reproduces your exact error message:

PATH=/tmp/foo

all:
    /bin/ln -nsf /tmp/foo /tmp/foo
    ln x y