deptgt.mk revision 1.17.2.1       1  1.17.2.1  perseant # $NetBSD: deptgt.mk,v 1.17.2.1 2025/08/02 05:58:33 perseant Exp $
      2       1.1    rillig #
      3       1.2    rillig # Tests for special targets like .BEGIN or .SUFFIXES in dependency
      4       1.2    rillig # declarations.
      5       1.1    rillig 
      6       1.1    rillig # TODO: Implementation
      7       1.1    rillig 
      8       1.3    rillig # Just in case anyone tries to compile several special targets in a single
      9       1.3    rillig # dependency line: That doesn't work, and make immediately rejects it.
     10  1.17.2.1  perseant # expect+1: warning: Extra target ".PHONY" ignored
     11       1.3    rillig .SUFFIXES .PHONY: .c.o
     12       1.3    rillig 
     13       1.5    rillig # The following lines demonstrate how 'targets' is set and reset during
     14       1.4    rillig # parsing of dependencies.  To see it in action, set breakpoints in:
     15       1.4    rillig #
     16      1.11    rillig #	ParseDependency		at the beginning
     17       1.6    rillig #	FinishDependencyGroup	at "targets = NULL"
     18       1.4    rillig #	Parse_File		at "Lst_Free(targets)"
     19       1.8    rillig #	Parse_File		at "targets = Lst_New()"
     20       1.7    rillig #	ParseLine_ShellCommand	at "targets == NULL"
     21       1.4    rillig #
     22       1.5    rillig # Keywords:
     23       1.5    rillig #	parse.c:targets
     24       1.5    rillig 
     25       1.5    rillig target1 target2: sources	# targets := [target1, target2]
     26       1.5    rillig 	: command1		# targets == [target1, target2]
     27       1.5    rillig 	: command2		# targets == [target1, target2]
     28       1.5    rillig VAR=value			# targets := NULL
     29      1.14    rillig # expect+1: Unassociated shell command ": command3		# parse error, since targets == NULL"
     30       1.5    rillig 	: command3		# parse error, since targets == NULL
     31       1.4    rillig 
     32       1.9    rillig # In a dependency declaration, the list of targets can be empty.
     33      1.15    rillig # It doesn't matter whether the empty string is generated by an
     34       1.9    rillig # expression or whether it is just omitted.
     35       1.9    rillig .MAKEFLAGS: -dp
     36       1.9    rillig ${:U}: empty-source
     37       1.9    rillig 	: command for empty targets list
     38       1.9    rillig : empty-source
     39       1.9    rillig 	: command for empty targets list
     40       1.9    rillig .MAKEFLAGS: -d0
     41       1.9    rillig 
     42  1.17.2.1  perseant # An expression based on an undefined variable is allowed on both sides of
     43  1.17.2.1  perseant # the dependency declaration.
     44  1.17.2.1  perseant .MAKEFLAGS: -dv
     45  1.17.2.1  perseant deptgt-${UNDEF}: depsrc-${UNDEF}
     46  1.17.2.1  perseant .MAKEFLAGS: -d0
     47  1.17.2.1  perseant 
     48  1.17.2.1  perseant # In a dependency declaration, the whole line is expanded before interpreting
     49  1.17.2.1  perseant # the line.
     50  1.17.2.1  perseant # expect+1: Unknown modifier ":Z"
     51  1.17.2.1  perseant ${:U:Z}:
     52  1.17.2.1  perseant # After expanding the line as a whole, each target is parsed but not
     53  1.17.2.1  perseant # evaluated, separately, in ParseDependencyTargetWord.
     54  1.17.2.1  perseant # expect+1: Unknown modifier ":Z"
     55  1.17.2.1  perseant $${:U:Z}:
     56      1.10    rillig 
     57  1.17.2.1  perseant # expect+1: warning: Extra target "ordinary" ignored
     58      1.12    rillig .END ordinary:
     59      1.12    rillig 
     60  1.17.2.1  perseant # expect+1: warning: Extra target "ordinary" ignored
     61      1.12    rillig .PATH ordinary:
     62      1.12    rillig 
     63      1.16    rillig # expect+1: warning: Special and mundane targets don't mix. Mundane ones ignored
     64      1.12    rillig ordinary .PATH:
     65