Makefile revision 138080
195158Sjmallett# $FreeBSD: head/tools/build/make_check/Makefile 138080 2004-11-25 10:03:29Z harti $ 295158Sjmallett 398442Sjmallett# Test for broken LHS expansion. 4107374Sru# This *must* cause make(1) to detect a recursive variable, and fail as such. 598442Sjmallett.if make(lhs_expn) 698442SjmallettFOO= ${BAR} 798442SjmallettBAR${NIL}= ${FOO} 898442SjmallettFOO${BAR}= ${FOO} 998442Sjmallett.endif 1098442Sjmallett 1195158SjmallettDATA1= helllo 1295158SjmallettDATA2:= ${DATA1} 1395158SjmallettDATA3= ${DATA2:S/ll/rr/g} 1495158SjmallettDATA4:= ${DATA2:S/ll/rr/g} 1595158SjmallettDATA2?= allo 1695158SjmallettDATA5:= ${DATA2:S/ll/ii/g} ${DATA1:S/ll/rr/g} 1795158SjmallettDATA2= yello 1895158SjmallettDATA1:= ${DATA5:S/l/r/g} 1996070SjmallettNIL= 2095158Sjmallett 2195158Sjmallettall: 22138080Sharti @echo '1..16' 2395158Sjmallett @echo 1:${DATA1} 2:${DATA2} 3:${DATA3} 4:${DATA4} 5:${DATA5} | \ 2495158Sjmallett diff -u ${.CURDIR}/regress.variables.out - || ${MAKE} failure 25137587Snik @echo "ok 1 - test_variables # Test variables detected no regression, output matches." 26110654Sgad @${MAKE} double 2>/dev/null || ${MAKE} failure 27137587Snik @echo "ok 2 - test_targets # Test targets detected no regression." 2896070Sjmallett @${MAKE} sysvmatch || ${MAKE} failure 29137587Snik @echo "ok 3 - sysvmatch # Test sysvmatch detected no regression." 3098461Sjmallett @! ${MAKE} lhs_expn && true || ${MAKE} failure 31137587Snik @echo "ok 4 lhs_expn # Test lhs_expn detected no regression." 32107374Sru @${MAKE} notdef || ${MAKE} failure 33137587Snik @echo "ok 5 - notdef # Test notdef detected no regression." 34107374Sru @${MAKE} modifiers || ${MAKE} failure 35137587Snik @echo "ok 6 - modifiers # Test modifiers detected no regression." 36107375Sru @${MAKE} funny_targets || ${MAKE} failure 37137587Snik @echo "ok 7 funny_targets # Test funny_targets detected no regression." 38117226Sru @${MAKE} arith_expr || ${MAKE} failure 39137587Snik @echo "ok 8 arith_expr # Test arith_expr detected no regression." 40120676Sru @${MAKE} PATH_exists || ${MAKE} failure 41137587Snik @echo "ok 9 PATH_exists # Test PATH_exists detected no regression." 42125219Sru @${MAKE} double_quotes || ${MAKE} failure 43137587Snik @echo "ok 10 double_quotes # Test double_quotes detected no regression." 44125227Sru @! ${MAKE} double_quotes2 >/dev/null 2>&1 && true || ${MAKE} failure 45137587Snik @echo "ok 11 double_quotes2 # Test double_quotes2 detected no regression." 46133109Sharti @${MAKE} pass_cmd_vars || ${MAKE} failure 47137587Snik @echo "ok 12 pass_cmd_vars # Test pass_cmd_vars detected no regression." 48133161Sharti @${MAKE} plus_flag || ${MAKE} failure 49137587Snik @echo "ok 13 plus_flag # Test plus_flag detected no regression." 50136842Sru @! ${MAKE} shell >/dev/null 2>&1 && true || ${MAKE} failure 51137587Snik @echo "ok 14 shell # Test shell detected no regression." 52138080Sharti @${MAKE} shell_1 || ${MAKE} failure 53138080Sharti @echo "ok 15 shell_1 # Test shell_1 detected no regression." 54138080Sharti @${MAKE} shell_2 || ${MAKE} failure 55138080Sharti @echo "ok 16 shell_2 # Test shell_2 detected no regression." 5695158Sjmallett 57105907Sjmallett.if make(double) 58100794Sjmallett# Doubly-defined targets. make(1) will warn, but use the "right" one. If it 59100794Sjmallett# switches to using the "non-right" one, it breaks things worse than a little 60100794Sjmallett# regression test. 6195167Sjmallettdouble: 6295167Sjmallett @true 6395167Sjmallett 6495167Sjmallettdouble: 6595167Sjmallett @false 66105907Sjmallett.endif 6795167Sjmallett 68105907Sjmallett.if make(sysvmatch) 6996070Sjmallett# Some versions of FreeBSD make(1) do not handle a nil LHS in sysvsubst. 7096070Sjmallettsysvmatch: 7196070Sjmallett @echo EMPTY ${NIL:=foo} LHS | \ 7296070Sjmallett diff -u ${.CURDIR}/regress.sysvmatch.out - || false 73105907Sjmallett.endif 7496070Sjmallett 7598442Sjmallett# A bogus target for the lhs_expn test; If this is reached, then the make(1) 7698442Sjmallett# program has not errored out because of the recursion caused by not expanding 7798442Sjmallett# the left-hand-side's embedded variables above. 7898442Sjmallettlhs_expn: 7998461Sjmallett @true 8098442Sjmallett 81107374Sru.if make(notdef) 82107374Sru# make(1) claims to only evaluate a conditional as far as is necessary 83107374Sru# to determine its value; that was not always the case. 84107374Sru.undef notdef 85107374Srunotdef: 86107374Sru.if defined(notdef) && ${notdef:U} 87107374Sru.endif 88107374Sru.endif 89107374Sru 90107374Sru.if make(modifiers) 91107374Sru# See if make(1) supports the C modifier. 92107374Srumodifiers: 93107374Sru @if ${MAKE} -V .CURDIR:C/.// 2>&1 >/dev/null | \ 94107374Sru grep -q "Unknown modifier 'C'"; then \ 95107374Sru false; \ 96107374Sru fi 97107374Sru.endif 98107374Sru 99107375Sru.if make(funny_targets) 100107375Srufunny_targets: colons::target exclamation!target 101107375Srucolons::target: 102107375Sruexclamation!target: 103107375Sru.endif 104107375Sru 105117226Sru.if make(arith_expr) 106117226Sruarith_expr: 107117226Sru# See if arithmetic expression parsing is broken. 108117226Sru# The different spacing below is intentional. 109117226SruVALUE= 0 110117226Sru.if (${VALUE} < 0)||(${VALUE}>0) 111117226Sru.endif 112117226Sru.endif 113117226Sru 114120676Sru.if make(PATH_exists) 115120676SruPATH_exists: 116120676Sru.PATH: ${.CURDIR} 117120676Sru.if !exists(${.CURDIR}/) || !exists(${.CURDIR}/.) || !exists(${.CURDIR}/..) 118120676Sru.error exists() failed 119120676Sru.endif 120120676Sru.endif 121120676Sru 122125219Sru.if make(double_quotes) 123125219SruVALUE= foo "" 124125219Srudouble_quotes: 125125219Sru.if ${VALUE:S/$//} != ${VALUE} 126125219Sru.error "" reduced to " 127125219Sru.endif 128125219Sru.endif 129125219Sru 130125227Sru.if make(double_quotes2) 131125227Srudouble_quotes2: 132125227Sru @cat /dev/null "" 133125227Sru.endif 134125227Sru 135133109Sharti# 136133109Sharti# Check passing of variable via MAKEFLAGS 137133109Sharti# 138133109Sharti.if make(pass_cmd_vars) 139133109Shartipass_cmd_vars: 140133109Sharti @${MAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_1 141133109Sharti @${MAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_2 142133109Sharti @${MAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_3 143133109Sharti @${MAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_4 144133109Sharti.endif 145133109Sharti 146133109Sharti.if make(pass_cmd_vars_1) 147133109Sharti# Check that the variable definition arrived from the calling make 148133109Shartipass_cmd_vars_1: 149133109Sharti @: 150133109Sharti 151133109Sharti.if ${CMD1} != cmd1 || ${CMD2} != cmd2 152133164Sharti.error variables not passed through MAKEFLAGS 153133109Sharti.endif 154133109Sharti 155133109Sharti# Check that the variable definition is in MAKEFLAGS 156133109Sharti.if ${.MAKEFLAGS:MCMD1=*} != "CMD1=cmd1" || ${.MAKEFLAGS:MCMD2=*} != "CMD2=cmd2" 157133164Sharti.error variable assignment not found in $${MAKEFLAGS} 158133109Sharti.endif 159133109Sharti 160133109Sharti# Check that the variable definition is not in MFLAGS 161133109Sharti.if ${MFLAGS:MCMD1=*} != "" || ${MFLAGS:MCMD2=*} != "" 162133164Sharti.error variable assignment found in $${MFLAGS} 163133109Sharti.endif 164133109Sharti.endif 165133109Sharti 166133109Sharti.if make(pass_cmd_vars_2) 167133109Sharti# Check that we cannot override the passed variables 168133109ShartiCMD1=foo1 169133109ShartiCMD2=foo2 170133109Sharti 171133109Sharti.if ${CMD1} != cmd1 || ${CMD2} != cmd2 172133164Sharti.error MAKEFLAGS-passed variables overridden 173133109Sharti.endif 174133109Sharti 175133109Shartipass_cmd_vars_2: 176133109Sharti @: 177133109Sharti.endif 178133109Sharti 179133109Sharti.if make(pass_cmd_vars_3) 180133109Sharti# Check that we can override the passed variables on the next sub-make's 181133109Sharti# command line 182133109Sharti 183133109Shartipass_cmd_vars_3: 184133109Sharti @${MAKE} CMD1=foo1 pass_cmd_vars_3_1 185133109Sharti.endif 186133109Sharti 187133109Sharti.if make(pass_cmd_vars_3_1) 188133109Sharti.if ${CMD1} != foo1 || ${CMD2} != cmd2 189133164Sharti.error MAKEFLAGS-passed variables not overridden on command line 190133109Sharti.endif 191133109Shartipass_cmd_vars_3_1: 192133109Sharti @: 193133109Sharti.endif 194133109Sharti 195133109Sharti.if make(pass_cmd_vars_4) 196133109Sharti# Ensure that a variable assignment passed via MAKEFLAGS may be overwritten 197133109Sharti# by evaluating the .MAKEFLAGS target. 198133109Sharti 199133109Sharti.MAKEFLAGS: CMD1=baz1 200133109Sharti 201133109Shartipass_cmd_vars_4: 202133593Sharti @${MAKE} pass_cmd_vars_4_1 203133109Sharti 204133109Sharti.if ${CMD1} != baz1 || ${CMD2} != cmd2 205133164Sharti.error MAKEFLAGS-passed variables not overridden via .MAKEFLAGS target 206133109Sharti.endif 207133109Sharti 208133109Sharti.endif 209133109Sharti.if make(pass_cmd_vars_4_1) 210133109Sharti.if ${CMD1} != baz1 || ${CMD2} != cmd2 211133164Sharti.error MAKEFLAGS-passed variables not overridden via .MAKEFLAGS target (2) 212133109Sharti.endif 213133109Shartipass_cmd_vars_4_1: 214133109Sharti @: 215133109Sharti.endif 216133109Sharti 217133161Sharti# 218133161Sharti# Test whether make supports the '+' flag (meaning: execute even with -n) 219133161Sharti# 220133161Sharti.if make(plus_flag) 221133161ShartiOUT != ${MAKE} -n plus_flag_1 222133161Sharti.if ${OUT} != "/tmp" 223133164Sharti.error make doesn't handle + flag 224133161Sharti.endif 225133161Shartiplus_flag: 226133161Sharti @: 227133161Sharti.endif 228133161Sharti.if make(plus_flag_1) 229133161Shartiplus_flag_1: 230133161Sharti +@cd /tmp; pwd 231133161Sharti.endif 232133161Sharti 233136842Sru.if make(shell) 234136842Sru# Test if make fully supports the .SHELL specification. 235136842Sru.SHELL: path=/nonexistent 236136842SruA!= echo ok 237136842Srushell: 238136842Sru.endif 239136842Sru 240138080Sharti.if make(shell_1) 241138080Sharti# Test if setting the shell by name only works. Because we have no ksh 242138080Sharti# in the base system we test that we can set sh and csh. We try only exact 243138080Sharti# matching names and do not exercise the rather strange matching algorithm. 244138080Shartishell_1: 245138080Sharti @${MAKE} shell_1_csh 246138080Sharti @${MAKE} shell_1_sh 247138080Sharti.endif 248138080Sharti.if make(shell_1_csh) 249138080Sharti.SHELL: name="csh" 250138080Shartishell_1_csh: 251138080Sharti @echo $${shell} | grep -q '^/bin/csh$$' 252138080Sharti.endif 253138080Sharti.if make(shell_1_sh) 254138080Sharti.SHELL: name="sh" 255138080Shartishell_1_sh: 256138080Sharti @ps -ax -opid,command | awk '$$1=="'$$$$'" { print $$2 }' | grep -q '^/bin/sh$$' 257138080Sharti.endif 258138080Sharti 259138080Sharti.if make(shell_2) 260138080Sharti# Test if we can replace the shell specification. We do this by using 261138080Sharti# a shell scripts that prints us its arguments and standard input as the shell 262138080Shartishell_2: 263138080Sharti @${MAKE} -B shell_2B | \ 264138080Sharti diff -u ${.CURDIR}/regress.shell_2B.out - || false 265138080Sharti @${MAKE} -j1 shell_2j | \ 266138080Sharti diff -u ${.CURDIR}/regress.shell_2j.out - || false 267138080Sharti.endif 268138080Sharti 269138080Sharti.if make(shell_2B) 270138080Sharti.SHELL: name="echo" path="${.CURDIR}/shell_test" quiet="be quiet" echo="be verbose" filter="be verbose" echoFlag="x" errFlag="y" hasErrCtl=y check="check errors" ignore="ignore errors" 271138080Sharti 272138080Shartishell_2B: 273138080Sharti -@funny $$ 274138080Sharti funnier $$ 275138080Sharti.endif 276138080Sharti 277138080Sharti.if make(shell_2j) 278138080Sharti.SHELL: name="echo" path="${.CURDIR}/shell_test" quiet="be quiet" echo="be verbose" filter="be verbose" echoFlag="x" errFlag="y" hasErrCtl=y check="check errors" ignore="ignore errors" 279138080Sharti 280138080Shartishell_2j: 281138080Sharti -@funny $$ 282138080Sharti funnier $$ 283138080Sharti.endif 284138080Sharti 28595158Sjmallettfailure: 286137587Snik @echo "not ok # Test failed: regression detected. See above." 28795158Sjmallett @false 288