On Mon, May 28, 2012 at 12:02 AM, Mark Galeck (CW) <[email protected]> wrote:
> How can I have ':' in a prerequisite name??

Put the filename in a variable, then use Secondary Expansion (c.f.
section 3.8 in the docs) and reference that variable in second
expansion and *NOT* first expansion.  For example:

$ cat Makefile
.SECONDEXPANSION:
f = baz foo:bar
bar: $${f}
        echo $^ > $@
$ ls
Makefile baz      foo:bar
$ cat Makefile
.SECONDEXPANSION:
f = baz foo:bar
bar: $${f}
        echo $^ > $@
$ ls -1
Makefile
baz
foo:bar
$ gmake
echo baz foo:bar > bar
$ gmake
gmake: `bar' is up to date.
$ touch foo:bar
$ gmake
echo baz foo:bar > bar
$

HOWEVER, note that this solution does *not* work for targets.  AFAICT,
there's no way to have a file whose name contains colons depend on a
file whose name doesn't contain the same subsequence of colons, and
even that possibility (via pattern rules) is limited in scope.


> I know it's silly but I need it, unfortunately some files have : in their 
> names and I can't change that...

There are other dependency management tools than make, most of which
were developed with grammars that are more regular and expressive than
that of make.  Some times the correct answer is "use a different
tool".


Philip Guenther

_______________________________________________
Help-make mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-make

Reply via email to