help-make
[Top][All Lists]
Advanced

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

Re: makefile error output


From: Paul D. Smith
Subject: Re: makefile error output
Date: Fri, 26 Mar 2004 15:29:01 -0500

%% "Mike Maxwell" <address@hidden> writes:

  mm> I just spent the morning trying to debug my makefile.  The error msg was
  mm>     Make: *** Unable to make target foo.bar.  Stop
  mm> (The name of the target has been changed to protect the innocent.)

Please do not paraphrase like this.  By not providing the _EXACT_
message you got, and the exact rule you wrote, etc. you are just
confusing the issue.

Either you are using some bastardized version of GNU make, or this is
not what make printed.  There is no code in GNU make that will print
that error message.  Given your description of what happened, the error
message make printed would have been some form of:

  No rule to make target `XXX'.

IMO that message is much clearer than what you wrote above.

  mm> Let me say for starters that that is not a very helpful error msg:
  mm> telling me that it was unable to make the target sounds like a
  mm> sort of last-ditch error msg, sort of like "General Error."

You may have read it that way, but that's not what it means.  The GNU
make manual section explaining error messages says:

     This means that `make' decided it needed to build a target, but
     then couldn't find any instructions in the makefile on how to do
     that, either explicit or implicit (including in the default rules
     database).

  mm> The problem turned out to be that I had misspelled one of the
  mm> prerequisities:

  mm> foo.bar: foo.baz   foo.ReadMe
  mm>     ...

  mm> Instead of a file foo.ReadMe, I had foo.Readme.  Simple to fix,
  mm> hard for me to find.

As Noel pointed out, if this is _REALLY_ what your makefile said then
make would have told you that it didn't know how to build foo.ReadMe.

>From your description of what happened, I believe that you really had
defined an implicit rule here, rather than an explicit rule as your
example shows.

The behavior is very different for those two types of rules, because for
implicit rules there's no way make can know that this rule _should_ have
matched.  All it can tell you is that it couldn't find any rule that
_did_ match.

  mm> I tried turning on various debug options (-d, -q, -r) on make, but
  mm> even after I knew what the problem was, and ran make with these
  mm> options to see how the debug output could help, I couldn't tell.
  mm> My naive idea of how 'make' works is that it is sort of like
  mm> Prolog: it tries various ways to prove (or in this case, make) a
  mm> goal, and when it finds a possible path, it pursues that.
  mm> Eventually it either solves all the goals for the top-level goal,
  mm> or else it fails to prove some goal.

That's more-or-less how make works when dealing with implicit rules,
yes.  Explicit rules of course either work or make fails: there can be
only one explicit rule for a target.

  mm> Couldn't make do the same thing?  I.e. when it tried to make the
  mm> foo.ReadMe file, it could have said something like

  mm>     Looking for foo.ReadMe...failed
  mm>     Trying implicit prerequisite foo.ReadMe,v ...failed
  mm>     Trying implicit prerequisite RCS/foo.ReadMe,v ...failed
  mm>     etc.

  mm> In other words, all it needs to do is add the string " ...failed" if a
  mm> prereq fails (or " ...succeeded" if it succeeds), to the output produced
  mm> with the -d flag.

Make debug output doesn't print "succeeded", but it does say "Found an
implicit rule for `XXX'" when it succeeds.

Make output doesn't print "failed", but you know it failed because it
went on to continue looking for another rule to match.

And if it never finds any rule that matches, it says 
"No implicit rule found for `XXX'".

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.paulandlesley.org
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist




reply via email to

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