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" 27413a16d8SGarance A Drosehn @${MAKE} double 2>/dev/null || ${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." 44c94d7043SRuslan Ermilov @echo "Running test arith_expr" 45c94d7043SRuslan Ermilov @${MAKE} arith_expr || ${MAKE} failure 46c94d7043SRuslan Ermilov @echo "PASS: Test arith_expr detected no regression." 4721159d16SRuslan Ermilov @echo "Running test PATH_exists" 4821159d16SRuslan Ermilov @${MAKE} PATH_exists || ${MAKE} failure 4921159d16SRuslan Ermilov @echo "PASS: Test PATH_exists detected no regression." 509608d7e2SRuslan Ermilov @echo "Running test double_quotes" 519608d7e2SRuslan Ermilov @${MAKE} double_quotes || ${MAKE} failure 529608d7e2SRuslan Ermilov @echo "PASS: Test double_quotes detected no regression." 536d3ca9deSJuli Mallett 545661d4a7SJuli Mallett.if make(double) 5589d22e2fSJuli Mallett# Doubly-defined targets. make(1) will warn, but use the "right" one. If it 5689d22e2fSJuli Mallett# switches to using the "non-right" one, it breaks things worse than a little 5789d22e2fSJuli Mallett# regression test. 586d3ca9deSJuli Mallettdouble: 596d3ca9deSJuli Mallett @true 606d3ca9deSJuli Mallett 616d3ca9deSJuli Mallettdouble: 626d3ca9deSJuli Mallett @false 635661d4a7SJuli Mallett.endif 646541d27cSJuli Mallett 655661d4a7SJuli Mallett.if make(sysvmatch) 66a9b736adSJuli Mallett# Some versions of FreeBSD make(1) do not handle a nil LHS in sysvsubst. 67a9b736adSJuli Mallettsysvmatch: 68a9b736adSJuli Mallett @echo EMPTY ${NIL:=foo} LHS | \ 69a9b736adSJuli Mallett diff -u ${.CURDIR}/regress.sysvmatch.out - || false 705661d4a7SJuli Mallett.endif 71a9b736adSJuli Mallett 720aa9e01cSJuli Mallett# A bogus target for the lhs_expn test; If this is reached, then the make(1) 730aa9e01cSJuli Mallett# program has not errored out because of the recursion caused by not expanding 740aa9e01cSJuli Mallett# the left-hand-side's embedded variables above. 750aa9e01cSJuli Mallettlhs_expn: 766d5fda5fSJuli Mallett @true 770aa9e01cSJuli Mallett 78113cf9e6SRuslan Ermilov.if make(notdef) 79113cf9e6SRuslan Ermilov# make(1) claims to only evaluate a conditional as far as is necessary 80113cf9e6SRuslan Ermilov# to determine its value; that was not always the case. 81113cf9e6SRuslan Ermilov.undef notdef 82113cf9e6SRuslan Ermilovnotdef: 83113cf9e6SRuslan Ermilov.if defined(notdef) && ${notdef:U} 84113cf9e6SRuslan Ermilov.endif 85113cf9e6SRuslan Ermilov.endif 86113cf9e6SRuslan Ermilov 87113cf9e6SRuslan Ermilov.if make(modifiers) 88113cf9e6SRuslan Ermilov# See if make(1) supports the C modifier. 89113cf9e6SRuslan Ermilovmodifiers: 90113cf9e6SRuslan Ermilov @if ${MAKE} -V .CURDIR:C/.// 2>&1 >/dev/null | \ 91113cf9e6SRuslan Ermilov grep -q "Unknown modifier 'C'"; then \ 92113cf9e6SRuslan Ermilov false; \ 93113cf9e6SRuslan Ermilov fi 94113cf9e6SRuslan Ermilov.endif 95113cf9e6SRuslan Ermilov 96be8b43b4SRuslan Ermilov.if make(funny_targets) 97be8b43b4SRuslan Ermilovfunny_targets: colons::target exclamation!target 98be8b43b4SRuslan Ermilovcolons::target: 99be8b43b4SRuslan Ermilovexclamation!target: 100be8b43b4SRuslan Ermilov.endif 101be8b43b4SRuslan Ermilov 102c94d7043SRuslan Ermilov.if make(arith_expr) 103c94d7043SRuslan Ermilovarith_expr: 104c94d7043SRuslan Ermilov# See if arithmetic expression parsing is broken. 105c94d7043SRuslan Ermilov# The different spacing below is intentional. 106c94d7043SRuslan ErmilovVALUE= 0 107c94d7043SRuslan Ermilov.if (${VALUE} < 0)||(${VALUE}>0) 108c94d7043SRuslan Ermilov.endif 109c94d7043SRuslan Ermilov.endif 110c94d7043SRuslan Ermilov 11121159d16SRuslan Ermilov.if make(PATH_exists) 11221159d16SRuslan ErmilovPATH_exists: 11321159d16SRuslan Ermilov.PATH: ${.CURDIR} 11421159d16SRuslan Ermilov.if !exists(${.CURDIR}/) || !exists(${.CURDIR}/.) || !exists(${.CURDIR}/..) 11521159d16SRuslan Ermilov.error exists() failed 11621159d16SRuslan Ermilov.endif 11721159d16SRuslan Ermilov.endif 11821159d16SRuslan Ermilov 1199608d7e2SRuslan Ermilov.if make(double_quotes) 1209608d7e2SRuslan ErmilovVALUE= foo "" 1219608d7e2SRuslan Ermilovdouble_quotes: 1229608d7e2SRuslan Ermilov.if ${VALUE:S/$//} != ${VALUE} 1239608d7e2SRuslan Ermilov.error "" reduced to " 1249608d7e2SRuslan Ermilov.endif 1259608d7e2SRuslan Ermilov.endif 1269608d7e2SRuslan Ermilov 1276541d27cSJuli Mallettfailure: 128624abf85SJuli Mallett @echo "FAIL: Test failed: regression detected. See above." 1296541d27cSJuli Mallett @false 130