summaryrefslogtreecommitdiff
path: root/unit-tests/varname-makefile.mk
blob: 785fe9301df21d1788584818cbda2bf20a71590e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# $NetBSD: varname-makefile.mk,v 1.2 2020/09/05 06:25:38 rillig Exp $
#
# Tests for the special MAKEFILE variable, which contains the current
# makefile from the -f command line option.
#
# When there are multiple -f options, the variable MAKEFILE is set
# again for each of these makefiles, before the file is parsed.
# Including a file via .include does not influence the MAKEFILE
# variable though.

.if ${MAKEFILE:T} != "varname-makefile.mk"
.  error
.endif

# This variable lives in the "Internal" namespace.
# TODO: Why does it do that, and what consequences does this have?

# Deleting the variable does not work since this variable does not live in
# the "Global" namespace but in "Internal", which is kind of a child
# namespace.
#
.undef MAKEFILE
.if ${MAKEFILE:T} != "varname-makefile.mk"
.  error
.endif

# Overwriting this variable is possible since the "Internal" namespace
# serves as a fallback for the "Global" namespace (see VarFind).
#
MAKEFILE=	overwritten
.if ${MAKEFILE:T} != "overwritten"
.  error
.endif

# When the overwritten value is deleted, the fallback value becomes
# visible again.
#
.undef MAKEFILE
.if ${MAKEFILE:T} != "varname-makefile.mk"
.  error
.endif

all:
	@:;