1# $NetBSD: varname-dot-parsefile.mk,v 1.7 2023/06/21 07:30:50 rillig Exp $
2#
3# Tests for the special .PARSEFILE variable, which contains the basename part
4# of the file that is currently parsed.
5#
6# See also
7#	varname-dot-includedfromdir.mk
8#	varname-dot-includedfromfile.mk
9#	varname-dot-parsedir.mk
10#
11# History
12#	.PARSEDIR and .PARSEFILE were added on 1999-08-09.
13
14.if ${.PARSEFILE} != "varname-dot-parsefile.mk"
15.  error
16.endif
17
18# During parsing, it is possible to undefine .PARSEFILE.
19# Not that anyone would ever want to do this, but there's code in parse.c,
20# function PrintLocation, that explicitly handles this situation.
21.if !defined(.PARSEFILE)
22.  error
23.endif
24.undef .PARSEFILE
25.if defined(.PARSEFILE)
26.  error
27.endif
28
29# The variable .PARSEFILE is indirectly used by the .info directive,
30# via PrintLocation.
31# expect+1: At this point, .PARSEFILE is undefined.
32.info At this point, .PARSEFILE is undefined.
33
34# There is absolutely no point in faking the location of the file that is
35# being parsed.  Technically, it's possible though, but only if the file
36# being parsed is a relative pathname.  See PrintLocation for details.
37.PARSEFILE=	fake-parsefile
38.info The location can be faked in some cases.
39
40# After including another file, .PARSEFILE is reset.
41.include "/dev/null"
42# expect+1: The location is no longer fake.
43.info The location is no longer fake.
44
45all:
46	@echo At run time, .PARSEFILE is ${.PARSEFILE:Uundefined}.
47