xref: /freebsd/contrib/bmake/unit-tests/deptgt-delete_on_error.mk (revision 148ee84570001f46b7b667c86573d378101c3801)
1*148ee845SSimon J. Gerraty# $NetBSD: deptgt-delete_on_error.mk,v 1.4 2023/06/01 20:56:35 rillig Exp $
22c3632d1SSimon J. Gerraty#
3956e45f6SSimon J. Gerraty# Tests for the special target .DELETE_ON_ERROR in dependency declarations,
4956e45f6SSimon J. Gerraty# which controls whether the target is deleted if a shell command fails or
5956e45f6SSimon J. Gerraty# is interrupted.
6956e45f6SSimon J. Gerraty#
7956e45f6SSimon J. Gerraty# In compatibility mode, regular and phony targets are deleted, but precious
8956e45f6SSimon J. Gerraty# targets are preserved.
9956e45f6SSimon J. Gerraty#
10956e45f6SSimon J. Gerraty# In parallel mode, regular targets are deleted, while phony and precious
11956e45f6SSimon J. Gerraty# targets are preserved.
12956e45f6SSimon J. Gerraty#
13956e45f6SSimon J. Gerraty# See also:
14956e45f6SSimon J. Gerraty#	CompatDeleteTarget
15956e45f6SSimon J. Gerraty#	JobDeleteTarget
162c3632d1SSimon J. Gerraty
17956e45f6SSimon J. GerratyTHIS=		deptgt-delete_on_error
18956e45f6SSimon J. GerratyTARGETS=	${THIS}-regular ${THIS}-regular-delete
19956e45f6SSimon J. GerratyTARGETS+=	${THIS}-phony ${THIS}-phony-delete
20956e45f6SSimon J. GerratyTARGETS+=	${THIS}-precious ${THIS}-precious-delete
212c3632d1SSimon J. Gerraty
222c3632d1SSimon J. Gerratyall:
23956e45f6SSimon J. Gerraty	@rm -f ${TARGETS}
24956e45f6SSimon J. Gerraty	@echo 'Compatibility mode'
25956e45f6SSimon J. Gerraty	@-${.MAKE} -f ${MAKEFILE} -k ${TARGETS}
26956e45f6SSimon J. Gerraty	@rm -f ${TARGETS}
27956e45f6SSimon J. Gerraty	@echo
28956e45f6SSimon J. Gerraty	@echo 'Parallel mode'
29956e45f6SSimon J. Gerraty	@-${.MAKE} -f ${MAKEFILE} -k -j1 ${TARGETS}
30956e45f6SSimon J. Gerraty	@rm -f ${TARGETS}
31956e45f6SSimon J. Gerraty
32956e45f6SSimon J. Gerraty${THIS}-regular{,-delete}:
33956e45f6SSimon J. Gerraty	> ${.TARGET}; false
34956e45f6SSimon J. Gerraty
35956e45f6SSimon J. Gerraty${THIS}-phony{,-delete}: .PHONY
36956e45f6SSimon J. Gerraty	> ${.TARGET}; false
37956e45f6SSimon J. Gerraty
38956e45f6SSimon J. Gerraty${THIS}-precious{,-delete}: .PRECIOUS
39956e45f6SSimon J. Gerraty	> ${.TARGET}; false
40956e45f6SSimon J. Gerraty
41956e45f6SSimon J. Gerraty# The special target .DELETE_ON_ERROR is a global setting.
42956e45f6SSimon J. Gerraty# It does not apply to single targets.
43956e45f6SSimon J. Gerraty# The following line is therefore misleading but does not generate any
44956e45f6SSimon J. Gerraty# warning or even an error message.
45956e45f6SSimon J. Gerraty.DELETE_ON_ERROR: ${TARGETS:M*-delete}
46