173d4ecff3
Since 2008-12-21, make has silently ignored strange variable names in constructs like '$$', '$}', '$' followed by nothing. Ignoring these bugs in makefiles instead of reporting them is not a good idea. To improve the situation, make complains about these errors now, but only in lint mode (-dL). This preserves existing behavior while still allowing to validate existing makefiles that they don't depend on this bug. If the test phase goes well, these error messages may be enabled unconditionally. https://mail-index.netbsd.org/pkgsrc-users/2020/09/12/msg032229.html
52 lines
1.3 KiB
Makefile
52 lines
1.3 KiB
Makefile
# $NetBSD: varmod.mk,v 1.3 2020/09/13 07:42:20 rillig Exp $
|
|
#
|
|
# Tests for variable modifiers, such as :Q, :S,from,to or :Ufallback.
|
|
|
|
DOLLAR1= $$
|
|
DOLLAR2= ${:U\$}
|
|
|
|
# To get a single '$' sign in the value of a variable expression, it has to
|
|
# be written as '$$' in a literal variable value.
|
|
#
|
|
# See Var_Parse, where it calls Var_Subst.
|
|
.if ${DOLLAR1} != "\$"
|
|
. error
|
|
.endif
|
|
|
|
# Another way to get a single '$' sign is to use the :U modifier. In the
|
|
# argument of that modifier, a '$' is escaped using the backslash instead.
|
|
#
|
|
# See Var_Parse, where it calls Var_Subst.
|
|
.if ${DOLLAR2} != "\$"
|
|
. error
|
|
.endif
|
|
|
|
# It is also possible to use the :U modifier directly in the expression.
|
|
#
|
|
# See Var_Parse, where it calls Var_Subst.
|
|
.if ${:U\$} != "\$"
|
|
. error
|
|
.endif
|
|
|
|
# XXX: As of 2020-09-13, it is not possible to use '$$' in a variable name
|
|
# to mean a single '$'. This contradicts the manual page, which says that
|
|
# '$' can be escaped as '$$'.
|
|
.if ${$$:L} != ""
|
|
. error
|
|
.endif
|
|
|
|
# In lint mode, make prints helpful error messages.
|
|
# For compatibility, make does not print these error messages in normal mode.
|
|
# Should it?
|
|
.MAKEFLAGS: -dL
|
|
.if ${$$:L} != ""
|
|
. error
|
|
.endif
|
|
|
|
# A '$' followed by nothing is an error as well.
|
|
.if ${:Uword:@word@${word}$@} != "word"
|
|
. error
|
|
.endif
|
|
|
|
all: # nothing
|