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