1 # $NetBSD: cond-op.mk,v 1.4 2020/08/28 14:07:51 rillig Exp $
3 # Tests for operators like &&, ||, ! in .if conditions.
9 # cond-op-parentheses.mk
11 # In make, && binds more tightly than ||, like in C.
12 # If make had the same precedence for both && and ||, the result would be
14 # If || were to bind more tightly than &&, the result would be different
20 # If make were to interpret the && and || operators like the shell, the
21 # implicit binding would be this:
26 # The precedence of the ! operator is different from C though. It has a
27 # lower precedence than the comparison operators.
32 # This is how the above condition is actually interpreted.
33 .if !("word" == "word")
37 # TODO: Demonstrate that the precedence of the ! and == operators actually
38 # makes a difference. There is a simple example for sure, I just cannot
39 # wrap my head around it.
41 # This condition is malformed because the '!' on the right-hand side must not
42 # appear unquoted. If any, it must be enclosed in quotes.
43 # In any case, it is not interpreted as a negation of an unquoted string.
49 # Surprisingly, the ampersand and pipe are allowed in bare strings.
50 # That's another opportunity for writing confusing code.
51 # See CondGetString, which only has '!' in the list of stop characters.
52 .if "a&&b||c" != a&&b||c
56 # Just in case that parsing should ever stop on the first error.
57 .info Parsing continues until here.