Home | History | Annotate | Line # | Download | only in unit-tests
var-scope-local.mk revision 1.1
      1  1.1  rillig # $NetBSD: var-scope-local.mk,v 1.1 2022/01/23 16:25:54 rillig Exp $
      2  1.1  rillig #
      3  1.1  rillig # Tests for target-local variables, such as ${.TARGET} or $@.
      4  1.1  rillig 
      5  1.1  rillig # TODO: Implementation
      6  1.1  rillig 
      7  1.1  rillig # Ensure that the name of the variable is exactly the given one.
      8  1.1  rillig # The variable "@" is an alias for ".TARGET", so the implementation might
      9  1.1  rillig # canonicalize these aliases at some point, and that might be surprising.
     10  1.1  rillig # This aliasing happens for single-character variable names like $@ or $<
     11  1.1  rillig # (see VarFind, CanonicalVarname), but not for braced or parenthesized
     12  1.1  rillig # expressions like ${@}, ${.TARGET} ${VAR:Mpattern} (see Var_Parse,
     13  1.1  rillig # ParseVarname).
     14  1.1  rillig .if ${@:L} != "@"
     15  1.1  rillig .  error
     16  1.1  rillig .endif
     17  1.1  rillig .if ${.TARGET:L} != ".TARGET"
     18  1.1  rillig .  error
     19  1.1  rillig .endif
     20  1.1  rillig .if ${@F:L} != "@F"
     21  1.1  rillig .  error
     22  1.1  rillig .endif
     23  1.1  rillig .if ${@D:L} != "@D"
     24  1.1  rillig .  error
     25  1.1  rillig .endif
     26  1.1  rillig 
     27  1.1  rillig all:
     28  1.1  rillig 
     29  1.1  rillig .SUFFIXES: .c .o
     30  1.1  rillig 
     31  1.1  rillig var-scope-local.c:
     32  1.1  rillig 	: Making ${.TARGET} out of nothing.
     33  1.1  rillig 
     34  1.1  rillig .c.o:
     35  1.1  rillig 	: Making ${.TARGET} from ${.IMPSRC}.
     36  1.1  rillig 
     37  1.1  rillig 	# The local variables @F, @D, <F, <D are legacy forms.
     38  1.1  rillig 	# See the manual page for details.
     39  1.1  rillig 	: Making basename "${@F}" in "${@D}" from "${<F}" in "${<D}".
     40  1.1  rillig 
     41  1.1  rillig all: var-scope-local.o
     42  1.1  rillig 	# The ::= modifier overwrites the .TARGET variable in the node
     43  1.1  rillig 	# 'all', not in the global scope.  This can be seen with the -dv
     44  1.1  rillig 	# option, looking for "all:@ = overwritten".
     45  1.1  rillig 	: ${.TARGET} ${.TARGET::=overwritten}${.TARGET}
     46