Makefile中规则的参数 [英] Parameter for rule in Makefile
问题描述
我需要制作一个Makefile,它应该具有run
规则.但是,运行需要一些参数.
I need to make a Makefile, and it should have a run
rule. However, the run requires some parameters.
有人知道在Makefile中运行规则时如何传递参数吗?我希望能够通过键入make run foo bar
来运行带有参数的run
规则.
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
.
我尝试过,但是没用:
run:
make compile
./scripts/runTrips $1 $2 $PLACES $OUT $VERS
我要提供的参数是第一个和第二个.
The parameters I want supplied are the first and the second.
推荐答案
将参数传递给make命令时,请像对待其他内部make变量一样引用它们.
When passing parameters to a make command, reference them like you would other internal make variables.
如果您的makefile看起来像这样:
If your makefile looks like:
run:
script $(param1) $(param2)
您可以使用以下语法来调用它:
You can call it with the following syntax:
$> make run param1=20 param2=30
,make应该像这样调用脚本:
and make should call the script like:
script 20 30
这篇关于Makefile中规则的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!