Create rule in makefile for just a set of files

走远了吗. 提交于 2019-11-29 01:19:37

You want a static pattern rule:

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).

Of course, 5 minutes later I found the answer myself... :)

What we need is a static pattern rule.

http://www.gnu.org/software/make/manual/make.html#Static-Pattern

So the example would be solved with

$(file_list) : % : bkp/%
    cp $< $@
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!