Makefile 中规则的参数
我需要创建一个 Makefile,它应该有一个 run
规则。然而,运行需要一些参数。
有谁知道在 Makefile 中运行规则时如何传递参数?我希望能够通过输入 make run foo bar
来运行带有参数的 run
规则。
我尝试了这个,但它不起作用:
run:
make compile
./scripts/runTrips $1 $2 $PLACES $OUT $VERS
我想要提供的参数是第一个和第二个。
I need to make a Makefile, and it should have a run
rule. However, the run requires some parameters.
Does anyone have any idea how I can pass arguments in when running a rule in a Makefile? I want to be able to run the run
rule with arguments by typing make run foo bar
.
I tried this, but it didn’t work:
run:
make compile
./scripts/runTrips $1 $2 $PLACES $OUT $VERS
The parameters I want supplied are the first and the second.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将参数传递给 make 命令时,请像引用其他内部 make 变量一样引用它们。
如果您的 makefile 如下所示:
您可以使用以下语法调用它:
并且 make 应调用如下脚本:
When passing parameters to a make command, reference them like you would other internal make variables.
If your makefile looks like:
You can call it with the following syntax:
and make should call the script like:
Make 本身不提供像脚本那样的传递参数。通常 make 按以下方式使用:配置项目而不是运行简单的“make”。可以通过运行 shell 脚本“configure”来完成配置。您可以向该脚本传递参数。例如:
configure脚本必须解析参数并将其写入config.mk。 config.mk 必须包含以下内容:
您的 Makefile 必须包含 config.mk:
在“配置”脚本中,您还可以检查参数的正确性并进行其他检查和计算。
Make itself doesn't provide passing arguments like for scripts. Usually make is used in the following way: you configure project than run just simple 'make'. Configuring can be done by running shell script 'configure'. This script is the one that you can pass parameters to. For example:
configure script must parse parameters and write them out to config.mk. config.mk must contain the following:
Your Makefile must include config.mk:
In your 'configure' script you can also check parameters for correctness and make other checks and calculations.