[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: make does not stop when a command returns an error
From: |
Cédric Lucantis |
Subject: |
Re: make does not stop when a command returns an error |
Date: |
Fri, 9 Mar 2007 18:46:17 +0100 |
User-agent: |
KMail/1.9.5 |
> > Hi,
> >
> > i think i need to track this down a bit further, but can anybody
> > see why "make" should continue to go even when i call a perl
> > script in a rule and that script does an "exit(-1)" ?
> >
> > In front of that rule i don't have any "-".
>
> If you showed us the rule we could be a lot more help.
>
> Without any further information, we can't say for sure; we can only
> guess. One common mistake is that the command that fails is not the
> last command in the script that make runs, so make doesn't see it. For
> example, if you have:
>
> foo:
> perl -e myscript; do_something_else
>
> then if the perl command fails make doesn't see that; make will only see
> the exit code of the do_something_else command. If you have multiple
> commands in make you should ALWAYS either put them on separate lines:
>
> foo:
> perl -e myscript
> do_something_else
>
> or else if you don't want to do that you should use the && operator
> between all your commands:
>
> foo:
> perl -e myscript && do_something_else
>
>
> Another problem, that is much harder to solve, is pipes: the shell will
> use the exit code of the final command as the exit of the shell, so:
>
> foo:
> perl -e myscript | do_something_else
>
> also won't see any exit code from the perl script.
Another obscure problem is when the target of the failing command is an
included makefile (with -include). As your talking about dependencies, it's
probably your problem here. For instance, the following will (strangely)
always success:
all:
echo "hello"
depends.d:
false
-include depends.d
--
Cédric Lucantis