xref: /freebsd/contrib/bmake/unit-tests/opt-no-action-touch.mk (revision dba7b0ef928af88caa38728a73657b837aeeac93)
1*dba7b0efSSimon J. Gerraty# $NetBSD: opt-no-action-touch.mk,v 1.1 2021/01/30 12:46:38 rillig Exp $
2*dba7b0efSSimon J. Gerraty#
3*dba7b0efSSimon J. Gerraty# Tests for combining the command line options -n (no action) and -t (touch).
4*dba7b0efSSimon J. Gerraty# This combination is unusual and probably doesn't ever happen in practice,
5*dba7b0efSSimon J. Gerraty# but still make needs to behave as expected.  The option -n is stronger than
6*dba7b0efSSimon J. Gerraty# -t, so instead of being touched, the commands of the targets are printed.
7*dba7b0efSSimon J. Gerraty#
8*dba7b0efSSimon J. Gerraty# See also:
9*dba7b0efSSimon J. Gerraty#	opt-touch-jobs.mk contains the same test without the option -n.
10*dba7b0efSSimon J. Gerraty
11*dba7b0efSSimon J. Gerraty.MAKEFLAGS: -j1 -n -t
12*dba7b0efSSimon J. Gerraty.MAKEFLAGS: opt-touch-phony
13*dba7b0efSSimon J. Gerraty.MAKEFLAGS: opt-touch-join
14*dba7b0efSSimon J. Gerraty.MAKEFLAGS: opt-touch-use
15*dba7b0efSSimon J. Gerraty.MAKEFLAGS: opt-touch-make
16*dba7b0efSSimon J. Gerraty.MAKEFLAGS: opt-touch-regular
17*dba7b0efSSimon J. Gerraty
18*dba7b0efSSimon J. Gerraty# .PHONY targets are not touched since they do not represent actual files.
19*dba7b0efSSimon J. Gerraty# See Job_Touch.
20*dba7b0efSSimon J. Gerratyopt-touch-phony: .PHONY
21*dba7b0efSSimon J. Gerraty	: Making $@.
22*dba7b0efSSimon J. Gerraty
23*dba7b0efSSimon J. Gerraty# .JOIN targets are not touched since they do not represent actual files.
24*dba7b0efSSimon J. Gerraty# See Job_Touch.
25*dba7b0efSSimon J. Gerratyopt-touch-join: .JOIN
26*dba7b0efSSimon J. Gerraty	: Making $@.
27*dba7b0efSSimon J. Gerraty
28*dba7b0efSSimon J. Gerraty# .USE targets are not touched since they do not represent actual files.
29*dba7b0efSSimon J. Gerraty# See Job_Touch.
30*dba7b0efSSimon J. Gerratyopt-touch-use: .USE
31*dba7b0efSSimon J. Gerraty	: Making use of $@.
32*dba7b0efSSimon J. Gerraty
33*dba7b0efSSimon J. Gerraty# The attribute .MAKE is stronger than the command line option -n.  Therefore
34*dba7b0efSSimon J. Gerraty# this target is run as usual.  It is not prefixed by '@', therefore it is
35*dba7b0efSSimon J. Gerraty# printed before being run.
36*dba7b0efSSimon J. Gerratyopt-touch-make: .MAKE
37*dba7b0efSSimon J. Gerraty	echo 'Making $@.'
38*dba7b0efSSimon J. Gerraty
39*dba7b0efSSimon J. Gerraty# Since the option -n is stronger than the option -t, this target is not
40*dba7b0efSSimon J. Gerraty# touched either.  Without the -n, it would be touched.
41*dba7b0efSSimon J. Gerratyopt-touch-regular:
42*dba7b0efSSimon J. Gerraty	: Making $@.
43*dba7b0efSSimon J. Gerraty
44*dba7b0efSSimon J. Gerraty# Since none of the above targets are actually touched, the following command
45*dba7b0efSSimon J. Gerraty# does not output anything.
46*dba7b0efSSimon J. Gerraty.END:
47*dba7b0efSSimon J. Gerraty	@files=$$(ls opt-touch-* 2>/dev/null | grep -v -e '\.'); \
48*dba7b0efSSimon J. Gerraty	[ -z "$$files" ] || { echo "created files: $$files" 1>&2; exit 1; }
49