Makefile revision 138317
195158Sjmallett# $FreeBSD: head/tools/build/make_check/Makefile 138317 2004-12-02 17:00:58Z 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 21138317ShartiSMAKE= ${MAKE} -C ${.CURDIR} 22138317Sharti 2395158Sjmallettall: 24138317Sharti @if [ ! -x ./shell_test ] ; then \ 25138317Sharti ${INSTALL} -m 555 ${.CURDIR}/shell_test.sh shell_test ; \ 26138317Sharti fi 27138317Sharti @echo '1..17' 28138317Sharti @${SMAKE} C_check || { cd ${.CURDIR} ; ${MAKE} failure ; } 29138317Sharti @echo "ok 1 - C_check # Test of -C flag existence detected no regression." 3095158Sjmallett @echo 1:${DATA1} 2:${DATA2} 3:${DATA3} 4:${DATA4} 5:${DATA5} | \ 31138317Sharti diff -u ${.CURDIR}/regress.variables.out - || \ 32138317Sharti ${SMAKE} failure 33138317Sharti @echo "ok 2 - test_variables # Test variables detected no regression, output matches." 34138317Sharti @${SMAKE} double 2>/dev/null || ${SMAKE} failure 35138317Sharti @echo "ok 3 - test_targets # Test targets detected no regression." 36138317Sharti @${SMAKE} sysvmatch || ${SMAKE} failure 37138317Sharti @echo "ok 4 - sysvmatch # Test sysvmatch detected no regression." 38138317Sharti @! ${SMAKE} lhs_expn && true || ${SMAKE} failure 39138317Sharti @echo "ok 5 lhs_expn # Test lhs_expn detected no regression." 40138317Sharti @${SMAKE} notdef || ${SMAKE} failure 41138317Sharti @echo "ok 6 - notdef # Test notdef detected no regression." 42138317Sharti @${SMAKE} modifiers || ${SMAKE} failure 43138317Sharti @echo "ok 7 - modifiers # Test modifiers detected no regression." 44138317Sharti @${SMAKE} funny_targets || ${SMAKE} failure 45138317Sharti @echo "ok 8 funny_targets # Test funny_targets detected no regression." 46138317Sharti @${SMAKE} arith_expr || ${SMAKE} failure 47138317Sharti @echo "ok 9 arith_expr # Test arith_expr detected no regression." 48138317Sharti @${SMAKE} PATH_exists || ${SMAKE} failure 49138317Sharti @echo "ok 10 PATH_exists # Test PATH_exists detected no regression." 50138317Sharti @${SMAKE} double_quotes || ${SMAKE} failure 51138317Sharti @echo "ok 11 double_quotes # Test double_quotes detected no regression." 52138317Sharti @! ${SMAKE} double_quotes2 >/dev/null 2>&1 && true || ${SMAKE} failure 53138317Sharti @echo "ok 12 double_quotes2 # Test double_quotes2 detected no regression." 54138317Sharti @${SMAKE} pass_cmd_vars || ${SMAKE} failure 55138317Sharti @echo "ok 13 pass_cmd_vars # Test pass_cmd_vars detected no regression." 56138317Sharti @${SMAKE} plus_flag || ${SMAKE} failure 57138317Sharti @echo "ok 14 plus_flag # Test plus_flag detected no regression." 58138317Sharti @! ${SMAKE} shell >/dev/null 2>&1 && true || ${SMAKE} failure 59138317Sharti @echo "ok 15 shell # Test shell detected no regression." 60138317Sharti @${SMAKE} shell_1 || ${SMAKE} failure 61138317Sharti @echo "ok 16 shell_1 # Test shell_1 detected no regression." 62138317Sharti @${SMAKE} shell_2 || ${SMAKE} failure 63138317Sharti @echo "ok 17 shell_2 # Test shell_2 detected no regression." 6495158Sjmallett 65138317Sharti.if make(C_check) 66138317ShartiC_check: 67138317Sharti.endif 68138317Sharti 69105907Sjmallett.if make(double) 70100794Sjmallett# Doubly-defined targets. make(1) will warn, but use the "right" one. If it 71100794Sjmallett# switches to using the "non-right" one, it breaks things worse than a little 72100794Sjmallett# regression test. 7395167Sjmallettdouble: 7495167Sjmallett @true 7595167Sjmallett 7695167Sjmallettdouble: 7795167Sjmallett @false 78105907Sjmallett.endif 7995167Sjmallett 80105907Sjmallett.if make(sysvmatch) 8196070Sjmallett# Some versions of FreeBSD make(1) do not handle a nil LHS in sysvsubst. 8296070Sjmallettsysvmatch: 8396070Sjmallett @echo EMPTY ${NIL:=foo} LHS | \ 8496070Sjmallett diff -u ${.CURDIR}/regress.sysvmatch.out - || false 85105907Sjmallett.endif 8696070Sjmallett 8798442Sjmallett# A bogus target for the lhs_expn test; If this is reached, then the make(1) 8898442Sjmallett# program has not errored out because of the recursion caused by not expanding 8998442Sjmallett# the left-hand-side's embedded variables above. 9098442Sjmallettlhs_expn: 9198461Sjmallett @true 9298442Sjmallett 93107374Sru.if make(notdef) 94107374Sru# make(1) claims to only evaluate a conditional as far as is necessary 95107374Sru# to determine its value; that was not always the case. 96107374Sru.undef notdef 97107374Srunotdef: 98107374Sru.if defined(notdef) && ${notdef:U} 99107374Sru.endif 100107374Sru.endif 101107374Sru 102107374Sru.if make(modifiers) 103107374Sru# See if make(1) supports the C modifier. 104107374Srumodifiers: 105138317Sharti @if ${SMAKE} -V .CURDIR:C/.// 2>&1 >/dev/null | \ 106107374Sru grep -q "Unknown modifier 'C'"; then \ 107107374Sru false; \ 108107374Sru fi 109107374Sru.endif 110107374Sru 111107375Sru.if make(funny_targets) 112107375Srufunny_targets: colons::target exclamation!target 113107375Srucolons::target: 114107375Sruexclamation!target: 115107375Sru.endif 116107375Sru 117117226Sru.if make(arith_expr) 118117226Sruarith_expr: 119117226Sru# See if arithmetic expression parsing is broken. 120117226Sru# The different spacing below is intentional. 121117226SruVALUE= 0 122117226Sru.if (${VALUE} < 0)||(${VALUE}>0) 123117226Sru.endif 124117226Sru.endif 125117226Sru 126120676Sru.if make(PATH_exists) 127120676SruPATH_exists: 128120676Sru.PATH: ${.CURDIR} 129120676Sru.if !exists(${.CURDIR}/) || !exists(${.CURDIR}/.) || !exists(${.CURDIR}/..) 130120676Sru.error exists() failed 131120676Sru.endif 132120676Sru.endif 133120676Sru 134125219Sru.if make(double_quotes) 135125219SruVALUE= foo "" 136125219Srudouble_quotes: 137125219Sru.if ${VALUE:S/$//} != ${VALUE} 138125219Sru.error "" reduced to " 139125219Sru.endif 140125219Sru.endif 141125219Sru 142125227Sru.if make(double_quotes2) 143125227Srudouble_quotes2: 144125227Sru @cat /dev/null "" 145125227Sru.endif 146125227Sru 147133109Sharti# 148133109Sharti# Check passing of variable via MAKEFLAGS 149133109Sharti# 150133109Sharti.if make(pass_cmd_vars) 151133109Shartipass_cmd_vars: 152138317Sharti @${SMAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_1 153138317Sharti @${SMAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_2 154138317Sharti @${SMAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_3 155138317Sharti @${SMAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_4 156133109Sharti.endif 157133109Sharti 158133109Sharti.if make(pass_cmd_vars_1) 159133109Sharti# Check that the variable definition arrived from the calling make 160133109Shartipass_cmd_vars_1: 161133109Sharti @: 162133109Sharti 163133109Sharti.if ${CMD1} != cmd1 || ${CMD2} != cmd2 164133164Sharti.error variables not passed through MAKEFLAGS 165133109Sharti.endif 166133109Sharti 167133109Sharti# Check that the variable definition is in MAKEFLAGS 168133109Sharti.if ${.MAKEFLAGS:MCMD1=*} != "CMD1=cmd1" || ${.MAKEFLAGS:MCMD2=*} != "CMD2=cmd2" 169133164Sharti.error variable assignment not found in $${MAKEFLAGS} 170133109Sharti.endif 171133109Sharti 172133109Sharti# Check that the variable definition is not in MFLAGS 173133109Sharti.if ${MFLAGS:MCMD1=*} != "" || ${MFLAGS:MCMD2=*} != "" 174133164Sharti.error variable assignment found in $${MFLAGS} 175133109Sharti.endif 176133109Sharti.endif 177133109Sharti 178133109Sharti.if make(pass_cmd_vars_2) 179133109Sharti# Check that we cannot override the passed variables 180133109ShartiCMD1=foo1 181133109ShartiCMD2=foo2 182133109Sharti 183133109Sharti.if ${CMD1} != cmd1 || ${CMD2} != cmd2 184133164Sharti.error MAKEFLAGS-passed variables overridden 185133109Sharti.endif 186133109Sharti 187133109Shartipass_cmd_vars_2: 188133109Sharti @: 189133109Sharti.endif 190133109Sharti 191133109Sharti.if make(pass_cmd_vars_3) 192133109Sharti# Check that we can override the passed variables on the next sub-make's 193133109Sharti# command line 194133109Sharti 195133109Shartipass_cmd_vars_3: 196138317Sharti @${SMAKE} CMD1=foo1 pass_cmd_vars_3_1 197133109Sharti.endif 198133109Sharti 199133109Sharti.if make(pass_cmd_vars_3_1) 200133109Sharti.if ${CMD1} != foo1 || ${CMD2} != cmd2 201133164Sharti.error MAKEFLAGS-passed variables not overridden on command line 202133109Sharti.endif 203133109Shartipass_cmd_vars_3_1: 204133109Sharti @: 205133109Sharti.endif 206133109Sharti 207133109Sharti.if make(pass_cmd_vars_4) 208133109Sharti# Ensure that a variable assignment passed via MAKEFLAGS may be overwritten 209133109Sharti# by evaluating the .MAKEFLAGS target. 210133109Sharti 211133109Sharti.MAKEFLAGS: CMD1=baz1 212133109Sharti 213133109Shartipass_cmd_vars_4: 214138317Sharti @${SMAKE} pass_cmd_vars_4_1 215133109Sharti 216133109Sharti.if ${CMD1} != baz1 || ${CMD2} != cmd2 217133164Sharti.error MAKEFLAGS-passed variables not overridden via .MAKEFLAGS target 218133109Sharti.endif 219133109Sharti 220133109Sharti.endif 221133109Sharti.if make(pass_cmd_vars_4_1) 222133109Sharti.if ${CMD1} != baz1 || ${CMD2} != cmd2 223133164Sharti.error MAKEFLAGS-passed variables not overridden via .MAKEFLAGS target (2) 224133109Sharti.endif 225133109Shartipass_cmd_vars_4_1: 226133109Sharti @: 227133109Sharti.endif 228133109Sharti 229133161Sharti# 230133161Sharti# Test whether make supports the '+' flag (meaning: execute even with -n) 231133161Sharti# 232133161Sharti.if make(plus_flag) 233138317ShartiOUT != ${SMAKE} -n plus_flag_1 234133161Sharti.if ${OUT} != "/tmp" 235133164Sharti.error make doesn't handle + flag 236133161Sharti.endif 237133161Shartiplus_flag: 238133161Sharti @: 239133161Sharti.endif 240133161Sharti.if make(plus_flag_1) 241133161Shartiplus_flag_1: 242133161Sharti +@cd /tmp; pwd 243133161Sharti.endif 244133161Sharti 245136842Sru.if make(shell) 246136842Sru# Test if make fully supports the .SHELL specification. 247136842Sru.SHELL: path=/nonexistent 248136842SruA!= echo ok 249136842Srushell: 250136842Sru.endif 251136842Sru 252138080Sharti.if make(shell_1) 253138080Sharti# Test if setting the shell by name only works. Because we have no ksh 254138080Sharti# in the base system we test that we can set sh and csh. We try only exact 255138080Sharti# matching names and do not exercise the rather strange matching algorithm. 256138080Shartishell_1: 257138317Sharti @${SMAKE} shell_1_csh 258138317Sharti @${SMAKE} shell_1_sh 259138080Sharti.endif 260138080Sharti.if make(shell_1_csh) 261138080Sharti.SHELL: name="csh" 262138080Shartishell_1_csh: 263138317Sharti @ps -ax -opid,command | awk '$$1=="'$$$$'" { print $$2 }' | grep -E -q '^(/bin/)?csh$$' 264138080Sharti.endif 265138080Sharti.if make(shell_1_sh) 266138080Sharti.SHELL: name="sh" 267138080Shartishell_1_sh: 268138080Sharti @ps -ax -opid,command | awk '$$1=="'$$$$'" { print $$2 }' | grep -q '^/bin/sh$$' 269138080Sharti.endif 270138080Sharti 271138080Sharti.if make(shell_2) 272138080Sharti# Test if we can replace the shell specification. We do this by using 273138080Sharti# a shell scripts that prints us its arguments and standard input as the shell 274138080Shartishell_2: 275138317Sharti @${SMAKE} -B shell_2B | \ 276138080Sharti diff -u ${.CURDIR}/regress.shell_2B.out - || false 277138317Sharti @${SMAKE} -j1 shell_2j | \ 278138080Sharti diff -u ${.CURDIR}/regress.shell_2j.out - || false 279138080Sharti.endif 280138080Sharti 281138080Sharti.if make(shell_2B) 282138317Sharti.SHELL: name="echo" path="${.OBJDIR}/shell_test" quiet="be quiet" echo="be verbose" filter="be verbose" echoFlag="x" errFlag="y" hasErrCtl=y check="check errors" ignore="ignore errors" 283138080Sharti 284138080Shartishell_2B: 285138080Sharti -@funny $$ 286138080Sharti funnier $$ 287138080Sharti.endif 288138080Sharti 289138080Sharti.if make(shell_2j) 290138317Sharti.SHELL: name="echo" path="${.OBJDIR}/shell_test" quiet="be quiet" echo="be verbose" filter="be verbose" echoFlag="x" errFlag="y" hasErrCtl=y check="check errors" ignore="ignore errors" 291138080Sharti 292138080Shartishell_2j: 293138080Sharti -@funny $$ 294138080Sharti funnier $$ 295138080Sharti.endif 296138080Sharti 29795158Sjmallettfailure: 298137587Snik @echo "not ok # Test failed: regression detected. See above." 29995158Sjmallett @false 300138317Sharti 301138317Sharticlean: 302138317Sharti rm -f shell_test 303