1 # $NetBSD: directive-undef.mk,v 1.9 2020/12/22 20:10:21 rillig Exp $
3 # Tests for the .undef directive.
6 # directive-misspellings.mk
8 # Before var.c 1.737 from 2020-12-19, .undef only undefined the first
9 # variable, silently skipping all further variable names.
11 # Before var.c 1.761 from 2020-12-22, .undef complained about too many
14 # Since var.c 1.761 from 2020-12-22, .undef handles multiple variable names
15 # just like the .export directive.
20 .if ${1:U_}${2:U_}${3:U_} != ___
25 # Without any arguments, until var.c 1.736 from 2020-12-19, .undef tried
26 # to delete the variable with the empty name, which never exists; see
27 # varname-empty.mk. Since var.c 1.737 from 2020-12-19, .undef complains
28 # about a missing argument.
32 # Trying to delete the variable with the empty name is ok, it just won't
33 # ever do anything since that variable is never defined.
37 # The argument of .undef is first expanded exactly once and then split into
38 # words, just like everywhere else. This prevents variables whose names
39 # contain spaces or unbalanced 'single' or "double" quotes from being
40 # undefined, but these characters do not appear in variables names anyway.
44 ${:U1 2 3}= one two three
46 .undef ${VARNAMES} # undefines the variable "1 2 3"
47 .if !defined(${:U1 2 3})
50 .if ${1:U_}${2:U_}${3:U_} != "___" # these are still defined
55 # A variable named " " cannot be undefined. There's no practical use case
56 # for such variables anyway.
59 .if !defined(${SPACE})
63 .if !defined(${SPACE})
68 # A variable named "$" can be undefined since the argument to .undef is
69 # expanded exactly once, before being split into words.
72 .if !defined(${DOLLAR})
76 .if defined(${DOLLAR})
81 # Since var.c 1.762 from 2020-12-22, parse errors in the argument should be
82 # properly detected and should stop the .undef directive from doing any work.
84 # As of var.c 1.762, this doesn't happen though because the error handling
85 # in Var_Parse and Var_Subst is not done properly.
86 .undef ${VARNAMES:L:Z}