varname-dot-parsedir.mk revision 1.7 1 # $NetBSD: varname-dot-parsedir.mk,v 1.7 2023/06/01 20:56:35 rillig Exp $
2 #
3 # Tests for the special .PARSEDIR variable, which contains the directory part
4 # of the file that is currently parsed.
5
6 # The .PARSEDIR may be absolute or relative, therefore there is not much that
7 # can be tested here.
8 .if !${.PARSEDIR:tA:M*/unit-tests}
9 . error
10 .endif
11
12 # During parsing, it is possible to undefine .PARSEDIR.
13 # Not that anyone would ever want to do this, but there's code in parse.c,
14 # function PrintLocation, that explicitly handles this situation.
15 .if !defined(.PARSEDIR)
16 . error
17 .endif
18 .undef .PARSEDIR
19 .if defined(.PARSEDIR)
20 . error
21 .endif
22
23 # The variable .PARSEDIR is indirectly used by the .info directive,
24 # via PrintLocation.
25 #
26 # The .rawout file contains the full path to the current directory.
27 # In the .out file, it is filtered out.
28 # expect+1: At this point, .PARSEDIR is undefined.
29 .info At this point, .PARSEDIR is undefined.
30
31 # There is absolutely no point in faking the location of the file that is
32 # being parsed. Technically, it's possible though, but only if the file
33 # being parsed is a relative pathname. See PrintLocation for details.
34 .PARSEDIR= /fake-absolute-path
35 .info The location can be faked in some cases.
36
37 # After including another file, .PARSEDIR is reset.
38 .include "/dev/null"
39 # expect+1: The location is no longer fake.
40 .info The location is no longer fake.
41
42 all:
43 @echo At run time, .PARSEDIR is ${.PARSEDIR:Uundefined}.
44