Makefile collect list of files in a new directory
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
.
精彩评论