加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Makefile:can’罐头食谱’有参数吗?

发布时间:2020-12-16 04:53:26 所属栏目:百科 来源:网络整理
导读:我的问题涉及GNU的制作. 如果你有一系列命令可用作多个目标的配方,那么canned recipe就派上用场了.我可能看起来像这样: define run-foo# Here comes a# sequence of commands that are# executed line by lineendef 现在您可以像这样使用罐装配方: file1:
我的问题涉及GNU的制作.

如果你有一系列命令可用作多个目标的配方,那么canned recipe就派上用场了.我可能看起来像这样:

define run-foo
# Here comes a
# sequence of commands that are
# executed line by line
endef

现在您可以像这样使用罐装配方:

file1: input1:
    $(run-foo)

$(pattern) : sub/% : %.inp
    $(run-foo)

等等.我想知道是否可以定义带参数的罐装食谱(或类似的东西),以便我可以像这样执行它们:

file2: input2
    $(run-foo) specific-parameter2 "additional"

file3: input3
    $(run-foo) another-parameter3 "text"

这可能吗?任何提示欢迎:)

解决方法

你这样做:

>在定义宏中使用参数$1,$2 …等
>通过$调用宏(调用…)

例如:

define recipe
echo $1
endef

all: t1 t2

t1:
    $(call recipe,"One")

t2:
    $(call recipe,"Two")

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读