deptgt.mk revision 1.20 1 # $NetBSD: deptgt.mk,v 1.20 2024/07/06 10:14: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
25 target1 target2: sources # targets := [target1, target2]
26 : command1 # targets == [target1, target2]
27 : command2 # targets == [target1, target2]
28 VAR=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 an
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 # In a dependency declaration, the whole line is expanded before interpreting
43 # the line.
44 # expect+1: while evaluating "${:U:Z}:" with value "": Unknown modifier "Z"
45 ${:U:Z}:
46 # After expanding the line as a whole, each target is parsed but not
47 # evaluated, separately, in ParseDependencyTargetWord.
48 # expect+1: while parsing "${:U:Z}:": 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: warning: Special and mundane targets don't mix. Mundane ones ignored
58 ordinary .PATH:
59