Is there a way to get GNU make to work correctly with filenames that contain colons?
The specific problem I'm running into happens to involve a pattern rule. Here's a simplified version that does not depend on cutting and pasting tab characters:
% make --version GNU Make 3.81 Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. This program built for x86_64-redhat-linux-gnu % cat Makefile COLON := \: all: ; true %.bar: ; cp $< $@ x.bar: x.foo %.foo: ; touch $@ a$(COLON)b.bar: a$(COLON)b.foo all: x.bar a$(COLON)b.bar clean: ; rm -f *.foo *.bar % make clean rm -f *.foo *.bar % make touch x.foo cp x.foo x.bar cp a\:b.bar cp: missing destination file operand after `a:b.bar' Try `cp --help' for more information. make: *** [a\:b.bar] Error 1
Replacing $(COLON) with a literal : produces exactly the same result. Without the backslash, it does this:
Makefile:6: *** target pattern contains no `%'. Stop.
In the first line, the list of target names is terminated by a colon. This, in turn, is followed by the dependency list, if there is one. If several targets are listed, this indicates that each such target is to be built independently using the rule supplied.
$@ is the name of the target being generated, and $< the first prerequisite (usually a source file). You can find a list of all these special variables in the GNU Make manual.
This means that when you do a "make all", make always thinks that it needs to build it, and so executes all the commands for that target. Those commands will typically be ones that build all the end-products that the makefile knows about, but it could do anything.
I doubt it's possible: see this discussion about colons in Makefiles. In summary, GNU make has never worked well with filenames that contain whitespace or colons. The maintainer, Paul D. Smith, says that adding support for escaping would tend to break existing makefiles. Furthermore, adding such support would require significant changes to the code.
You might be able to work around with some sort of nasty temporary file arrangement.
Good luck!
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