Home | History | Annotate | Line # | Download | only in unit-tests
      1 # $NetBSD: varcmd.mk,v 1.7 2023/04/07 05:54:16 rillig Exp $
      2 #
      3 # Test behaviour of recursive make and vars set on command line.
      4 #
      5 # FIXME: The purpose of this test is unclear.  The test uses six levels of
      6 # sub-makes, which makes it incredibly hard to understand.  There must be at
      7 # least an introductory explanation about what _should_ happen here.
      8 # The variable names are terrible, as well as their values.
      9 #
     10 # This test produces different results if the large block with the condition
     11 # "scope == SCOPE_GLOBAL" in Var_SetWithFlags is removed.  This test should
     12 # be rewritten to make it clear why there is a difference and why this is
     13 # actually intended.  Removing that large block of code makes only this test
     14 # and vardebug.mk fail, which is not enough.
     15 #
     16 # See also:
     17 #	var-scope-cmdline.mk
     18 #	varname-makeflags.mk
     19 
     20 FU=	fu
     21 FOO?=	foo
     22 .if !empty(.TARGETS)
     23 TAG=	${.TARGETS}
     24 .endif
     25 TAG?=	default
     26 
     27 all:	one
     28 
     29 show:
     30 	@echo "${TAG} FU=<v>${FU}</v> FOO=<v>${FOO}</v> VAR=<v>${VAR}</v>"
     31 
     32 one:	show
     33 	@${.MAKE} -f ${MAKEFILE} FU=bar FOO+=goo two
     34 
     35 two:	show
     36 	@${.MAKE} -f ${MAKEFILE} three
     37 
     38 three:	show
     39 	@${.MAKE} -f ${MAKEFILE} four
     40 
     41 
     42 .ifmake two
     43 # this should not work
     44 FU+= oops
     45 FOO+= oops
     46 _FU:= ${FU}
     47 _FOO:= ${FOO}
     48 two: immutable
     49 immutable:
     50 	@echo "$@ FU='${_FU}'"
     51 	@echo "$@ FOO='${_FOO}'"
     52 .endif
     53 .ifmake four
     54 VAR=Internal
     55 .MAKEOVERRIDES+= VAR
     56 .endif
     57 
     58 four:	show
     59 	@${.MAKE} -f ${MAKEFILE} five
     60 
     61 M=	x
     62 V.y=	is y
     63 V.x=	is x
     64 V:=	${V.$M}
     65 K:=	${V}
     66 
     67 show-v:
     68 	@echo '${TAG} v=${V} k=${K}'
     69 
     70 five:	show show-v
     71 	@${.MAKE} -f ${MAKEFILE} M=y six
     72 
     73 six:	show-v
     74 	@${.MAKE} -f ${MAKEFILE} V=override show-v
     75