Consider following make:
all: a b
a:
echo a
exit 1
b:
echo b start
sleep 1
echo b end
While running it as make -j2 I receive the following output:
echo a
echo b start
a
exit 1
b start
sleep 1
make: *** [a] Error 1
make: *** Waiting for unfinished jobs....
echo b end
b end
We have quite a big make file and it’s easy to miss error, since there’s no error message at the end of execution.
Is there a way for error message to appear also just in the end of the make execution?
UPDATE:
See my possible solution how to check make exit status from within make.
If any program called by
makereturns with an error, the return code ofmakewill not be zero. So after callingmakeyou could just check the return code to see if an error occurred. Onbash(and many other shells likezsh) you could do the following:The echo will print
0if anything was ok and will print something else if it wasn’t.You could also run the check from inside a shell script:
If you need the exact error message the easiest way is to redirect the output from
maketo some file andgrepfor the error if execution failed.But the way I usually do this is to run
makein parallel and re-execute it with-j1if something went wrong so I will get a clean error message. I guess this could be put into a shell script using the technique above.