xref: /freebsd/contrib/bmake/unit-tests/deptgt.mk (revision 4d846d26)
1# $NetBSD: deptgt.mk,v 1.13 2023/01/03 00:00:45 rillig Exp $
2#
3# Tests for special targets like .BEGIN or .SUFFIXES in dependency
4# declarations.
5
6# TODO: Implementation
7
8# Just in case anyone tries to compile several special targets in a single
9# dependency line: That doesn't work, and make immediately rejects it.
10.SUFFIXES .PHONY: .c.o
11
12# The following lines demonstrate how 'targets' is set and reset during
13# parsing of dependencies.  To see it in action, set breakpoints in:
14#
15#	ParseDependency		at the beginning
16#	FinishDependencyGroup	at "targets = NULL"
17#	Parse_File		at "Lst_Free(targets)"
18#	Parse_File		at "targets = Lst_New()"
19#	ParseLine_ShellCommand	at "targets == NULL"
20#
21# Keywords:
22#	parse.c:targets
23
24target1 target2: sources	# targets := [target1, target2]
25	: command1		# targets == [target1, target2]
26	: command2		# targets == [target1, target2]
27VAR=value			# targets := NULL
28	: command3		# parse error, since targets == NULL
29
30# In a dependency declaration, the list of targets can be empty.
31# It doesn't matter whether the empty string is generated by a variable
32# expression or whether it is just omitted.
33.MAKEFLAGS: -dp
34${:U}: empty-source
35	: command for empty targets list
36: empty-source
37	: command for empty targets list
38.MAKEFLAGS: -d0
39
40# Just to show that a malformed expression is only expanded once in
41# ParseDependencyTargetWord.  The only way to produce an expression that
42# is well-formed on the first expansion and ill-formed on the second
43# expansion would be to use the variable modifier '::=' to modify the
44# targets.  This in turn would be such an extreme and unreliable edge case
45# that nobody uses it.
46$$$$$$$${:U:Z}:
47
48# expect+1: warning: Extra target 'ordinary' ignored
49.END ordinary:
50
51# expect+1: warning: Extra target (ordinary) ignored
52.PATH ordinary:
53
54# expect+1: Special and mundane targets don't mix. Mundane ones ignored
55ordinary .PATH:
56
57all:
58	@:;
59