Home | History | Annotate | Line # | Download | only in unit-tests
varmod-defined.mk revision 1.3
      1  1.3  rillig # $NetBSD: varmod-defined.mk,v 1.3 2020/08/25 21:58:08 rillig Exp $
      2  1.1  rillig #
      3  1.2  rillig # Tests for the :D variable modifier, which returns the given string
      4  1.2  rillig # if the variable is defined.  It is closely related to the :U modifier.
      5  1.1  rillig 
      6  1.3  rillig DEF=	defined
      7  1.3  rillig .undef UNDEF
      8  1.3  rillig 
      9  1.3  rillig # Since DEF is defined, the value of the expression is "value", not
     10  1.3  rillig # "defined".
     11  1.3  rillig #
     12  1.3  rillig .if ${DEF:Dvalue} != "value"
     13  1.3  rillig .error
     14  1.3  rillig .endif
     15  1.3  rillig 
     16  1.3  rillig # Since UNDEF is not defined, the "value" is ignored.  Instead of leaving the
     17  1.3  rillig # expression undefined, it is set to "", exactly to allow the expression to
     18  1.3  rillig # be used in .if conditions.  In this place, other undefined expressions
     19  1.3  rillig # would generate an error message.
     20  1.3  rillig # XXX: Ideally the error message would be "undefined variable", but as of
     21  1.3  rillig # 2020-08-25 it is "Malformed conditional".
     22  1.3  rillig #
     23  1.3  rillig .if ${UNDEF:Dvalue} != ""
     24  1.3  rillig .error
     25  1.3  rillig .endif
     26  1.1  rillig 
     27  1.1  rillig all:
     28  1.1  rillig 	@:;
     29