Home | History | Annotate | Line # | Download | only in unit-tests
opt-define.mk revision 1.3
      1  1.3  rillig # $NetBSD: opt-define.mk,v 1.3 2022/01/23 16:09:38 rillig Exp $
      2  1.1  rillig #
      3  1.3  rillig # Tests for the -D command line option, which defines global variables to the
      4  1.3  rillig # value 1, like in the C preprocessor.
      5  1.1  rillig 
      6  1.3  rillig .MAKEFLAGS: -DVAR
      7  1.1  rillig 
      8  1.3  rillig # The variable has the exact value "1", not "1.0".
      9  1.3  rillig .if ${VAR} != "1"
     10  1.3  rillig .  error
     11  1.3  rillig .endif
     12  1.3  rillig 
     13  1.3  rillig # The variable can be overwritten by assigning another value to it.  This
     14  1.3  rillig # would not be possible if the variable had been specified on the command line
     15  1.3  rillig # as 'VAR=1' instead of '-DVAR'.
     16  1.3  rillig VAR=		overwritten
     17  1.3  rillig .if ${VAR} != "overwritten"
     18  1.3  rillig .  error
     19  1.3  rillig .endif
     20  1.3  rillig 
     21  1.3  rillig # The variable can be undefined.  If the variable had been defined in the
     22  1.3  rillig # "Internal" scope instead, undefining it would have no effect.
     23  1.3  rillig .undef VAR
     24  1.3  rillig .if defined(VAR)
     25  1.3  rillig .  error
     26  1.3  rillig .endif
     27  1.3  rillig 
     28  1.3  rillig all: .PHONY
     29