help-make
[Top][All Lists]
Advanced

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

Re: how to have prerequisites with ':' in the name?


From: Philip Guenther
Subject: Re: how to have prerequisites with ':' in the name?
Date: Mon, 28 May 2012 01:06:29 -0700

On Mon, May 28, 2012 at 12:02 AM, Mark Galeck (CW) <address@hidden> 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



reply via email to

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