1 # $NetBSD: varmod-undefined.mk,v 1.3 2020/08/23 20:49:33 rillig Exp $
3 # Tests for the :U variable modifier, which returns the given string
4 # if the variable is undefined.
6 # The pattern ${:Uword} is heavily used when expanding .for loops.
8 # This is how an expanded .for loop looks like.
19 # The variable expressions in the text of the :U modifier may be arbitrarily
22 .if ${:U${:Unested}${${${:Udeeply}}}} != nested
26 # The nested variable expressions may contain braces, and these braces don't
27 # need to match pairwise. In the following example, the :S modifier uses '{'
28 # as delimiter, which confuses both editors and humans because the opening
29 # and # closing braces don't match anymore. It's syntactically valid though.
30 # For more similar examples, see varmod-subst.mk, mod-subst-delimiter.
32 .if ${:U${:Uvalue:S{a{X{}} != vXlue
36 # The escaping rules for the :U modifier (left-hand side) and condition
37 # string literals (right-hand side) are completely different.
39 # In the :U modifier, the backslash only escapes very few characters, all
40 # other backslashes are retained.
42 # In condition string literals, the backslash always escapes the following
43 # character, no matter whether it would be necessary or not.
45 # In both contexts, \n is an escaped letter n, not a newline; that's what
46 # the .newline variable is for.
48 # Whitespace at the edges is preserved, on both sides of the comparison.
50 .if ${:U \: \} \$ \\ \a \b \n } != " : } \$ \\ \\a \\b \\n "