同时从两个变量自动生成 makefile 中的规则
我有一些搜索模式不太适合作为结果文件名的一部分。因此,我将正则表达式和相应的文件名部分拆分为两个不同的变量,如下所示。如何自动执行以下操作,以便我不必手动列出所有文件,也不必手动输入运行 grep 的规则?
SEARCH_RE = test a/b/c a.*b
SEARCH_FILE = test abc ab
ALL = result.test result.abc result.ab
all: $(ALL)
result.test:
grep test inputfile > result.test
result.abc:
grep a/b/c inputfile > result.abc
result.ab
grep a.*b inputfile > result.ab
I have some search patterns that fits poorly as part of a file name for the result. I therefore split the regular expression and the corresponding file name part into two different variables like below. How can I automate the following so that I do not have to manually list files for ALL and also do not have to manually enter the rules running grep?
SEARCH_RE = test a/b/c a.*b
SEARCH_FILE = test abc ab
ALL = result.test result.abc result.ab
all: $(ALL)
result.test:
grep test inputfile > result.test
result.abc:
grep a/b/c inputfile > result.abc
result.ab
grep a.*b inputfile > result.ab
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我建议
至于编写规则,我认为您想要的那种查找可以在 Make 中完成,但实际上不应该这样做——这将是一个可怕的混乱。我建议这样做:
I recommend
As for writing the rules, the kind of lookup I think you want can be done in Make, but really shouldn't be-- it would be a horrible kludge. I'd suggest doing it this way:
我不知道如何创建规则,但是
ALL
目标很简单:I don't know how to create the rules, but the
ALL
target is easy enough: