Stop compilation with parallel make immediately

Is there a way to make parallel calls to GNU make (i.e. make -jN) to terminate ALL compilation immediately when an error occurs?

Currently, I see the message “Waiting for incomplete jobs” and then a lot of lines of output, while existing make processes are terminating.

+5
source share
2 answers

There is no way to do this (in GNU make). The only possible way would be to add a template stanza to all your recipes so that in case of failure you could catch the failure and use killall or something similar to kill all make instances. Difficult and dangerous.

Of course, you can always press CTRL-C to stop doing.

+3

, , . :

#!/usr/bin/make -f

MAKEPID:= $(shell echo $$PPID)

$(mytargets):
    @script_that_runs_in_parallel.sh $@ || kill -TERM $(MAKEPID)

, .

+1

All Articles