help-make
[Top][All Lists]
Advanced

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

Optional prerequisites


From: Vilar Camara Neto
Subject: Optional prerequisites
Date: Wed, 31 Aug 2005 15:23:13 -0400
User-agent: Mozilla Thunderbird 1.0.6 (Windows/20050716)

Hello everyone,

I'm trying to build a rule with an "optional" prerequisite, i.e.,
something that says that "if a given file doesn't exist, then ignore it,
otherwise consider it as a prerequisite".

An example:  all files "%.z" depends on files "%.x" and, if existent,
"%.y".  The following works:

----------

all: first.z second.z

first.z: first.x $(wildcard first.y)
        echo $^

second.z: second.x $(wildcard second.y)
        echo $^

----------

Given that files "first.x", "first.y" and "second.x" (but not
"second.y") exist in the current directory, the echo commands print
exactly what I want (two prerequisites for "first.z" and one for
"second.z").

Surprisingly, a patterned rule doesn't work as I expect:

----------

all: first.z second.z

%.z: %.x $(wildcard %.y)
        echo $^

----------

It never expands the "$(wildcard ...)" clause accordingly.  I think that
there's something about operator precedence.

How do I solve it?  Maybe not using "$(wildcard ...)" at all?

Best regards,
Vilar Neto





reply via email to

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