title: Escaping colons in filenames in a Makefile
body: <p>Is there a way to get GNU make to work correctly with filenames that contain colons?</p>
  
  <p>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:</p>
  
  <pre><code>% 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 $&lt; $@
  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
  </code></pre>
  
  <p>Replacing $(COLON) with a literal : produces exactly the same result.  Without the backslash, it does this:</p>
  
  <pre><code>Makefile:6: *** target pattern contains no `%'.  Stop.
  </code></pre>