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