xref: /freebsd/contrib/bmake/unit-tests/varcmd.mk (revision 13ea0450a9c8742119d36f3bf8f47accdce46e54)
1# $Id: varcmd.mk,v 1.1.1.3 2017/12/08 03:37:54 sjg Exp $
2#
3# Test behaviour of recursive make and vars set on command line.
4
5FU=fu
6FOO?=foo
7.if !empty(.TARGETS)
8TAG=${.TARGETS}
9.endif
10TAG?=default
11
12all:	one
13
14show:
15	@echo "${TAG} FU=<v>${FU}</v> FOO=<v>${FOO}</v> VAR=<v>${VAR}</v>"
16
17one:	show
18	@${.MAKE} -f ${MAKEFILE} FU=bar FOO+=goo two
19
20two:	show
21	@${.MAKE} -f ${MAKEFILE} three
22
23three:	show
24	@${.MAKE} -f ${MAKEFILE} four
25
26
27.ifmake two
28# this should not work
29FU+= oops
30FOO+= oops
31_FU:= ${FU}
32_FOO:= ${FOO}
33two: immutable
34immutable:
35	@echo "$@ FU='${_FU}'"
36	@echo "$@ FOO='${_FOO}'"
37.endif
38.ifmake four
39VAR=Internal
40.MAKEOVERRIDES+= VAR
41.endif
42
43four:	show
44	@${.MAKE} -f ${MAKEFILE} five
45
46M = x
47V.y = is y
48V.x = is x
49V := ${V.$M}
50K := ${V}
51
52show-v:
53	@echo '${TAG} v=${V} k=${K}'
54
55five:	show show-v
56	@${.MAKE} -f ${MAKEFILE} M=y six
57
58six:	show-v
59	@${.MAKE} -f ${MAKEFILE} V=override show-v
60
61