1# $NetBSD: cond-func-defined.mk,v 1.11 2023/11/19 21:47:52 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# expect+1: Missing closing parenthesis for defined()
24.if !defined(A B)
25.  error
26.endif
27
28# If necessary, the whitespace can be generated by an expression.
29.if !defined(${:UA B})
30.  error
31.endif
32
33# expect+1: Missing closing parenthesis for defined()
34.if defined(DEF
35.  error
36.else
37.  error
38.endif
39
40# Variables from .for loops are not defined.
41# See directive-for.mk for more details.
42.for var in value
43.  if defined(var)
44.    error
45.  else
46# expect+1: In .for loops, expressions for the loop variables are
47.    info In .for loops, expressions for the loop variables are
48# expect+1: substituted at evaluation time.  There is no actual variable
49.    info substituted at evaluation time.  There is no actual variable
50# expect+1: involved, even if it feels like it.
51.    info involved, even if it feels like it.
52.  endif
53.endfor
54
55# Neither of the conditions is true.  Before July 2020, the right-hand
56# condition was evaluated even though it was irrelevant.
57.if defined(UNDEF) && ${UNDEF:Mx} != ""
58.  error
59.endif
60
61all: .PHONY
62