xref: /freebsd/tools/build/make_check/Makefile (revision 5661d4a7b974b9f4b24820c2b9953b14e16a3aa1)
16541d27cSJuli Mallett# $FreeBSD$
26541d27cSJuli Mallett
30aa9e01cSJuli Mallett# Test for broken LHS expansion.
40aa9e01cSJuli Mallett# This *must* case make(1) to detect a recursive variable, and fail as such.
50aa9e01cSJuli Mallett.if make(lhs_expn)
60aa9e01cSJuli MallettFOO=		${BAR}
70aa9e01cSJuli MallettBAR${NIL}=	${FOO}
80aa9e01cSJuli MallettFOO${BAR}=	${FOO}
90aa9e01cSJuli Mallett.endif
100aa9e01cSJuli Mallett
116541d27cSJuli MallettDATA1=	helllo
126541d27cSJuli MallettDATA2:=	${DATA1}
136541d27cSJuli MallettDATA3=	${DATA2:S/ll/rr/g}
146541d27cSJuli MallettDATA4:=	${DATA2:S/ll/rr/g}
156541d27cSJuli MallettDATA2?=	allo
166541d27cSJuli MallettDATA5:= ${DATA2:S/ll/ii/g} ${DATA1:S/ll/rr/g}
176541d27cSJuli MallettDATA2=	yello
186541d27cSJuli MallettDATA1:=	${DATA5:S/l/r/g}
19a9b736adSJuli MallettNIL=
206541d27cSJuli Mallett
216541d27cSJuli Mallettall:
226541d27cSJuli Mallett	@echo "Running test variables"
236541d27cSJuli Mallett	@echo 1:${DATA1} 2:${DATA2} 3:${DATA3} 4:${DATA4} 5:${DATA5} | \
246541d27cSJuli Mallett		diff -u ${.CURDIR}/regress.variables.out - || ${MAKE} failure
25624abf85SJuli Mallett	@echo "PASS: Test variables detected no regression, output matches."
266d3ca9deSJuli Mallett	@echo "Running test targets"
276d3ca9deSJuli Mallett	@${MAKE} double || ${MAKE} failure
28624abf85SJuli Mallett	@echo "PASS: Test targets detected no regression."
29a9b736adSJuli Mallett	@echo "Running test sysvmatch"
30a9b736adSJuli Mallett	@${MAKE} sysvmatch || ${MAKE} failure
31a9b736adSJuli Mallett	@echo "PASS: Test sysvmatch detected no regression."
320aa9e01cSJuli Mallett	@echo "Running test lhs_expn"
336d5fda5fSJuli Mallett	@! ${MAKE} lhs_expn && true || ${MAKE} failure
340aa9e01cSJuli Mallett	@echo "PASS: Test lhs_expn detected no regression."
356d3ca9deSJuli Mallett
365661d4a7SJuli Mallett.if make(double)
3789d22e2fSJuli Mallett# Doubly-defined targets.  make(1) will warn, but use the "right" one.  If it
3889d22e2fSJuli Mallett# switches to using the "non-right" one, it breaks things worse than a little
3989d22e2fSJuli Mallett# regression test.
406d3ca9deSJuli Mallettdouble:
416d3ca9deSJuli Mallett	@true
426d3ca9deSJuli Mallett
436d3ca9deSJuli Mallettdouble:
446d3ca9deSJuli Mallett	@false
455661d4a7SJuli Mallett.endif
466541d27cSJuli Mallett
475661d4a7SJuli Mallett.if make(sysvmatch)
48a9b736adSJuli Mallett# Some versions of FreeBSD make(1) do not handle a nil LHS in sysvsubst.
49a9b736adSJuli Mallettsysvmatch:
50a9b736adSJuli Mallett	@echo EMPTY ${NIL:=foo} LHS | \
51a9b736adSJuli Mallett		diff -u ${.CURDIR}/regress.sysvmatch.out - || false
525661d4a7SJuli Mallett.endif
53a9b736adSJuli Mallett
540aa9e01cSJuli Mallett# A bogus target for the lhs_expn test;  If this is reached, then the make(1)
550aa9e01cSJuli Mallett# program has not errored out because of the recursion caused by not expanding
560aa9e01cSJuli Mallett# the left-hand-side's embedded variables above.
570aa9e01cSJuli Mallettlhs_expn:
586d5fda5fSJuli Mallett	@true
590aa9e01cSJuli Mallett
606541d27cSJuli Mallettfailure:
61624abf85SJuli Mallett	@echo "FAIL: Test failed: regression detected.  See above."
626541d27cSJuli Mallett	@false
63