xref: /freebsd/contrib/bmake/unit-tests/varname-dot-make-level.mk (revision 8d5c8e21c690b35d0a9a604d6b886fba222cd2fe)
1# $NetBSD: varname-dot-make-level.mk,v 1.3 2024/06/01 18:44:05 rillig Exp $
2#
3# Tests for the special .MAKE.LEVEL variable, which informs about the
4# recursion level.  It is related to the environment variable MAKELEVEL,
5# even though they don't have the same value.
6
7level_1: .PHONY
8	@printf 'level 1: variable %s, env %s\n' ${.MAKE.LEVEL} "$$${.MAKE.LEVEL.ENV}"
9	@${MAKE} -f ${MAKEFILE} level_2
10
11level_2: .PHONY
12	@printf 'level 2: variable %s, env %s\n' ${.MAKE.LEVEL} "$$${.MAKE.LEVEL.ENV}"
13	@${MAKE} -f ${MAKEFILE} level_3
14
15level_3: .PHONY
16	@printf 'level 3: variable %s, env %s\n' ${.MAKE.LEVEL} "$$${.MAKE.LEVEL.ENV}"
17
18# The .unexport-env directive clears the environment, except for the
19# MAKE_LEVEL variable.
20.if make(level_2)
21.unexport-env
22.endif
23