1*8c973ee2SSimon J. Gerraty# $NetBSD: cmd-interrupt.mk,v 1.4 2023/03/18 22:20:12 sjg Exp $ 22c3632d1SSimon J. Gerraty# 32c3632d1SSimon J. Gerraty# Tests for interrupting a command. 42c3632d1SSimon J. Gerraty# 52c3632d1SSimon J. Gerraty# If a command is interrupted (usually by the user, here by itself), the 62c3632d1SSimon J. Gerraty# target is removed. This is to avoid having an unfinished target that 72c3632d1SSimon J. Gerraty# would be newer than all of its sources and would therefore not be 82c3632d1SSimon J. Gerraty# tried again in the next run. 92c3632d1SSimon J. Gerraty# 102c3632d1SSimon J. Gerraty# This happens for ordinary targets as well as for .PHONY targets, even 112c3632d1SSimon J. Gerraty# though the .PHONY targets usually do not correspond to a file. 122c3632d1SSimon J. Gerraty# 132c3632d1SSimon J. Gerraty# To protect the target from being removed, the target has to be marked with 142c3632d1SSimon J. Gerraty# the special source .PRECIOUS. These targets need to ensure for themselves 152c3632d1SSimon J. Gerraty# that interrupting them does not leave an inconsistent state behind. 162c3632d1SSimon J. Gerraty# 172c3632d1SSimon J. Gerraty# See also: 182c3632d1SSimon J. Gerraty# CompatDeleteTarget 192c3632d1SSimon J. Gerraty 202c3632d1SSimon J. Gerratyall: clean-before interrupt-ordinary interrupt-phony interrupt-precious clean-after 212c3632d1SSimon J. Gerraty 222c3632d1SSimon J. Gerratyclean-before clean-after: .PHONY 232c3632d1SSimon J. Gerraty @rm -f cmd-interrupt-ordinary cmd-interrupt-phony cmd-interrupt-precious 242c3632d1SSimon J. Gerraty 25e2eeea75SSimon J. Gerratyinterrupt-ordinary: 262c3632d1SSimon J. Gerraty @${.MAKE} ${MAKEFLAGS} -f ${MAKEFILE} cmd-interrupt-ordinary || true 272c3632d1SSimon J. Gerraty # The ././ is necessary to work around the file cache. 282c3632d1SSimon J. Gerraty @echo ${.TARGET}: ${exists(././cmd-interrupt-ordinary) :? error : ok } 292c3632d1SSimon J. Gerraty 302c3632d1SSimon J. Gerratyinterrupt-phony: .PHONY 312c3632d1SSimon J. Gerraty @${.MAKE} ${MAKEFLAGS} -f ${MAKEFILE} cmd-interrupt-phony || true 322c3632d1SSimon J. Gerraty # The ././ is necessary to work around the file cache. 33*8c973ee2SSimon J. Gerraty @echo ${.TARGET}: ${exists(././cmd-interrupt-phony) :? ok : error } 342c3632d1SSimon J. Gerraty 352c3632d1SSimon J. Gerratyinterrupt-precious: .PRECIOUS 362c3632d1SSimon J. Gerraty @${.MAKE} ${MAKEFLAGS} -f ${MAKEFILE} cmd-interrupt-precious || true 372c3632d1SSimon J. Gerraty # The ././ is necessary to work around the file cache. 382c3632d1SSimon J. Gerraty @echo ${.TARGET}: ${exists(././cmd-interrupt-precious) :? ok : error } 392c3632d1SSimon J. Gerraty 402c3632d1SSimon J. Gerratycmd-interrupt-ordinary: 412c3632d1SSimon J. Gerraty > ${.TARGET} 422c3632d1SSimon J. Gerraty @kill -INT ${.MAKE.PID} 432c3632d1SSimon J. Gerraty 442c3632d1SSimon J. Gerratycmd-interrupt-phony: .PHONY 452c3632d1SSimon J. Gerraty > ${.TARGET} 462c3632d1SSimon J. Gerraty @kill -INT ${.MAKE.PID} 472c3632d1SSimon J. Gerraty 482c3632d1SSimon J. Gerratycmd-interrupt-precious: .PRECIOUS 492c3632d1SSimon J. Gerraty > ${.TARGET} 502c3632d1SSimon J. Gerraty @kill -INT ${.MAKE.PID} 51