1 # $NetBSD: cond-func.mk,v 1.9 2020/11/15 14:07:53 rillig Exp $
3 # Tests for those parts of the functions in .if conditions that are common
4 # among several functions.
6 # The below test uses the function defined(...) since it has no side-effects,
7 # the other functions (except empty(...)) would work equally well. The
8 # function empty is special because it uses a different parsing algorithm for
12 ${:UA B}= variable name with spaces
13 ${:UVAR(value)}= variable name with parentheses
14 ${:UVAR{value}}= variable name with balanced braces
16 # Really strange variable names must be given indirectly via another variable,
17 # so that no unbalanced braces appear in the top-level expression.
18 VARNAME_UNBALANCED_BRACES= VAR{{{value
19 ${VARNAME_UNBALANCED_BRACES}= variable name with unbalanced braces
25 # Horizontal whitespace (space tab) after the opening parenthesis is ignored.
30 # Horizontal whitespace (space tab) before the closing parenthesis is ignored.
35 # The argument of a function must not directly contain whitespace.
40 # If necessary, the whitespace can be generated by a variable expression.
41 .if !defined(${:UA B})
45 # Characters that could be mistaken for operators must not appear directly
46 # in a function argument. As with whitespace, these can be generated
49 # It's not entirely clear why these characters are forbidden.
50 # The most plausible reason seems to be typo detection.
58 # Even parentheses may appear in variable names.
59 # They must be balanced though.
60 .if !defined(VAR(value))
64 # Braces do not have any special meaning when parsing arguments.
65 .if !defined(VAR{value})
69 # Braces do not have any special meaning when parsing arguments.
70 # They don't need to be balanced.
71 .if !defined(VAR{{{value)
75 # There may be spaces around the operators and parentheses, and even
76 # inside the parentheses. The spaces inside the parentheses are not
77 # allowed for the empty() function (see cond-func-empty.mk), therefore
78 # they are typically omitted for the other functions as well.
83 # The following condition is interpreted as defined(A) && defined(B).
84 # In lack of a function call expression, each kind of .if directive has a
85 # default function that is called when a bare word is parsed. For the plain
86 # .if directive, this function is defined(); see "struct If ifs" in cond.c.
94 . info The empty variable is never defined.
97 # The plain word 'defined' is interpreted as '!empty(defined)'.
98 # That variable is not defined (yet).
102 . info A plain function name is parsed as !empty(...).
105 # If a variable named 'defined' is actually defined and not empty, the plain
106 # symbol 'defined' evaluates to true.
109 . info A plain function name is parsed as !empty(...).
114 # A plain symbol name may start with one of the function names, in this case
119 . info Symbols may start with a function name.
122 defined-var= non-empty
124 . info Symbols may start with a function name.
129 # Missing closing parenthesis when parsing the function argument.