freebsd-dev/contrib/bmake/unit-tests/varcmd.mk
Simon J. Gerraty 8c973ee23d Merge bmake-20230414
Merge commit '51d8a8b4ac1dd7265e891149e470a803906de2a7'
2023-04-24 16:50:16 -07:00

75 lines
1.5 KiB
Makefile

# $NetBSD: varcmd.mk,v 1.7 2023/04/07 05:54:16 rillig Exp $
#
# Test behaviour of recursive make and vars set on command line.
#
# FIXME: The purpose of this test is unclear. The test uses six levels of
# sub-makes, which makes it incredibly hard to understand. There must be at
# least an introductory explanation about what _should_ happen here.
# The variable names are terrible, as well as their values.
#
# This test produces different results if the large block with the condition
# "scope == SCOPE_GLOBAL" in Var_SetWithFlags is removed. This test should
# be rewritten to make it clear why there is a difference and why this is
# actually intended. Removing that large block of code makes only this test
# and vardebug.mk fail, which is not enough.
#
# See also:
# var-scope-cmdline.mk
# varname-makeflags.mk
FU= fu
FOO?= foo
.if !empty(.TARGETS)
TAG= ${.TARGETS}
.endif
TAG?= default
all: one
show:
@echo "${TAG} FU=<v>${FU}</v> FOO=<v>${FOO}</v> VAR=<v>${VAR}</v>"
one: show
@${.MAKE} -f ${MAKEFILE} FU=bar FOO+=goo two
two: show
@${.MAKE} -f ${MAKEFILE} three
three: show
@${.MAKE} -f ${MAKEFILE} four
.ifmake two
# this should not work
FU+= oops
FOO+= oops
_FU:= ${FU}
_FOO:= ${FOO}
two: immutable
immutable:
@echo "$@ FU='${_FU}'"
@echo "$@ FOO='${_FOO}'"
.endif
.ifmake four
VAR=Internal
.MAKEOVERRIDES+= VAR
.endif
four: show
@${.MAKE} -f ${MAKEFILE} five
M= x
V.y= is y
V.x= is x
V:= ${V.$M}
K:= ${V}
show-v:
@echo '${TAG} v=${V} k=${K}'
five: show show-v
@${.MAKE} -f ${MAKEFILE} M=y six
six: show-v
@${.MAKE} -f ${MAKEFILE} V=override show-v