Home | History | Annotate | Line # | Download | only in unit-tests
cmdline-undefined.mk revision 1.1
      1  1.1  rillig # $NetBSD: cmdline-undefined.mk,v 1.1 2020/11/04 04:24:57 rillig Exp $
      2  1.1  rillig #
      3  1.1  rillig # Tests for undefined variable expressions in the command line.
      4  1.1  rillig 
      5  1.1  rillig all:
      6  1.1  rillig 	# When the command line is parsed during the initial call of
      7  1.1  rillig 	# MainParseArgs, discardUndefined is still FALSE, therefore preserving
      8  1.1  rillig 	# undefined subexpressions.  This makes sense because at that early
      9  1.1  rillig 	# stage, almost no variables are defined.  On the other hand, the '='
     10  1.1  rillig 	# assignment operator does not expand its right-hand side anyway.
     11  1.1  rillig 	@echo 'The = assignment operator'
     12  1.1  rillig 	@${.MAKE} -f ${MAKEFILE} print-undefined \
     13  1.1  rillig 		CMDLINE='Undefined is $${UNDEFINED}.'
     14  1.1  rillig 	@echo
     15  1.1  rillig 
     16  1.1  rillig 	# The interesting case is using the ':=' assignment operator, which
     17  1.1  rillig 	# expands its right-hand side.  But only those variables that are
     18  1.1  rillig 	# defined.
     19  1.1  rillig 	@echo 'The := assignment operator'
     20  1.1  rillig 	@${.MAKE} -f ${MAKEFILE} print-undefined \
     21  1.1  rillig 		CMDLINE:='Undefined is $${UNDEFINED}.'
     22  1.1  rillig 	@echo
     23  1.1  rillig 
     24  1.1  rillig .if make(print-undefined)
     25  1.1  rillig 
     26  1.1  rillig .MAKEFLAGS: MAKEFLAGS_ASSIGN='Undefined is $${UNDEFINED}.'
     27  1.1  rillig .MAKEFLAGS: MAKEFLAGS_SUBST:='Undefined is $${UNDEFINED}.'
     28  1.1  rillig 
     29  1.1  rillig .info From the command line: ${CMDLINE}
     30  1.1  rillig .info From .MAKEFLAGS '=': ${MAKEFLAGS_ASSIGN}
     31  1.1  rillig .info From .MAKEFLAGS ':=': ${MAKEFLAGS_SUBST}
     32  1.1  rillig 
     33  1.1  rillig UNDEFINED?=	now defined
     34  1.1  rillig 
     35  1.1  rillig .info From the command line: ${CMDLINE}
     36  1.1  rillig .info From .MAKEFLAGS '=': ${MAKEFLAGS_ASSIGN}
     37  1.1  rillig .info From .MAKEFLAGS ':=': ${MAKEFLAGS_SUBST}
     38  1.1  rillig 
     39  1.1  rillig print-undefined:
     40  1.1  rillig .endif
     41