1 # $NetBSD: cond-token-plain.mk,v 1.6 2020/11/15 14:58:14 rillig Exp $
3 # Tests for plain tokens (that is, string literals without quotes)
8 .if ${:Uvalue} != value
12 # Malformed condition since comment parsing is done in an early phase
13 # and removes the '#' and everything behind it long before the condition
14 # parser gets to see it.
16 # XXX: The error message is missing for this malformed condition.
17 # The right-hand side of the comparison is just a '"', before unescaping.
22 # To get a '#' into a condition, it has to be escaped using a backslash.
23 # This prevents the comment parser from removing it, and in turn, it becomes
24 # visible to CondParser_String.
25 .if ${:U\#hash} != "\#hash"
29 # Since 2002-12-30, and still as of 2020-09-11, CondParser_Token handles
30 # the '#' specially, even though at this point, there should be no need for
31 # comment handling anymore. The comments are supposed to be stripped off
32 # in a very early parsing phase.
34 # See https://gnats.netbsd.org/19596 for example makefiles demonstrating the
35 # original problems. This workaround is probably not needed anymore.
37 # XXX: Missing error message for the malformed condition. The right-hand
38 # side before unescaping is double-quotes, backslash, backslash.
39 .if ${:U\\} != "\\#hash"
43 # The right-hand side of a comparison is not parsed as a token, therefore
44 # the code from CondParser_Token does not apply to it.
45 # TODO: Explain the consequences.
46 # TODO: Does this mean that more syntactic variants are allowed here?
47 .if ${:U\#hash} != \#hash
51 # XXX: What is the purpose of treating an escaped '#' in the following
52 # condition as a comment? And why only at the beginning of a token,
53 # just as in the shell?
54 .if 0 \# This is treated as a comment, but why?
58 # Ah, ok, this can be used to add an end-of-condition comment. But does
59 # anybody really use this? This is neither documented nor obvious since
60 # the '#' is escaped. It's much clearer to write a comment in the line
61 # above the condition.
62 .if ${0 \# comment :?yes:no} != no
65 .if ${1 \# comment :?yes:no} != yes
69 # Usually there is whitespace around the comparison operator, but this is
71 .if ${UNDEF:Uundefined}!=undefined
74 .if ${UNDEF:U12345}>12345
77 .if ${UNDEF:U12345}<12345
84 # Only the comparison operator terminates the comparison operand, and it's
85 # a coincidence that the '!' is both used in the '!=' comparison operator
86 # as well as for negating a comparison result.
88 # The boolean operators '&' and '|' don't terminate a comparison operand.
89 .if ${:Uvar}&&name != "var&&name"
92 .if ${:Uvar}||name != "var||name"