开发者

Why does this Makefile error out?

开发者 https://www.devze.com 2023-03-26 21:21 出处:网络
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:

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

精彩评论

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