将参数传递给"make run"; [英] Passing arguments to "make run"

查看:69
本文介绍了将参数传递给"make run";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Makefile.

I use Makefiles.

我有一个名为run的目标,该目标运行构建目标.简化后,它看起来如下所示:

I have a target called run which runs the build target. Simplified, it looks like the following:

prog: ....
  ...

run: prog
  ./prog

坐下来.我知道这很巧妙,但无需站立鼓掌.

Sit back down. I know this is ingenious, but no need for a standing ovation.

现在,我的问题是-有什么方法可以传递参数?这样

Now, my question is -- is there any way to pass arguments? So that

make run asdf --> ./prog asdf
make run the dog kicked the cat --> ./prog the dog kicked the cat

谢谢!

推荐答案

我不知道完全按照自己的意愿做事的方法,但是可能的解决方法是:

I don't know a way to do what you want exactly, but a workaround might be:

run: ./prog
    ./prog $(ARGS)

然后:

make ARGS="asdf" run
# or
make run ARGS="asdf"

这篇关于将参数传递给"make run";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆