如何调用 shell 来创建一个新环境,以便在另一个 make 中运行一个 make?
我希望在我的 GNUmakefile 中有一个调用新 shell 的目标规则,然后用新 shell 的干净状态调用新的 make。
执行此操作的语法是什么?
我尝试了这个,但它不起作用:
.PHONY: setup
setup:
shell cd myDir; make; cd ..
它会无限重复以下错误:
make[1]: Entering directory `/disk4/home/user/parent'
shell cd myDir; make; cd ..
/bin/sh: shell: command not found
make[1]: Entering directory `/disk4/home/user/parent'
shell cd myDir; make; cd ..
/bin/sh: shell: command not found
[...]
I would like in my GNUmakefile to have a target rule that invokes a new shell and then with the clean slate of the new shell invokes a new make.
What is the syntax to do this?
I tried this but it didn't work:
.PHONY: setup
setup:
shell cd myDir; make; cd ..
It gets infinite repeat of the following error:
make[1]: Entering directory `/disk4/home/user/parent'
shell cd myDir; make; cd ..
/bin/sh: shell: command not found
make[1]: Entering directory `/disk4/home/user/parent'
shell cd myDir; make; cd ..
/bin/sh: shell: command not found
[...]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
括号调用一个新的子 shell,它有自己的“当前目录”。
The parens invoke a new subshell, with its own "current directory".
括号不是必需的。无论如何,配方中的每一行都会在其自己的 shell 中调用。你的配方似乎有一个多余的shell字符串,你的shell尝试将其作为命令执行(/bin/sh(你的shell,不是 make)抱怨
shell :未找到命令
)。另外,在这种情况下,make 的
-C
参数也很方便。另外,当从 shell 调用 make 时,请使用
${MAKE}
宏。The parens are not necessary. Every line in a recipe is invoked in its own shell anyway. Your recipe seems to have a superfluous shell string, which your shell tries to execute as a command (/bin/sh (your shell, not make) complains
shell: command not found
).Also, make's
-C
parameter is handy in this case.Also, when calling make from the shell, use the
${MAKE}
macro.这是有效的:
Here is what works: