macos 没有规则可以创建目标`/Makefile',需要`Makefile'
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4763381/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
No rule to make target `/Makefile', needed by `Makefile'
提问by Dana
I'm trying to 'make' using a pretty simple makefile. My makefile is named 'Makefile' so I'm simply using the command 'make'.
我正在尝试使用一个非常简单的 makefile 来“制作”。我的 makefile 被命名为“Makefile”,所以我只是使用命令“make”。
I get this strange error:make: *** No rule to make target `/Makefile', needed by `Makefile'. Stop.
我收到这个奇怪的错误:make: *** No rule to make target `/Makefile', needed by `Makefile'. Stop.
If, however, I use
make -f "full-path-to-makefile"
it actually does run (with odd consequences...). I should say that I'm running all this from the directory where the Makefile lies, of course.
但是,如果我使用
make -f "full-path-to-makefile"
它确实运行(具有奇怪的后果......)。当然,我应该说我是从 Makefile 所在的目录运行所有这些的。
I'm working on Mac OSX, using tcsh.
我正在使用 tcsh 在 Mac OSX 上工作。
Edit:
编辑:
I'm working in the LLVM framework, trying to compile a pass function and this is the associated makefile:
我在 LLVM 框架中工作,尝试编译传递函数,这是关联的 makefile:
LEVEL = ../../../ LIBRARYNAME = FunctionName LOADABLE_MODULE = 1 include $(LEVEL)/Makefile.common
Any ideas will be appreciated :)
任何想法将不胜感激:)
采纳答案by Dana
I found the answer, sort of:
我找到了答案,有点:
The problem was with the installation process of LLVM. It seems that if you do the installation in one order instead of another it can lead to this error. It doesn't make any sense to me, but after I installed it properly everything compiles great (same code, same Makefile, same make program).
问题出在 LLVM 的安装过程中。似乎如果您以一种顺序而不是另一种顺序进行安装,则可能会导致此错误。这对我来说没有任何意义,但是在我正确安装它之后,一切都编译得很好(相同的代码,相同的 Makefile,相同的 make 程序)。
I don't really know why this happened, but I know how to fix it :)
我真的不知道为什么会发生这种情况,但我知道如何解决它:)
What you want to do is ./configure again then make from the base directory(contrary to what is stated in the instructions on the web-site). That worked for me.
您想要做的是 ./configure 再次从基本目录制作(与网站上的说明中所述相反)。那对我有用。
BTW - I got the same results running on Ubuntu (with the same fix).
顺便说一句 - 我在 Ubuntu 上运行得到了相同的结果(使用相同的修复)。
回答by Nate
I had the same problem trying to write a new pass for LLVM i followed these instructions trying to make a HelloB (as Hello already exsited) http://llvm.org/docs/WritingAnLLVMPass.html#quickstart
我在尝试为 LLVM 编写新通行证时遇到了同样的问题,我按照这些说明尝试制作 HelloB(因为 Hello 已经存在)http://llvm.org/docs/WritingAnLLVMPass.html#quickstart
What i has to do was do a ./configure again then make from the base directory.
我必须做的是再次执行 ./configure 然后从基本目录制作。
回答by Ben
Just to add some information here (since this is the first hit that comes up on Google when looking for the error) - I had the same problem which suddenly popped up on a (previously working) LLVM setup on OSX, and traced it back to the behavior of the realpath command in make.
只是在这里添加一些信息(因为这是在查找错误时出现在 Google 上的第一次点击)-我遇到了同样的问题,该问题突然出现在 OSX 上的(以前工作的)LLVM 设置中,并将其追溯到make 中 realpath 命令的行为。
Specifically, what was happening was that I had a directory called "LLVM/llvm-2.9-build", but for some reason the attempt to resolve PROJECT_OBJ_ROOT at the top of Makefile.config would decide that this directory was in fact called "llvm/llvm-2.9-build". Since OSX is case-insensitive by default, this doesn't cause an immediate problem, except that subsequently LLVM_SRC_ROOT would be set to "LLVM/llvm-2.9-build". This then meant that the creation of PROJ_SRC_DIR using patsubst to replace the object directory would result in a non-existent path (as the unmatched case means that no pattern replace occurs), which in turn would get resolved to / by realpath.
具体来说,发生的事情是我有一个名为“LLVM/llvm-2.9-build”的目录,但由于某种原因,在 Makefile.config 顶部解析 PROJECT_OBJ_ROOT 的尝试会决定这个目录实际上被称为“llvm/ llvm-2.9-build”。由于默认情况下 OSX 不区分大小写,因此这不会立即导致问题,除非随后 LLVM_SRC_ROOT 将设置为“LLVM/llvm-2.9-build”。这意味着使用 patsubst 创建 PROJ_SRC_DIR 来替换对象目录将导致不存在的路径(因为不匹配的情况意味着没有模式替换发生),这反过来会被 realpath 解析为 /。
With PROJ_SRC_DIR set to /, this results in the makefile copy rule in Makefile.rules deciding that the source makefile is at $(PROJ_SRC_DIR)/Makefile (ie /Makefile), and the error message described.
PROJ_SRC_DIR 设置为 /,这导致 Makefile.rules 中的 makefile 复制规则决定源 makefile 位于 $(PROJ_SRC_DIR)/Makefile(即 /Makefile),并描述错误消息。
It seems that it is only the built-in implementation of realpath in Make (GNU Make 3.81 in my case) that has this behaviour, as forcibly using the macro version of realpath from the top of Makefile.config fixes the problem. However, this isn't a good long-term fix, as you'd have to manually patch every one of the LLVM makefiles.
似乎只有 Make 中 realpath 的内置实现(在我的情况下为 GNU Make 3.81)具有这种行为,因为强行使用 Makefile.config 顶部的 realpath 宏版本解决了这个问题。但是,这不是一个好的长期修复,因为您必须手动修补每个 LLVM 生成文件。
In the end, I couldn't see where realpath would be getting the lower-case "llvm" from, but figured it was probably an artifact somehow of some caching of the name from a point in time when I'd referenced the directory using its lower-case name. Hence I tried going to that directory and mv-ing it to a completely different name, and then back to "LLVM" before going in and building again, and that seems to have solved the problem.
最后,我看不到 realpath 将从哪里获得小写的“llvm”,但我认为它可能是我引用目录时某个时间点以某种方式缓存名称的工件它的小写名称。因此,我尝试转到该目录并将其转换为完全不同的名称,然后在进入并再次构建之前返回“LLVM”,这似乎解决了问题。
I hope that's of some use to anyone else who comes across this particular weirdness!
我希望这对遇到这种特殊奇怪现象的任何其他人都有用!
回答by Beta
I'll go out on a limb: you have an extra slash. Try omitting the final slash in $(LEVEL).
我会毫不犹豫地出去:你有一个额外的斜线。尝试省略 $(LEVEL) 中的最后一个斜杠。
回答by Jonathan Leffler
Since your include line reads:
由于您的包含行显示:
include $(LEVEL)/Makefile.common
it is puzzling that you are not getting an error about /Makefile.common
. If you were, then I'd suggest that maybe you have a trailing blank after the definition of LEVEL.
令人费解的是,您没有收到关于/Makefile.common
. 如果是,那么我建议您在 LEVEL 的定义之后有一个尾随空格。
Could there be a line in Makefile.common that itself includes $(SOMEMACRO)/Makefile and you have not set the value of SOMEMACRO?
Makefile.common 中是否有一行包含 $(SOMEMACRO)/Makefile 而您还没有设置 SOMEMACRO 的值?
回答by Lars
It's not a complete answer, but what you are seeing is gmake not finding the Makefile it is told to include, and thus it is trying to remake it and failing because it can't find a recipe for it either.
这不是一个完整的答案,但您所看到的是 gmake 没有找到它被告知要包含的 Makefile,因此它试图重新制作它并失败,因为它也找不到它的配方。
However, the Makefile snippet you posted does not produce the error message you are seeing, so I think the problem is inside the Makefile.common file. Look for include statements which reference a $(some variable expansion)/Makefile and work backwards from there. You can also try to run gmake with the -d option and follow the processing based on the output.
但是,您发布的 Makefile 片段不会产生您看到的错误消息,因此我认为问题出在 Makefile.common 文件中。查找引用 $(some variable expand)/Makefile 的 include 语句并从那里向后工作。您也可以尝试使用 -d 选项运行 gmake 并根据输出进行处理。
回答by mindon
here's my fixes for this issue: (https://github.com/rust-lang/rust/issues/24887#issuecomment-99391849)
这是我对此问题的修复:(https://github.com/rust-lang/rust/issues/24887#issuecomment-99391849)
update src/llvm/Makefile.config.inbefore running ./configure
在运行 ./configure 之前更新src/llvm/Makefile.config.in
or update x86_64-apple-darwin/llvm/Makefile.configbefore make
或在 make 之前更新x86_64-apple-darwin/llvm/Makefile.config
line 59:
第 59 行:
PROJ_SRC_DIR := $(LLVM_SRC_ROOT)$(patsubst $(PROJ_OBJ_ROOT)%,%,$(PROJ_OBJ_DIR))
update to
更新到
PROJ_SRC_DIR := $(patsubst $(PROJ_OBJ_ROOT)%,$(LLVM_SRC_ROOT)%,$(PROJ_OBJ_DIR))
line 86:
第 86 行:
PROJ_SRC_DIR := $(call realpath, $(PROJ_SRC_ROOT)/$(patsubst $(PROJ_OBJ_ROOT)%,%,$(PROJ_OBJ_DIR)))
update to
更新到
PROJ_SRC_DIR := $(call realpath, $(patsubst $(PROJ_OBJ_ROOT)%,$(PROJ_SRC_ROOT)%,$(PROJ_OBJ_DIR)))