Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Makefile 使用make复制具有不同文件名的文件_Makefile - Fatal编程技术网

Makefile 使用make复制具有不同文件名的文件

Makefile 使用make复制具有不同文件名的文件,makefile,Makefile,我想有一个makefile从另一个目录复制文件并更改它们的名称。现在,我做了这样的事情: ALL: figure1.eps figure2.eps figure3.eps figure1.eps: ../other_directory/a_nice_graph.eps cp $< $@ figure2.eps: ../other_directory/a_beautiful_graph.eps cp $< $@ figure3.eps: ../ot

我想有一个makefile从另一个目录复制文件并更改它们的名称。现在,我做了这样的事情:

ALL: figure1.eps figure2.eps figure3.eps

figure1.eps: ../other_directory/a_nice_graph.eps
        cp $< $@

figure2.eps: ../other_directory/a_beautiful_graph.eps
        cp $< $@

figure3.eps: ../other_directory/an_ugly_graph.eps
        cp $< $@
ALL:图1.eps图2.eps图3.eps
图1.eps:../other\u目录/a\u nice\u graph.eps
cp$<$@
图2.eps:../other\u目录/a\u beautiful\u graph.eps
cp$<$@
图3.eps:../other\u目录/an\u丑陋的\u graph.eps
cp$<$@
我希望避免为每一行编写相同的规则(cp$<$@)。我无法使用标准通配符(%.eps),因为文件名不匹配。有什么方法可以做到这一点吗?

试试这个:

ALL: figure1.eps figure2.eps figure3.eps

%.eps:
        cp $< $@

figure1.eps: ../other_directory/a_nice_graph.eps

figure2.eps: ../other_directory/a_beautiful_graph.eps

figure3.eps: ../other_directory/an_ugly_graph.eps
ALL:图1.eps图2.eps图3.eps
%.eps:
cp$<$@
图1.eps:../other\u目录/a\u nice\u graph.eps
图2.eps:../other\u目录/a\u beautiful\u graph.eps
图3.eps:../other\u目录/an\u丑陋的\u graph.eps

是的,谢谢,这很有效。我从来没想过只有一件事