开发者

Why does this Makefile error out?

I'm making a Makefile to iterate over files and execute a command for each file. The开发者_运维知识库 commands execute fine but then make errors out. This is my Makefile:

SHELL := /bin/bash

link: .gemrc .vimrc .gitconfig
    $(foreach df, $^, cat $(df) )

The output is the contents of each file and then make: *** [link] Error 1

How do I make make not error out?


The problem is that the command expands to cat .gemrc cat .vimrc cat .gitconfig, which gives an error because it can't find a file named cat to, well, cat.

Here are two of ways to do it:

link: .gemrc .vimrc .gitconfig
    cat $^

link: .gemrc .vimrc .gitconfig
    $(foreach df, $^, cat $(df);)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜