在makefile中为仅一组文件创建规则 [英] Create rule in makefile for just a set of files
本文介绍了在makefile中为仅一组文件创建规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在编写一个Makefile,并且想对通配符使用通用规则,例如
I am writing a Makefile, and I want to use a generic rule with wildcards, like
%: bkp/%
cp $< $@
但是我希望该规则仅对一些特定文件有效.我想用列表定义一个变量,例如
But I wanted this rule to be valid only for a few specific files. I wanted to define a variable with the list, for example
file_list = foo.c bar.c zzz.c
file_list = foo.c bar.c zzz.c
并配置规则,使其仅对此变量中列出的文件有效.我该怎么办?
and configure the rule so it is only valid for files that are listed in this variable. How do I do that?
推荐答案
您需要静态模式规则:
file_list = foo.c bar.c zzz.c
$(file_list): %: bkp/%
cp $< $@
语法非常类似于隐式模式规则您正在使用.是的,它通常更安全(更可预测).
The syntax is very similar to the implicit pattern rule you were using. And yes, it's generally safer (more predictable).
这篇关于在makefile中为仅一组文件创建规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文