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