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