开发者

Makefile collect list of files in a new directory

开发者 https://www.devze.com 2023-03-14 16:01 出处:网络
I have a list of file paths in a variable. I\'d like to copy each file in this list to a new location. The problem is that I\'m very new to makefiles and I\'m struggling to get anything working. My at

I have a list of file paths in a variable. I'd like to copy each file in this list to a new location. The problem is that I'm very new to makefiles and I'm struggling to get anything working. My attempt has culminated at the following, although not working (and probably totally wrong) I hope it illustrates what I'm trying to do.

FILES = a/b/file c/d/file e/.../file etc...
copyfiles:
       for file in $(FILES); do \
        开发者_如何学Python   cp $$file newDir/$(notdir $$file);  \
       done


You could do

FILES = a/b/file c/d/file e/.../file etc...
copyfiles:
    cp $(FILES) newDir

I tried it, and it works.

Remember, globbing is done by the shell, not by the commands. cp takes a list of files as arguments, and copies all of them to the location specified by the last argument. When you type cp *.cpp all the cp program sees as its arguments are the files in the current directory that end in .cpp.

0

精彩评论

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