I have a directory containing several files, some of which have spaces in their names:
Test workspace/ Another directory/ file1.ext file2.ext demo 2012-03-23.odp
I use GNU's $(wildcard)
command on this directory, and then iterate over the result using $(foreach)
, printing everything out. Here's the code:
FOO := $(wildcard *) $(info FOO = $(FOO)) $(foreach PLACE,$(FOO),$(info PLACE = $(PLACE)))
Here's what I would expect to see printed out:
Test workspace Another directory file1.ext file2.ext demo 2012-03-23.odp
Here's what I would actually get:
Test workspace Another directory file1.ext file2.ext demo 2012-03-23.odp
The latter is obviously of no use to me. The documentation for $(wildcard)
flat-out states that it returns a "space-separated list of names" but completely fails to acknowledge the huge problems this raises. Nor does the documentation for $(foreach)
.
Is it possible to work around this? If so, how? Renaming every file and directory to remove the spaces is not an option.
The bug #712 suggests that make does not handle names with spaces. Nowhere, never.
I found a blog post saying it's partially implemented by escaping the spaces with \
(\\
seems to be typo or formatting artefact), but:
$(wildcard)
.$?
, $^
and $+
as well as any user-defined variable. Which in turn means that while $(wildcard)
will match correct files, you won't be able to interpret the result anyway.So with explicit or very simple pattern rules you can get it to work, but beyond that you are out of luck. You'll have to look for some other build system that does support spaces. I am not sure whether jam/bjam does, scons, waf, ant, nant and msbuild all should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With