varname-dot-parsefile.mk revision 1.6 1 # $NetBSD: varname-dot-parsefile.mk,v 1.6 2023/06/01 20:56:35 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 .if ${.PARSEFILE} != "varname-dot-parsefile.mk"
7 . error
8 .endif
9
10 # During parsing, it is possible to undefine .PARSEFILE.
11 # Not that anyone would ever want to do this, but there's code in parse.c,
12 # function PrintLocation, that explicitly handles this situation.
13 .if !defined(.PARSEFILE)
14 . error
15 .endif
16 .undef .PARSEFILE
17 .if defined(.PARSEFILE)
18 . error
19 .endif
20
21 # The variable .PARSEFILE is indirectly used by the .info directive,
22 # via PrintLocation.
23 # expect+1: At this point, .PARSEFILE is undefined.
24 .info At this point, .PARSEFILE is undefined.
25
26 # There is absolutely no point in faking the location of the file that is
27 # being parsed. Technically, it's possible though, but only if the file
28 # being parsed is a relative pathname. See PrintLocation for details.
29 .PARSEFILE= fake-parsefile
30 .info The location can be faked in some cases.
31
32 # After including another file, .PARSEFILE is reset.
33 .include "/dev/null"
34 # expect+1: The location is no longer fake.
35 .info The location is no longer fake.
36
37 all:
38 @echo At run time, .PARSEFILE is ${.PARSEFILE:Uundefined}.
39