1 1.4 sjg # $NetBSD: cmd-interrupt.mk,v 1.4 2023/03/18 22:20:12 sjg Exp $ 2 1.1 rillig # 3 1.1 rillig # Tests for interrupting a command. 4 1.1 rillig # 5 1.1 rillig # If a command is interrupted (usually by the user, here by itself), the 6 1.1 rillig # target is removed. This is to avoid having an unfinished target that 7 1.1 rillig # would be newer than all of its sources and would therefore not be 8 1.1 rillig # tried again in the next run. 9 1.1 rillig # 10 1.2 rillig # This happens for ordinary targets as well as for .PHONY targets, even 11 1.2 rillig # though the .PHONY targets usually do not correspond to a file. 12 1.2 rillig # 13 1.2 rillig # To protect the target from being removed, the target has to be marked with 14 1.2 rillig # the special source .PRECIOUS. These targets need to ensure for themselves 15 1.2 rillig # that interrupting them does not leave an inconsistent state behind. 16 1.2 rillig # 17 1.2 rillig # See also: 18 1.2 rillig # CompatDeleteTarget 19 1.1 rillig 20 1.2 rillig all: clean-before interrupt-ordinary interrupt-phony interrupt-precious clean-after 21 1.1 rillig 22 1.2 rillig clean-before clean-after: .PHONY 23 1.2 rillig @rm -f cmd-interrupt-ordinary cmd-interrupt-phony cmd-interrupt-precious 24 1.1 rillig 25 1.3 rillig interrupt-ordinary: 26 1.2 rillig @${.MAKE} ${MAKEFLAGS} -f ${MAKEFILE} cmd-interrupt-ordinary || true 27 1.2 rillig # The ././ is necessary to work around the file cache. 28 1.2 rillig @echo ${.TARGET}: ${exists(././cmd-interrupt-ordinary) :? error : ok } 29 1.2 rillig 30 1.2 rillig interrupt-phony: .PHONY 31 1.2 rillig @${.MAKE} ${MAKEFLAGS} -f ${MAKEFILE} cmd-interrupt-phony || true 32 1.2 rillig # The ././ is necessary to work around the file cache. 33 1.4 sjg @echo ${.TARGET}: ${exists(././cmd-interrupt-phony) :? ok : error } 34 1.2 rillig 35 1.2 rillig interrupt-precious: .PRECIOUS 36 1.2 rillig @${.MAKE} ${MAKEFLAGS} -f ${MAKEFILE} cmd-interrupt-precious || true 37 1.2 rillig # The ././ is necessary to work around the file cache. 38 1.2 rillig @echo ${.TARGET}: ${exists(././cmd-interrupt-precious) :? ok : error } 39 1.1 rillig 40 1.1 rillig cmd-interrupt-ordinary: 41 1.1 rillig > ${.TARGET} 42 1.2 rillig @kill -INT ${.MAKE.PID} 43 1.1 rillig 44 1.1 rillig cmd-interrupt-phony: .PHONY 45 1.1 rillig > ${.TARGET} 46 1.2 rillig @kill -INT ${.MAKE.PID} 47 1.2 rillig 48 1.2 rillig cmd-interrupt-precious: .PRECIOUS 49 1.2 rillig > ${.TARGET} 50 1.2 rillig @kill -INT ${.MAKE.PID} 51