2023-04-24 23:44:30 +00:00
|
|
|
# $NetBSD: varcmd.mk,v 1.7 2023/04/07 05:54:16 rillig Exp $
|
2012-06-08 21:57:36 +00:00
|
|
|
#
|
|
|
|
# Test behaviour of recursive make and vars set on command line.
|
2021-06-25 18:16:24 +00:00
|
|
|
#
|
|
|
|
# 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.
|
2023-04-24 23:44:30 +00:00
|
|
|
#
|
|
|
|
# See also:
|
|
|
|
# var-scope-cmdline.mk
|
|
|
|
# varname-makeflags.mk
|
2012-06-08 21:57:36 +00:00
|
|
|
|
2020-11-07 19:39:21 +00:00
|
|
|
FU= fu
|
|
|
|
FOO?= foo
|
2012-06-08 21:57:36 +00:00
|
|
|
.if !empty(.TARGETS)
|
2020-11-07 19:39:21 +00:00
|
|
|
TAG= ${.TARGETS}
|
2012-06-08 21:57:36 +00:00
|
|
|
.endif
|
2020-11-07 19:39:21 +00:00
|
|
|
TAG?= default
|
2012-06-08 21:57:36 +00:00
|
|
|
|
|
|
|
all: one
|
|
|
|
|
|
|
|
show:
|
|
|
|
@echo "${TAG} FU=<v>${FU}</v> FOO=<v>${FOO}</v> VAR=<v>${VAR}</v>"
|
|
|
|
|
|
|
|
one: show
|
2018-03-01 23:45:44 +00:00
|
|
|
@${.MAKE} -f ${MAKEFILE} FU=bar FOO+=goo two
|
2012-06-08 21:57:36 +00:00
|
|
|
|
|
|
|
two: show
|
|
|
|
@${.MAKE} -f ${MAKEFILE} three
|
|
|
|
|
|
|
|
three: show
|
|
|
|
@${.MAKE} -f ${MAKEFILE} four
|
|
|
|
|
|
|
|
|
2018-03-01 23:45:44 +00:00
|
|
|
.ifmake two
|
|
|
|
# this should not work
|
|
|
|
FU+= oops
|
|
|
|
FOO+= oops
|
|
|
|
_FU:= ${FU}
|
|
|
|
_FOO:= ${FOO}
|
|
|
|
two: immutable
|
|
|
|
immutable:
|
|
|
|
@echo "$@ FU='${_FU}'"
|
|
|
|
@echo "$@ FOO='${_FOO}'"
|
|
|
|
.endif
|
2012-06-08 21:57:36 +00:00
|
|
|
.ifmake four
|
|
|
|
VAR=Internal
|
|
|
|
.MAKEOVERRIDES+= VAR
|
|
|
|
.endif
|
|
|
|
|
|
|
|
four: show
|
|
|
|
@${.MAKE} -f ${MAKEFILE} five
|
|
|
|
|
2020-11-07 19:39:21 +00:00
|
|
|
M= x
|
|
|
|
V.y= is y
|
|
|
|
V.x= is x
|
|
|
|
V:= ${V.$M}
|
|
|
|
K:= ${V}
|
2012-06-08 21:57:36 +00:00
|
|
|
|
|
|
|
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
|