Can GNU make handle filenames with spaces?

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:

  • It does not work in any functions except $(wildcard).
  • It does not work when expanding lists of names from variables, which includes the special variables $?, $^ 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.

Leave a Comment