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