16541d27cSJuli Mallett# $FreeBSD$ 26541d27cSJuli Mallett 30aa9e01cSJuli Mallett# Test for broken LHS expansion. 4113cf9e6SRuslan Ermilov# This *must* cause 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." 35113cf9e6SRuslan Ermilov @echo "Running test notdef" 36113cf9e6SRuslan Ermilov @${MAKE} notdef || ${MAKE} failure 37113cf9e6SRuslan Ermilov @echo "PASS: Test notdef detected no regression." 38113cf9e6SRuslan Ermilov @echo "Running test modifiers" 39113cf9e6SRuslan Ermilov @${MAKE} modifiers || ${MAKE} failure 40113cf9e6SRuslan Ermilov @echo "PASS: Test modifiers detected no regression." 41be8b43b4SRuslan Ermilov @echo "Running test funny_targets" 42be8b43b4SRuslan Ermilov @${MAKE} funny_targets || ${MAKE} failure 43be8b43b4SRuslan Ermilov @echo "PASS: Test funny_targets detected no regression." 446d3ca9deSJuli Mallett 455661d4a7SJuli Mallett.if make(double) 4689d22e2fSJuli Mallett# Doubly-defined targets. make(1) will warn, but use the "right" one. If it 4789d22e2fSJuli Mallett# switches to using the "non-right" one, it breaks things worse than a little 4889d22e2fSJuli Mallett# regression test. 496d3ca9deSJuli Mallettdouble: 506d3ca9deSJuli Mallett @true 516d3ca9deSJuli Mallett 526d3ca9deSJuli Mallettdouble: 536d3ca9deSJuli Mallett @false 545661d4a7SJuli Mallett.endif 556541d27cSJuli Mallett 565661d4a7SJuli Mallett.if make(sysvmatch) 57a9b736adSJuli Mallett# Some versions of FreeBSD make(1) do not handle a nil LHS in sysvsubst. 58a9b736adSJuli Mallettsysvmatch: 59a9b736adSJuli Mallett @echo EMPTY ${NIL:=foo} LHS | \ 60a9b736adSJuli Mallett diff -u ${.CURDIR}/regress.sysvmatch.out - || false 615661d4a7SJuli Mallett.endif 62a9b736adSJuli Mallett 630aa9e01cSJuli Mallett# A bogus target for the lhs_expn test; If this is reached, then the make(1) 640aa9e01cSJuli Mallett# program has not errored out because of the recursion caused by not expanding 650aa9e01cSJuli Mallett# the left-hand-side's embedded variables above. 660aa9e01cSJuli Mallettlhs_expn: 676d5fda5fSJuli Mallett @true 680aa9e01cSJuli Mallett 69113cf9e6SRuslan Ermilov.if make(notdef) 70113cf9e6SRuslan Ermilov# make(1) claims to only evaluate a conditional as far as is necessary 71113cf9e6SRuslan Ermilov# to determine its value; that was not always the case. 72113cf9e6SRuslan Ermilov.undef notdef 73113cf9e6SRuslan Ermilovnotdef: 74113cf9e6SRuslan Ermilov.if defined(notdef) && ${notdef:U} 75113cf9e6SRuslan Ermilov.endif 76113cf9e6SRuslan Ermilov.endif 77113cf9e6SRuslan Ermilov 78113cf9e6SRuslan Ermilov.if make(modifiers) 79113cf9e6SRuslan Ermilov# See if make(1) supports the C modifier. 80113cf9e6SRuslan Ermilovmodifiers: 81113cf9e6SRuslan Ermilov @if ${MAKE} -V .CURDIR:C/.// 2>&1 >/dev/null | \ 82113cf9e6SRuslan Ermilov grep -q "Unknown modifier 'C'"; then \ 83113cf9e6SRuslan Ermilov false; \ 84113cf9e6SRuslan Ermilov fi 85113cf9e6SRuslan Ermilov.endif 86113cf9e6SRuslan Ermilov 87be8b43b4SRuslan Ermilov.if make(funny_targets) 88be8b43b4SRuslan Ermilovfunny_targets: colons::target exclamation!target 89be8b43b4SRuslan Ermilovcolons::target: 90be8b43b4SRuslan Ermilovexclamation!target: 91be8b43b4SRuslan Ermilov.endif 92be8b43b4SRuslan Ermilov 936541d27cSJuli Mallettfailure: 94624abf85SJuli Mallett @echo "FAIL: Test failed: regression detected. See above." 956541d27cSJuli Mallett @false 96