help-make
[Top][All Lists]
Advanced

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

Re: Optional prerequisites


From: Noel Yap
Subject: Re: Optional prerequisites
Date: Wed, 31 Aug 2005 14:30:05 -0400
User-agent: Mozilla Thunderbird 1.0.2 (Windows/20050711)

Have you tried:

target: $(wildcard optional-prereq)

Oh, I see you already thought of that.  Yes, pattern rules won't work for this 
since $(wildcard) is evaluated at makefile parse time.

Due to these sorts of issues, I've started abandoning pattern rules in favor of user functions that create explicit rules. This gets extremely complicated and I've never used this kind of setup in a non-trivial build. Because of this, I've contemplated starting to use SCons.

Noel

Vilar Camara Neto wrote:
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



_______________________________________________
Help-make mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/help-make




reply via email to

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