I am writing a makefile. However except for the path expansion and restrictions on what I can do, this is basically a shell scripting question. As part of the make process, I want to copy a directory to the destination. My source directory and destination directory are variables, so I can't assume a lot about them. They may be fully qualified, they may be relative.
But I want to copy the directory $(A) to the destination $(B). $(B) is the name I want the directory to have at the destination, not the directory I want to copy $(A) to (i.e. the resulting directory name will be $(B), not $(A)/$(B)), it might be the same path for source and dest, so I check with an ifneq ($(A),$(B)) before doing anything. But the question is, what do I do in the block.
If I do
cp -r $(A) $(B)
it will work the first time. $(A) is copied to $(B). But if the rule triggers again later, it will make a new copy of $(A) inside $(B) (i.e. $(B)/$(A)).
And before you ask, I'd rather not rm -r $(B)
before doing this if at all possible.