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);)
精彩评论