help-make
[Top][All Lists]
Advanced

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

Re: Make doesn't bail on compile errors


From: Philip Guenther
Subject: Re: Make doesn't bail on compile errors
Date: Fri, 23 Mar 2007 16:08:46 -0600

On 3/23/07, Michael L Brown <address@hidden> wrote:
"Philip Guenther" <address@hidden> wrote on 03/23/2007 04:02:42 PM:
...
> A correct makefile.  The makefile which is continuing instead of
> stopping has an incorrectly written set of commands that execute
> multiple recursive makes without checking all their exit statuses.

The makefile has to do the checking and stop?  Oh how horrible.

GNU make checks the status of each separate command.  The issue only
arises when "a command" actually consists of a series of shell
commands using shell functionality such as ';' or 'for' loops.  So, if
you write:

target:
       command1
       command2

then make will notice when 'command1' fails and stop the build.  If
you instead write:

target:
       command1; command2

then the failure of command1 will only be known to the shell and the
semicolon effectively tells it to ignore the failure, so make will not
stop when command1 fails.  Note that it *would* work correctly if you
wrote:

target:
       command1 && command2

as the '&&' tells the shell to check the status of the command before
it and fail if it failed.

With
Sun/Solaris make the program saw the error and bail all compiling at that
point and issued an error when exiting, which the script that called the
make the caught and bailed.

Ah yes.  That's a contentious behaviour of Sun's make.  To quote the
GNU make info pages:

  * Some versions of `make' invoke the shell with the `-e' flag,
    except under `-k' (*note Testing the Compilation of a Program:
    Testing.).  The `-e' flag tells the shell to exit as soon as any
    program it runs returns a nonzero status.  We feel it is cleaner to
    write each shell command line to stand on its own and not require
    this special treatment.

The fact that Sun make behaves like that means that portable makefiles
that *want* a command's status to be ignored in a compound action have
to go to extra effort.  Thanks a lot, Sun!


Doesn't that seem like overkill to have the makefile do the checking? That
makes the makefile lots larger, when the make program itself should see
the error and back all the way out.

If the makefile was written correctly to not hide the error from make,
then make's checking would work just fine.


Philip Guenther




reply via email to

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