help-make
[Top][All Lists]
Advanced

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

Re: implicit rules


From: Noel Yap
Subject: Re: implicit rules
Date: Mon, 26 Apr 2004 16:58:54 -0400
User-agent: Mozilla Thunderbird 0.5 (Windows/20040212)

After re-reading the bottom of make.info-6, I see that I had completely misread 
it before.

Thanks,
Noel

Paul D. Smith wrote:

%% Noel Yap <address@hidden> writes:
  ny> IIUC, make can use "%.mk: %.mk" to match "aoeu/aoeu.mk: aoeu.mk".
  ny> OTOH, IIUC, make should use "%.mk: %.mk" to match "aoeu/aoeu.mk:
  ny> aoeu.m" so I'm clearly missing something here.

Yes: you're missing that the string that replaces the pattern ("%") has
to be THE IDENTICAL STRING in the target and the prerequisite.  These
are not globs, like shell wildcards or something, which are individually
examined.

When make sees a rule like:

    %.x : %.y

it does this: match the target pattern against the thing we're trying to
build.  If it doesn't match, go to the next one.  If it does match, then
take the string that matched the % in the target and substitute it into
the % in the prerequisite (if any).  Then try to see if _THAT_ target
can be built.

What it does _NOT_ do is this: match the target pattern against the
thing we're trying to build.  If it doesn't match, go to the next one.
If it does match, then try to find some file that might match the
prerequisite pattern or some way to build some file that might match the
prerequisite pattern.  Even writing this out it's obvious that this is
not a realistic algorithm.

  ny> This rule is now not as generic as before; one would have to write
  ny> a new rule depending on where the target will be created.

Yes, you're correct.  That's what you have to do.





reply via email to

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