help-make
[Top][All Lists]
Advanced

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

Escape rules for target name and dependency list


From: Allan Odgaard
Subject: Escape rules for target name and dependency list
Date: Tue, 6 Apr 2010 18:18:50 +0200

(this is a resend from October 2009, but I never received a reply, so trying again)

I am generating a Makefile from a script so I need to handle proepr escaping of special characters (my files have lots of these).

By experimentation I found that in the target I need to escape: » : %#*;=$:« and in the dependencies: » \#*[|;=$:«. I may have missed some and maybe some are not necessary.

Anyway, the problem is that not all charactes (from my set) can actually be escaped. In particular ;, =, and : are problematic. I managed to escape the first two using variables like:

   semi-colon = \;
   foo$(semi-colon)bar.o: foo$(semi-colon)bar.c
       …

This however does not work for the colon in the dependency list. The best solution I found was replacing it with a shell wildcard:

   foo\:bar.o: foo?bar.c
       …

While theoretically fragile, my main problem with this is that it only works when the dependency already exists, e.g. this fails:

   foo\:bar.o: foo?bar.s
       …

   foo\:bar.s: foo?bar.c
       …

This is where I decided to seek professional help ;)





reply via email to

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