summaryrefslogtreecommitdiff
path: root/usr.bin/make/unit-tests/cond-func-defined.mk
blob: 10adfde292edaadb6c1e8c59d73ee65e35a60ca3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# $NetBSD: cond-func-defined.mk,v 1.10 2023/06/01 20:56:35 rillig Exp $
#
# Tests for the defined() function in .if conditions.

DEF=		defined
${:UA B}=	variable name with spaces

.if !defined(DEF)
.  error
.endif

# Horizontal whitespace (space tab) after the opening parenthesis is ignored.
.if !defined( 	DEF)
.  error
.endif

# Horizontal whitespace (space tab) before the closing parenthesis is ignored.
.if !defined(DEF 	)
.  error
.endif

# The argument of a function must not directly contain whitespace.
# expect+1: Missing closing parenthesis for defined()
.if !defined(A B)
.  error
.endif

# If necessary, the whitespace can be generated by a variable expression.
.if !defined(${:UA B})
.  error
.endif

# expect+1: Missing closing parenthesis for defined()
.if defined(DEF
.  error
.else
.  error
.endif

# Variables from .for loops are not defined.
# See directive-for.mk for more details.
.for var in value
.  if defined(var)
.    error
.  else
# expect+1: In .for loops, variable expressions for the loop variables are
.    info In .for loops, variable expressions for the loop variables are
# expect+1: substituted at evaluation time.  There is no actual variable
.    info substituted at evaluation time.  There is no actual variable
# expect+1: involved, even if it feels like it.
.    info involved, even if it feels like it.
.  endif
.endfor

# Neither of the conditions is true.  Before July 2020, the right-hand
# condition was evaluated even though it was irrelevant.
.if defined(UNDEF) && ${UNDEF:Mx} != ""
.  error
.endif

all: .PHONY