1# $NetBSD: varname-dot-makeflags.mk,v 1.7 2023/02/25 19:24:07 rillig Exp $
2#
3# Tests for the special .MAKEFLAGS variable, which collects almost all
4# command line arguments and passes them on to any child processes via
5# the environment variable MAKEFLAGS (without leading '.').
6#
7# See also:
8#	varname-dot-makeoverrides.mk
9
10.info MAKEFLAGS=<${MAKEFLAGS:Uundefined}>
11.info .MAKEFLAGS=<${.MAKEFLAGS}>
12.info .MAKEOVERRIDES=<${.MAKEOVERRIDES:Uundefined}>
13
14# Append an option with argument, a plain option and a variable assignment.
15.MAKEFLAGS: -DVARNAME -r VAR=value
16
17# expect+1: MAKEFLAGS=<undefined>
18.info MAKEFLAGS=<${MAKEFLAGS:Uundefined}>
19# expect+1: .MAKEFLAGS=< -r -k -D VARNAME -r>
20.info .MAKEFLAGS=<${.MAKEFLAGS}>
21# expect+1: .MAKEOVERRIDES=< VAR>
22.info .MAKEOVERRIDES=<${.MAKEOVERRIDES}>
23
24# The environment variable 'MAKEFLAGS' is not available to child processes
25# when parsing the makefiles.  This is different from exported variables,
26# which are already available during parse time.
27.if ${:!echo "\${MAKEFLAGS-undef}"!} != "undef"
28.  error
29.endif
30
31# After parsing, the environment variable 'MAKEFLAGS' is set based on the
32# special variables '.MAKEFLAGS' and '.MAKEOVERRIDES'.
33runtime:
34	@echo '$@: MAKEFLAGS=<'${MAKEFLAGS:Q}'>'
35	@echo '$@: .MAKEFLAGS=<'${.MAKEFLAGS:Q}'>'
36	@echo '$@: .MAKEOVERRIDES=<'${.MAKEOVERRIDES:Q}'>'
37