On Fri, 2008-06-06 at 19:49 +0800, [EMAIL PROTECTED] wrote: > All is well: > $ cat Makefile > all:z.bak > %.bak:; > $ make > make: Nothing to be done for `all'. > Until we add a %: > $ cat Makefile > all:z.bak > %.bak:%; > $ make > make: *** No rule to make target `z.bak', needed by `all'. Stop. > Suddenly it can't find the rule anymore. Or prints the wrong message. > Indeed, instead of % use > %.bak:some_file_that_exists; > No problem. But > %.bak:some_file_that_does_not_exist; > then make says it can't find the rule to make target z.bak, when it > should say it can't find the rule to make target > some_file_that_does_not_exist, > which it does when one uses > z.bak:some_file_that_does_not_exist;
I have this weird deja-vu feeling like I've already explained this to you before. However. There is nothing that can be done about this; this is expected behavior. A pattern rule is not a guarantee that that particular rule will be used to build every target that matches the pattern. Indeed, the builtin rules have a large number of different patterns that can build "%.o" (for example), all with different prerequisites. If there is no explicit rule to build a target, then make will search the pattern rules, looking for one that matches. "Matches" means that BOTH the target pattern matches the target to be built, AND that all the prerequisites exist OR can be built. If the pattern does not match, make goes on to the next pattern and tries that. If no pattern matches, make says it doesn't know how to build the target, just as you're seeing. You are using your innate understanding of your environment and your needs to see that the problem is that that particular prerequisite doesn't exist, and suggesting make should also be able to see that... but make CAN'T see that. All it can see is that the makefile doesn't contain any rules it can use to build that target. It would be disaster to print all the possible prerequisites make looked at to decide whether a given target could be built: consider all the built-in rules to create executables (where the pattern, "%", matches everything); to check things out of source control (again where the pattern matches everything); not to mention the above multiple rules to build .o's: if you were missing a .c file you'd get a long list of possible prerequisites (.c, .cc, .cpp, .f, .F, etc. etc.) An explicit rule is, of course, much simpler for make: if there's an implicit rule then that's the way the target must be built and if the prerequisites don't exist make can tell you about that directly. _______________________________________________ Bug-make mailing list Bug-make@gnu.org http://lists.gnu.org/mailman/listinfo/bug-make