Home | History | Annotate | Line # | Download | only in unit-tests
deptgt.mk revision 1.22
      1 # $NetBSD: deptgt.mk,v 1.22 2025/01/10 23:00:38 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 # An expression based on an undefined variable is allowed on both sides of
     43 # the dependency declaration.
     44 .MAKEFLAGS: -dv
     45 deptgt-${UNDEF}: depsrc-${UNDEF}
     46 .MAKEFLAGS: -d0
     47 
     48 # In a dependency declaration, the whole line is expanded before interpreting
     49 # the line.
     50 # expect+1: Unknown modifier "Z"
     51 ${:U:Z}:
     52 # After expanding the line as a whole, each target is parsed but not
     53 # evaluated, separately, in ParseDependencyTargetWord.
     54 # expect+1: Unknown modifier "Z"
     55 $${:U:Z}:
     56 
     57 # expect+1: warning: Extra target 'ordinary' ignored
     58 .END ordinary:
     59 
     60 # expect+1: warning: Extra target (ordinary) ignored
     61 .PATH ordinary:
     62 
     63 # expect+1: warning: Special and mundane targets don't mix. Mundane ones ignored
     64 ordinary .PATH:
     65