directive.mk revision 1.7
11.7Srillig# $NetBSD: directive.mk,v 1.7 2023/08/19 10:52:14 rillig Exp $
21.1Srillig#
31.2Srillig# Tests for the preprocessing directives, such as .if or .info.
41.1Srillig
51.1Srillig# TODO: Implementation
61.1Srillig
71.3Srillig# Unknown directives are correctly named in the error messages,
81.3Srillig# even if they are indented.
91.6Srillig# expect+1: Unknown directive "indented"
101.3Srillig.indented none
111.6Srillig# expect+1: Unknown directive "indented"
121.3Srillig.  indented 2 spaces
131.6Srillig# expect+1: Unknown directive "indented"
141.3Srillig.	indented tab
151.3Srillig
161.3Srillig# Directives must be written directly, not indirectly via variable
171.3Srillig# expressions.
181.6Srillig# FIXME: The error message is misleading because it shows the expanded text of
191.6Srillig#  the line, while the parser works on the unexpanded line.
201.6Srillig# expect+1: Unknown directive "info"
211.3Srillig.${:Uinfo} directives cannot be indirect
221.3Srillig
231.4Srillig# There is no directive called '.target', therefore this is parsed as a
241.4Srillig# dependency declaration with 2 targets and 1 source.
251.4Srillig.target target: source
261.4Srillig
271.6Srillig# The following lines demonstrate how the parser tells an .info message apart
281.6Srillig# from a variable assignment to ".info", which syntactically is very similar.
291.4Srillig.MAKEFLAGS: -dv
301.6Srillig.info:=		value		# This is a variable assignment.
311.4Srillig.info?=		value		# This is a variable assignment as well.
321.6Srillig# expect+1: :=	value
331.4Srillig.info :=	value		# The space after the '.info' makes this
341.4Srillig				# a directive.
351.4Srillig.MAKEFLAGS: -d0
361.4Srillig
371.4Srillig# This is a dependency since directives must be given directly.
381.4Srillig# Not even the space after the '.info' can change anything about this.
391.4Srillig.${:Uinfo} : source
401.4Srillig
411.7Srillig# expect+1: Invalid line 'target-without-colon'
421.5Srilligtarget-without-colon
431.5Srillig
441.7Srillig# expect+1: Invalid line 'target-without-colon another-target'
451.5Srilligtarget-without-colon another-target
46