1

I saw this question: Escaping colons in filenames in a Makefile, which is explicitly in reference to GNU make. The accepted answer references a discussion on the bug-make@gnu.org mailing list which states pretty definitively that it's impossible; GNU make does not support files with colons or spaces in the name.

Fair enough. But is there any make variant that does? I'm guessing the answer is still no but I wanted to see if there's an answer more definitive than my guess.

Community
  • 1
  • 1
bahamat
  • 738
  • 2
  • 9
  • 19

1 Answers1

2

You can kind of use colons but it requires extra work. You can use a colon in a target or a prerequisite if you escape it with a backslash... but then it's escaped with a backslash if you use that variable in your recipe, too:

FOO = biz\:baz

all: foo\:bar $(FOO) ; @echo '$@: $^'
foo\:bar:            ; @echo '$@'
$(FOO):              ; @echo '$@' '$(FOO)'

This gives:

foo:bar
biz:baz biz\:baz
all: foo:bar biz:baz

Note how the expansion of $(FOO) (and only that!) contains the backslash. So, while it's do-able, it's problematic. As you start to work with it you'll run into all kinds of issues.

As for whitespace, you can also escape that in targets and prerequisites with backslashes. However, again the problem is that the backslashes are included sometimes in the recipe and not other times. Whitespace has an even bigger problem, because the functions make uses to manipulate words are not backslash-aware so things like addsuffix, etc. will not work right.

I'm not aware of any general-purpose make variant that handles this better, at the moment.

MadScientist
  • 92,819
  • 9
  • 109
  • 136