Makefile 使用目标调用其他 makefile,给出错误的目标
我有一个目标为 clean 的 makefile:
clean:
$(MAKE) -f <other makefile location> clean
当我在此 makefile 中调用 make clean 时,它告诉我在另一个 makefile 中没有规则“clean-linux”。 具体来说,这是输出。
make -f /root/ovaldi-5.5.25-src/project/linux/Makefile clean
make[1]: Entering directory '/root/ovaldi-5.5.25-src'
make[2]: Entering directory '/root/ovaldi-5.5.25-src'
make[2]: *** No rule to make target 'clean-linux'. Stop.
make[2]: Leaving directory '/root/ovaldi-5.5.25-src'
make[1]: Leaving directory '/root/ovaldi-5.5.25-src'
为什么它给它 clean-linux 目标而不是像我指定的那样干净?
I have a makefile with a target clean:
clean:
$(MAKE) -f <other makefile location> clean
When I call make clean in this makefile, it tells me that in the other makefile there is no rule 'clean-linux'. Specifically here is the output.
make -f /root/ovaldi-5.5.25-src/project/linux/Makefile clean
make[1]: Entering directory '/root/ovaldi-5.5.25-src'
make[2]: Entering directory '/root/ovaldi-5.5.25-src'
make[2]: *** No rule to make target 'clean-linux'. Stop.
make[2]: Leaving directory '/root/ovaldi-5.5.25-src'
make[1]: Leaving directory '/root/ovaldi-5.5.25-src'
Why is it giving it the clean-linux target and not just clean like I specified?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当您 make(或 $(MAKE))时,默认情况下您使用那里的任何 makefile。 这就是我认为正在发生的事情。
解决方案:重写你的第二个 makefile(具有 clean-linux 的那个),以便 clean-linux 成为 clean 的先决条件(如果/当你在 Linux 系统上时)。 这样它就不会运行 make[2]。
When you make (or $(MAKE)), by default you use whatever makefile is there. So here's what I think is happening.
The solution: rewrite your second makefile (the one that has clean-linux) so that clean-linux becomes a prerequisite of clean (if/when you're on a linux system). That way it won't run make[2].
只是猜测,但也许第二个 makefile 中的“clean”目标调用“clean-linux”?
你能发布第二个makefile的干净目标吗?
编辑:
根据您发布的 clean 目标,您似乎只是错误地调用了 clean-linux 目标。
Beta 已在其答案中发布了处理您的问题的正确方法,因此我将+1。
Just a guess but maybe the 'clean' target in the second makefile calls 'clean-linux'?
Can you post the clean target of the second makefile?
Edit:
In light of your posted clean target it seems you're just calling the clean-linux target incorrectly.
Beta has posted the correct way of dealing with your problem in their answer so I'm going to +1 that.