Makefile和符号链接(Makefile and symbolic links)

我遇到了一个makefile的奇怪问题。 我只是想在makefile中设置一个符号链接,但在一台机器上得到一条错误信息(Linux 2.6.18-238.12.1.el5)

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

它在我的MacBook上完美运行。 如果我在shell中执行相同的命令,它也可以正常工作。 怎么可能出错? 是否有任何环境变量对ln很重要?

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?

最满意答案

我认为错误消息中的execvp是关键。 我相信在尝试找到ln命令本身时 ,有太多级别的符号链接。

例:

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

使用此Makefile错误运行“make”:

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

那么,你的Makefile如何调用ln呢? 你的PATH等是什么?

[更新]

我敢打赌,Makefile会弄乱你的PATH。 这是一个Makefile,它可以重现您的确切错误消息:

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

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

更多推荐