195158Sjmallett# $FreeBSD$ 295158Sjmallett 3222295Sobrien.MAKE.MODE= normal 4222295Sobrien 598442Sjmallett# Test for broken LHS expansion. 6107374Sru# This *must* cause make(1) to detect a recursive variable, and fail as such. 798442Sjmallett.if make(lhs_expn) 898442SjmallettFOO= ${BAR} 998442SjmallettBAR${NIL}= ${FOO} 1098442SjmallettFOO${BAR}= ${FOO} 1198442Sjmallett.endif 1298442Sjmallett 1395158SjmallettDATA1= helllo 1495158SjmallettDATA2:= ${DATA1} 1595158SjmallettDATA3= ${DATA2:S/ll/rr/g} 1695158SjmallettDATA4:= ${DATA2:S/ll/rr/g} 1795158SjmallettDATA2?= allo 1895158SjmallettDATA5:= ${DATA2:S/ll/ii/g} ${DATA1:S/ll/rr/g} 1995158SjmallettDATA2= yello 2095158SjmallettDATA1:= ${DATA5:S/l/r/g} 2196070SjmallettNIL= 2295158Sjmallett 23138432SruSMAKE= MAKEFLAGS= ${MAKE} -C ${.CURDIR} 24138317Sharti 2595158Sjmallettall: 26238143Sobrien @echo '1..16' 27245171Sobrien @${SMAKE} C_check || { ${MAKE} -C ${.CURDIR} failure ; } 28138317Sharti @echo "ok 1 - C_check # Test of -C flag existence detected no regression." 2995158Sjmallett @echo 1:${DATA1} 2:${DATA2} 3:${DATA3} 4:${DATA4} 5:${DATA5} | \ 30138317Sharti diff -u ${.CURDIR}/regress.variables.out - || \ 31138317Sharti ${SMAKE} failure 32138317Sharti @echo "ok 2 - test_variables # Test variables detected no regression, output matches." 33138317Sharti @${SMAKE} double 2>/dev/null || ${SMAKE} failure 34138317Sharti @echo "ok 3 - test_targets # Test targets detected no regression." 35138317Sharti @${SMAKE} sysvmatch || ${SMAKE} failure 36138317Sharti @echo "ok 4 - sysvmatch # Test sysvmatch detected no regression." 37138317Sharti @! ${SMAKE} lhs_expn && true || ${SMAKE} failure 38138317Sharti @echo "ok 5 lhs_expn # Test lhs_expn detected no regression." 39138317Sharti @${SMAKE} notdef || ${SMAKE} failure 40138317Sharti @echo "ok 6 - notdef # Test notdef detected no regression." 41138317Sharti @${SMAKE} modifiers || ${SMAKE} failure 42138317Sharti @echo "ok 7 - modifiers # Test modifiers detected no regression." 43138317Sharti @${SMAKE} arith_expr || ${SMAKE} failure 44238143Sobrien @echo "ok 8 arith_expr # Test arith_expr detected no regression." 45138317Sharti @${SMAKE} PATH_exists || ${SMAKE} failure 46238143Sobrien @echo "ok 9 PATH_exists # Test PATH_exists detected no regression." 47138317Sharti @${SMAKE} double_quotes || ${SMAKE} failure 48238143Sobrien @echo "ok 10 double_quotes # Test double_quotes detected no regression." 49138317Sharti @! ${SMAKE} double_quotes2 >/dev/null 2>&1 && true || ${SMAKE} failure 50238143Sobrien @echo "ok 11 double_quotes2 # Test double_quotes2 detected no regression." 51138317Sharti @${SMAKE} pass_cmd_vars || ${SMAKE} failure 52238143Sobrien @echo "ok 12 pass_cmd_vars # Test pass_cmd_vars detected no regression." 53138317Sharti @${SMAKE} plus_flag || ${SMAKE} failure 54238143Sobrien @echo "ok 13 plus_flag # Test plus_flag detected no regression." 55138317Sharti @! ${SMAKE} shell >/dev/null 2>&1 && true || ${SMAKE} failure 56238143Sobrien @echo "ok 14 shell # Test shell detected no regression." 57138317Sharti @${SMAKE} shell_1 || ${SMAKE} failure 58238143Sobrien @echo "ok 15 shell_1 # Test shell_1 detected no regression." 59241298Smarcel.if !defined(.PARSEDIR) 60138317Sharti @${SMAKE} shell_2 || ${SMAKE} failure 61238143Sobrien @echo "ok 16 shell_2 # Test shell_2 detected no regression." 62241298Smarcel.endif 6395158Sjmallett 64138317Sharti.if make(C_check) 65138317ShartiC_check: 66138317Sharti.endif 67138317Sharti 68105907Sjmallett.if make(double) 69100794Sjmallett# Doubly-defined targets. make(1) will warn, but use the "right" one. If it 70100794Sjmallett# switches to using the "non-right" one, it breaks things worse than a little 71100794Sjmallett# regression test. 7295167Sjmallettdouble: 7395167Sjmallett @true 7495167Sjmallett 7595167Sjmallettdouble: 7695167Sjmallett @false 77105907Sjmallett.endif 7895167Sjmallett 79105907Sjmallett.if make(sysvmatch) 8096070Sjmallett# Some versions of FreeBSD make(1) do not handle a nil LHS in sysvsubst. 8196070Sjmallettsysvmatch: 8296070Sjmallett @echo EMPTY ${NIL:=foo} LHS | \ 8396070Sjmallett diff -u ${.CURDIR}/regress.sysvmatch.out - || false 84105907Sjmallett.endif 8596070Sjmallett 8698442Sjmallett# A bogus target for the lhs_expn test; If this is reached, then the make(1) 8798442Sjmallett# program has not errored out because of the recursion caused by not expanding 8898442Sjmallett# the left-hand-side's embedded variables above. 8998442Sjmallettlhs_expn: 9098461Sjmallett @true 9198442Sjmallett 92107374Sru.if make(notdef) 93107374Sru# make(1) claims to only evaluate a conditional as far as is necessary 94107374Sru# to determine its value; that was not always the case. 95107374Sru.undef notdef 96107374Srunotdef: 97241298Smarcel.if defined(notdef) && ${notdef:M/} 98107374Sru.endif 99107374Sru.endif 100107374Sru 101107374Sru.if make(modifiers) 102241298Smarcel.if defined(.PARSEDIR) 103241298Smarcel# check if bmake can expand plain variables 104241298Smarcel.MAKE.EXPAND_VARIABLES= yes 105241298Smarcelx!= ${SMAKE} -V .CURDIR:H 106241298Smarcelmodifiers: 107241298Smarcel.if ${.CURDIR:H} != "$x" 108241298Smarcel @false 109241298Smarcel.endif 110241298Smarcel.else 111107374Sru# See if make(1) supports the C modifier. 112241298Smarcelmodifiers: dollarV 113138317Sharti @if ${SMAKE} -V .CURDIR:C/.// 2>&1 >/dev/null | \ 114107374Sru grep -q "Unknown modifier 'C'"; then \ 115107374Sru false; \ 116107374Sru fi 117241298Smarcel 118241298Smarcel# check that make -V '${VAR}' works 119241298SmarcelV_expn != V_OK=ok ${SMAKE} -r -f /dev/null -V '$${V_OK}' 120241298SmarceldollarV: 121241298Smarcel.if ${V_expn} == "" 122241298Smarcel @false 123107374Sru.endif 124241298Smarcel.endif 125241298Smarcel.endif 126107374Sru 127117226Sru.if make(arith_expr) 128117226Sruarith_expr: 129117226Sru# See if arithmetic expression parsing is broken. 130117226Sru# The different spacing below is intentional. 131117226SruVALUE= 0 132117226Sru.if (${VALUE} < 0)||(${VALUE}>0) 133117226Sru.endif 134117226Sru.endif 135117226Sru 136120676Sru.if make(PATH_exists) 137120676SruPATH_exists: 138120676Sru.PATH: ${.CURDIR} 139120676Sru.if !exists(${.CURDIR}/) || !exists(${.CURDIR}/.) || !exists(${.CURDIR}/..) 140120676Sru.error exists() failed 141120676Sru.endif 142120676Sru.endif 143120676Sru 144125219Sru.if make(double_quotes) 145125219SruVALUE= foo "" 146125219Srudouble_quotes: 147125219Sru.if ${VALUE:S/$//} != ${VALUE} 148125219Sru.error "" reduced to " 149125219Sru.endif 150125219Sru.endif 151125219Sru 152125227Sru.if make(double_quotes2) 153125227Srudouble_quotes2: 154125227Sru @cat /dev/null "" 155125227Sru.endif 156125227Sru 157133109Sharti# 158133109Sharti# Check passing of variable via MAKEFLAGS 159133109Sharti# 160133109Sharti.if make(pass_cmd_vars) 161133109Shartipass_cmd_vars: 162138317Sharti @${SMAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_1 163138317Sharti @${SMAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_2 164138317Sharti @${SMAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_3 165138317Sharti @${SMAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_4 166133109Sharti.endif 167133109Sharti 168222295Sobrien# 169222295Sobrien# Check that the variable definition arrived from the calling make 170222295Sobrien# 171133109Sharti.if make(pass_cmd_vars_1) 172222295Sobrien# These values should get overridden by the commandline 173222295SobrienCMD1=oops1 174222295SobrienCMD2=oops2 175133109Shartipass_cmd_vars_1: 176133109Sharti @: 177133109Sharti 178133109Sharti.if ${CMD1} != cmd1 || ${CMD2} != cmd2 179133164Sharti.error variables not passed through MAKEFLAGS 180133109Sharti.endif 181133109Sharti.endif 182133109Sharti 183133109Sharti.if make(pass_cmd_vars_2) 184133109Sharti# Check that we cannot override the passed variables 185133109ShartiCMD1=foo1 186133109ShartiCMD2=foo2 187133109Sharti 188133109Sharti.if ${CMD1} != cmd1 || ${CMD2} != cmd2 189133164Sharti.error MAKEFLAGS-passed variables overridden 190133109Sharti.endif 191133109Sharti 192133109Shartipass_cmd_vars_2: 193133109Sharti @: 194133109Sharti.endif 195133109Sharti 196133109Sharti.if make(pass_cmd_vars_3) 197133109Sharti# Check that we can override the passed variables on the next sub-make's 198133109Sharti# command line 199133109Sharti 200133109Shartipass_cmd_vars_3: 201138317Sharti @${SMAKE} CMD1=foo1 pass_cmd_vars_3_1 202133109Sharti.endif 203133109Sharti 204133109Sharti.if make(pass_cmd_vars_3_1) 205133109Sharti.if ${CMD1} != foo1 || ${CMD2} != cmd2 206133164Sharti.error MAKEFLAGS-passed variables not overridden on command line 207133109Sharti.endif 208133109Shartipass_cmd_vars_3_1: 209133109Sharti @: 210133109Sharti.endif 211133109Sharti 212133109Sharti.if make(pass_cmd_vars_4) 213133109Sharti# Ensure that a variable assignment passed via MAKEFLAGS may be overwritten 214133109Sharti# by evaluating the .MAKEFLAGS target. 215133109Sharti 216133109Sharti.MAKEFLAGS: CMD1=baz1 217133109Sharti 218133109Shartipass_cmd_vars_4: 219138317Sharti @${SMAKE} pass_cmd_vars_4_1 220133109Sharti 221133109Sharti.if ${CMD1} != baz1 || ${CMD2} != cmd2 222133164Sharti.error MAKEFLAGS-passed variables not overridden via .MAKEFLAGS target 223133109Sharti.endif 224133109Sharti 225133109Sharti.endif 226133109Sharti.if make(pass_cmd_vars_4_1) 227133109Sharti.if ${CMD1} != baz1 || ${CMD2} != cmd2 228133164Sharti.error MAKEFLAGS-passed variables not overridden via .MAKEFLAGS target (2) 229133109Sharti.endif 230133109Shartipass_cmd_vars_4_1: 231133109Sharti @: 232133109Sharti.endif 233133109Sharti 234133161Sharti# 235133161Sharti# Test whether make supports the '+' flag (meaning: execute even with -n) 236133161Sharti# 237133161Sharti.if make(plus_flag) 238138317ShartiOUT != ${SMAKE} -n plus_flag_1 239222295Sobrien.if ${OUT:M/tmp} != "/tmp" 240133164Sharti.error make doesn't handle + flag 241133161Sharti.endif 242133161Shartiplus_flag: 243133161Sharti @: 244133161Sharti.endif 245133161Sharti.if make(plus_flag_1) 246133161Shartiplus_flag_1: 247133161Sharti +@cd /tmp; pwd 248133161Sharti.endif 249133161Sharti 250136842Sru.if make(shell) 251136842Sru# Test if make fully supports the .SHELL specification. 252136842Sru.SHELL: path=/nonexistent 253136842SruA!= echo ok 254136842Srushell: 255136842Sru.endif 256136842Sru 257138080Sharti.if make(shell_1) 258138080Sharti# Test if setting the shell by name only works. Because we have no ksh 259138080Sharti# in the base system we test that we can set sh and csh. We try only exact 260138080Sharti# matching names and do not exercise the rather strange matching algorithm. 261138080Shartishell_1: 262138317Sharti @${SMAKE} shell_1_csh 263138317Sharti @${SMAKE} shell_1_sh 264138080Sharti.endif 265138080Sharti.if make(shell_1_csh) 266138080Sharti.SHELL: name="csh" 267138080Shartishell_1_csh: 268138317Sharti @ps -ax -opid,command | awk '$$1=="'$$$$'" { print $$2 }' | grep -E -q '^(/bin/)?csh$$' 269138080Sharti.endif 270138080Sharti.if make(shell_1_sh) 271138080Sharti.SHELL: name="sh" 272138080Shartishell_1_sh: 273172399Sru @ps -ax -opid,command | awk '$$1=="'$$$$'" { print $$2 }' | grep -E -q '^(/bin/)?sh$$' 274138080Sharti.endif 275138080Sharti 276138080Sharti.if make(shell_2) 277138080Sharti# Test if we can replace the shell specification. We do this by using 278138080Sharti# a shell scripts that prints us its arguments and standard input as the shell 279138515Shartishell_2: shell_test 280138317Sharti @${SMAKE} -B shell_2B | \ 281138080Sharti diff -u ${.CURDIR}/regress.shell_2B.out - || false 282138317Sharti @${SMAKE} -j1 shell_2j | \ 283138080Sharti diff -u ${.CURDIR}/regress.shell_2j.out - || false 284138080Sharti.endif 285138080Sharti 286138080Sharti.if make(shell_2B) 287138317Sharti.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" 288138080Sharti 289138080Shartishell_2B: 290138080Sharti -@funny $$ 291138080Sharti funnier $$ 292138080Sharti.endif 293138080Sharti 294138080Sharti.if make(shell_2j) 295138317Sharti.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" 296138080Sharti 297138080Shartishell_2j: 298138080Sharti -@funny $$ 299138080Sharti funnier $$ 300138080Sharti.endif 301138080Sharti 30295158Sjmallettfailure: 303137587Snik @echo "not ok # Test failed: regression detected. See above." 30495158Sjmallett @false 305138317Sharti 306138515ShartiCLEANFILES= shell_test 307138515Sharti 308138515Sharti.include <bsd.obj.mk> 309