xref: /freebsd/contrib/bmake/unit-tests/deptgt.mk (revision 6a7405f5a6b639682cacf01e35d561411ff556aa)
1*6a7405f5SSimon J. Gerraty# $NetBSD: deptgt.mk,v 1.22 2025/01/10 23:00:38 rillig Exp $
22c3632d1SSimon J. Gerraty#
32c3632d1SSimon J. Gerraty# Tests for special targets like .BEGIN or .SUFFIXES in dependency
42c3632d1SSimon J. Gerraty# declarations.
52c3632d1SSimon J. Gerraty
62c3632d1SSimon J. Gerraty# TODO: Implementation
72c3632d1SSimon J. Gerraty
8956e45f6SSimon J. Gerraty# Just in case anyone tries to compile several special targets in a single
9956e45f6SSimon J. Gerraty# dependency line: That doesn't work, and make immediately rejects it.
10148ee845SSimon J. Gerraty# expect+1: warning: Extra target '.PHONY' ignored
11956e45f6SSimon J. Gerraty.SUFFIXES .PHONY: .c.o
12956e45f6SSimon J. Gerraty
13956e45f6SSimon J. Gerraty# The following lines demonstrate how 'targets' is set and reset during
14956e45f6SSimon J. Gerraty# parsing of dependencies.  To see it in action, set breakpoints in:
15956e45f6SSimon J. Gerraty#
16b0c40a00SSimon J. Gerraty#	ParseDependency		at the beginning
17956e45f6SSimon J. Gerraty#	FinishDependencyGroup	at "targets = NULL"
18956e45f6SSimon J. Gerraty#	Parse_File		at "Lst_Free(targets)"
19956e45f6SSimon J. Gerraty#	Parse_File		at "targets = Lst_New()"
20956e45f6SSimon J. Gerraty#	ParseLine_ShellCommand	at "targets == NULL"
21956e45f6SSimon J. Gerraty#
22956e45f6SSimon J. Gerraty# Keywords:
23956e45f6SSimon J. Gerraty#	parse.c:targets
24956e45f6SSimon J. Gerraty
25956e45f6SSimon J. Gerratytarget1 target2: sources	# targets := [target1, target2]
26956e45f6SSimon J. Gerraty	: command1		# targets == [target1, target2]
27956e45f6SSimon J. Gerraty	: command2		# targets == [target1, target2]
28956e45f6SSimon J. GerratyVAR=value			# targets := NULL
29148ee845SSimon J. Gerraty# expect+1: Unassociated shell command ": command3		# parse error, since targets == NULL"
30956e45f6SSimon J. Gerraty	: command3		# parse error, since targets == NULL
31956e45f6SSimon J. Gerraty
32e2eeea75SSimon J. Gerraty# In a dependency declaration, the list of targets can be empty.
33d5e0a182SSimon J. Gerraty# It doesn't matter whether the empty string is generated by an
34e2eeea75SSimon J. Gerraty# expression or whether it is just omitted.
35e2eeea75SSimon J. Gerraty.MAKEFLAGS: -dp
36e2eeea75SSimon J. Gerraty${:U}: empty-source
37e2eeea75SSimon J. Gerraty	: command for empty targets list
38e2eeea75SSimon J. Gerraty: empty-source
39e2eeea75SSimon J. Gerraty	: command for empty targets list
40e2eeea75SSimon J. Gerraty.MAKEFLAGS: -d0
41e2eeea75SSimon J. Gerraty
42*6a7405f5SSimon J. Gerraty# An expression based on an undefined variable is allowed on both sides of
43*6a7405f5SSimon J. Gerraty# the dependency declaration.
44*6a7405f5SSimon J. Gerraty.MAKEFLAGS: -dv
45*6a7405f5SSimon J. Gerratydeptgt-${UNDEF}: depsrc-${UNDEF}
46*6a7405f5SSimon J. Gerraty.MAKEFLAGS: -d0
47*6a7405f5SSimon J. Gerraty
4822619282SSimon J. Gerraty# In a dependency declaration, the whole line is expanded before interpreting
4922619282SSimon J. Gerraty# the line.
50*6a7405f5SSimon J. Gerraty# expect+1: Unknown modifier "Z"
5122619282SSimon J. Gerraty${:U:Z}:
5222619282SSimon J. Gerraty# After expanding the line as a whole, each target is parsed but not
5322619282SSimon J. Gerraty# evaluated, separately, in ParseDependencyTargetWord.
54*6a7405f5SSimon J. Gerraty# expect+1: Unknown modifier "Z"
5522619282SSimon J. Gerraty$${:U:Z}:
5606b9b3e0SSimon J. Gerraty
574fde40d9SSimon J. Gerraty# expect+1: warning: Extra target 'ordinary' ignored
589f45a3c8SSimon J. Gerraty.END ordinary:
599f45a3c8SSimon J. Gerraty
609f45a3c8SSimon J. Gerraty# expect+1: warning: Extra target (ordinary) ignored
619f45a3c8SSimon J. Gerraty.PATH ordinary:
629f45a3c8SSimon J. Gerraty
63d5e0a182SSimon J. Gerraty# expect+1: warning: Special and mundane targets don't mix. Mundane ones ignored
649f45a3c8SSimon J. Gerratyordinary .PATH:
65