Let's say I have a makefile like the following.
foo: filename file\ name\ with\ spaces
cat 'filename' 'file name with spaces' > foo
However, I don't have 2 files. I have a lot of them, so I am trying to make the makefile more consistent this way.
foo: filename file\ name\ with\ spaces
cat $^ > foo
This works fine as long as the file names do not contain any spaces.
Is it any way to put file names from $^
in single quotes?
Or is there some other way to get around the problem of spaces?
EDIT
I found a partially solution.
foo: filename.txt file\ name\ with\ spaces.txt
cat '$(subst .txt ,.txt' ',$^)' > foo
Unfortunately, this works only when all files have the same extension. I can not write script which works with any file name.