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