make: Errors

1 
1 5.5 Errors in Recipes
1 =====================
1 
1 After each shell invocation returns, 'make' looks at its exit status.
1 If the shell completed successfully (the exit status is zero), the next
1 line in the recipe is executed in a new shell; after the last line is
1 finished, the rule is finished.
1 
1    If there is an error (the exit status is nonzero), 'make' gives up on
1 the current rule, and perhaps on all rules.
1 
1    Sometimes the failure of a certain recipe line does not indicate a
1 problem.  For example, you may use the 'mkdir' command to ensure that a
1 directory exists.  If the directory already exists, 'mkdir' will report
1 an error, but you probably want 'make' to continue regardless.
1 
1    To ignore errors in a recipe line, write a '-' at the beginning of
1 the line's text (after the initial tab).  The '-' is discarded before
1 the line is passed to the shell for execution.
1 
1    For example,
1 
1      clean:
1              -rm -f *.o
1 
1 This causes 'make' to continue even if 'rm' is unable to remove a file.
1 
1    When you run 'make' with the '-i' or '--ignore-errors' flag, errors
1 are ignored in all recipes of all rules.  A rule in the makefile for the
1 special target '.IGNORE' has the same effect, if there are no
1 prerequisites.  These ways of ignoring errors are obsolete because '-'
1 is more flexible.
1 
1    When errors are to be ignored, because of either a '-' or the '-i'
1 flag, 'make' treats an error return just like success, except that it
1 prints out a message that tells you the status code the shell exited
1 with, and says that the error has been ignored.
1 
1    When an error happens that 'make' has not been told to ignore, it
1 implies that the current target cannot be correctly remade, and neither
1 can any other that depends on it either directly or indirectly.  No
1 further recipes will be executed for these targets, since their
1 preconditions have not been achieved.
1 
1    Normally 'make' gives up immediately in this circumstance, returning
1 a nonzero status.  However, if the '-k' or '--keep-going' flag is
1 specified, 'make' continues to consider the other prerequisites of the
1 pending targets, remaking them if necessary, before it gives up and
1 returns nonzero status.  For example, after an error in compiling one
1 object file, 'make -k' will continue compiling other object files even
11 though it already knows that linking them will be impossible.  ⇒
 Summary of Options Options Summary.
1 
1    The usual behavior assumes that your purpose is to get the specified
1 targets up to date; once 'make' learns that this is impossible, it might
1 as well report the failure immediately.  The '-k' option says that the
1 real purpose is to test as many of the changes made in the program as
1 possible, perhaps to find several independent problems so that you can
1 correct them all before the next attempt to compile.  This is why Emacs'
1 'compile' command passes the '-k' flag by default.
1 
1    Usually when a recipe line fails, if it has changed the target file
1 at all, the file is corrupted and cannot be used--or at least it is not
1 completely updated.  Yet the file's time stamp says that it is now up to
1 date, so the next time 'make' runs, it will not try to update that file.
1 The situation is just the same as when the shell is killed by a signal;
1 ⇒Interrupts.  So generally the right thing to do is to delete the
1 target file if the recipe fails after beginning to change the file.
1 'make' will do this if '.DELETE_ON_ERROR' appears as a target.  This is
1 almost always what you want 'make' to do, but it is not historical
1 practice; so for compatibility, you must explicitly request it.
1