1 # $NetBSD: cmdline-undefined.mk,v 1.2 2020/11/04 04:49:33 rillig Exp $
3 # Tests for undefined variable expressions in the command line.
6 # When the command line is parsed, variable assignments using the
7 # '=' assignment operator do get their variable name expanded
8 # (which probably occurs rarely in practice, if at all), but their
9 # variable value is not expanded, as usual.
11 @echo 'The = assignment operator'
12 @${.MAKE} -f ${MAKEFILE} print-undefined \
13 CMDLINE='Undefined is $${UNDEFINED}.'
16 # The interesting case is using the ':=' assignment operator, which
17 # expands its right-hand side. But only those variables that are
19 @echo 'The := assignment operator'
20 @${.MAKE} -f ${MAKEFILE} print-undefined \
21 CMDLINE:='Undefined is $${UNDEFINED}.'
24 .if make(print-undefined)
26 .MAKEFLAGS: MAKEFLAGS_ASSIGN='Undefined is $${UNDEFINED}.'
27 .MAKEFLAGS: MAKEFLAGS_SUBST:='Undefined is $${UNDEFINED}.'
29 .info From the command line: ${CMDLINE}
30 .info From .MAKEFLAGS '=': ${MAKEFLAGS_ASSIGN}
31 .info From .MAKEFLAGS ':=': ${MAKEFLAGS_SUBST}
33 UNDEFINED?= now defined
35 .info From the command line: ${CMDLINE}
36 .info From .MAKEFLAGS '=': ${MAKEFLAGS_ASSIGN}
37 .info From .MAKEFLAGS ':=': ${MAKEFLAGS_SUBST}