1# $NetBSD: cond-func-defined.mk,v 1.9 2022/05/08 06:51:27 rillig Exp $
2#
3# Tests for the defined() function in .if conditions.
4
5DEF=		defined
6${:UA B}=	variable name with spaces
7
8.if !defined(DEF)
9.  error
10.endif
11
12# Horizontal whitespace (space tab) after the opening parenthesis is ignored.
13.if !defined( 	DEF)
14.  error
15.endif
16
17# Horizontal whitespace (space tab) before the closing parenthesis is ignored.
18.if !defined(DEF 	)
19.  error
20.endif
21
22# The argument of a function must not directly contain whitespace.
23.if !defined(A B)
24.  error
25.endif
26
27# If necessary, the whitespace can be generated by a variable expression.
28.if !defined(${:UA B})
29.  error
30.endif
31
32# Parse error: missing closing parenthesis; see ParseWord.
33.if defined(DEF
34.  error
35.else
36.  error
37.endif
38
39# Variables from .for loops are not defined.
40# See directive-for.mk for more details.
41.for var in value
42.  if defined(var)
43.    error
44.  else
45.    info In .for loops, variable expressions for the loop variables are
46.    info substituted at evaluation time.  There is no actual variable
47.    info involved, even if it feels like it.
48.  endif
49.endfor
50
51# Neither of the conditions is true.  Before July 2020, the right-hand
52# condition was evaluated even though it was irrelevant.
53.if defined(UNDEF) && ${UNDEF:Mx} != ""
54.  error
55.endif
56
57all: .PHONY
58