Home | History | Annotate | Line # | Download | only in unit-tests
varname-makeflags.mk revision 1.4
      1 # $NetBSD: varname-makeflags.mk,v 1.4 2021/12/27 20:17:35 rillig Exp $
      2 #
      3 # Tests for the special MAKEFLAGS variable, which is basically just a normal
      4 # environment variable.  It is closely related to .MAKEFLAGS but captures the
      5 # state of .MAKEFLAGS at the very beginning of make, before any makefiles are
      6 # read.
      7 
      8 # TODO: Implementation
      9 
     10 .MAKEFLAGS: -d0
     11 
     12 # The unit tests are run with an almost empty environment.  In particular,
     13 # the variable MAKEFLAGS is not set.  The '.MAKEFLAGS:' above also doesn't
     14 # influence the environment variable MAKEFLAGS, therefore it is still
     15 # undefined at this point.
     16 .if ${MAKEFLAGS:Uundefined} != "undefined"
     17 .  error
     18 .endif
     19 
     20 # The special variable .MAKEFLAGS is influenced though.
     21 # See varname-dot-makeflags.mk for more details.
     22 .if ${.MAKEFLAGS} != " -r -k -d 0"
     23 .  error
     24 .endif
     25 
     26 
     27 # In POSIX mode, the environment variable MAKEFLAGS can contain letters only,
     28 # for compatibility.  These letters are exploded to form regular options.
     29 OUTPUT!=	env MAKEFLAGS=ikrs ${MAKE} -f /dev/null -v .MAKEFLAGS
     30 .if ${OUTPUT} != " -i -k -r -s -V .MAKEFLAGS"
     31 .  error
     32 .endif
     33 
     34 # As soon as there is a single non-alphabetic character in the environment
     35 # variable MAKEFLAGS, it is no longer split.  In this example, the word
     36 # "d0ikrs" is treated as a target, but the option '-v' prevents any targets
     37 # from being built.
     38 OUTPUT!=	env MAKEFLAGS=d0ikrs ${MAKE} -f /dev/null -v .MAKEFLAGS
     39 .if ${OUTPUT} != " -V .MAKEFLAGS"
     40 .  error ${OUTPUT}
     41 .endif
     42 
     43 
     44 all:
     45