X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=scripts%2FKbuild.include;h=914ea5eb16a8ceb6f7b5ebb53e784a7c92ba5ced;hb=refs%2Fheads%2Faccepted%2Ftizen_8.0_unified;hp=cdec22088423e42fc1a82357ef5f5fe41a0807be;hpb=21f577b0f48fd3a8871ca4116dad0e9c41ec42b2;p=platform%2Fkernel%2Flinux-rpi.git diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index cdec220..914ea5e 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -96,8 +96,29 @@ echo-cmd = $(if $($(quiet)cmd_$(1)),\ quiet_redirect := silent_redirect := exec >/dev/null; +# Delete the target on interruption +# +# GNU Make automatically deletes the target if it has already been changed by +# the interrupted recipe. So, you can safely stop the build by Ctrl-C (Make +# will delete incomplete targets), and resume it later. +# +# However, this does not work when the stderr is piped to another program, like +# $ make >&2 | tee log +# Make dies with SIGPIPE before cleaning the targets. +# +# To address it, we clean the target in signal traps. +# +# Make deletes the target when it catches SIGHUP, SIGINT, SIGQUIT, SIGTERM. +# So, we cover them, and also SIGPIPE just in case. +# +# Of course, this is unneeded for phony targets. +delete-on-interrupt = \ + $(if $(filter-out $(PHONY), $@), \ + $(foreach sig, HUP INT QUIT TERM PIPE, \ + trap 'rm -f $@; trap - $(sig); kill -s $(sig) $$$$' $(sig);)) + # printing commands -cmd = @set -e; $(echo-cmd) $($(quiet)redirect) $(cmd_$(1)) +cmd = @set -e; $(echo-cmd) $($(quiet)redirect) $(delete-on-interrupt) $(cmd_$(1)) ### # if_changed - execute command if any prerequisite is newer than