1 # $NetBSD: cond-undef-lint.mk,v 1.3 2020/11/15 14:58:14 rillig Exp $
3 # Tests for defined and undefined variables in .if conditions, in lint mode.
5 # As of 2020-09-14, lint mode contains experimental code for printing
6 # accurate error messages in case of undefined variables, instead of the
7 # wrong "Malformed condition".
14 # DEF is defined, UNDEF is not.
17 # An expression based on a defined variable is fine.
22 # Since the condition fails to evaluate, neither of the branches is taken.
29 # The variable name depends on the undefined variable, which is probably a
30 # mistake. The variable UNDEF, as used here, can be easily turned into
31 # an expression that is always defined, using the :U modifier.
33 # The outer expression does not generate an error message since there was
34 # already an error evaluating this variable's name.
36 # TODO: Suppress the error message "Variable VAR. is undefined". That part
37 # of the expression must not be evaluated at all.
44 # The variable VAR.defined is not defined and thus generates an error message.
46 # TODO: This pattern looks a lot like CFLAGS.${OPSYS}, which is at least
47 # debatable. Or would any practical use of CFLAGS.${OPSYS} be via an indirect
48 # expression, as in the next example?
56 # Variables that are referenced indirectly may be undefined in a condition.
58 # A practical example for this is CFLAGS, which consists of CWARNS, COPTS
59 # and a few others. Just because these nested variables are not defined,
60 # this does not make the condition invalid.
62 # The crucial point is that at the point where the variable appears in the
63 # condition, there is no way to influence the definedness of the nested
64 # variables. In particular, there is no modifier that would turn undefined
65 # nested variables into empty strings, as an equivalent to the :U modifier.
66 INDIRECT= ${NESTED_UNDEF} ${NESTED_DEF}
67 NESTED_DEF= nested-defined
69 # Since NESTED_UNDEF is not controllable at this point, it must not generate
70 # an error message, and it doesn't do so, since 2020-09-14.