make-alpha
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Possible solution for special characters in makefile paths


From: Paul Smith
Subject: Re: Possible solution for special characters in makefile paths
Date: Sun, 02 Mar 2014 11:38:20 -0500

On Thu, 2014-02-20 at 03:22 -0500, Paul Smith wrote:
> Hi all.

Thanks for participating so far.  I thought before I dive in with a
trial summary of the options on the table so far, I would back up and
describe make's current behaviors with respect to escaping; this is
important for considering backward-compatibility issues.

I'll skip "$" escaping because this is simple and well-understood.  I'll
also skip any special handling of backslash in the various Windows ports
(mostly because I don't know much about them :-)).


Today make supports a limited form of backslash escaping.  Certain
special characters (for example " ", ":", ";", "=", and backslash
itself) are subject to this escaping.  It means that when this character
appears in a context where it might have had a special meaning, it is
instead treated as a normal character.

However, when make stores these values internally it strips off the
backslashes before doing so.  This makes this form of escaping very
difficult to work with.  For example:

  all: foo\:bar ; @echo '$<'
  foo\:bar: ; @echo '$@'

Does work, and prints:

  foo:bar
  foo:bar

Also if you use "make -p" you'll see that the internal database has
stored the name as the literal 'foo:bar'.  You can replace the "\:" with
"\ " above and get the same behavior, but with whitespace, even today.


However, the problem comes when you try to combine this with variables.
Those escape characters are preserved, but not treated specially in a
variable value, because those characters don't have any special meaning
in a variable value.  So you get:

  FOO = foo\:bar

  all: $(FOO) ; @echo '$<'
  $(FOO): ; @echo 'address@hidden(FOO)'

You get:

  foo:bar-foo\:bar
  foo:bar

And further, they have no special meaning to functions; this is most
visible if you use escaped whitespace:

  FOO = foo\ bar

  all: $(FOO) ; @echo '$(addsuffix .f,$@)'
  $(FOO): ; @echo '$(addsuffix .f,$@)-$(addsuffix .f,$(FOO))'

Gives:

  foo.f bar.f-foo\.f bar.f
  foo.f bar.f




reply via email to

[Prev in Thread] Current Thread [Next in Thread]