cond-func-defined.mk revision 1.8
11.8Srillig# $NetBSD: cond-func-defined.mk,v 1.8 2021/12/12 08:55:28 rillig Exp $
21.1Srillig#
31.2Srillig# Tests for the defined() function in .if conditions.
41.1Srillig
51.3SrilligDEF=		defined
61.3Srillig${:UA B}=	variable name with spaces
71.3Srillig
81.3Srillig.if !defined(DEF)
91.5Srillig.  error
101.3Srillig.endif
111.3Srillig
121.4Srillig# Horizontal whitespace (space tab) after the opening parenthesis is ignored.
131.3Srillig.if !defined( 	DEF)
141.5Srillig.  error
151.3Srillig.endif
161.3Srillig
171.4Srillig# Horizontal whitespace (space tab) before the closing parenthesis is ignored.
181.3Srillig.if !defined(DEF 	)
191.5Srillig.  error
201.3Srillig.endif
211.3Srillig
221.3Srillig# The argument of a function must not directly contain whitespace.
231.3Srillig.if !defined(A B)
241.5Srillig.  error
251.3Srillig.endif
261.3Srillig
271.3Srillig# If necessary, the whitespace can be generated by a variable expression.
281.3Srillig.if !defined(${:UA B})
291.5Srillig.  error
301.3Srillig.endif
311.1Srillig
321.8Srillig# Parse error: missing closing parenthesis; see ParseWord.
331.6Srillig.if defined(DEF
341.6Srillig.  error
351.6Srillig.else
361.6Srillig.  error
371.6Srillig.endif
381.6Srillig
391.7Srillig# Variables from .for loops are not defined.
401.7Srillig# See directive-for.mk for more details.
411.7Srillig.for var in value
421.7Srillig.  if defined(var)
431.7Srillig.    error
441.7Srillig.  else
451.7Srillig.    info In .for loops, variable expressions for the loop variables are
461.7Srillig.    info substituted at evaluation time.  There is no actual variable
471.7Srillig.    info involved, even if it feels like it.
481.7Srillig.  endif
491.7Srillig.endfor
501.7Srillig
511.1Srilligall:
521.1Srillig	@:;
53