1*148ee845SSimon J. Gerraty# $NetBSD: varname-dot-parsefile.mk,v 1.7 2023/06/21 07:30:50 rillig Exp $ 22c3632d1SSimon J. Gerraty# 3956e45f6SSimon J. Gerraty# Tests for the special .PARSEFILE variable, which contains the basename part 4956e45f6SSimon J. Gerraty# of the file that is currently parsed. 5*148ee845SSimon J. Gerraty# 6*148ee845SSimon J. Gerraty# See also 7*148ee845SSimon J. Gerraty# varname-dot-includedfromdir.mk 8*148ee845SSimon J. Gerraty# varname-dot-includedfromfile.mk 9*148ee845SSimon J. Gerraty# varname-dot-parsedir.mk 10*148ee845SSimon J. Gerraty# 11*148ee845SSimon J. Gerraty# History 12*148ee845SSimon J. Gerraty# .PARSEDIR and .PARSEFILE were added on 1999-08-09. 132c3632d1SSimon J. Gerraty 14956e45f6SSimon J. Gerraty.if ${.PARSEFILE} != "varname-dot-parsefile.mk" 15956e45f6SSimon J. Gerraty. error 16956e45f6SSimon J. Gerraty.endif 17956e45f6SSimon J. Gerraty 18956e45f6SSimon J. Gerraty# During parsing, it is possible to undefine .PARSEFILE. 19956e45f6SSimon J. Gerraty# Not that anyone would ever want to do this, but there's code in parse.c, 20956e45f6SSimon J. Gerraty# function PrintLocation, that explicitly handles this situation. 21956e45f6SSimon J. Gerraty.if !defined(.PARSEFILE) 22956e45f6SSimon J. Gerraty. error 23956e45f6SSimon J. Gerraty.endif 24956e45f6SSimon J. Gerraty.undef .PARSEFILE 25956e45f6SSimon J. Gerraty.if defined(.PARSEFILE) 26956e45f6SSimon J. Gerraty. error 27956e45f6SSimon J. Gerraty.endif 28956e45f6SSimon J. Gerraty 29956e45f6SSimon J. Gerraty# The variable .PARSEFILE is indirectly used by the .info directive, 30956e45f6SSimon J. Gerraty# via PrintLocation. 31*148ee845SSimon J. Gerraty# expect+1: At this point, .PARSEFILE is undefined. 32956e45f6SSimon J. Gerraty.info At this point, .PARSEFILE is undefined. 33956e45f6SSimon J. Gerraty 34956e45f6SSimon J. Gerraty# There is absolutely no point in faking the location of the file that is 35956e45f6SSimon J. Gerraty# being parsed. Technically, it's possible though, but only if the file 36956e45f6SSimon J. Gerraty# being parsed is a relative pathname. See PrintLocation for details. 37956e45f6SSimon J. Gerraty.PARSEFILE= fake-parsefile 38956e45f6SSimon J. Gerraty.info The location can be faked in some cases. 39956e45f6SSimon J. Gerraty 40956e45f6SSimon J. Gerraty# After including another file, .PARSEFILE is reset. 41956e45f6SSimon J. Gerraty.include "/dev/null" 42*148ee845SSimon J. Gerraty# expect+1: The location is no longer fake. 43956e45f6SSimon J. Gerraty.info The location is no longer fake. 442c3632d1SSimon J. Gerraty 452c3632d1SSimon J. Gerratyall: 46956e45f6SSimon J. Gerraty @echo At run time, .PARSEFILE is ${.PARSEFILE:Uundefined}. 47