xref: /freebsd/contrib/bmake/unit-tests/varname-dot-makeflags.mk (revision 148ee84570001f46b7b667c86573d378101c3801)
1# $NetBSD: varname-dot-makeflags.mk,v 1.8 2023/06/01 20:56:35 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 not available to child processes
28# when parsing the makefiles.  This is different from exported variables,
29# which are already available during parse time.
30.if ${:!echo "\${MAKEFLAGS-undef}"!} != "undef"
31.  error
32.endif
33
34# After parsing, the environment variable 'MAKEFLAGS' is set based on the
35# special variables '.MAKEFLAGS' and '.MAKEOVERRIDES'.
36runtime:
37	@echo '$@: MAKEFLAGS=<'${MAKEFLAGS:Q}'>'
38	@echo '$@: .MAKEFLAGS=<'${.MAKEFLAGS:Q}'>'
39	@echo '$@: .MAKEOVERRIDES=<'${.MAKEOVERRIDES:Q}'>'
40