varname-dot-makeflags.mk revision 1.10 1 # $NetBSD: varname-dot-makeflags.mk,v 1.10 2025/05/18 22:51:02 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 # expect+1: MAKEFLAGS=<undefined>
11 .info MAKEFLAGS=<${MAKEFLAGS:Uundefined}>
12 # expect+1: .MAKEFLAGS=< -r -k>
13 .info .MAKEFLAGS=<${.MAKEFLAGS}>
14 # expect+1: .MAKEOVERRIDES=<>
15 .info .MAKEOVERRIDES=<${.MAKEOVERRIDES:Uundefined}>
16
17 # Append an option with argument, a plain option and a variable assignment.
18 .MAKEFLAGS: -DVARNAME -r VAR=value
19
20 # expect+1: MAKEFLAGS=<undefined>
21 .info MAKEFLAGS=<${MAKEFLAGS:Uundefined}>
22 # expect+1: .MAKEFLAGS=< -r -k -D VARNAME -r>
23 .info .MAKEFLAGS=<${.MAKEFLAGS}>
24 # expect+1: .MAKEOVERRIDES=< VAR>
25 .info .MAKEOVERRIDES=<${.MAKEOVERRIDES}>
26
27 # The environment variable 'MAKEFLAGS' is available to child processes
28 # while parsing the makefiles, just like the exported make variables.
29 .if ${:!echo "\${MAKEFLAGS-undef}"!} != " -r -k -D VARNAME -r VAR=value"
30 . error
31 .endif
32
33 # After parsing, the environment variable 'MAKEFLAGS' is set based on the
34 # special variables '.MAKEFLAGS' and '.MAKEOVERRIDES'.
35 runtime:
36 @echo '$@: MAKEFLAGS=<'${MAKEFLAGS:Q}'>'
37 @echo '$@: .MAKEFLAGS=<'${.MAKEFLAGS:Q}'>'
38 @echo '$@: .MAKEOVERRIDES=<'${.MAKEOVERRIDES:Q}'>'
39