Home | History | Annotate | Line # | Download | only in unit-tests
      1  1.3  rillig # $NetBSD: varname-makefile.mk,v 1.3 2020/11/09 22:36:44 rillig Exp $
      2  1.1  rillig #
      3  1.1  rillig # Tests for the special MAKEFILE variable, which contains the current
      4  1.1  rillig # makefile from the -f command line option.
      5  1.1  rillig #
      6  1.1  rillig # When there are multiple -f options, the variable MAKEFILE is set
      7  1.1  rillig # again for each of these makefiles, before the file is parsed.
      8  1.1  rillig # Including a file via .include does not influence the MAKEFILE
      9  1.1  rillig # variable though.
     10  1.1  rillig 
     11  1.2  rillig .if ${MAKEFILE:T} != "varname-makefile.mk"
     12  1.1  rillig .  error
     13  1.1  rillig .endif
     14  1.1  rillig 
     15  1.1  rillig # This variable lives in the "Internal" namespace.
     16  1.1  rillig # TODO: Why does it do that, and what consequences does this have?
     17  1.1  rillig 
     18  1.1  rillig # Deleting the variable does not work since this variable does not live in
     19  1.1  rillig # the "Global" namespace but in "Internal", which is kind of a child
     20  1.1  rillig # namespace.
     21  1.1  rillig #
     22  1.1  rillig .undef MAKEFILE
     23  1.2  rillig .if ${MAKEFILE:T} != "varname-makefile.mk"
     24  1.1  rillig .  error
     25  1.1  rillig .endif
     26  1.1  rillig 
     27  1.1  rillig # Overwriting this variable is possible since the "Internal" namespace
     28  1.1  rillig # serves as a fallback for the "Global" namespace (see VarFind).
     29  1.1  rillig #
     30  1.1  rillig MAKEFILE=	overwritten
     31  1.2  rillig .if ${MAKEFILE:T} != "overwritten"
     32  1.1  rillig .  error
     33  1.1  rillig .endif
     34  1.1  rillig 
     35  1.1  rillig # When the overwritten value is deleted, the fallback value becomes
     36  1.1  rillig # visible again.
     37  1.1  rillig #
     38  1.1  rillig .undef MAKEFILE
     39  1.2  rillig .if ${MAKEFILE:T} != "varname-makefile.mk"
     40  1.1  rillig .  error
     41  1.1  rillig .endif
     42  1.1  rillig 
     43  1.1  rillig all:
     44  1.3  rillig 	# MAKEFILE is the file that appeared last in the command line.
     45  1.3  rillig 	: In the end, MAKEFILE is ${MAKEFILE}.
     46  1.3  rillig 
     47  1.3  rillig # Additional makefiles can be added while reading a makefile.  They will be
     48  1.3  rillig # read in order.
     49  1.3  rillig .MAKEFLAGS: -f /dev/null
     50