summaryrefslogtreecommitdiff
path: root/unit-tests/opt-no-action.mk
blob: 91c05b2dc00f9ac0e250e526f4e7d96fd0f64d39 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# $NetBSD: opt-no-action.mk,v 1.4 2020/11/09 20:50:56 rillig Exp $
#
# Tests for the -n command line option, which runs almost no commands.
# It just outputs them, to be inspected by human readers.
# Only commands that are in a .MAKE target or prefixed by '+' are run.

.MAKEFLAGS: -n

# This command cannot be prevented from being run since it is used at parse
# time, and any later variable assignments may depend on its result.
!=	echo 'command during parsing' 1>&2; echo

all: main
all: run-always

# Both of these commands are printed, but only the '+' command is run.
.BEGIN:
	@echo '$@: hidden command'
	@+echo '$@: run always'

# Both of these commands are printed, but only the '+' command is run.
main:
	@echo '$@: hidden command'
	@+echo '$@: run always'

# None of these commands is printed, but both are run, because this target
# depends on the special source ".MAKE".
run-always: .MAKE
	@echo '$@: hidden command'
	@+echo '$@: run always'

# Both of these commands are printed, but only the '+' command is run.
.END:
	@echo '$@: hidden command'
	@+echo '$@: run always'