xref: /freebsd/tools/build/make_check/Makefile (revision d37ea99837e6ad50837fd9fe1771ddf1c3ba6002)
1# $FreeBSD$
2
3# Test for broken LHS expansion.
4# This *must* cause make(1) to detect a recursive variable, and fail as such.
5.if make(lhs_expn)
6FOO=		${BAR}
7BAR${NIL}=	${FOO}
8FOO${BAR}=	${FOO}
9.endif
10
11DATA1=	helllo
12DATA2:=	${DATA1}
13DATA3=	${DATA2:S/ll/rr/g}
14DATA4:=	${DATA2:S/ll/rr/g}
15DATA2?=	allo
16DATA5:= ${DATA2:S/ll/ii/g} ${DATA1:S/ll/rr/g}
17DATA2=	yello
18DATA1:=	${DATA5:S/l/r/g}
19NIL=
20
21all:
22	@echo "Running test variables"
23	@echo 1:${DATA1} 2:${DATA2} 3:${DATA3} 4:${DATA4} 5:${DATA5} | \
24		diff -u ${.CURDIR}/regress.variables.out - || ${MAKE} failure
25	@echo "PASS: Test variables detected no regression, output matches."
26	@echo "Running test targets"
27	@${MAKE} double 2>/dev/null || ${MAKE} failure
28	@echo "PASS: Test targets detected no regression."
29	@echo "Running test sysvmatch"
30	@${MAKE} sysvmatch || ${MAKE} failure
31	@echo "PASS: Test sysvmatch detected no regression."
32	@echo "Running test lhs_expn"
33	@! ${MAKE} lhs_expn && true || ${MAKE} failure
34	@echo "PASS: Test lhs_expn detected no regression."
35	@echo "Running test notdef"
36	@${MAKE} notdef || ${MAKE} failure
37	@echo "PASS: Test notdef detected no regression."
38	@echo "Running test modifiers"
39	@${MAKE} modifiers || ${MAKE} failure
40	@echo "PASS: Test modifiers detected no regression."
41	@echo "Running test funny_targets"
42	@${MAKE} funny_targets || ${MAKE} failure
43	@echo "PASS: Test funny_targets detected no regression."
44	@echo "Running test arith_expr"
45	@${MAKE} arith_expr || ${MAKE} failure
46	@echo "PASS: Test arith_expr detected no regression."
47	@echo "Running test PATH_exists"
48	@${MAKE} PATH_exists || ${MAKE} failure
49	@echo "PASS: Test PATH_exists detected no regression."
50	@echo "Running test double_quotes"
51	@${MAKE} double_quotes || ${MAKE} failure
52	@echo "PASS: Test double_quotes detected no regression."
53	@echo "Running test double_quotes2"
54	@! ${MAKE} double_quotes2 >/dev/null 2>&1 && true || ${MAKE} failure
55	@echo "PASS: Test double_quotes2 detected no regression."
56
57.if make(double)
58# Doubly-defined targets.  make(1) will warn, but use the "right" one.  If it
59# switches to using the "non-right" one, it breaks things worse than a little
60# regression test.
61double:
62	@true
63
64double:
65	@false
66.endif
67
68.if make(sysvmatch)
69# Some versions of FreeBSD make(1) do not handle a nil LHS in sysvsubst.
70sysvmatch:
71	@echo EMPTY ${NIL:=foo} LHS | \
72		diff -u ${.CURDIR}/regress.sysvmatch.out - || false
73.endif
74
75# A bogus target for the lhs_expn test;  If this is reached, then the make(1)
76# program has not errored out because of the recursion caused by not expanding
77# the left-hand-side's embedded variables above.
78lhs_expn:
79	@true
80
81.if make(notdef)
82# make(1) claims to only evaluate a conditional as far as is necessary
83# to determine its value; that was not always the case.
84.undef notdef
85notdef:
86.if defined(notdef) && ${notdef:U}
87.endif
88.endif
89
90.if make(modifiers)
91# See if make(1) supports the C modifier.
92modifiers:
93	@if ${MAKE} -V .CURDIR:C/.// 2>&1 >/dev/null | \
94	    grep -q "Unknown modifier 'C'"; then \
95		false; \
96	fi
97.endif
98
99.if make(funny_targets)
100funny_targets: colons::target exclamation!target
101colons::target:
102exclamation!target:
103.endif
104
105.if make(arith_expr)
106arith_expr:
107# See if arithmetic expression parsing is broken.
108# The different spacing below is intentional.
109VALUE=	0
110.if (${VALUE} < 0)||(${VALUE}>0)
111.endif
112.endif
113
114.if make(PATH_exists)
115PATH_exists:
116.PATH: ${.CURDIR}
117.if !exists(${.CURDIR}/) || !exists(${.CURDIR}/.) || !exists(${.CURDIR}/..)
118.error exists() failed
119.endif
120.endif
121
122.if make(double_quotes)
123VALUE=	foo ""
124double_quotes:
125.if ${VALUE:S/$//} != ${VALUE}
126.error "" reduced to "
127.endif
128.endif
129
130.if make(double_quotes2)
131double_quotes2:
132	@cat /dev/null ""
133.endif
134
135failure:
136	@echo "FAIL: Test failed: regression detected.  See above."
137	@false
138