Makefile revision 136842
1# $FreeBSD: head/tools/build/make_check/Makefile 136842 2004-10-23 21:38:58Z ru $ 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 @echo "Running test pass_cmd_vars" 57 @${MAKE} pass_cmd_vars || ${MAKE} failure 58 @echo "PASS: Test pass_cmd_vars detected no regression." 59 @echo "Running test plus_flag" 60 @${MAKE} plus_flag || ${MAKE} failure 61 @echo "PASS: Test plus_flag detected no regression." 62 @echo "Running test shell" 63 @! ${MAKE} shell >/dev/null 2>&1 && true || ${MAKE} failure 64 @echo "PASS: Test shell detected no regression." 65 66.if make(double) 67# Doubly-defined targets. make(1) will warn, but use the "right" one. If it 68# switches to using the "non-right" one, it breaks things worse than a little 69# regression test. 70double: 71 @true 72 73double: 74 @false 75.endif 76 77.if make(sysvmatch) 78# Some versions of FreeBSD make(1) do not handle a nil LHS in sysvsubst. 79sysvmatch: 80 @echo EMPTY ${NIL:=foo} LHS | \ 81 diff -u ${.CURDIR}/regress.sysvmatch.out - || false 82.endif 83 84# A bogus target for the lhs_expn test; If this is reached, then the make(1) 85# program has not errored out because of the recursion caused by not expanding 86# the left-hand-side's embedded variables above. 87lhs_expn: 88 @true 89 90.if make(notdef) 91# make(1) claims to only evaluate a conditional as far as is necessary 92# to determine its value; that was not always the case. 93.undef notdef 94notdef: 95.if defined(notdef) && ${notdef:U} 96.endif 97.endif 98 99.if make(modifiers) 100# See if make(1) supports the C modifier. 101modifiers: 102 @if ${MAKE} -V .CURDIR:C/.// 2>&1 >/dev/null | \ 103 grep -q "Unknown modifier 'C'"; then \ 104 false; \ 105 fi 106.endif 107 108.if make(funny_targets) 109funny_targets: colons::target exclamation!target 110colons::target: 111exclamation!target: 112.endif 113 114.if make(arith_expr) 115arith_expr: 116# See if arithmetic expression parsing is broken. 117# The different spacing below is intentional. 118VALUE= 0 119.if (${VALUE} < 0)||(${VALUE}>0) 120.endif 121.endif 122 123.if make(PATH_exists) 124PATH_exists: 125.PATH: ${.CURDIR} 126.if !exists(${.CURDIR}/) || !exists(${.CURDIR}/.) || !exists(${.CURDIR}/..) 127.error exists() failed 128.endif 129.endif 130 131.if make(double_quotes) 132VALUE= foo "" 133double_quotes: 134.if ${VALUE:S/$//} != ${VALUE} 135.error "" reduced to " 136.endif 137.endif 138 139.if make(double_quotes2) 140double_quotes2: 141 @cat /dev/null "" 142.endif 143 144# 145# Check passing of variable via MAKEFLAGS 146# 147.if make(pass_cmd_vars) 148pass_cmd_vars: 149 @${MAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_1 150 @${MAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_2 151 @${MAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_3 152 @${MAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_4 153.endif 154 155.if make(pass_cmd_vars_1) 156# Check that the variable definition arrived from the calling make 157pass_cmd_vars_1: 158 @: 159 160.if ${CMD1} != cmd1 || ${CMD2} != cmd2 161.error variables not passed through MAKEFLAGS 162.endif 163 164# Check that the variable definition is in MAKEFLAGS 165.if ${.MAKEFLAGS:MCMD1=*} != "CMD1=cmd1" || ${.MAKEFLAGS:MCMD2=*} != "CMD2=cmd2" 166.error variable assignment not found in $${MAKEFLAGS} 167.endif 168 169# Check that the variable definition is not in MFLAGS 170.if ${MFLAGS:MCMD1=*} != "" || ${MFLAGS:MCMD2=*} != "" 171.error variable assignment found in $${MFLAGS} 172.endif 173.endif 174 175.if make(pass_cmd_vars_2) 176# Check that we cannot override the passed variables 177CMD1=foo1 178CMD2=foo2 179 180.if ${CMD1} != cmd1 || ${CMD2} != cmd2 181.error MAKEFLAGS-passed variables overridden 182.endif 183 184pass_cmd_vars_2: 185 @: 186.endif 187 188.if make(pass_cmd_vars_3) 189# Check that we can override the passed variables on the next sub-make's 190# command line 191 192pass_cmd_vars_3: 193 @${MAKE} CMD1=foo1 pass_cmd_vars_3_1 194.endif 195 196.if make(pass_cmd_vars_3_1) 197.if ${CMD1} != foo1 || ${CMD2} != cmd2 198.error MAKEFLAGS-passed variables not overridden on command line 199.endif 200pass_cmd_vars_3_1: 201 @: 202.endif 203 204.if make(pass_cmd_vars_4) 205# Ensure that a variable assignment passed via MAKEFLAGS may be overwritten 206# by evaluating the .MAKEFLAGS target. 207 208.MAKEFLAGS: CMD1=baz1 209 210pass_cmd_vars_4: 211 @${MAKE} pass_cmd_vars_4_1 212 213.if ${CMD1} != baz1 || ${CMD2} != cmd2 214.error MAKEFLAGS-passed variables not overridden via .MAKEFLAGS target 215.endif 216 217.endif 218.if make(pass_cmd_vars_4_1) 219.if ${CMD1} != baz1 || ${CMD2} != cmd2 220.error MAKEFLAGS-passed variables not overridden via .MAKEFLAGS target (2) 221.endif 222pass_cmd_vars_4_1: 223 @: 224.endif 225 226# 227# Test whether make supports the '+' flag (meaning: execute even with -n) 228# 229.if make(plus_flag) 230OUT != ${MAKE} -n plus_flag_1 231.if ${OUT} != "/tmp" 232.error make doesn't handle + flag 233.endif 234plus_flag: 235 @: 236.endif 237.if make(plus_flag_1) 238plus_flag_1: 239 +@cd /tmp; pwd 240.endif 241 242.if make(shell) 243# Test if make fully supports the .SHELL specification. 244.SHELL: path=/nonexistent 245A!= echo ok 246shell: 247.endif 248 249failure: 250 @echo "FAIL: Test failed: regression detected. See above." 251 @false 252